From nobody Sat Jan 08 15:22:20 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8F8AB1942FA8; Sat, 8 Jan 2022 15:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JWP302HMbz4cZD; Sat, 8 Jan 2022 15:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2FF69211A7; Sat, 8 Jan 2022 15:22:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 208FMKbh000916; Sat, 8 Jan 2022 15:22:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 208FMKae000915; Sat, 8 Jan 2022 15:22:20 GMT (envelope-from git) Date: Sat, 8 Jan 2022 15:22:20 GMT Message-Id: <202201081522.208FMKae000915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0ea87a8fbc89 - stable/13 - bhyve: Correct unmapping of the MSI-X table BAR List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0ea87a8fbc892ea32e4fef2b31589a466fffe816 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641655340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HUSYHvaxCPseSziw5Bbkkmx5+clndroiq6V0NIGuuJ8=; b=E3CLOhxbdTKcVWzFffe2yK8YRe01ACwowUy6caE+GXO4u366BjoEbdDRG+ce75dd9PqgvI pzwIp0JTqgbUh6cGyPNQD6CYrxBNoHxaGRKH2O1eZVWH1KAkkjxhOuKlKjLfR6DTmHS71h 8yzET53wfQ841CYTzpF2qG23+mlw+7ehk7Hj3eblahR4pcweOHpykueFpGcgv/5nCA499Q lzXr5/HnCdWnADsiTKofCC4WTwcsFdZTZJJfesDkSzn2TzTllBlJe5/NsjcsP5v5vgU2ea 9g76xpjja8K6kCOxk82LoP95nYgS/wQ8BxEhJ1pgVj54ozPRCHNPaRXEdt0xYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641655340; a=rsa-sha256; cv=none; b=QMf/ECYx5AcyjJZimnwMQbuz5he7PFFDAk5OWO3HHNAItc6/9WGsU/2HJIOn8EFJ/10Ry+ JGPksTjpWO5rFQt2pbZP0/jc2CQxCEYntJtYx3V1XRqJfXSti5ez6zpYFhqn3R6Ftr5oAv fom8dVDpRfmAgMkHpsylwA+4aps72WLshSMAE6F/becasrJgE21EZohNQoOM4RJsZOIudA l15OIMxQ3DTuG2bgCa2ac1Lo+ZiaaVdoHQA+XlmPLsMCgG/p3rTpyy59fw2SN9vfWi8rc0 E4OBe5sqCeSbYte4z+mhVOJJjOj6eVcXkLFeIEI9ivMgbnUSvwLfaDLE8AZiAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0ea87a8fbc892ea32e4fef2b31589a466fffe816 commit 0ea87a8fbc892ea32e4fef2b31589a466fffe816 Author: Mark Johnston AuthorDate: 2022-01-05 15:08:13 +0000 Commit: Mark Johnston CommitDate: 2022-01-08 15:21:58 +0000 bhyve: Correct unmapping of the MSI-X table BAR The starting address passed to mprotect was wrong, so in the case where the last page containing the table is not the last page of the BAR, the wrong region would be unmapped. Reported by: Andy Fiddaman Reviewed by: jhb Fixes: 7fa233534736 ("bhyve: Map the MSI-X table unconditionally for passthrough") Sponsored by: The FreeBSD Foundation (cherry picked from commit 4558c11f1b4dfd7fd505d70b79467eb7f1193f07) --- usr.sbin/bhyve/pci_passthru.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index bf99c646c480..313f73dc4df1 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -462,7 +462,7 @@ init_msix_table(struct vmctx *ctx, struct passthru_softc *sc, uint64_t base) table_size = roundup2(table_size, 4096); /* - * Unmap any pages not covered by the table, we do not need to emulate + * Unmap any pages not containing the table, we do not need to emulate * accesses to them. Avoid releasing address space to help ensure that * a buggy out-of-bounds access causes a crash. */ @@ -471,7 +471,8 @@ init_msix_table(struct vmctx *ctx, struct passthru_softc *sc, uint64_t base) PROT_NONE) != 0) warn("Failed to unmap MSI-X table BAR region"); if (table_offset + table_size != pi->pi_msix.mapped_size) - if (mprotect(pi->pi_msix.mapped_addr, + if (mprotect( + pi->pi_msix.mapped_addr + table_offset + table_size, pi->pi_msix.mapped_size - (table_offset + table_size), PROT_NONE) != 0) warn("Failed to unmap MSI-X table BAR region");