From nobody Wed Jan 05 15:12:19 2022 X-Original-To: dev-commits-src-main@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 1E71F1926263; Wed, 5 Jan 2022 15:12:21 +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 4JTXyq74HWz4Yvt; Wed, 5 Jan 2022 15:12:19 +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 A95B464D3; Wed, 5 Jan 2022 15:12:19 +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 205FCJLQ023503; Wed, 5 Jan 2022 15:12:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 205FCJJ6023502; Wed, 5 Jan 2022 15:12:19 GMT (envelope-from git) Date: Wed, 5 Jan 2022 15:12:19 GMT Message-Id: <202201051512.205FCJJ6023502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4558c11f1b4d - main - bhyve: Correct unmapping of the MSI-X table BAR List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 4558c11f1b4dfd7fd505d70b79467eb7f1193f07 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641395540; 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=oc7ni4wba9X8Y5HZo5kA0EF6/nXbgRbii4PdxmfW+OU=; b=lMPbjbm8knFzIqEs0UQ96MadQ/zjOhXEmN4Tg864pDBghPizcMxrbgbA3cd3kmv4Zo+N2J Dqu8HhlkW4/JJNa3Q3Z1NZzKe08dqDw4rYQUMR8roJBYjdFS1OoDFGL/IeDWhEynJtSFbh 45+PraFFviaOv+Zhy7w5oKA8YqjXt7qkXgnefMsgDqyiQJ1M1lB4W4vkomsDjz9gpo2gE0 g0aw0FycIwIB8uwF0e7c4mqSkJnTE1vsrMW2frIdkQHUCruTSx24PfxXeFmsLAz9aNE2EJ 9c2q1/v3RaJBiQB8mFhdh1qQHKYnn1oTMYTYOLUjPuzWF+PcC0c8g71VoR5wnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641395540; a=rsa-sha256; cv=none; b=scVHmq0gGZa5713GJJu+iRuIRLH0QcyMmjIGcet+3kh5NFXyq7lb+Gafz/B+aa2m8wE8s2 jupqDQTY9dJG4+gcbzk+Jzj+SE4H+sZhT9GxBpnM0MXmSVbHKteSiGSbGXiJfipHZBi09j afYHncfE4y/JDwguDFxDtBSH8Xt5nJQCw/ajwwiQYn6hA1adYGsdcQkV/RYMVjRopQsSIM m5j4aCZplPhJ5t0VWu1Eufd1dAq0XuB+YDBbV+z/s/9JjgQEaq8qa/VYx8rLpWP3ew26/E pRGg9X3K2pIvhBHezj2zgTgGZvfCSBMUuneCLJ3DUISF8O/pMf1Aa5DFY08dHA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4558c11f1b4dfd7fd505d70b79467eb7f1193f07 commit 4558c11f1b4dfd7fd505d70b79467eb7f1193f07 Author: Mark Johnston AuthorDate: 2022-01-05 15:08:13 +0000 Commit: Mark Johnston CommitDate: 2022-01-05 15:12:09 +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") MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33739 --- 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 0d25a8d8143f..725ae4fbdb91 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) 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) 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");