[Bug 300844] bhyve: restored PCI BAR dispatch is not registered and MEMEN clear aborts

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 17 Nov 2026 16:06:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300844

            Bug ID: 300844
           Summary: bhyve: restored PCI BAR dispatch is not registered and
                    MEMEN clear aborts
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bhyve
          Assignee: virtualization@FreeBSD.org
          Reporter: 1350430676@qq.com

Created attachment 277397
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277397&action=edit
Reproduction bundle: PoC source, test script, runtime logs, crash output, and
SHA-256 manifest.

Environment:
- FreeBSD 15.1-RELEASE-p3 with snapshot-enabled bhyve/bhyvectl.
- Source releng/15.1 commit 88e7371d9.
- Device: virtio-net at 0:2:0.

The PCI restore path restores config space and BAR descriptors but, in this
branch, does not restore the memory-manager registrations. The restored command
register can therefore report MEMEN while the BAR dispatch is absent. Clearing
MEMEN calls unregister_mem(), which returns non-zero, and
modify_bar_registration() asserts error==0.

Steps to reproduce:
1. Boot the supplied ROM; it enables MEMEN and then delays.
2. Save while the guest is still delaying.
3. Restore the unmodified snapshot.
4. Wait for the ROM to clear MEMEN.

Expected: restored registration matches the command register, or clearing an
absent registration is a no-op.
Actual: bhyve terminates with SIGABRT, exit status 134:

    Assertion failed: (error == 0), function modify_bar_registration

The same ROM without save/restore survives a 30-second control run, making this
a strict restore-dependent failure.

Current status: this remains in releng/15.1 at 95719d8a8 (15.1-RELEASE-p6).
Main contains:
- 6f051f0e56fe: treat BAR registration failures as non-fatal.
- 75b1f9677268: restore BARs at the addresses supplied by the guest.

Please consider an MFC or confirm that snapshot fixes are not merged to 15.1.

Impact: denial of service and loss of the restored VM.

Suggested fix: replay BAR registration after restoring config space and BAR
addresses; do not assert on unregistering a missing range.

-- 
You are receiving this mail because:
You are the assignee for the bug.