git: nvmm(4): Enable selective CR0 write intercept in the SVM backend

Aaron LI aly at crater.dragonflybsd.org
Thu Feb 12 21:26:05 PST 2026


commit a91151ff5d39253c6852a7579fc988f68937658f
Author: Aaron LI <aly at aaronly.me>
Date:   Thu Jan 29 10:17:55 2026 +0800

    nvmm(4): Enable selective CR0 write intercept in the SVM backend
    
    Similar to the VMX backend [1], enable selective CR0 write intercept in
    the SVM backend to force CR0_ET/CR0_NE to 1, and CR0_CD/CR0_NW to 0.
    
    This addresses the severe performance issue observed in UEFI guests [2].
    When booting a DragonFly installation ISO on my AMD 3700X, it previously
    took 50-60 seconds from VM power-on before the kernel started loading,
    and around 17 *minutes* to reach the login prompt.  Even when the guest
    OS was otherwise idle, the qemu process consumed 40-50% CPU.
    
    Note that the selective CR0 write intercept is enabled only when the CPU
    supports the DecodeAssists feature, as the intercept handling relies on
    the decoded information provided in EXITINFO1.  A diagnostic message is
    printed in svm_ident() when DecodeAssists is unavailable.
    
    Meanwhile, rename 'VMCB_CTRL_INTERCEPT_CR0_SPEC' to
    'VMCB_CTRL_INTERCEPT_CR0_SEL' to better align with
    'VMCB_EXITCODE_CR0_SEL_WRITE'.
    
    WARNING: I'm ignoring the LMSW instruction here, which should be okay
    for modern operating systems.  A complete fix requires to implement the
    instruction emulation in libnvmm and then delgate to it.
    
    [1] https://github.com/NetBSD/src/commit/ed319587070ffa2d8b15b945a3d7222b0fe53bf1
    [2] https://bugs.dragonflybsd.org/issues/3310
    
    Credit: Claude Sonnet 4.5, Google Gemini 3

Summary of changes:
 sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c | 94 +++++++++++++++++++++++++++++++--
 1 file changed, 90 insertions(+), 4 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a91151ff5d39253c6852a7579fc988f68937658f


-- 
DragonFly BSD source repository


More information about the Commits mailing list