VirtualBox

Changeset 73773 in vbox for trunk


Ignore:
Timestamp:
Aug 20, 2018 8:04:14 AM (6 years ago)
Author:
vboxsync
Message:

hm_vmx.h: Nested VMX: bugref:9180 VMCS index and encoding are different (going by Intel's terminology).

File:
1 edited

Legend:

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

    r73772 r73773  
    30943094 *
    30953095 * @param   uFieldEnc       VMCS field encoding.
    3096  * @param   u32Val          32-bit value.
     3096 * @param   u32Val          The 32-bit value to set.
    30973097 *
    30983098 * @remarks The values of the two status codes can be OR'ed together, the result
     
    31003100 */
    31013101#if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)
    3102 DECLASM(int) VMXWriteVmcs32(uint32_t idxField, uint32_t u32Val);
     3102DECLASM(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val);
    31033103#else
    3104 DECLINLINE(int) VMXWriteVmcs32(uint32_t idxField, uint32_t u32Val)
     3104DECLINLINE(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val)
    31053105{
    31063106# if RT_INLINE_ASM_GNU_STYLE
     
    31173117       :"=rm"(rc)
    31183118       :"0"(VINF_SUCCESS),
    3119         "a"(idxField),
     3119        "a"(uFieldEnc),
    31203120        "d"(u32Val)
    31213121       );
     
    31233123
    31243124# elif VMX_USE_MSC_INTRINSICS
    3125      unsigned char rcMsc = __vmx_vmwrite(idxField, u32Val);
     3125     unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u32Val);
    31263126     if (RT_LIKELY(rcMsc == 0))
    31273127         return VINF_SUCCESS;
     
    31333133    {
    31343134        push   dword ptr [u32Val]
    3135         mov    eax, [idxField]
     3135        mov    eax, [uFieldEnc]
    31363136        _emit  0x0f
    31373137        _emit  0x79
     
    31613161 * @retval  VERR_VMX_INVALID_VMCS_FIELD.
    31623162 *
    3163  * @param   idxField        VMCS index.
    3164  * @param   u64Val          16, 32 or 64-bit value.
     3163 * @param   uFieldEnc       The VMCS field encoding.
     3164 * @param   u64Val          The 16, 32 or 64-bit value to set.
    31653165 *
    31663166 * @remarks The values of the two status codes can be OR'ed together, the result
     
    31693169#if !defined(RT_ARCH_X86)
    31703170# if !VMX_USE_MSC_INTRINSICS || ARCH_BITS != 64
    3171 DECLASM(int) VMXWriteVmcs64(uint32_t idxField, uint64_t u64Val);
     3171DECLASM(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val);
    31723172# else  /* VMX_USE_MSC_INTRINSICS */
    3173 DECLINLINE(int) VMXWriteVmcs64(uint32_t idxField, uint64_t u64Val)
    3174 {
    3175     unsigned char rcMsc = __vmx_vmwrite(idxField, u64Val);
     3173DECLINLINE(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val)
     3174{
     3175    unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u64Val);
    31763176    if (RT_LIKELY(rcMsc == 0))
    31773177        return VINF_SUCCESS;
     
    31803180# endif /* VMX_USE_MSC_INTRINSICS */
    31813181#else
    3182 # define VMXWriteVmcs64(idxField, u64Val)    VMXWriteVmcs64Ex(pVCpu, idxField, u64Val) /** @todo dead ugly, picking up pVCpu like this */
    3183 VMMR0DECL(int) VMXWriteVmcs64Ex(PVMCPU pVCpu, uint32_t idxField, uint64_t u64Val);
     3182# define VMXWriteVmcs64(uFieldEnc, u64Val)    VMXWriteVmcs64Ex(pVCpu, uFieldEnc, u64Val) /** @todo dead ugly, picking up pVCpu like this */
     3183VMMR0DECL(int) VMXWriteVmcs64Ex(PVMCPU pVCpu, uint32_t uFieldEnc, uint64_t u64Val);
    31843184#endif
    31853185
    31863186#if ARCH_BITS == 32
    31873187# define VMXWriteVmcsHstN                       VMXWriteVmcs32
    3188 # define VMXWriteVmcsGstN(idxField, u64Val)     VMXWriteVmcs64Ex(pVCpu, idxField, u64Val)
     3188# define VMXWriteVmcsGstN(uFieldEnc, u64Val)     VMXWriteVmcs64Ex(pVCpu, uFieldEnc, u64Val)
    31893189#else  /* ARCH_BITS == 64 */
    31903190# define VMXWriteVmcsHstN                       VMXWriteVmcs64
     
    32143214
    32153215/**
    3216  * Executes VMREAD.
     3216 * Executes VMREAD for a 32-bit field.
    32173217 *
    32183218 * @returns VBox status code.
     
    32213221 * @retval  VERR_VMX_INVALID_VMCS_FIELD.
    32223222 *
    3223  * @param   idxField        VMCS index.
    3224  * @param   pData           Where to store VM field value.
     3223 * @param   uFieldEnc       The VMCS field encoding.
     3224 * @param   pData           Where to store VMCS field value.
    32253225 *
    32263226 * @remarks The values of the two status codes can be OR'ed together, the result
     
    32283228 */
    32293229#if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)
    3230 DECLASM(int) VMXReadVmcs32(uint32_t idxField, uint32_t *pData);
     3230DECLASM(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData);
    32313231#else
    3232 DECLINLINE(int) VMXReadVmcs32(uint32_t idxField, uint32_t *pData)
     3232DECLINLINE(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData)
    32333233{
    32343234# if RT_INLINE_ASM_GNU_STYLE
     
    32463246       :"=&r"(rc),
    32473247        "=d"(*pData)
    3248        :"a"(idxField),
     3248       :"a"(uFieldEnc),
    32493249        "d"(0)
    32503250       );
     
    32543254    unsigned char rcMsc;
    32553255#  if ARCH_BITS == 32
    3256     rcMsc = __vmx_vmread(idxField, pData);
     3256    rcMsc = __vmx_vmread(uFieldEnc, pData);
    32573257#  else
    32583258    uint64_t u64Tmp;
    3259     rcMsc = __vmx_vmread(idxField, &u64Tmp);
     3259    rcMsc = __vmx_vmread(uFieldEnc, &u64Tmp);
    32603260    *pData = (uint32_t)u64Tmp;
    32613261#  endif
     
    32703270        sub     esp, 4
    32713271        mov     dword ptr [esp], 0
    3272         mov     eax, [idxField]
     3272        mov     eax, [uFieldEnc]
    32733273        _emit   0x0f
    32743274        _emit   0x78
     
    32923292
    32933293/**
    3294  * Executes VMREAD.
     3294 * Executes VMREAD for a 64-bit field.
    32953295 *
    32963296 * @returns VBox status code.
     
    32993299 * @retval  VERR_VMX_INVALID_VMCS_FIELD.
    33003300 *
    3301  * @param   idxField        VMCS index.
    3302  * @param   pData           Where to store VM field value.
     3301 * @param   uFieldEnc       The VMCS field encoding.
     3302 * @param   pData           Where to store VMCS field value.
    33033303 *
    33043304 * @remarks The values of the two status codes can be OR'ed together, the result
     
    33063306 */
    33073307#if (!defined(RT_ARCH_X86) && !VMX_USE_MSC_INTRINSICS)
    3308 DECLASM(int) VMXReadVmcs64(uint32_t idxField, uint64_t *pData);
     3308DECLASM(int) VMXReadVmcs64(uint32_t uFieldEnc, uint64_t *pData);
    33093309#else
    3310 DECLINLINE(int) VMXReadVmcs64(uint32_t idxField, uint64_t *pData)
     3310DECLINLINE(int) VMXReadVmcs64(uint32_t uFieldEnc, uint64_t *pData)
    33113311{
    33123312# if VMX_USE_MSC_INTRINSICS
     
    33153315    size_t        uLow;
    33163316    size_t        uHigh;
    3317     rcMsc  = __vmx_vmread(idxField, &uLow);
    3318     rcMsc |= __vmx_vmread(idxField + 1, &uHigh);
     3317    rcMsc  = __vmx_vmread(uFieldEnc, &uLow);
     3318    rcMsc |= __vmx_vmread(uFieldEnc + 1, &uHigh);
    33193319    *pData = RT_MAKE_U64(uLow, uHigh);
    33203320# else
    3321     rcMsc = __vmx_vmread(idxField, pData);
     3321    rcMsc = __vmx_vmread(uFieldEnc, pData);
    33223322# endif
    33233323    if (RT_LIKELY(rcMsc == 0))
     
    33283328    int rc;
    33293329    uint32_t val_hi, val;
    3330     rc  = VMXReadVmcs32(idxField, &val);
    3331     rc |= VMXReadVmcs32(idxField + 1, &val_hi);
     3330    rc  = VMXReadVmcs32(uFieldEnc, &val);
     3331    rc |= VMXReadVmcs32(uFieldEnc + 1, &val_hi);
    33323332    AssertRC(rc);
    33333333    *pData = RT_MAKE_U64(val, val_hi);
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