Changeset 13343
- Timestamp:
- 10/16/08 17:01:44 (3 months ago)
- Files:
-
- trunk/include/VBox/hwaccm.h (modified) (1 diff)
- trunk/src/VBox/VMM/EM.cpp (modified) (1 diff)
- trunk/src/VBox/VMM/HWACCM.cpp (modified) (2 diffs)
- trunk/src/VBox/VMM/HWACCMInternal.h (modified) (1 diff)
- trunk/src/VBox/VMM/PGM.cpp (modified) (1 diff)
- trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/VBox/hwaccm.h
r13221 r13343 110 110 VMMR3DECL(bool) HWACCMR3IsNestedPagingActive(PVM pVM); 111 111 VMMR3DECL(bool) HWACCMR3IsAllowed(PVM pVM); 112 VMMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode );112 VMMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode, PGMMODE enmGuestMode); 113 113 VMMR3DECL(bool) HWACCMR3IsVPIDActive(PVM pVM); 114 114 trunk/src/VBox/VMM/EM.cpp
r13265 r13343 779 779 Log(("EMV86: %04X:%08X IF=%d\n", pCtx->cs, pCtx->eip, pCtx->eflags.Bits.u1IF)); 780 780 else 781 Log(("EMR%d: %0 8X ESP=%08X IF=%d CR0=%x\n", cpl, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, (uint32_t)pCtx->cr0));781 Log(("EMR%d: %04X:%08X ESP=%08X IF=%d CR0=%x\n", cpl, pCtx->cs, pCtx->eip, pCtx->esp, pCtx->eflags.Bits.u1IF, (uint32_t)pCtx->cr0)); 782 782 #endif 783 783 STAM_REL_PROFILE_ADV_START(&pVM->em.s.StatREMTotal, a); trunk/src/VBox/VMM/HWACCM.cpp
r13276 r13343 783 783 * 784 784 * @param pVM The VM to operate on. 785 * @param enmShadowMode New paging mode. 786 */ 787 VMMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode) 785 * @param enmShadowMode New shadow paging mode. 786 * @param enmGuestMode New guest paging mode. 787 */ 788 VMMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode, PGMMODE enmGuestMode) 788 789 { 789 790 pVM->hwaccm.s.enmShadowMode = enmShadowMode; 791 if ( pVM->hwaccm.s.vmx.fEnabled 792 && pVM->fHWACCMEnabled) 793 { 794 if ( pVM->hwaccm.s.vmx.enmCurrGuestMode == PGMMODE_REAL 795 && enmGuestMode >= PGMMODE_PROTECTED) 796 { 797 PCPUMCTX pCtx; 798 799 CPUMQueryGuestCtxPtr(pVM, &pCtx); 800 801 /* After a real mode switch to protected mode we must force 802 * CPL to 0. Our real mode emulation had to set it to 3. 803 */ 804 pCtx->ssHid.Attr.n.u2Dpl = 0; 805 } 806 } 790 807 } 791 808 … … 874 891 || pCtx->gsHid.u64Base > 0xfffff) 875 892 return false; 893 894 if ( ( pCtx->cs != (pCtx->csHid.u64Base >> 4) 895 && pCtx->csHid.u64Base != 0xffff0000 /* we can deal with the BIOS code as it's also mapped into the lower region. */) 896 || pCtx->ds != (pCtx->dsHid.u64Base >> 4) 897 || pCtx->es != (pCtx->esHid.u64Base >> 4) 898 || pCtx->fs != (pCtx->fsHid.u64Base >> 4) 899 || pCtx->gs != (pCtx->gsHid.u64Base >> 4) 900 || pCtx->ss != (pCtx->ssHid.u64Base >> 4)) 901 return false; 902 } 903 else 904 { 905 PGMMODE enmGuestMode = PGMGetGuestMode(pVM); 906 /* Correct weird requirements for switching to protected mode. */ 907 if ( pVM->hwaccm.s.vmx.enmCurrGuestMode == PGMMODE_REAL 908 && enmGuestMode >= PGMMODE_PROTECTED) 909 { 910 if ( (pCtx->cs & X86_SEL_RPL) 911 || (pCtx->ds & X86_SEL_RPL) 912 || (pCtx->es & X86_SEL_RPL) 913 || (pCtx->fs & X86_SEL_RPL) 914 || (pCtx->gs & X86_SEL_RPL) 915 || (pCtx->ss & X86_SEL_RPL)) 916 return false; 917 } 876 918 } 877 919 #else trunk/src/VBox/VMM/HWACCMInternal.h
r13276 r13343 340 340 struct 341 341 { 342 CPUMSELREGHID dsHid;343 CPUMSELREGHID esHid;344 CPUMSELREGHID fsHid;345 CPUMSELREGHID gsHid;346 CPUMSELREGHID ssHid;347 RTSEL ds;348 RTSEL es;349 RTSEL fs;350 RTSEL gs;351 RTSEL ss;352 RTSEL padding5[1];353 342 X86EFLAGS eflags; 354 343 uint32_t fValid; trunk/src/VBox/VMM/PGM.cpp
r13235 r13343 3450 3450 3451 3451 /* Notify HWACCM as well. */ 3452 HWACCMR3PagingModeChanged(pVM, pVM->pgm.s.enmShadowMode );3452 HWACCMR3PagingModeChanged(pVM, pVM->pgm.s.enmShadowMode, pVM->pgm.s.enmGuestMode); 3453 3453 return rc; 3454 3454 } trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r13289 r13343 954 954 if (pVM->hwaccm.s.vmx.enmCurrGuestMode != enmGuestMode) 955 955 { 956 # define VTX_CORRECT_PROT_SEL(reg) \957 { \958 if ( pCtx->reg##Hid.u64Base == (pVM->hwaccm.s.vmx.RealMode.reg##Hid.u64Base & 0xfffff) \959 && pCtx->reg == ((pVM->hwaccm.s.vmx.RealMode.reg##Hid.u64Base >> 4) & ~X86_SEL_RPL)) \960 { \961 pCtx->reg##Hid = pVM->hwaccm.s.vmx.RealMode.reg##Hid; \962 pCtx->reg = pVM->hwaccm.s.vmx.RealMode.reg; \963 } \964 }965 966 956 /* Correct weird requirements for switching to protected mode. */ 967 957 if ( pVM->hwaccm.s.vmx.enmCurrGuestMode == PGMMODE_REAL … … 977 967 pCtx->gsHid.Attr.n.u2Dpl = 0; 978 968 pCtx->ssHid.Attr.n.u2Dpl = 0; 979 980 /* RPL of all selectors must match the current CPL (0). */981 pCtx->cs &= ~X86_SEL_RPL;982 pCtx->ds &= ~X86_SEL_RPL;983 pCtx->es &= ~X86_SEL_RPL;984 pCtx->fs &= ~X86_SEL_RPL;985 pCtx->gs &= ~X86_SEL_RPL;986 pCtx->ss &= ~X86_SEL_RPL;987 988 if (pVM->hwaccm.s.vmx.RealMode.fValid)989 {990 VTX_CORRECT_PROT_SEL(ds);991 VTX_CORRECT_PROT_SEL(es);992 VTX_CORRECT_PROT_SEL(fs);993 VTX_CORRECT_PROT_SEL(gs);994 pVM->hwaccm.s.vmx.RealMode.fValid = false;995 }996 969 } 997 970 else … … 1000 973 && enmGuestMode == PGMMODE_REAL) 1001 974 { 1002 /* Save the original hidden selectors in case we need to restore them later on. */1003 pVM->hwaccm.s.vmx.RealMode.ds = pCtx->ds;1004 pVM->hwaccm.s.vmx.RealMode.dsHid = pCtx->dsHid;1005 pVM->hwaccm.s.vmx.RealMode.es = pCtx->es;1006 pVM->hwaccm.s.vmx.RealMode.esHid = pCtx->esHid;1007 pVM->hwaccm.s.vmx.RealMode.fs = pCtx->fs;1008 pVM->hwaccm.s.vmx.RealMode.fsHid = pCtx->fsHid;1009 pVM->hwaccm.s.vmx.RealMode.gs = pCtx->gs;1010 pVM->hwaccm.s.vmx.RealMode.gsHid = pCtx->gsHid;1011 pVM->hwaccm.s.vmx.RealMode.ss = pCtx->ss;1012 pVM->hwaccm.s.vmx.RealMode.ssHid = pCtx->ssHid;1013 pVM->hwaccm.s.vmx.RealMode.fValid = true;1014 1015 /* The selector value & base must be adjusted or else... */1016 pCtx->cs = pCtx->csHid.u64Base >> 4;1017 pCtx->ds = pCtx->dsHid.u64Base >> 4;1018 pCtx->es = pCtx->esHid.u64Base >> 4;1019 pCtx->fs = pCtx->fsHid.u64Base >> 4;1020 pCtx->gs = pCtx->gsHid.u64Base >> 4;1021 pCtx->ss = pCtx->ssHid.u64Base >> 4;1022 1023 975 /* The limit must also be adjusted. */ 1024 976 pCtx->csHid.u32Limit &= 0xffff;

