VirtualBox

Changeset 50426 in vbox


Ignore:
Timestamp:
Feb 12, 2014 1:16:33 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92215
Message:

HMR0VMX.cpp: Hacked hmR0VmxSaveHostSegmentRegs to call VMXRestoreHostState when necessary so we don't corrupt the host state should HM_CHANGED_HOST_CONTEXT be set and executed without leaving the HM ring-0 context. Also restricted the dont-bother-to-restore-host-Idtr.limit condition to only include Linux and Solaris as this is known to cause trouble on Windows and Darwin already (HMR0Mixed.mac needs tweaking and testing to complete this change.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r50285 r50426  
    27502750        { \
    27512751            uint32_t uAttr = ASMGetSegAttr((selValue)); \
    2752             fValidSelector = RT_BOOL(uAttr != ~0U && (uAttr & X86_DESC_P)); \
     2752            fValidSelector = RT_BOOL(uAttr != UINT32_MAX && (uAttr & X86_DESC_P)); \
    27532753        } \
    27542754        if (fValidSelector) \
     
    27742774    NOREF(pVM);
    27752775    int rc = VERR_INTERNAL_ERROR_5;
     2776
     2777    /*
     2778     * Quick fix for regression #7240.  Restore the host state if we've messed
     2779     * it up already, otherwise all we'll get it all wrong below!
     2780     */
     2781    if (   (pVCpu->hm.s.vmx.fRestoreHostFlags & VMX_RESTORE_HOST_REQUIRED)
     2782        && (pVCpu->hm.s.vmx.fRestoreHostFlags & ~VMX_RESTORE_HOST_REQUIRED))
     2783        VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    27762784
    27772785    /*
     
    28992907
    29002908        /*
    2901          * IDT limit is practically 0xfff. Therefore if the host has the limit as 0xfff, VT-x bloating the limit to 0xffff
    2902          * is not a problem as it's not possible to get at them anyway. See Intel spec. 6.14.1 "64-Bit Mode IDT" and
    2903          * Intel spec. 6.2 "Exception and Interrupt Vectors".
     2909         * IDT limit is effectively capped at 0xfff. (See Intel spec. 6.14.1 "64-Bit Mode IDT"
     2910         * and Intel spec. 6.2 "Exception and Interrupt Vectors".)  Therefore if the host has the limit as 0xfff, VT-x
     2911         * bloating the limit to 0xffff shouldn't cause any different CPU behavior.  However, several hosts either insists
     2912         * on 0xfff being the limit (Windows Patch Guard) or uses the limit for other purposes (darwin puts the CPU ID in there
     2913         * but botches sidt alignment in at least one consumer).  So, we're only allowing IDTR.LIMIT to be left at 0xffff on
     2914         * hosts where we are pretty sure it won't cause trouble.
    29042915         */
    2905         if (Idtr.cbIdt < 0x0fff)
     2916# if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
     2917        if (Idtr.cbIdt <  0x0fff)
     2918# else
     2919        if (Idtr.cbIdt != 0xffff)
     2920# endif
    29062921        {
    29072922            pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_IDTR;
     
    66386653        Log4Func(("Restoring Host State: fRestoreHostFlags=%#RX32 HostCpuId=%u\n", pVCpu->hm.s.vmx.fRestoreHostFlags, idCpu));
    66396654        VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    6640         pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
    6641     }
     6655    }
     6656    pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
    66426657#endif
    66436658
     
    68696884        if (   (pVCpu->hm.s.vmx.fRestoreHostFlags & VMX_RESTORE_HOST_REQUIRED)
    68706885            && (pVCpu->hm.s.vmx.fRestoreHostFlags & ~VMX_RESTORE_HOST_REQUIRED))
    6871         {
    68726886            VMXRestoreHostState(pVCpu->hm.s.vmx.fRestoreHostFlags, &pVCpu->hm.s.vmx.RestoreHost);
    6873             pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
    6874         }
     6887        pVCpu->hm.s.vmx.fRestoreHostFlags = 0;
     6888
    68756889        /* Restore the host MSRs as we're leaving VT-x context. */
    68766890        if (   pVM->hm.s.fAllow64BitGuests
Note: See TracChangeset for help on using the changeset viewer.

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