Changeset 15587 in vbox
- Timestamp:
- Dec 16, 2008 2:07:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp
r15576 r15587 1072 1072 # ifdef HWACCM_VMX_EMULATE_REALMODE 1073 1073 /* Intercept all exceptions in real mode as none of them can be injected directly (#GP otherwise). */ 1074 if (CPUMIsGuestInRealModeEx(pCtx) )1074 if (CPUMIsGuestInRealModeEx(pCtx) && pVM->hwaccm.s.vmx.pRealModeTSS) 1075 1075 u32TrapMask |= HWACCM_VMX_TRAP_MASK_REALMODE; 1076 1076 # endif /* HWACCM_VMX_EMULATE_REALMODE */ … … 1126 1126 #else 1127 1127 val |= VMX_VMCS_CTRL_EXIT_CONTROLS_SAVE_DEBUG; 1128 #endif 1128 #endif 1129 1129 1130 1130 #if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBRID_32BIT_KERNEL) … … 1147 1147 { 1148 1148 #ifdef HWACCM_VMX_EMULATE_REALMODE 1149 PGMMODE enmGuestMode = PGMGetGuestMode(pVM); 1150 if (pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode != enmGuestMode) 1151 { 1152 /* Correct weird requirements for switching to protected mode. */ 1153 if ( pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode == PGMMODE_REAL 1154 && enmGuestMode >= PGMMODE_PROTECTED) 1149 if (pVM->hwaccm.s.vmx.pRealModeTSS) 1150 { 1151 PGMMODE enmGuestMode = PGMGetGuestMode(pVM); 1152 if (pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode != enmGuestMode) 1155 1153 { 1156 /* DPL of all hidden selector registers must match the current CPL (0). */ 1157 pCtx->csHid.Attr.n.u2Dpl = 0; 1158 pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_CODE | X86_SEL_TYPE_RW_ACC; 1159 1160 pCtx->dsHid.Attr.n.u2Dpl = 0; 1161 pCtx->esHid.Attr.n.u2Dpl = 0; 1162 pCtx->fsHid.Attr.n.u2Dpl = 0; 1163 pCtx->gsHid.Attr.n.u2Dpl = 0; 1164 pCtx->ssHid.Attr.n.u2Dpl = 0; 1154 /* Correct weird requirements for switching to protected mode. */ 1155 if ( pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode == PGMMODE_REAL 1156 && enmGuestMode >= PGMMODE_PROTECTED) 1157 { 1158 /* DPL of all hidden selector registers must match the current CPL (0). */ 1159 pCtx->csHid.Attr.n.u2Dpl = 0; 1160 pCtx->csHid.Attr.n.u4Type = X86_SEL_TYPE_CODE | X86_SEL_TYPE_RW_ACC; 1161 1162 pCtx->dsHid.Attr.n.u2Dpl = 0; 1163 pCtx->esHid.Attr.n.u2Dpl = 0; 1164 pCtx->fsHid.Attr.n.u2Dpl = 0; 1165 pCtx->gsHid.Attr.n.u2Dpl = 0; 1166 pCtx->ssHid.Attr.n.u2Dpl = 0; 1167 } 1168 else 1169 /* Switching from protected mode to real mode. */ 1170 if ( pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode >= PGMMODE_PROTECTED 1171 && enmGuestMode == PGMMODE_REAL) 1172 { 1173 /* The limit must also be adjusted. */ 1174 pCtx->csHid.u32Limit &= 0xffff; 1175 pCtx->dsHid.u32Limit &= 0xffff; 1176 pCtx->esHid.u32Limit &= 0xffff; 1177 pCtx->fsHid.u32Limit &= 0xffff; 1178 pCtx->gsHid.u32Limit &= 0xffff; 1179 pCtx->ssHid.u32Limit &= 0xffff; 1180 1181 Assert(pCtx->csHid.u64Base <= 0xfffff); 1182 Assert(pCtx->dsHid.u64Base <= 0xfffff); 1183 Assert(pCtx->esHid.u64Base <= 0xfffff); 1184 Assert(pCtx->fsHid.u64Base <= 0xfffff); 1185 Assert(pCtx->gsHid.u64Base <= 0xfffff); 1186 } 1187 pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode = enmGuestMode; 1165 1188 } 1166 1189 else 1167 /* Switching from protected mode to real mode.*/1168 if ( pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode >= PGMMODE_PROTECTED1169 && enmGuestMode == PGMMODE_REAL)1190 /* VT-x will fail with a guest invalid state otherwise... (CPU state after a reset) */ 1191 if ( CPUMIsGuestInRealModeEx(pCtx) 1192 && pCtx->csHid.u64Base == 0xffff0000) 1170 1193 { 1171 /* The limit must also be adjusted. */ 1172 pCtx->csHid.u32Limit &= 0xffff; 1173 pCtx->dsHid.u32Limit &= 0xffff; 1174 pCtx->esHid.u32Limit &= 0xffff; 1175 pCtx->fsHid.u32Limit &= 0xffff; 1176 pCtx->gsHid.u32Limit &= 0xffff; 1177 pCtx->ssHid.u32Limit &= 0xffff; 1178 1179 Assert(pCtx->csHid.u64Base <= 0xfffff); 1180 Assert(pCtx->dsHid.u64Base <= 0xfffff); 1181 Assert(pCtx->esHid.u64Base <= 0xfffff); 1182 Assert(pCtx->fsHid.u64Base <= 0xfffff); 1183 Assert(pCtx->gsHid.u64Base <= 0xfffff); 1194 pCtx->csHid.u64Base = 0xf0000; 1195 pCtx->cs = 0xf000; 1184 1196 } 1185 pVCpu->hwaccm.s.vmx.enmLastSeenGuestMode = enmGuestMode;1186 }1187 else1188 /* VT-x will fail with a guest invalid state otherwise... (CPU state after a reset) */1189 if ( CPUMIsGuestInRealModeEx(pCtx)1190 && pCtx->csHid.u64Base == 0xffff0000)1191 {1192 pCtx->csHid.u64Base = 0xf0000;1193 pCtx->cs = 0xf000;1194 1197 } 1195 1198 #endif /* HWACCM_VMX_EMULATE_REALMODE */ … … 1383 1386 case PGMMODE_REAL: /* Real mode -> emulated using v86 mode */ 1384 1387 case PGMMODE_PROTECTED: /* Protected mode, no paging -> emulated using identity mapping. */ 1385 case PGMMODE_32_BIT: /* 32-bit paging. */ 1388 case PGMMODE_32_BIT: /* 32-bit paging. */ 1386 1389 val &= ~X86_CR4_PAE; 1387 1390 break;
Note:
See TracChangeset
for help on using the changeset viewer.