VirtualBox

Changeset 74648 in vbox for trunk


Ignore:
Timestamp:
Oct 7, 2018 6:20:55 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM, CPUM: Nested VMX: bugref:9180 VM-exit bits; Add TPR virtualization for WRMSR.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r74632 r74648  
    12681268    /** @name VMX Miscellaneous data.
    12691269     * @{ */
    1270     /** VMX: Supports storing EFER.LMA on VM-exits into IA32e-mode guest field. */
    1271     uint32_t        fVmxExitStoreEferLma : 1;
     1270    /** VMX: Supports storing EFER.LMA into IA32e-mode guest field on VM-exit. */
     1271    uint32_t        fVmxExitSaveEferLma : 1;
     1272    /** VMX: Whether Intel PT (Processor Trace) is supported in VMX mode or not. */
     1273    uint32_t        fVmxIntelPt : 1;
    12721274    /** VMX: Supports VMWRITE to any valid VMCS field incl. read-only fields, otherwise
    12731275     *  VMWRITE cannot modify read-only VM-exit information fields. */
     
    12791281
    12801282    /** VMX: Padding / reserved for future features. */
    1281     uint32_t        fVmxPadding1 : 2;
     1283    uint32_t        fVmxPadding1 : 1;
    12821284    uint32_t        fVmxPadding2;
    12831285} CPUMFEATURES;
  • trunk/include/VBox/vmm/hm_vmx.h

    r74604 r74648  
    14571457 */
    14581458/** Whether VM-exit stores EFER.LMA into the "IA32e mode guest" field. */
    1459 #define VMX_MISC_EXIT_STORE_EFER_LMA                            RT_BIT(5)
     1459#define VMX_MISC_EXIT_SAVE_EFER_LMA                             RT_BIT(5)
     1460/** Whether Intel PT is supported in VMX operation. */
     1461#define VMX_MISC_INTEL_PT                                       RT_BIT(14)
    14601462/** Whether VMWRITE to any valid VMCS field incl. read-only fields, otherwise
    14611463 * VMWRITE cannot modify read-only VM-exit information fields. */
     
    14721474#define VMX_BF_MISC_PREEMPT_TIMER_TSC_MASK                      UINT64_C(0x000000000000001f)
    14731475/** Whether VM-exit stores EFER.LMA into the "IA32e mode guest" field. */
    1474 #define VMX_BF_MISC_EXIT_STORE_EFER_LMA_SHIFT                   5
    1475 #define VMX_BF_MISC_EXIT_STORE_EFER_LMA_MASK                    UINT64_C(0x0000000000000020)
     1476#define VMX_BF_MISC_EXIT_SAVE_EFER_LMA_SHIFT                    5
     1477#define VMX_BF_MISC_EXIT_SAVE_EFER_LMA_MASK                     UINT64_C(0x0000000000000020)
    14761478/** Activity states supported by the implementation. */
    14771479#define VMX_BF_MISC_ACTIVITY_STATES_SHIFT                       6
     
    14811483#define VMX_BF_MISC_RSVD_9_13_MASK                              UINT64_C(0x0000000000003e00)
    14821484/** Whether Intel PT (Processor Trace) can be used in VMX operation.  */
    1483 #define VMX_BF_MISC_PT_SHIFT                                    14
    1484 #define VMX_BF_MISC_PT_MASK                                     UINT64_C(0x0000000000004000)
     1485#define VMX_BF_MISC_INTEL_PT_SHIFT                              14
     1486#define VMX_BF_MISC_INTEL_PT_MASK                               UINT64_C(0x0000000000004000)
    14851487/** Whether RDMSR can be used to read IA32_SMBASE MSR in SMM. */
    14861488#define VMX_BF_MISC_SMM_READ_SMBASE_MSR_SHIFT                   15
     
    15111513#define VMX_BF_MISC_MSEG_ID_MASK                                UINT64_C(0xffffffff00000000)
    15121514RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_MISC_, UINT64_C(0), UINT64_MAX,
    1513                             (PREEMPT_TIMER_TSC, EXIT_STORE_EFER_LMA, ACTIVITY_STATES, RSVD_9_13, PT, SMM_READ_SMBASE_MSR,
     1515                            (PREEMPT_TIMER_TSC, EXIT_SAVE_EFER_LMA, ACTIVITY_STATES, RSVD_9_13, INTEL_PT, SMM_READ_SMBASE_MSR,
    15141516                             CR3_TARGET, MAX_MSRS, VMXOFF_BLOCK_SMI, VMWRITE_ALL, ENTRY_INJECT_SOFT_INT, RSVD_31, MSEG_ID));
    15151517/** @} */
  • trunk/include/iprt/x86.h

    r74388 r74648  
    14491449#define MSR_IA32_VMX_VMFUNC                 0x491
    14501450
     1451/** Intel PT - Enable and control for trace packet generation. */
     1452#define MSR_IA32_RTIT_CTL                   0x570
    14511453
    14521454/** DS Save Area (R/W). */
  • trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp

    r74392 r74648  
    15211521        uint8_t const cMaxMsrs       = RT_MIN(RT_BF_GET(uHostMsr, VMX_BF_MISC_MAX_MSRS), VMX_V_AUTOMSR_COUNT_MAX);
    15221522        uint8_t const fActivityState = RT_BF_GET(uHostMsr, VMX_BF_MISC_ACTIVITY_STATES) & VMX_V_GUEST_ACTIVITY_STATE_MASK;
    1523         uVmxMsr = RT_BF_MAKE(VMX_BF_MISC_PREEMPT_TIMER_TSC,       VMX_V_PREEMPT_TIMER_SHIFT            )
    1524                 | RT_BF_MAKE(VMX_BF_MISC_EXIT_STORE_EFER_LMA,    pGuestFeatures->fVmxExitStoreEferLma  )
     1523        uVmxMsr = RT_BF_MAKE(VMX_BF_MISC_PREEMPT_TIMER_TSC,      VMX_V_PREEMPT_TIMER_SHIFT             )
     1524                | RT_BF_MAKE(VMX_BF_MISC_EXIT_SAVE_EFER_LMA,     pGuestFeatures->fVmxExitSaveEferLma   )
    15251525                | RT_BF_MAKE(VMX_BF_MISC_ACTIVITY_STATES,        fActivityState                        )
    1526                 | RT_BF_MAKE(VMX_BF_MISC_PT,                     0                                     )
     1526                | RT_BF_MAKE(VMX_BF_MISC_INTEL_PT,               pGuestFeatures->fVmxIntelPt           )
    15271527                | RT_BF_MAKE(VMX_BF_MISC_SMM_READ_SMBASE_MSR,    0                                     )
    15281528                | RT_BF_MAKE(VMX_BF_MISC_CR3_TARGET,             VMX_V_CR3_TARGET_COUNT                )
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r74633 r74648  
    64826482     */
    64836483#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    6484     if (   IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
    6485         && iemVmxIsRdmsrWrmsrInterceptSet(pVCpu, VMX_EXIT_RDMSR, pVCpu->cpum.GstCtx.ecx))
    6486         IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_RDMSR, cbInstr);
     6484    if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu))
     6485    {
     6486        if (iemVmxIsRdmsrWrmsrInterceptSet(pVCpu, VMX_EXIT_RDMSR, pVCpu->cpum.GstCtx.ecx))
     6487            IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_RDMSR, cbInstr);
     6488    }
    64876489#endif
    64886490
     
    65546556        return iemRaiseGeneralProtectionFault0(pVCpu);
    65556557
     6558    RTUINT64U uValue;
     6559    uValue.s.Lo = pVCpu->cpum.GstCtx.eax;
     6560    uValue.s.Hi = pVCpu->cpum.GstCtx.edx;
     6561
     6562    /** @todo make CPUMAllMsrs.cpp import the necessary MSR state. */
     6563    IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_ALL_MSRS);
     6564
    65566565    /*
    65576566     * Check nested-guest intercepts.
    65586567     */
    65596568#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    6560     if (   IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
    6561         && iemVmxIsRdmsrWrmsrInterceptSet(pVCpu, VMX_EXIT_WRMSR, pVCpu->cpum.GstCtx.ecx))
    6562         IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_WRMSR, cbInstr);
     6569    if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu))
     6570    {
     6571        if (iemVmxIsRdmsrWrmsrInterceptSet(pVCpu, VMX_EXIT_WRMSR, pVCpu->cpum.GstCtx.ecx))
     6572            IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_WRMSR, cbInstr);
     6573
     6574        /* Check x2APIC MSRs first. */
     6575        if (IEM_VMX_IS_PROCCTLS2_SET(pVCpu, VMX_PROC_CTLS2_VIRT_X2APIC_MODE))
     6576        {
     6577            switch (pVCpu->cpum.GstCtx.ecx)
     6578            {
     6579                case MSR_IA32_X2APIC_TPR:
     6580                {
     6581                    if (   !uValue.s.Hi
     6582                        && !(uValue.s.Lo & UINT32_C(0xffffff00)))
     6583                    {
     6584                        uint32_t const uVTpr = (uValue.s.Lo & 0xf) << 4;
     6585                        iemVmxVirtApicWriteRaw32(pVCpu, uVTpr, XAPIC_OFF_TPR);
     6586                        VBOXSTRICTRC rcStrict = iemVmxVmexitTprVirtualization(pVCpu, cbInstr);
     6587                        if (rcStrict != VINF_VMX_INTERCEPT_NOT_ACTIVE)
     6588                            return rcStrict;
     6589                        return VINF_SUCCESS;
     6590                    }
     6591                    Log(("IEM: Invalid TPR MSR write -> #GP(0)\n", pVCpu->cpum.GstCtx.ecx, uValue.s.Hi, uValue.s.Lo));
     6592                    return iemRaiseGeneralProtectionFault0(pVCpu);
     6593                }
     6594
     6595                case MSR_IA32_X2APIC_EOI:
     6596                case MSR_IA32_X2APIC_SELF_IPI:
     6597                {
     6598                    /** @todo NSTVMX: EOI and Self-IPI virtualization. */
     6599                    break;
     6600                }
     6601            }
     6602        }
     6603        else if (pVCpu->cpum.GstCtx.ecx == MSR_IA32_BIOS_UPDT_TRIG)
     6604        {
     6605            /** @todo NSTVMX: We must not allow any microcode updates in VMX non-root mode.
     6606             *        Since we don't implement this MSR anyway it's currently not a problem.
     6607             *        If we do, we should probably move this check to the MSR handler.  */
     6608        }
     6609        else if (pVCpu->cpum.GstCtx.ecx == MSR_IA32_RTIT_CTL)
     6610        {
     6611            /** @todo NSTVMX: We don't support Intel PT yet. When we do, this MSR must #GP
     6612             *        when IntelPT is not supported in VMX. */
     6613        }
     6614    }
    65636615#endif
    65646616
     
    65806632     * Do the job.
    65816633     */
    6582     RTUINT64U uValue;
    6583     uValue.s.Lo = pVCpu->cpum.GstCtx.eax;
    6584     uValue.s.Hi = pVCpu->cpum.GstCtx.edx;
    6585 
    6586     /** @todo make CPUMAllMsrs.cpp import the necessary MSR state. */
    6587     IEM_CTX_IMPORT_RET(pVCpu, CPUMCTX_EXTRN_ALL_MSRS);
    6588 
    65896634    VBOXSTRICTRC rcStrict = CPUMSetGuestMsr(pVCpu, pVCpu->cpum.GstCtx.ecx, uValue.u);
    65906635    if (rcStrict == VINF_SUCCESS)
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r74542 r74648  
    11841184        VMXFEATDUMP("ExitLoadEferMsr - Load IA32_EFER on VM-exit            ", fVmxExitLoadEferMsr);
    11851185        VMXFEATDUMP("SavePreemptTimer - Save VMX-preemption timer           ", fVmxSavePreemptTimer);
    1186         VMXFEATDUMP("ExitStoreEferLma - Store EFER.LMA on VM-exit           ", fVmxExitStoreEferLma);
    1187         VMXFEATDUMP("VmwriteAll - VMWRITE to any VMCS field                 ", fVmxVmwriteAll);
    1188         VMXFEATDUMP("EntryInjectSoftInt - Inject softint. with 0-len instr. ", fVmxEntryInjectSoftInt);
    11891186        /* Miscellaneous data. */
    1190         VMXFEATDUMP("ExitStoreEferLma - Inject softint. with 0-len instr.   ", fVmxExitStoreEferLma);
     1187        VMXFEATDUMP("ExitSaveEferLma - Save EFER.LMA on VM-exit             ", fVmxExitSaveEferLma);
     1188        VMXFEATDUMP("IntelPt - Intel PT (Processor Trace) in VMX operation  ", fVmxIntelPt);
    11911189        VMXFEATDUMP("VmwriteAll - Inject softint. with 0-len instr.         ", fVmxVmwriteAll);
    11921190        VMXFEATDUMP("EntryInjectSoftInt - Inject softint. with 0-len instr. ", fVmxEntryInjectSoftInt);
     
    12971295        /* Miscellaneous data. */
    12981296        uint32_t const fMiscData = VmxMsrs.u64Misc;
    1299         pHostFeat->fVmxExitStoreEferLma      = RT_BOOL(fMiscData & VMX_MISC_EXIT_STORE_EFER_LMA);
     1297        pHostFeat->fVmxExitSaveEferLma       = RT_BOOL(fMiscData & VMX_MISC_EXIT_SAVE_EFER_LMA);
     1298        pHostFeat->fVmxIntelPt               = RT_BOOL(fMiscData & VMX_MISC_INTEL_PT);
    13001299        pHostFeat->fVmxVmwriteAll            = RT_BOOL(fMiscData & VMX_MISC_VMWRITE_ALL);
    13011300        pHostFeat->fVmxEntryInjectSoftInt    = RT_BOOL(fMiscData & VMX_MISC_ENTRY_INJECT_SOFT_INT);
     
    13691368    EmuFeat.fVmxExitLoadEferMsr       = 1;
    13701369    EmuFeat.fVmxSavePreemptTimer      = 0;
    1371     EmuFeat.fVmxExitStoreEferLma      = 1;
     1370    EmuFeat.fVmxExitSaveEferLma       = 1;
     1371    EmuFeat.fVmxIntelPt               = 0;
    13721372    EmuFeat.fVmxVmwriteAll            = 0;
    13731373    EmuFeat.fVmxEntryInjectSoftInt    = 0;
     
    14431443    pGuestFeat->fVmxExitLoadEferMsr       = (pBaseFeat->fVmxExitLoadEferMsr       & EmuFeat.fVmxExitLoadEferMsr      );
    14441444    pGuestFeat->fVmxSavePreemptTimer      = (pBaseFeat->fVmxSavePreemptTimer      & EmuFeat.fVmxSavePreemptTimer     );
    1445     pGuestFeat->fVmxExitStoreEferLma      = (pBaseFeat->fVmxExitStoreEferLma      & EmuFeat.fVmxExitStoreEferLma     );
     1445    pGuestFeat->fVmxExitSaveEferLma       = (pBaseFeat->fVmxExitSaveEferLma       & EmuFeat.fVmxExitSaveEferLma      );
     1446    pGuestFeat->fVmxIntelPt               = (pBaseFeat->fVmxIntelPt               & EmuFeat.fVmxIntelPt              );
    14461447    pGuestFeat->fVmxVmwriteAll            = (pBaseFeat->fVmxVmwriteAll            & EmuFeat.fVmxVmwriteAll           );
    14471448    pGuestFeat->fVmxEntryInjectSoftInt    = (pBaseFeat->fVmxEntryInjectSoftInt    & EmuFeat.fVmxEntryInjectSoftInt   );
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r74457 r74648  
    15981598                pVM->hm.s.vmx.cPreemptTimerShift));
    15991599    }
    1600     LogRel(("HM:   EXIT_STORE_EFER_LMA               = %RTbool\n",    RT_BF_GET(fMisc, VMX_BF_MISC_EXIT_STORE_EFER_LMA)));
     1600    LogRel(("HM:   EXIT_SAVE_EFER_LMA                = %RTbool\n",    RT_BF_GET(fMisc, VMX_BF_MISC_EXIT_SAVE_EFER_LMA)));
    16011601    LogRel(("HM:   ACTIVITY_STATES                   = %#x%s\n",      RT_BF_GET(fMisc, VMX_BF_MISC_ACTIVITY_STATES),
    16021602                                                                      hmR3VmxGetActivityStateAllDesc(fMisc)));
    1603     LogRel(("HM:   PT                                = %RTbool\n",    RT_BF_GET(fMisc, VMX_BF_MISC_PT)));
     1603    LogRel(("HM:   INTEL_PT                          = %RTbool\n",    RT_BF_GET(fMisc, VMX_BF_MISC_INTEL_PT)));
    16041604    LogRel(("HM:   SMM_READ_SMBASE_MSR               = %RTbool\n",    RT_BF_GET(fMisc, VMX_BF_MISC_SMM_READ_SMBASE_MSR)));
    16051605    LogRel(("HM:   CR3_TARGET                        = %#x\n",        RT_BF_GET(fMisc, VMX_BF_MISC_CR3_TARGET)));
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