Bug 268744

Summary: Running the wifibox (bhyve VM) crashes system with vmm lock error
Product: Base System Reporter: mmatalka
Component: bhyveAssignee: Robert Wing <rew>
Status: Closed FIXED    
Severity: Affects Only Me CC: bj.rn, emaste, mmatalka, rew
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Screenshot of error none

Description mmatalka 2023-01-04 09:24:18 UTC
The error is:

panic: Lock (sx) vm mem_segs not locked @ /usr/src/sys/amd64/vmm/vmm.c:1188

I'm on a1f28ec729f7491da8607e8eeaee1b0f547c60d0

I've included a picture of the error.
Comment 1 bj.rn 2023-01-04 21:19:30 UTC
This seems to be an issue with pci-passthru, a vm with pci-passthru crashes the host, same vm without pci-passthru works
Comment 2 Robert Wing freebsd_committer freebsd_triage 2023-01-05 17:49:03 UTC
(In reply to mmatalka from comment #0)

It doesn't appear the picture got attached.

Are either of you able to reproduce on-demand? If so, please provide the steps to do so.
Comment 3 mmatalka 2023-01-05 22:17:11 UTC
Created attachment 239289 [details]
Screenshot of error
Comment 4 mmatalka 2023-01-05 22:17:56 UTC
(In reply to Robert Wing from comment #2)

Whoops, I have uploaded the image.

For me it is as simple as compiling the commit I gave and doing service wifibox start
Comment 5 Robert Wing freebsd_committer freebsd_triage 2023-01-06 10:18:06 UTC
(In reply to mmatalka from comment #4)

Alright, thanks for the info.

I've proposed a fix at https://reviews.freebsd.org/D37962
Comment 6 bj.rn 2023-01-07 16:07:51 UTC
With this patch I am able to boot the VM with pci-passthru again, thanks!

The machine however freezes the system on reboot now - something I have not seen before, not sure if related
Comment 7 bj.rn 2023-01-07 21:40:23 UTC
(In reply to bj.rn from comment #6)
Also freezes on vm shutdown
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-01-20 19:05:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ccf32a68f821c5c724fb9a5b4b9576925122292f

commit ccf32a68f821c5c724fb9a5b4b9576925122292f
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2023-01-20 10:03:59 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2023-01-20 10:03:59 +0000

    vmm: take exclusive mem_segs_lock when (un)assigning ppt dev

    PR:             268744
    Reported by:    mmatalka@gmail.com
    Reviewed by:    corvink, markj, jhb
    Fixes:  67b69e76e8ee ("vmm: Use an sx lock to protect the memory map.")
    Differential Revision:  https://reviews.freebsd.org/D37962

 sys/amd64/vmm/vmm_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 9 mmatalka 2023-01-21 08:13:43 UTC
This is working for me.  Thank you for the fast resolution.
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-01-26 22:13:00 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=eb37d3cc565e278d568b0454fc3b2b9cab4c3518

commit eb37d3cc565e278d568b0454fc3b2b9cab4c3518
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2023-01-20 10:03:59 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-01-26 22:05:13 +0000

    vmm: take exclusive mem_segs_lock when (un)assigning ppt dev

    PR:             268744
    Reported by:    mmatalka@gmail.com
    Reviewed by:    corvink, markj, jhb
    Fixes:  67b69e76e8ee ("vmm: Use an sx lock to protect the memory map.")
    Differential Revision:  https://reviews.freebsd.org/D37962

    (cherry picked from commit ccf32a68f821c5c724fb9a5b4b9576925122292f)

 sys/amd64/vmm/vmm_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)