Bug 271251 - Kernel panics when loading vmm module with VT-x disabled
Summary: Kernel panics when loading vmm module with VT-x disabled
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bhyve (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Corvin Köhne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-05 03:38 UTC by Aleksandr
Modified: 2023-05-11 13:33 UTC (History)
3 users (show)

See Also:


Attachments
kernel panic screenshot (66.96 KB, image/png)
2023-05-05 03:38 UTC, Aleksandr
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksandr 2023-05-05 03:38:45 UTC
Created attachment 241983 [details]
kernel panic screenshot

Loading vmm module causes panic when VT-x is disabled in BIOS.

This starts to happen after https://reviews.freebsd.org/D39805

Memory for vmxon_region is freed in vmx_modcleanup() when it was not allocated in vmx_modinit() due to disabled VMX.
Comment 1 Corvin Köhne freebsd_committer freebsd_triage 2023-05-05 06:46:36 UTC
Could you please check if https://reviews.freebsd.org/D39974 fixes your issue?
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-05-05 13:34:47 UTC
A commit in branch main references this bug:

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

commit b10e100d1696782cfebef09b5870dfc6d1b3217b
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-05-05 06:36:20 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-05-05 13:34:00 +0000

    vmm: don't free unallocated memory

    If vmx or svm is disabled in BIOS or the device isn't supported by vmm,
    modinit won't allocate these state save areas. As kmem_free panics when
    passing a NULL pointer to it, loading the vmm kernel module causes a
    panic too.

    PR:                     271251
    Reviewed by:            markj
    Fixes:                  74ac712f72cfd6d7b3db3c9d3b72ccf2824aa183 ("vmm: Dynamically allocate a couple of per-CPU state save areas")
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D39974

 sys/amd64/vmm/amd/svm.c   | 5 ++++-
 sys/amd64/vmm/intel/vmx.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
Comment 3 Aleksandr 2023-05-06 07:17:19 UTC
I don't have AMD systems, but this patch works on my Intel system.
Thank you!
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-05-11 13:33:28 UTC
A commit in branch stable/13 references this bug:

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

commit be14baa34b82e3ca50d0a2b61ddb05b355616c93
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-05-10 13:19:25 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-05-11 13:32:32 +0000

    vmm: don't free unallocated memory

    If vmx or svm is disabled in BIOS or the device isn't supported by vmm,
    modinit won't allocate these state save areas. As kmem_free panics when
    passing a NULL pointer to it, loading the vmm kernel module causes a
    panic too.

    PR:                     271251
    Reviewed by:            markj
    Fixes:                  74ac712f72cfd6d7b3db3c9d3b72ccf2824aa183 ("vmm: Dynamically allocate a couple of per-CPU state save areas")
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D39974

    (cherry picked from commit b10e100d1696782cfebef09b5870dfc6d1b3217b)

 sys/amd64/vmm/amd/svm.c   | 5 ++++-
 sys/amd64/vmm/intel/vmx.c | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)