VirtualBox

Changeset 87469 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Jan 28, 2021 5:01:06 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142489
Message:

VMM/HMVMX: Moving more stuff to HMR0PERVCPU. bugref:9217

Location:
trunk/src/VBox/VMM/VMMR0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0A.asm

    r87462 r87469  
    2525%include "VBox/vmm/hm_vmx.mac"
    2626%include "VBox/vmm/cpum.mac"
    27 %include "VBox/vmm/vm.mac"
     27%include "VBox/vmm/gvm.mac"
    2828%include "iprt/x86.mac"
    2929%include "HMInternal.mac"
     
    903903        ; before writing here.
    904904        lea     rcx, [NAME(RT_CONCAT(hmR0VmxStartVmHostRIP,%1)) wrt rip]
    905         cmp     rcx, [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRIP]
     905        cmp     rcx, [rsi + GVMCPU.hmr0 + HMR0PERVCPU.u + HMR0CPUVMX.uHostRIP]
    906906        jne     .write_host_rip
    907907.wrote_host_rip:
    908         cmp     rsp, [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRSP]
     908        cmp     rsp, [rsi + GVMCPU.hmr0 + HMR0PERVCPU.u + HMR0CPUVMX.uHostRSP]
    909909        jne     .write_host_rsp
    910910.wrote_host_rsp:
     
    967967ALIGNCODE(8)
    968968.write_host_rip:
    969         mov     [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRIP], rcx
     969        mov     [rsi + GVMCPU.hmr0 + HMR0PERVCPU.u + HMR0CPUVMX.uHostRIP], rcx
    970970        mov     eax, VMX_VMCS_HOST_RIP                      ;; @todo It is only strictly necessary to write VMX_VMCS_HOST_RIP when
    971971        vmwrite rax, rcx                                    ;;       the VMXVMCSINFO::pfnStartVM function changes (eventually
     
    977977ALIGNCODE(8)
    978978.write_host_rsp:
    979         mov     [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRSP], rsp
     979        mov     [rsi + GVMCPU.hmr0 + HMR0PERVCPU.u + HMR0CPUVMX.uHostRSP], rsp
    980980        mov     eax, VMX_VMCS_HOST_RSP
    981981        vmwrite rax, rsp
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r87466 r87469  
    13991399         * if its content differs, we would have to update the host MSRs anyway.
    14001400         */
    1401         pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs = false;
     1401        pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs = false;
    14021402    }
    14031403    else
     
    23232323        {
    23242324            /* Someone else can do the work. */
    2325             pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs = false;
     2325            pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs = false;
    23262326        }
    23272327    }
     
    24712471     * Note: If you're adding MSRs here, make sure to update the MSR-bitmap accesses in hmR0VmxSetupVmcsProcCtls().
    24722472     */
    2473     if (!(pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST))
    2474     {
    2475         Assert(!(pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST));  /* Guest MSRs better not be loaded now. */
     2473    if (!(pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST))
     2474    {
     2475        Assert(!(pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST));  /* Guest MSRs better not be loaded now. */
    24762476        if (pVCpu->CTX_SUFF(pVM)->hm.s.fAllow64BitGuests)
    24772477        {
    2478             pVCpu->hm.s.vmx.u64HostMsrLStar        = ASMRdMsr(MSR_K8_LSTAR);
    2479             pVCpu->hm.s.vmx.u64HostMsrStar         = ASMRdMsr(MSR_K6_STAR);
    2480             pVCpu->hm.s.vmx.u64HostMsrSfMask       = ASMRdMsr(MSR_K8_SF_MASK);
    2481             pVCpu->hm.s.vmx.u64HostMsrKernelGsBase = ASMRdMsr(MSR_K8_KERNEL_GS_BASE);
    2482         }
    2483         pVCpu->hm.s.vmx.fLazyMsrs |= VMX_LAZY_MSRS_SAVED_HOST;
     2478            pVCpu->hmr0.s.vmx.u64HostMsrLStar        = ASMRdMsr(MSR_K8_LSTAR);
     2479            pVCpu->hmr0.s.vmx.u64HostMsrStar         = ASMRdMsr(MSR_K6_STAR);
     2480            pVCpu->hmr0.s.vmx.u64HostMsrSfMask       = ASMRdMsr(MSR_K8_SF_MASK);
     2481            pVCpu->hmr0.s.vmx.u64HostMsrKernelGsBase = ASMRdMsr(MSR_K8_KERNEL_GS_BASE);
     2482        }
     2483        pVCpu->hmr0.s.vmx.fLazyMsrs |= VMX_LAZY_MSRS_SAVED_HOST;
    24842484    }
    24852485}
     
    25282528    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
    25292529
    2530     Assert(pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST);
     2530    Assert(pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST);
    25312531    if (pVCpu->CTX_SUFF(pVM)->hm.s.fAllow64BitGuests)
    25322532    {
     
    25422542         */
    25432543        PCCPUMCTX pCtx = &pVCpu->cpum.GstCtx;
    2544         if (   !(pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
    2545             && pCtx->msrKERNELGSBASE == pVCpu->hm.s.vmx.u64HostMsrKernelGsBase
    2546             && pCtx->msrLSTAR        == pVCpu->hm.s.vmx.u64HostMsrLStar
    2547             && pCtx->msrSTAR         == pVCpu->hm.s.vmx.u64HostMsrStar
    2548             && pCtx->msrSFMASK       == pVCpu->hm.s.vmx.u64HostMsrSfMask)
     2544        if (   !(pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
     2545            && pCtx->msrKERNELGSBASE == pVCpu->hmr0.s.vmx.u64HostMsrKernelGsBase
     2546            && pCtx->msrLSTAR        == pVCpu->hmr0.s.vmx.u64HostMsrLStar
     2547            && pCtx->msrSTAR         == pVCpu->hmr0.s.vmx.u64HostMsrStar
     2548            && pCtx->msrSFMASK       == pVCpu->hmr0.s.vmx.u64HostMsrSfMask)
    25492549        {
    25502550#ifdef VBOX_STRICT
     
    25632563        }
    25642564    }
    2565     pVCpu->hm.s.vmx.fLazyMsrs |= VMX_LAZY_MSRS_LOADED_GUEST;
     2565    pVCpu->hmr0.s.vmx.fLazyMsrs |= VMX_LAZY_MSRS_LOADED_GUEST;
    25662566}
    25672567
     
    25822582    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
    25832583
    2584     if (pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
    2585     {
    2586         Assert(pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST);
     2584    if (pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
     2585    {
     2586        Assert(pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_SAVED_HOST);
    25872587        if (pVCpu->CTX_SUFF(pVM)->hm.s.fAllow64BitGuests)
    25882588        {
    2589             ASMWrMsr(MSR_K8_LSTAR,          pVCpu->hm.s.vmx.u64HostMsrLStar);
    2590             ASMWrMsr(MSR_K6_STAR,           pVCpu->hm.s.vmx.u64HostMsrStar);
    2591             ASMWrMsr(MSR_K8_SF_MASK,        pVCpu->hm.s.vmx.u64HostMsrSfMask);
    2592             ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pVCpu->hm.s.vmx.u64HostMsrKernelGsBase);
    2593         }
    2594     }
    2595     pVCpu->hm.s.vmx.fLazyMsrs &= ~(VMX_LAZY_MSRS_LOADED_GUEST | VMX_LAZY_MSRS_SAVED_HOST);
     2589            ASMWrMsr(MSR_K8_LSTAR,          pVCpu->hmr0.s.vmx.u64HostMsrLStar);
     2590            ASMWrMsr(MSR_K6_STAR,           pVCpu->hmr0.s.vmx.u64HostMsrStar);
     2591            ASMWrMsr(MSR_K8_SF_MASK,        pVCpu->hmr0.s.vmx.u64HostMsrSfMask);
     2592            ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pVCpu->hmr0.s.vmx.u64HostMsrKernelGsBase);
     2593        }
     2594    }
     2595    pVCpu->hmr0.s.vmx.fLazyMsrs &= ~(VMX_LAZY_MSRS_LOADED_GUEST | VMX_LAZY_MSRS_SAVED_HOST);
    25962596}
    25972597
     
    46054605     * asserting. Was observed booting Solaris 10u10 32-bit guest.
    46064606     */
    4607     if (pVCpu->hm.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
    4608     {
    4609         Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hm.s.vmx.fRestoreHostFlags,
     4607    if (pVCpu->hmr0.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
     4608    {
     4609        Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hmr0.s.vmx.fRestoreHostFlags,
    46104610                  pVCpu->idCpu));
    4611         VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    4612         pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
     4611        VMXRestoreHostState(pVCpu->hmr0.s.vmx.fRestoreHostFlags, &pVCpu->hmr0.s.vmx.RestoreHost);
     4612        pVCpu->hmr0.s.vmx.fRestoreHostFlags = 0;
    46134613    }
    46144614
     
    46224622    if (uHostCr4 & X86_CR4_FSGSBASE)
    46234623    {
    4624         hmR0VmxExportHostSegmentRegsAsmHlp(&pVCpu->hm.s.vmx.RestoreHost, true /*fHaveFsGsBase*/);
     4624        hmR0VmxExportHostSegmentRegsAsmHlp(&pVCpu->hmr0.s.vmx.RestoreHost, true /*fHaveFsGsBase*/);
    46254625        fRestoreHostFlags = VMX_RESTORE_HOST_CAN_USE_WRFSBASE_AND_WRGSBASE;
    46264626    }
    46274627    else
    46284628    {
    4629         hmR0VmxExportHostSegmentRegsAsmHlp(&pVCpu->hm.s.vmx.RestoreHost, false /*fHaveFsGsBase*/);
     4629        hmR0VmxExportHostSegmentRegsAsmHlp(&pVCpu->hmr0.s.vmx.RestoreHost, false /*fHaveFsGsBase*/);
    46304630        fRestoreHostFlags = 0;
    46314631    }
    4632     RTSEL uSelES = pVCpu->hm.s.vmx.RestoreHost.uHostSelES;
    4633     RTSEL uSelDS = pVCpu->hm.s.vmx.RestoreHost.uHostSelDS;
    4634     RTSEL uSelFS = pVCpu->hm.s.vmx.RestoreHost.uHostSelFS;
    4635     RTSEL uSelGS = pVCpu->hm.s.vmx.RestoreHost.uHostSelGS;
     4632    RTSEL uSelES = pVCpu->hmr0.s.vmx.RestoreHost.uHostSelES;
     4633    RTSEL uSelDS = pVCpu->hmr0.s.vmx.RestoreHost.uHostSelDS;
     4634    RTSEL uSelFS = pVCpu->hmr0.s.vmx.RestoreHost.uHostSelFS;
     4635    RTSEL uSelGS = pVCpu->hmr0.s.vmx.RestoreHost.uHostSelGS;
    46364636#else
    4637     pVCpu->hm.s.vmx.RestoreHost.uHostSelTR = ASMGetTR();
    4638     pVCpu->hm.s.vmx.RestoreHost.uHostSelSS = ASMGetSS();
    4639     pVCpu->hm.s.vmx.RestoreHost.uHostSelCS = ASMGetCS();
    4640     ASMGetGDTR((PRTGDTR)&pVCpu->hm.s.vmx.RestoreHost.HostGdtr);
    4641     ASMGetIDTR((PRTIDTR)&pVCpu->hm.s.vmx.RestoreHost.HostIdtr);
     4637    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR = ASMGetTR();
     4638    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelSS = ASMGetSS();
     4639    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelCS = ASMGetCS();
     4640    ASMGetGDTR((PRTGDTR)&pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr);
     4641    ASMGetIDTR((PRTIDTR)&pVCpu->hmr0.s.vmx.RestoreHost.HostIdtr);
    46424642    if (uHostCr4 & X86_CR4_FSGSBASE)
    46434643    {
    4644         pVCpu->hm.s.vmx.RestoreHost.uHostFSBase = ASMGetFSBase();
    4645         pVCpu->hm.s.vmx.RestoreHost.uHostGSBase = ASMGetGSBase();
     4644        pVCpu->hmr0.s.vmx.RestoreHost.uHostFSBase = ASMGetFSBase();
     4645        pVCpu->hmr0.s.vmx.RestoreHost.uHostGSBase = ASMGetGSBase();
    46464646        fRestoreHostFlags = VMX_RESTORE_HOST_CAN_USE_WRFSBASE_AND_WRGSBASE;
    46474647    }
    46484648    else
    46494649    {
    4650         pVCpu->hm.s.vmx.RestoreHost.uHostFSBase = ASMRdMsr(MSR_K8_FS_BASE);
    4651         pVCpu->hm.s.vmx.RestoreHost.uHostGSBase = ASMRdMsr(MSR_K8_GS_BASE);
     4650        pVCpu->hmr0.s.vmx.RestoreHost.uHostFSBase = ASMRdMsr(MSR_K8_FS_BASE);
     4651        pVCpu->hmr0.s.vmx.RestoreHost.uHostGSBase = ASMRdMsr(MSR_K8_GS_BASE);
    46524652        fRestoreHostFlags = 0;
    46534653    }
    46544654    RTSEL uSelES, uSelDS, uSelFS, uSelGS;
    4655     pVCpu->hm.s.vmx.RestoreHost.uHostSelDS = uSelDS = ASMGetDS();
    4656     pVCpu->hm.s.vmx.RestoreHost.uHostSelES = uSelES = ASMGetES();
    4657     pVCpu->hm.s.vmx.RestoreHost.uHostSelFS = uSelFS = ASMGetFS();
    4658     pVCpu->hm.s.vmx.RestoreHost.uHostSelGS = uSelGS = ASMGetGS();
     4655    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelDS = uSelDS = ASMGetDS();
     4656    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelES = uSelES = ASMGetES();
     4657    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelFS = uSelFS = ASMGetFS();
     4658    pVCpu->hmr0.s.vmx.RestoreHost.uHostSelGS = uSelGS = ASMGetGS();
    46594659#endif
    46604660
     
    46724672#define VMXLOCAL_ADJUST_HOST_SEG(a_Seg, a_uVmcsVar) \
    46734673                do { \
    4674                     (a_uVmcsVar) = pVCpu->hm.s.vmx.RestoreHost.uHostSel##a_Seg; \
     4674                    (a_uVmcsVar) = pVCpu->hmr0.s.vmx.RestoreHost.uHostSel##a_Seg; \
    46754675                    if ((a_uVmcsVar) & X86_SEL_RPL) \
    46764676                    { \
     
    46894689#define VMXLOCAL_ADJUST_HOST_SEG(a_Seg, a_uVmcsVar) \
    46904690                do { \
    4691                     (a_uVmcsVar) = pVCpu->hm.s.vmx.RestoreHost.uHostSel##a_Seg; \
     4691                    (a_uVmcsVar) = pVCpu->hmr0.s.vmx.RestoreHost.uHostSel##a_Seg; \
    46924692                    if ((a_uVmcsVar) & (X86_SEL_RPL | X86_SEL_LDT)) \
    46934693                    { \
     
    47124712
    47134713    /* Verification based on Intel spec. 26.2.3 "Checks on Host Segment and Descriptor-Table Registers"  */
    4714     Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelTR & X86_SEL_RPL)); Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelTR & X86_SEL_LDT)); Assert(pVCpu->hm.s.vmx.RestoreHost.uHostSelTR);
    4715     Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelCS & X86_SEL_RPL)); Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelCS & X86_SEL_LDT)); Assert(pVCpu->hm.s.vmx.RestoreHost.uHostSelCS);
    4716     Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelSS & X86_SEL_RPL)); Assert(!(pVCpu->hm.s.vmx.RestoreHost.uHostSelSS & X86_SEL_LDT));
     4714    Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR & X86_SEL_RPL)); Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR & X86_SEL_LDT)); Assert(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR);
     4715    Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelCS & X86_SEL_RPL)); Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelCS & X86_SEL_LDT)); Assert(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelCS);
     4716    Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelSS & X86_SEL_RPL)); Assert(!(pVCpu->hmr0.s.vmx.RestoreHost.uHostSelSS & X86_SEL_LDT));
    47174717    Assert(!(uSelDS & X86_SEL_RPL)); Assert(!(uSelDS & X86_SEL_LDT));
    47184718    Assert(!(uSelES & X86_SEL_RPL)); Assert(!(uSelES & X86_SEL_LDT));
     
    47244724     * them to the maximum limit (0xffff) on every VM-exit.
    47254725     */
    4726     if (pVCpu->hm.s.vmx.RestoreHost.HostGdtr.cb != 0xffff)
     4726    if (pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.cb != 0xffff)
    47274727        fRestoreHostFlags |= VMX_RESTORE_HOST_GDTR;
    47284728
     
    47374737     */
    47384738#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
    4739     if (pVCpu->hm.s.vmx.RestoreHost.HostIdtr.cb <  0x0fff)
     4739    if (pVCpu->hmr0.s.vmx.RestoreHost.HostIdtr.cb <  0x0fff)
    47404740#else
    4741     if (pVCpu->hm.s.vmx.RestoreHost.HostIdtr.cb != 0xffff)
     4741    if (pVCpu->hmr0.s.vmx.RestoreHost.HostIdtr.cb != 0xffff)
    47424742#endif
    47434743        fRestoreHostFlags |= VMX_RESTORE_HOST_IDTR;
     
    47484748     * RPL should be too in most cases.
    47494749     */
    4750     RTSEL const uSelTR = pVCpu->hm.s.vmx.RestoreHost.uHostSelTR;
    4751     AssertMsgReturn((uSelTR | X86_SEL_RPL_LDT) <= pVCpu->hm.s.vmx.RestoreHost.HostGdtr.cb,
    4752                     ("TR selector exceeds limit. TR=%RTsel cbGdt=%#x\n", uSelTR, pVCpu->hm.s.vmx.RestoreHost.HostGdtr.cb),
     4750    RTSEL const uSelTR = pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR;
     4751    AssertMsgReturn((uSelTR | X86_SEL_RPL_LDT) <= pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.cb,
     4752                    ("TR selector exceeds limit. TR=%RTsel cbGdt=%#x\n", uSelTR, pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.cb),
    47534753                    VERR_VMX_INVALID_HOST_STATE);
    47544754
    4755     PCX86DESCHC pDesc = (PCX86DESCHC)(pVCpu->hm.s.vmx.RestoreHost.HostGdtr.uAddr + (uSelTR & X86_SEL_MASK));
     4755    PCX86DESCHC pDesc = (PCX86DESCHC)(pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.uAddr + (uSelTR & X86_SEL_MASK));
    47564756    uintptr_t const uTRBase = X86DESC64_BASE(pDesc);
    47574757
     
    47804780            /* The GDT is read-only but the writable GDT is available. */
    47814781            fRestoreHostFlags |= VMX_RESTORE_HOST_GDT_NEED_WRITABLE;
    4782             pVCpu->hm.s.vmx.RestoreHost.HostGdtrRw.cb = pVCpu->hm.s.vmx.RestoreHost.HostGdtr.cb;
    4783             int rc = SUPR0GetCurrentGdtRw(&pVCpu->hm.s.vmx.RestoreHost.HostGdtrRw.uAddr);
     4782            pVCpu->hmr0.s.vmx.RestoreHost.HostGdtrRw.cb = pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.cb;
     4783            int rc = SUPR0GetCurrentGdtRw(&pVCpu->hmr0.s.vmx.RestoreHost.HostGdtrRw.uAddr);
    47844784            AssertRCReturn(rc, rc);
    47854785        }
    47864786    }
    47874787
    4788     pVCpu->hm.s.vmx.fRestoreHostFlags = fRestoreHostFlags;
     4788    pVCpu->hmr0.s.vmx.fRestoreHostFlags = fRestoreHostFlags;
    47894789
    47904790    /*
     
    47924792     */
    47934793    int rc;
    4794     rc = VMXWriteVmcs16(VMX_VMCS16_HOST_CS_SEL,  pVCpu->hm.s.vmx.RestoreHost.uHostSelCS);       AssertRC(rc);
    4795     rc = VMXWriteVmcs16(VMX_VMCS16_HOST_SS_SEL,  pVCpu->hm.s.vmx.RestoreHost.uHostSelSS);       AssertRC(rc);
     4794    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_CS_SEL,  pVCpu->hmr0.s.vmx.RestoreHost.uHostSelCS);       AssertRC(rc);
     4795    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_SS_SEL,  pVCpu->hmr0.s.vmx.RestoreHost.uHostSelSS);       AssertRC(rc);
    47964796    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_DS_SEL,  uSelDS);                                       AssertRC(rc);
    47974797    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_ES_SEL,  uSelES);                                       AssertRC(rc);
    47984798    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_FS_SEL,  uSelFS);                                       AssertRC(rc);
    47994799    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_GS_SEL,  uSelGS);                                       AssertRC(rc);
    4800     rc = VMXWriteVmcs16(VMX_VMCS16_HOST_TR_SEL,  pVCpu->hm.s.vmx.RestoreHost.uHostSelTR);       AssertRC(rc);
    4801     rc = VMXWriteVmcsNw(VMX_VMCS_HOST_GDTR_BASE, pVCpu->hm.s.vmx.RestoreHost.HostGdtr.uAddr);   AssertRC(rc);
    4802     rc = VMXWriteVmcsNw(VMX_VMCS_HOST_IDTR_BASE, pVCpu->hm.s.vmx.RestoreHost.HostIdtr.uAddr);   AssertRC(rc);
     4800    rc = VMXWriteVmcs16(VMX_VMCS16_HOST_TR_SEL,  pVCpu->hmr0.s.vmx.RestoreHost.uHostSelTR);       AssertRC(rc);
     4801    rc = VMXWriteVmcsNw(VMX_VMCS_HOST_GDTR_BASE, pVCpu->hmr0.s.vmx.RestoreHost.HostGdtr.uAddr);   AssertRC(rc);
     4802    rc = VMXWriteVmcsNw(VMX_VMCS_HOST_IDTR_BASE, pVCpu->hmr0.s.vmx.RestoreHost.HostIdtr.uAddr);   AssertRC(rc);
    48034803    rc = VMXWriteVmcsNw(VMX_VMCS_HOST_TR_BASE,   uTRBase);                                      AssertRC(rc);
    4804     rc = VMXWriteVmcsNw(VMX_VMCS_HOST_FS_BASE,   pVCpu->hm.s.vmx.RestoreHost.uHostFSBase);      AssertRC(rc);
    4805     rc = VMXWriteVmcsNw(VMX_VMCS_HOST_GS_BASE,   pVCpu->hm.s.vmx.RestoreHost.uHostGSBase);      AssertRC(rc);
     4804    rc = VMXWriteVmcsNw(VMX_VMCS_HOST_FS_BASE,   pVCpu->hmr0.s.vmx.RestoreHost.uHostFSBase);      AssertRC(rc);
     4805    rc = VMXWriteVmcsNw(VMX_VMCS_HOST_GS_BASE,   pVCpu->hmr0.s.vmx.RestoreHost.uHostGSBase);      AssertRC(rc);
    48064806
    48074807    return VINF_SUCCESS;
     
    77047704            {
    77057705                if (   pVM->hm.s.fAllow64BitGuests
    7706                     && (pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST))
     7706                    && (pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST))
    77077707                    pCtx->msrKERNELGSBASE = ASMRdMsr(MSR_K8_KERNEL_GS_BASE);
    77087708            }
     
    77117711            {
    77127712                if (   pVM->hm.s.fAllow64BitGuests
    7713                     && (pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST))
     7713                    && (pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST))
    77147714                {
    77157715                    pCtx->msrLSTAR  = ASMRdMsr(MSR_K8_LSTAR);
     
    83068306
    83078307    /* Restore host-state bits that VT-x only restores partially. */
    8308     if (pVCpu->hm.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
    8309     {
    8310         Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hm.s.vmx.fRestoreHostFlags, idCpu));
    8311         VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    8312     }
    8313     pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
     8308    if (pVCpu->hmr0.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
     8309    {
     8310        Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hmr0.s.vmx.fRestoreHostFlags, idCpu));
     8311        VMXRestoreHostState(pVCpu->hmr0.s.vmx.fRestoreHostFlags, &pVCpu->hmr0.s.vmx.RestoreHost);
     8312    }
     8313    pVCpu->hmr0.s.vmx.fRestoreHostFlags = 0;
    83148314
    83158315    /* Restore the lazy host MSRs as we're leaving VT-x context. */
    8316     if (pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
     8316    if (pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
    83178317    {
    83188318        /* We shouldn't restore the host MSRs without saving the guest MSRs first. */
     
    83238323        }
    83248324        hmR0VmxLazyRestoreHostMsrs(pVCpu);
    8325         Assert(!pVCpu->hm.s.vmx.fLazyMsrs);
     8325        Assert(!pVCpu->hmr0.s.vmx.fLazyMsrs);
    83268326    }
    83278327    else
    8328         pVCpu->hm.s.vmx.fLazyMsrs = 0;
     8328        pVCpu->hmr0.s.vmx.fLazyMsrs = 0;
    83298329
    83308330    /* Update auto-load/store host MSRs values when we re-enter VT-x (as we could be on a different CPU). */
    8331     pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs = false;
     8331    pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs = false;
    83328332
    83338333    STAM_PROFILE_ADV_SET_STOPPED(&pVCpu->hm.s.StatEntry);
     
    85968596
    85978597        /* Restore host-state bits that VT-x only restores partially. */
    8598         if (pVCpu->hm.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
    8599             VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    8600         pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
     8598        if (pVCpu->hmr0.s.vmx.fRestoreHostFlags > VMX_RESTORE_HOST_REQUIRED)
     8599            VMXRestoreHostState(pVCpu->hmr0.s.vmx.fRestoreHostFlags, &pVCpu->hmr0.s.vmx.RestoreHost);
     8600        pVCpu->hmr0.s.vmx.fRestoreHostFlags = 0;
    86018601
    86028602        /* Restore the lazy host MSRs as we're leaving VT-x context. */
    8603         if (pVCpu->hm.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
     8603        if (pVCpu->hmr0.s.vmx.fLazyMsrs & VMX_LAZY_MSRS_LOADED_GUEST)
    86048604            hmR0VmxLazyRestoreHostMsrs(pVCpu);
    86058605
    86068606        /* Update auto-load/store host MSRs values when we re-enter VT-x (as we could be on a different CPU). */
    8607         pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs = false;
     8607        pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs = false;
    86088608        VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_HM, VMCPUSTATE_STARTED_EXEC);
    86098609
     
    1097310973     * Update the host MSRs values in the VM-exit MSR-load area.
    1097410974     */
    10975     if (!pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs)
     10975    if (!pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs)
    1097610976    {
    1097710977        if (pVmcsInfo->cExitMsrLoad > 0)
    1097810978            hmR0VmxUpdateAutoLoadHostMsrs(pVCpu, pVmcsInfo);
    10979         pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs = true;
     10979        pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs = true;
    1098010980    }
    1098110981
     
    1103211032
    1103311033#ifdef VBOX_STRICT
    11034     Assert(pVCpu->hm.s.vmx.fUpdatedHostAutoMsrs);
     11034    Assert(pVCpu->hmr0.s.vmx.fUpdatedHostAutoMsrs);
    1103511035    hmR0VmxCheckAutoLoadStoreMsrs(pVCpu, pVmcsInfo, pVmxTransient->fIsNestedGuest);
    1103611036    hmR0VmxCheckHostEferMsr(pVCpu, pVmcsInfo);
     
    1109011090    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HM);
    1109111091
    11092     pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_REQUIRED;     /* Some host state messed up by VMX needs restoring. */
     11092    pVCpu->hmr0.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_REQUIRED;     /* Some host state messed up by VMX needs restoring. */
    1109311093    pVmcsInfo->fVmcsState |= VMX_V_VMCS_LAUNCH_STATE_LAUNCHED;          /* Use VMRESUME instead of VMLAUNCH in the next run. */
    1109411094#ifdef VBOX_STRICT
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette