From nobody Tue Mar 31 15:58:42 2026 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 4flXpq2MfNz6WDsS for ; Tue, 31 Mar 2026 15:58:43 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4flXpp6SMyz3gXy for ; Tue, 31 Mar 2026 15:58:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1774972722; 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=Tu1ZQU0LVHbFyLfbsXLXptowZSD2kezMFCUvVo/IQa8=; b=a73yDY1f1KyDQvjavXvCzzAPXCUd8QtmdpfbwggMfntEkSQkMuBf24aYl0joMzIPjdgCBK G58CIrkEd9Pfx4p1aUZ8CLA59Tqls6No6C0dMGVyrBiWnEIcTvF9CgFfcN96cPByuo8ULh K7PMkt6nHPPTb2Td/oQQ1iLn1MR7UcIP+al0CXkVVJTZ7Z1e1VVVo4aZSTuZHEYTAuQ9u9 OJgSFdZ5hyRgSbTAzeGwM+s/rBuXHwLii0aH9IAcNfDBFlDNrMZGKWvHOtUpkfcogSCIjo aAs59xI3BERuE1DK8yPsWcU+e5mYyVho8BbkW0JDK8JNxtpR348vYDAR9RRPvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1774972722; a=rsa-sha256; cv=none; b=yI+G8gXH3ol3hrnTRsJvJ2FzZulqdns43VnBGFX00o5GA256wLJvtf6WMm1kufTlauADeo AswH9WtvGlsoM9FKpShfzh4GK6Mph3dTeiz238B8IHVSF/CJx2ZysGc76EBOQuCkZf1CoW o5U46UQYQ380GF9LEvUtVaexg8Kgj8w8lZfXBxN59H8+deMzJH3ZwRakh7U0cu6J/Thtzs 2Lus3lemMbNHmtUY9zRUr8L6mXSm+fr9EFoqpK2Zoc+RncppkUttO4nxpmpA49iwXKqJ8K rLooAH94jjU0VBFxyul7Q0sSGelVauTWn+L49C90MD7i58uHjE0+l0hSLZBk/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1774972722; 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=Tu1ZQU0LVHbFyLfbsXLXptowZSD2kezMFCUvVo/IQa8=; b=qvrk2G39qUXmrq8cuYn6SSeYEsQdfCAOLlqT8v5ySqLnSXGK1sFfjwGreOSvMCw2g/ftp/ W2VDhQugmELqdhJfvhq/K6wTZDBJ58IsLYaziIFYFsP3M4yQWOPovi3b3LnobtGzt4K/5j InK76CMVrLZDD0+xLSCIa5P0iIINgFrEMZOKJepBrpV2eberRrg4fBbDZWhbzJZttsx1SM mensxTvIiIlvPIsuLLINpM2/Av9lLvMhKSdgBCo14sRRm+xcEZLeHWJau8Gln56HeuxIOr xtQxXjy6SI1qS9lWgyq4S8m+Y2am2iVVsYvlwTQRolqVUocaOT0go12Szw7+CQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4flXpp5pQfzcHR for ; Tue, 31 Mar 2026 15:58:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 395e7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 31 Mar 2026 15:58:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: f4b45d9e9a95 - stable/15 - bhyve: Simplify passthru_msix_addr() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/15 X-Git-Reftype: branch X-Git-Commit: f4b45d9e9a95e0ad5d96c7ad8fb709f3af6df687 Auto-Submitted: auto-generated Date: Tue, 31 Mar 2026 15:58:42 +0000 Message-Id: <69cbef32.395e7.12878bc0@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f4b45d9e9a95e0ad5d96c7ad8fb709f3af6df687 commit f4b45d9e9a95e0ad5d96c7ad8fb709f3af6df687 Author: Mark Johnston AuthorDate: 2026-02-06 15:30:56 +0000 Commit: Mark Johnston CommitDate: 2026-03-31 15:57:28 +0000 bhyve: Simplify passthru_msix_addr() It can use the passthru_mmio_map() helper function. Make that change, and also make passthru_mmio_map() use EPRINTLN to fix formatting when the guest console is stdio. Reviewed by: corvink, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D55067 (cherry picked from commit 86150ed98b7903feaba942f01619e74894cd23c4) --- usr.sbin/bhyve/pci_passthru.c | 80 ++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 54 deletions(-) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 8ddcd8bd56e8..662390413dbc 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -1310,58 +1310,6 @@ passthru_read(struct pci_devinst *pi, int baridx, uint64_t offset, int size) return (val); } -static void -passthru_msix_addr(struct pci_devinst *pi, int baridx, int enabled, - uint64_t address) -{ - struct passthru_softc *sc; - size_t remaining; - uint32_t table_size, table_offset; - - sc = pi->pi_arg; - table_offset = rounddown2(pi->pi_msix.table_offset, 4096); - if (table_offset > 0) { - if (!enabled) { - if (vm_unmap_pptdev_mmio(pi->pi_vmctx, - sc->psc_sel.pc_bus, - sc->psc_sel.pc_dev, - sc->psc_sel.pc_func, address, - table_offset) != 0) - warnx("pci_passthru: unmap_pptdev_mmio failed"); - } else { - if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus, - sc->psc_sel.pc_dev, - sc->psc_sel.pc_func, address, - table_offset, - sc->psc_bar[baridx].addr) != 0) - warnx("pci_passthru: map_pptdev_mmio failed"); - } - } - table_size = pi->pi_msix.table_offset - table_offset; - table_size += pi->pi_msix.table_count * MSIX_TABLE_ENTRY_SIZE; - table_size = roundup2(table_size, 4096); - remaining = pi->pi_bar[baridx].size - table_offset - table_size; - if (remaining > 0) { - address += table_offset + table_size; - if (!enabled) { - if (vm_unmap_pptdev_mmio(pi->pi_vmctx, - sc->psc_sel.pc_bus, - sc->psc_sel.pc_dev, - sc->psc_sel.pc_func, address, - remaining) != 0) - warnx("pci_passthru: unmap_pptdev_mmio failed"); - } else { - if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus, - sc->psc_sel.pc_dev, - sc->psc_sel.pc_func, address, - remaining, - sc->psc_bar[baridx].addr + - table_offset + table_size) != 0) - warnx("pci_passthru: map_pptdev_mmio failed"); - } - } -} - static int passthru_mmio_map(struct pci_devinst *pi, int baridx, int enabled, uint64_t address, uint64_t off, uint64_t size) @@ -1373,14 +1321,16 @@ passthru_mmio_map(struct pci_devinst *pi, int baridx, int enabled, if (vm_unmap_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus, sc->psc_sel.pc_dev, sc->psc_sel.pc_func, address + off, size) != 0) { - warnx("pci_passthru: unmap_pptdev_mmio failed"); + EPRINTLN("pci_passthru: unmap_pptdev_mmio failed: %s", + strerror(errno)); return (-1); } } else { if (vm_map_pptdev_mmio(pi->pi_vmctx, sc->psc_sel.pc_bus, sc->psc_sel.pc_dev, sc->psc_sel.pc_func, address + off, size, sc->psc_bar[baridx].addr + off) != 0) { - warnx("pci_passthru: map_pptdev_mmio failed"); + EPRINTLN("pci_passthru: map_pptdev_mmio failed: %s", + strerror(errno)); return (-1); } } @@ -1388,6 +1338,28 @@ passthru_mmio_map(struct pci_devinst *pi, int baridx, int enabled, return (0); } +static void +passthru_msix_addr(struct pci_devinst *pi, int baridx, int enabled, + uint64_t address) +{ + size_t remaining; + uint32_t table_size, table_offset; + + table_offset = rounddown2(pi->pi_msix.table_offset, 4096); + if (table_offset > 0) { + (void)passthru_mmio_map(pi, baridx, enabled, address, 0, + table_offset); + } + table_size = pi->pi_msix.table_offset - table_offset; + table_size += pi->pi_msix.table_count * MSIX_TABLE_ENTRY_SIZE; + table_size = roundup2(table_size, 4096); + remaining = pi->pi_bar[baridx].size - table_offset - table_size; + if (remaining > 0) { + (void)passthru_mmio_map(pi, baridx, enabled, address, + table_offset + table_size, remaining); + } +} + static void passthru_mmio_addr(struct pci_devinst *pi, int baridx, int enabled, uint64_t address)