Changeset 97223 in vbox
- Timestamp:
- Oct 18, 2022 10:55:58 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154199
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/VMXAllTemplate.cpp.h
r97208 r97223 1800 1800 HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_RFLAGS); 1801 1801 1802 /* Intel spec. 2.3.1 "System Flags and Fields in IA-32e Mode" claims the upper 32-bits of RFLAGS are reserved (MBZ). 1803 Let us assert it as such and use 32-bit VMWRITE. */ 1804 Assert(!RT_HI_U32(pVCpu->cpum.GstCtx.rflags.u64)); 1805 X86EFLAGS fEFlags = pVCpu->cpum.GstCtx.eflags; 1806 Assert(fEFlags.u32 & X86_EFL_RA1_MASK); 1807 Assert(!(fEFlags.u32 & ~(X86_EFL_1 | X86_EFL_LIVE_MASK))); 1802 /* Intel spec. 2.3.1 "System Flags and Fields in IA-32e Mode" claims the upper 32-bits 1803 of RFLAGS are reserved (MBZ). We use bits 63:24 for internal purposes, so no need 1804 to assert this, the CPUMX86EFLAGS/CPUMX86RFLAGS union masks these off for us. 1805 Use 32-bit VMWRITE. */ 1806 uint32_t fEFlags = pVCpu->cpum.GstCtx.eflags.u; 1807 Assert(fEFlags & X86_EFL_RA1_MASK); 1808 Assert(!(fEFlags & ~(X86_EFL_1 | X86_EFL_LIVE_MASK))); 1808 1809 1809 1810 #ifndef IN_NEM_DARWIN … … 1819 1820 Assert(PDMVmmDevHeapIsEnabled(pVCpu->CTX_SUFF(pVM))); 1820 1821 Assert(!pVmxTransient->fIsNestedGuest); 1821 pVmcsInfo->RealMode.Eflags.u32 = fEFlags .u32;/* Save the original eflags of the real-mode guest. */1822 fEFlags .Bits.u1VM = 1;/* Set the Virtual 8086 mode bit. */1823 fEFlags .Bits.u2IOPL = 0;/* Change IOPL to 0, otherwise certain instructions won't fault. */1822 pVmcsInfo->RealMode.Eflags.u32 = fEFlags; /* Save the original eflags of the real-mode guest. */ 1823 fEFlags |= X86_EFL_VM; /* Set the Virtual 8086 mode bit. */ 1824 fEFlags &= ~X86_EFL_IOPL; /* Change IOPL to 0, otherwise certain instructions won't fault. */ 1824 1825 } 1825 1826 #else … … 1827 1828 #endif 1828 1829 1829 int rc = VMX_VMCS_WRITE_NW(pVCpu, VMX_VMCS_GUEST_RFLAGS, fEFlags .u32);1830 int rc = VMX_VMCS_WRITE_NW(pVCpu, VMX_VMCS_GUEST_RFLAGS, fEFlags); 1830 1831 AssertRC(rc); 1831 1832 1832 1833 ASMAtomicUoAndU64(&VCPU_2_VMXSTATE(pVCpu).fCtxChanged, ~HM_CHANGED_GUEST_RFLAGS); 1833 Log4Func(("eflags=%#RX32\n", fEFlags .u32));1834 Log4Func(("eflags=%#RX32\n", fEFlags)); 1834 1835 } 1835 1836 } … … 3329 3330 DECL_FORCE_INLINE(void) vmxHCImportGuestCoreRFlags(PVMCPUCC pVCpu, PCVMXVMCSINFO pVmcsInfo) 3330 3331 { 3331 uint64_t u64Val;3332 int const rc = VMX_VMCS_READ_NW(pVCpu, VMX_VMCS_GUEST_RFLAGS, & u64Val);3332 uint64_t fRFlags; 3333 int const rc = VMX_VMCS_READ_NW(pVCpu, VMX_VMCS_GUEST_RFLAGS, &fRFlags); 3333 3334 AssertRC(rc); 3334 3335 3335 pVCpu->cpum.GstCtx.rflags.u64 = u64Val; 3336 Assert((fRFlags & X86_EFL_RA1_MASK) == X86_EFL_RA1_MASK); 3337 Assert((fRFlags & ~(uint64_t)(X86_EFL_1 | X86_EFL_LIVE_MASK)) == 0); 3338 3339 pVCpu->cpum.GstCtx.rflags.u = fRFlags; 3336 3340 #ifndef IN_NEM_DARWIN 3337 3341 PCVMXVMCSINFOSHARED pVmcsInfoShared = pVmcsInfo->pShared; 3338 if (pVmcsInfoShared->RealMode.fRealOnV86Active) 3342 if (!pVmcsInfoShared->RealMode.fRealOnV86Active) 3343 { /* mostly likely */ } 3344 else 3339 3345 { 3340 3346 pVCpu->cpum.GstCtx.eflags.Bits.u1VM = 0; … … 4797 4803 /* Construct the stack frame for the interrupt/exception handler. */ 4798 4804 VBOXSTRICTRC rcStrict; 4799 rcStrict = hmR0VmxRealModeGuestStackPush(pVCpu, pCtx->eflags.u 32);4805 rcStrict = hmR0VmxRealModeGuestStackPush(pVCpu, pCtx->eflags.u); 4800 4806 if (rcStrict == VINF_SUCCESS) 4801 4807 { … … 4808 4814 if (rcStrict == VINF_SUCCESS) 4809 4815 { 4810 pCtx->eflags.u 32&= ~(X86_EFL_IF | X86_EFL_TF | X86_EFL_RF | X86_EFL_AC);4816 pCtx->eflags.u &= ~(X86_EFL_IF | X86_EFL_TF | X86_EFL_RF | X86_EFL_AC); 4811 4817 pCtx->rip = IdtEntry.offSel; 4812 4818 pCtx->cs.Sel = IdtEntry.uSel; … … 5102 5108 if (uIntType == VMX_ENTRY_INT_INFO_TYPE_EXT_INT) 5103 5109 { 5104 Assert(pVCpu->cpum.GstCtx.eflags.u 32& X86_EFL_IF);5110 Assert(pVCpu->cpum.GstCtx.eflags.u & X86_EFL_IF); 5105 5111 Assert(!(fIntrState & VMX_VMCS_GUEST_INT_STATE_BLOCK_STI)); 5106 5112 Assert(!(fIntrState & VMX_VMCS_GUEST_INT_STATE_BLOCK_MOVSS)); … … 5147 5153 */ 5148 5154 Assert(!DBGFIsStepping(pVCpu)); 5149 uint8_t const fTrapFlag = !!(pVCpu->cpum.GstCtx.eflags.u32 & X86_EFL_TF); 5150 int rc = VMX_VMCS_WRITE_NW(pVCpu, VMX_VMCS_GUEST_PENDING_DEBUG_XCPTS, fTrapFlag << VMX_BF_VMCS_PENDING_DBG_XCPT_BS_SHIFT); 5155 uint8_t const fTrapFlag = !!(pVCpu->cpum.GstCtx.eflags.u & X86_EFL_TF); 5156 int rc = VMX_VMCS_WRITE_NW(pVCpu, VMX_VMCS_GUEST_PENDING_DEBUG_XCPTS, 5157 fTrapFlag << VMX_BF_VMCS_PENDING_DBG_XCPT_BS_SHIFT); 5151 5158 AssertRC(rc); 5152 5159 }
Note:
See TracChangeset
for help on using the changeset viewer.