VirtualBox

Changeset 74539 in vbox for trunk


Ignore:
Timestamp:
Oct 1, 2018 4:09:23 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 VM-exit bits; RDTSC, RDTSCP intercepts.

Location:
trunk
Files:
3 edited

Legend:

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

    r74491 r74539  
    18751875
    18761876/**
    1877  * Checks whether the given Pin-based VM-execution controls are set.
     1877 * Checks whether the given Pin-based VM-execution controls are set when executing a
     1878 * nested-guest.
    18781879 *
    18791880 * @returns @c true if set, @c false otherwise.
     
    18811882 * @param   pCtx        Pointer to the context.
    18821883 * @param   uPinCtl     The Pin-based VM-execution controls to check.
     1884 *
     1885 * @remarks This does not check if all given controls are set if more than one
     1886 *          control is passed in @a uPinCtl.
    18831887 */
    18841888DECLINLINE(bool) CPUMIsGuestVmxPinCtlsSet(PVMCPU pVCpu, PCCPUMCTX pCtx, uint32_t uPinCtl)
     
    18871891    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_VMX)
    18881892        return false;
    1889     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
     1893    if (!pCtx->hwvirt.vmx.fInVmxNonRootMode)
     1894        return false;
    18901895    Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    18911896    return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32PinCtls & uPinCtl);
     
    18931898
    18941899/**
    1895  * Checks whether the given Processor-based VM-execution controls are set.
     1900 * Checks whether the given Processor-based VM-execution controls are set when
     1901 * executing a nested-guest.
    18961902 *
    18971903 * @returns @c true if set, @c false otherwise.
    18981904 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    18991905 * @param   pCtx        Pointer to the context.
    1900  * @param   uPinCtl     The Processor-based VM-execution controls to check.
    1901  */
    1902 DECLINLINE(bool) CPUMIsGuestVmxProcCtlsSet(PVMCPU pVCpu, PCCPUMCTX pCtx, uint32_t uProcCtls)
     1906 * @param   uProcCtl    The Processor-based VM-execution controls to check.
     1907 *
     1908 * @remarks This does not check if all given controls are set if more than one
     1909 *          control is passed in @a uProcCtls.
     1910 */
     1911DECLINLINE(bool) CPUMIsGuestVmxProcCtlsSet(PVMCPU pVCpu, PCCPUMCTX pCtx, uint32_t uProcCtl)
    19031912{
    19041913    RT_NOREF(pVCpu);
    19051914    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_VMX)
    19061915        return false;
    1907     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
     1916    if (!pCtx->hwvirt.vmx.fInVmxNonRootMode)
     1917        return false;
    19081918    Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    1909     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls & uProcCtls);
    1910 }
    1911 
    1912 /**
    1913  * Checks whether the given Secondary Processor-based VM-execution controls are set.
     1919    return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls & uProcCtl);
     1920}
     1921
     1922/**
     1923 * Checks whether the given Secondary Processor-based VM-execution controls are set
     1924 * when executing a nested-guest.
    19141925 *
    19151926 * @returns @c true if set, @c false otherwise.
    19161927 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    19171928 * @param   pCtx        Pointer to the context.
    1918  * @param   uPinCtl     The Secondary Processor-based VM-execution controls to
     1929 * @param   uProcCtl2   The Secondary Processor-based VM-execution controls to
    19191930 *                      check.
    1920  */
    1921 DECLINLINE(bool) CPUMIsGuestVmxProcCtls2Set(PVMCPU pVCpu, PCCPUMCTX pCtx, uint32_t uProcCtls2)
     1931 *
     1932 * @remarks This does not check if all given controls are set if more than one
     1933 *          control is passed in @a uProcCtl2.
     1934 *
     1935 */
     1936DECLINLINE(bool) CPUMIsGuestVmxProcCtls2Set(PVMCPU pVCpu, PCCPUMCTX pCtx, uint32_t uProcCtl2)
    19221937{
    19231938    RT_NOREF(pVCpu);
    19241939    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_VMX)
    19251940        return false;
    1926     Assert(pCtx->hwvirt.vmx.fInVmxNonRootMode);
     1941    if (!pCtx->hwvirt.vmx.fInVmxNonRootMode)
     1942        return false;
    19271943    Assert(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs));
    1928     return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls2 & uProcCtls2);
     1944    return RT_BOOL(pCtx->hwvirt.vmx.CTX_SUFF(pVmcs)->u32ProcCtls2 & uProcCtl2);
    19291945}
    19301946
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r74532 r74539  
    389389 * Check if the guest has entered VMX root operation.
    390390 */
    391 # define IEM_VMX_IS_ROOT_MODE(a_pVCpu)                              (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
     391# define IEM_VMX_IS_ROOT_MODE(a_pVCpu)      (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
    392392
    393393/**
    394394 * Check if the guest has entered VMX non-root operation.
    395395 */
    396 # define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu)                          (CPUMIsGuestInVmxNonRootMode(IEM_GET_CTX(a_pVCpu)))
     396# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu)  (CPUMIsGuestInVmxNonRootMode(IEM_GET_CTX(a_pVCpu)))
    397397
    398398/**
     
    402402    do { return iemVmxVmexitInstr((a_pVCpu), (a_uExitReason), (a_cbInstr)); } while (0)
    403403
     404/**
     405 * Check if the nested-guest has the given Pin-based VM-execution control set.
     406 */
     407# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_PinCtl) \
     408    (CPUMIsGuestVmxPinCtlsSet((a_pVCpu), IEM_GET_CTX(a_pVCpu), (a_PinCtl)))
     409
     410/**
     411 * Check if the nested-guest has the given Processor-based VM-execution control set.
     412 */
     413#define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_ProcCtl) \
     414    (CPUMIsGuestVmxProcCtlsSet((a_pVCpu), IEM_GET_CTX(a_pVCpu), (a_ProcCtl)))
     415
     416/**
     417 * Check if the nested-guest has the given Secondary Processor-based VM-execution
     418 * control set.
     419 */
     420#define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_ProcCtl2) \
     421    (CPUMIsGuestVmxProcCtls2Set((a_pVCpu), IEM_GET_CTX(a_pVCpu), (a_ProcCtl2)))
     422
    404423#else
    405 # define IEM_VMX_IS_ROOT_MODE(a_pVCpu)                              (false)
    406 # define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu)                          (false)
    407 # define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_Reason, a_cbInstr)     do { return VERR_VMX_IPE_1; } while (0)
     424# define IEM_VMX_IS_ROOT_MODE(a_pVCpu)                                  (false)
     425# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu)                              (false)
     426# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_cbInstr)                     (false)
     427# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr)                    (false)
     428# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr)                   (false)
     429# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_Reason, a_cbInstr)         do { return VERR_VMX_IPE_1; } while (0)
     430
    408431#endif
    409432
     
    412435 * Check if an SVM control/instruction intercept is set.
    413436 */
    414 # define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) (CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
     437# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) \
     438    (CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
    415439
    416440/**
    417441 * Check if an SVM read CRx intercept is set.
    418442 */
    419 # define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr)    (CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
     443# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
     444    (CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
    420445
    421446/**
    422447 * Check if an SVM write CRx intercept is set.
    423448 */
    424 # define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr)   (CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
     449# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
     450    (CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
    425451
    426452/**
    427453 * Check if an SVM read DRx intercept is set.
    428454 */
    429 # define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr)    (CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
     455# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
     456    (CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
    430457
    431458/**
    432459 * Check if an SVM write DRx intercept is set.
    433460 */
    434 # define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr)   (CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
     461# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
     462    (CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
    435463
    436464/**
    437465 * Check if an SVM exception intercept is set.
    438466 */
    439 # define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector)   (CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
     467# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) \
     468    (CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
    440469
    441470/**
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r74532 r74539  
    61436143    }
    61446144
     6145    if (IEM_VMX_IS_PROCCTLS_SET(pVCpu, VMX_PROC_CTLS_RDTSC_EXIT))
     6146    {
     6147        Log(("rdtsc: Guest intercept -> VM-exit\n"));
     6148        IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_RDTSC, cbInstr);
     6149    }
     6150
    61456151    if (IEM_SVM_IS_CTRL_INTERCEPT_SET(pVCpu, SVM_CTRL_INTERCEPT_RDTSC))
    61466152    {
     
    61866192    }
    61876193
     6194    if (IEM_VMX_IS_PROCCTLS2_SET(pVCpu, VMX_PROC_CTLS2_RDTSCP))
     6195    {
     6196        Log(("rdtscp: Guest intercept -> VM-exit\n"));
     6197        IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_RDTSCP, cbInstr);
     6198    }
     6199
    61886200    if (IEM_SVM_IS_CTRL_INTERCEPT_SET(pVCpu, SVM_CTRL_INTERCEPT_RDTSCP))
    61896201    {
     
    68436855IEM_CIMPL_DEF_0(iemCImpl_cpuid)
    68446856{
     6857    if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu))
     6858    {
     6859        Log2(("cpuid: Guest intercept -> VM-exit\n"));
     6860        IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_CPUID, cbInstr);
     6861    }
     6862
    68456863    if (IEM_SVM_IS_CTRL_INTERCEPT_SET(pVCpu, SVM_CTRL_INTERCEPT_CPUID))
    68466864    {
     
    68486866        IEM_SVM_UPDATE_NRIP(pVCpu);
    68496867        IEM_SVM_VMEXIT_RET(pVCpu, SVM_EXIT_CPUID, 0 /* uExitInfo1 */, 0 /* uExitInfo2 */);
    6850     }
    6851 
    6852     if (IEM_VMX_IS_NON_ROOT_MODE(pVCpu))
    6853     {
    6854         Log2(("cpuid: Guest intercept -> VM-exit\n"));
    6855         IEM_VMX_VMEXIT_INSTR_RET(pVCpu, VMX_EXIT_CPUID, cbInstr);
    68566868    }
    68576869
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