git: nvmm: Port to DragonFly #12: FPU save & restore

Aaron LI aly at
Tue Jul 20 16:30:18 PDT 2021

commit 614bd53980ffd35595e42d31a529a8f8ec7c38cd
Author: Aaron LI <aly at>
Date:   Tue May 25 14:40:41 2021 +0800

    nvmm: Port to DragonFly #12: FPU save & restore
    Note that the host FPU state is indeterminant and depends on whether
    the user program used the FPU or not, so there might not be any state to
    save.  npxpush() and npxpop() can handle this.  Accordingly, need to use
    'mcontext_t' to store host FPU state.
    At first I used fpu_area_save() and fpu_area_restore() to deal with the
    host FPU state, but it caused a hard fault loop when trying to boot an
    OS in QEMU, because it failed to handle an uninitialized FPU.  Thanks
    to Matt Dillon for tracking it down and fixing it.
    Credit to FreeBSD vmm code: save_guest_fpustate(), restore_guest_fpustate()

Summary of changes:
 sys/dev/virtual/nvmm/nvmm_compat.h      |  9 +++++++
 sys/dev/virtual/nvmm/x86/nvmm_x86.c     | 12 ++++-----
 sys/dev/virtual/nvmm/x86/nvmm_x86.h     |  4 +--
 sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c | 46 +++++++++++++++++++++++----------
 sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c | 46 +++++++++++++++++++++++----------
 5 files changed, 81 insertions(+), 36 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list