From nobody Fri Nov 06 19:54:58 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 4jLqdt5SqYz6ydsy for ; Fri, 06 Nov 2026 19:54:58 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jLqdt29q5z4FRC for ; Fri, 06 Nov 2026 19:54:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793994898; 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=0FG651pMQWaPO4LQIzPOCS17TZO3vGjdpDHuQlf0zPE=; b=Jm1U6+lDZdk7TA+hj7+phjIpaa0cfhcD6mfoDVVHhs5DTFSVg4/F1JzfJZe8sgxJhOPVst 7aqfzZKgl5p29Dm0El1fYJn5yXj7jnEEEyCQoEvPJfYOFSdM7ZWqOc9ROCZoc2MrmGUx0n ORZWMd4zZLzoIOOkGzD7m6JCXx6E+0yccvc35QKSYUVe6kbcH7ITAacLld/Sn48k0SbZpL +kJvlb2AirieX07lCz41ZUTRW3A2kWg9TdB+ISxTt0abQW9jny8HTjLQH2UaAcrA0+lJY8 3FMdQgMQ0hDLDd1281QlbzQ5fh5jvPYFMhrllFM1PKF/2D8VeprCxovgAMviqg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793994898; b=xMQQcPeUhr8ZUD/tdkWOL12SLyr+onajgX5z8cZR0pUkzmA+3OF3mY//w3GO98b+diIqQT uVsHwgU3rIhdZYsMB3pyyrJeAYvWMuJPutQ+JHmkZq6H48nLHiH8mkpVqbPqMwcLdTaiG1 P34D2N5ZsxTbXD4gr6Eadauubk8OeRY7rpq4a40WkXgV0Mi63Cj3sjz0wtuRkbgcVZxg5K uLn9QZ8d0UgLKZxbnGQxxRCybkEqLzmSgkrAwKHKSBmzohIu83LED4nMh9h8uNtFxuZ7n/ VRggiqT7X7vK+eVmhjn3cdBc1o7rnu5GfeFykm5gJJN7rETtpLXRU+tM9kFJRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793994898; 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=0FG651pMQWaPO4LQIzPOCS17TZO3vGjdpDHuQlf0zPE=; b=QdtkvVFopey20E/TPz2dXfACBhpUimsFRWbg9lYVifuaJxmzBiAnGDAvnIVBqPOlsD5toH +RjodU0NcXjA4y8q2XoWn5cEIQ7PinWufz4H+9ivcdtU2pFDFGHhH8ZX8UruR40ZxYYmq2 l26gcIqwWINI04QH9VCgEpzdg1yXXIrRaNdAM/hV9f9DYjDrd5p72AOURQWKxc9dmbAXPx F4fwodrHo9fV1mAT/FOyQfvBY2b2yEjiJeTAq5/WMcrfUnmOY08bOCoYZ4e6/Zr+pOS3fk yIrXLsBPPZ7g/nDfmNzNPsP2DDy+PN4yv9kbghiHPUPqBncz7MSuVpGtIstCFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jLqdt1pFBzrq2 for ; Fri, 06 Nov 2026 19:54:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d8b8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 06 Nov 2026 19:54:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2f300b591651 - stable/15 - bhyve: Treat BAR registration failures as non-fatal List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 2f300b59165150ad30000bdf9f05170391f5a1bf Auto-Submitted: auto-generated Date: Fri, 06 Nov 2026 19:54:58 +0000 Message-Id: <6aee3092.1d8b8.7618c1df@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2f300b59165150ad30000bdf9f05170391f5a1bf commit 2f300b59165150ad30000bdf9f05170391f5a1bf Author: Mark Johnston AuthorDate: 2026-10-20 15:41:21 +0000 Commit: Mark Johnston CommitDate: 2026-11-06 15:52:19 +0000 bhyve: Treat BAR registration failures as non-fatal Some guest operating systems (at least 9front) will leave device I/O space decoding enabled while probing BAR sizes. In this case, a sufficiently large 32-bit BAR can overlap with the HPET MMIO region fixed at 0xfed00000. This results in an assertion failure in modify_bar_registration(), even though the collision is transient, i.e., the guest will promptly map the BAR elsewhere. Tolerate such overlaps. Keep track of a BAR's registration state and make sure that modify_bar_registration() doesn't try to unregister an I/O space if registration failed. This fixes a problem where a 32MB framebuffer ends up overlapping with the HPET MMIO region, causing some guests to crash with an assertion failure when probing BARs during boot. PR: 290098 Reviewed by: bnovkov MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60748 (cherry picked from commit 6f051f0e56feba19731adfa6f6bd2a098b5091de) --- usr.sbin/bhyve/pci_emul.c | 46 +++++++++++++++++++++++++++++++--------------- usr.sbin/bhyve/pci_emul.h | 2 ++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 9170e0b6b93c..60128a735de1 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -639,12 +639,16 @@ static void modify_bar_registration(struct pci_devinst *pi, int idx, int registration) { struct pci_devemu *pe; + struct pcibar *bar; int error; - enum pcibar_type type; pe = pi->pi_d; - type = pi->pi_bar[idx].type; - switch (type) { + bar = &pi->pi_bar[idx]; + + if (!registration && !bar->registered) + return; + + switch (bar->type) { case PCIBAR_IO: { #ifdef __amd64__ @@ -652,30 +656,34 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration) bzero(&iop, sizeof(struct inout_port)); iop.name = pi->pi_name; - iop.port = pi->pi_bar[idx].addr; - iop.size = pi->pi_bar[idx].size; + iop.port = bar->addr; + iop.size = bar->size; if (registration) { iop.flags = IOPORT_F_INOUT; iop.handler = pci_emul_io_handler; iop.arg = pi; error = register_inout(&iop); - } else + } else { error = unregister_inout(&iop); + assert(error == 0); + } #else struct mem_range mr; bzero(&mr, sizeof(struct mem_range)); mr.name = pi->pi_name; - mr.base = pi->pi_bar[idx].addr; - mr.size = pi->pi_bar[idx].size; + mr.base = bar->addr; + mr.size = bar->size; if (registration) { mr.flags = MEM_F_RW; mr.handler = pci_emul_iomem_handler; mr.arg1 = pi; mr.arg2 = idx; error = register_mem(&mr); - } else + } else { error = unregister_mem(&mr); + assert(error == 0); + } #endif break; } @@ -686,16 +694,18 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration) bzero(&mr, sizeof(struct mem_range)); mr.name = pi->pi_name; - mr.base = pi->pi_bar[idx].addr; - mr.size = pi->pi_bar[idx].size; + mr.base = bar->addr; + mr.size = bar->size; if (registration) { mr.flags = MEM_F_RW; mr.handler = pci_emul_mem_handler; mr.arg1 = pi; mr.arg2 = idx; error = register_mem(&mr); - } else + } else { error = unregister_mem(&mr); + assert(error == 0); + } break; } case PCIBAR_ROM: @@ -705,10 +715,16 @@ modify_bar_registration(struct pci_devinst *pi, int idx, int registration) error = EINVAL; break; } - assert(error == 0); - if (pe->pe_baraddr != NULL) - (*pe->pe_baraddr)(pi, idx, registration, pi->pi_bar[idx].addr); + /* + * An error may legitimately occur if the guest is probing BARs and + * leaves decoding enabled. Keep track of this if it happens so that we + * can skip unregistration. + */ + bar->registered = (registration && error == 0); + + if (error == 0 && pe->pe_baraddr != NULL) + (*pe->pe_baraddr)(pi, idx, registration, bar->addr); } static void diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h index 9aeb11496943..b7ddfd73bda1 100644 --- a/usr.sbin/bhyve/pci_emul.h +++ b/usr.sbin/bhyve/pci_emul.h @@ -39,6 +39,7 @@ #include #include +#include #include "pci_irq.h" @@ -99,6 +100,7 @@ struct pcibar { uint64_t size; uint64_t addr; uint8_t lobits; + bool registered; /* io region is registered */ }; #define PI_NAMESZ 40