Changeset 79078 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Jun 11, 2019 6:36:07 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131238
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h
r79059 r79078 190 190 * 191 191 * The first array dimension is VMCS field encoding of Width OR'ed with Type and the 192 * second dimension is the Index, see VMXVMCSFIELD ENC.192 * second dimension is the Index, see VMXVMCSFIELD. 193 193 */ 194 194 uint16_t const g_aoffVmcsMap[16][VMX_V_VMCS_MAX_INDEX + 1] = … … 445 445 * 446 446 * @param pVCpu The cross context virtual CPU structure. 447 * @param u64 FieldEnc The VMCS field encoding.447 * @param u64VmcsField The VMCS field. 448 448 * 449 449 * @remarks This takes into account the CPU features exposed to the guest. 450 450 */ 451 IEM_STATIC bool iemVmxIsVmcsFieldValid(PCVMCPU pVCpu, uint64_t u64 FieldEnc)452 { 453 uint32_t const uFieldEncHi = RT_HI_U32(u64 FieldEnc);454 uint32_t const uFieldEncLo = RT_LO_U32(u64 FieldEnc);451 IEM_STATIC bool iemVmxIsVmcsFieldValid(PCVMCPU pVCpu, uint64_t u64VmcsField) 452 { 453 uint32_t const uFieldEncHi = RT_HI_U32(u64VmcsField); 454 uint32_t const uFieldEncLo = RT_LO_U32(u64VmcsField); 455 455 if (!uFieldEncHi) 456 456 { /* likely */ } … … 7783 7783 * @param pu64Dst Where to write the VMCS value (only updated when 7784 7784 * VINF_SUCCESS is returned). 7785 * @param u64 FieldEnc The VMCS field encoding.7785 * @param u64VmcsField The VMCS field. 7786 7786 * @param pExitInfo Pointer to the VM-exit information. Optional, can be 7787 7787 * NULL. 7788 7788 */ 7789 IEM_STATIC VBOXSTRICTRC iemVmxVmreadCommon(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64 FieldEnc,7789 IEM_STATIC VBOXSTRICTRC iemVmxVmreadCommon(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64VmcsField, 7790 7790 PCVMXVEXITINFO pExitInfo) 7791 7791 { 7792 7792 /* Nested-guest intercept. */ 7793 7793 if ( IEM_VMX_IS_NON_ROOT_MODE(pVCpu) 7794 && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMREAD, u64 FieldEnc))7794 && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMREAD, u64VmcsField)) 7795 7795 { 7796 7796 if (pExitInfo) … … 7836 7836 7837 7837 /* Supported VMCS field. */ 7838 if (iemVmxIsVmcsFieldValid(pVCpu, u64 FieldEnc))7838 if (iemVmxIsVmcsFieldValid(pVCpu, u64VmcsField)) 7839 7839 { /* likely */ } 7840 7840 else 7841 7841 { 7842 Log(("vmread: VMCS field %#RX64 invalid -> VMFail\n", u64 FieldEnc));7842 Log(("vmread: VMCS field %#RX64 invalid -> VMFail\n", u64VmcsField)); 7843 7843 pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmread_FieldInvalid; 7844 7844 iemVmxVmFail(pVCpu, VMXINSTRERR_VMREAD_INVALID_COMPONENT); … … 7857 7857 Assert(pbVmcs); 7858 7858 7859 VMXVMCSFIELD ENC FieldEnc;7860 FieldEnc.u = u64FieldEnc;7861 uint8_t const uWidth = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_WIDTH);7862 uint8_t const uType = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_TYPE);7859 VMXVMCSFIELD VmcsField; 7860 VmcsField.u = u64VmcsField; 7861 uint8_t const uWidth = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_WIDTH); 7862 uint8_t const uType = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_TYPE); 7863 7863 uint8_t const uWidthType = (uWidth << 2) | uType; 7864 uint8_t const uIndex = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_INDEX);7864 uint8_t const uIndex = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_INDEX); 7865 7865 AssertReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_2); 7866 7866 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; … … 7878 7878 */ 7879 7879 uint8_t *pbField = pbVmcs + offField; 7880 uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff( FieldEnc.u);7880 uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(VmcsField.u); 7881 7881 switch (uEffWidth) 7882 7882 { … … 7897 7897 * @param cbInstr The instruction length in bytes. 7898 7898 * @param pu64Dst Where to store the VMCS field's value. 7899 * @param u64 FieldEnc The VMCS field encoding.7899 * @param u64VmcsField The VMCS field. 7900 7900 * @param pExitInfo Pointer to the VM-exit information. Optional, can be 7901 7901 * NULL. 7902 7902 */ 7903 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg64(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64 FieldEnc,7903 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg64(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64VmcsField, 7904 7904 PCVMXVEXITINFO pExitInfo) 7905 7905 { 7906 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, pu64Dst, u64 FieldEnc, pExitInfo);7906 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, pu64Dst, u64VmcsField, pExitInfo); 7907 7907 if (rcStrict == VINF_SUCCESS) 7908 7908 { … … 7923 7923 * @param cbInstr The instruction length in bytes. 7924 7924 * @param pu32Dst Where to store the VMCS field's value. 7925 * @param u32 FieldEnc The VMCS field encoding.7925 * @param u32VmcsField The VMCS field. 7926 7926 * @param pExitInfo Pointer to the VM-exit information. Optional, can be 7927 7927 * NULL. 7928 7928 */ 7929 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg32(PVMCPU pVCpu, uint8_t cbInstr, uint32_t *pu32Dst, uint64_t u32 FieldEnc,7929 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg32(PVMCPU pVCpu, uint8_t cbInstr, uint32_t *pu32Dst, uint64_t u32VmcsField, 7930 7930 PCVMXVEXITINFO pExitInfo) 7931 7931 { 7932 7932 uint64_t u64Dst; 7933 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u32 FieldEnc, pExitInfo);7933 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u32VmcsField, pExitInfo); 7934 7934 if (rcStrict == VINF_SUCCESS) 7935 7935 { … … 7954 7954 * @param GCPtrDst The guest linear address to store the VMCS field's 7955 7955 * value. 7956 * @param u64 FieldEnc The VMCS field encoding.7956 * @param u64VmcsField The VMCS field. 7957 7957 * @param pExitInfo Pointer to the VM-exit information. Optional, can be 7958 7958 * NULL. 7959 7959 */ 7960 IEM_STATIC VBOXSTRICTRC iemVmxVmreadMem(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDst, uint64_t u64 FieldEnc,7960 IEM_STATIC VBOXSTRICTRC iemVmxVmreadMem(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDst, uint64_t u64VmcsField, 7961 7961 PCVMXVEXITINFO pExitInfo) 7962 7962 { 7963 7963 uint64_t u64Dst; 7964 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u64 FieldEnc, pExitInfo);7964 VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u64VmcsField, pExitInfo); 7965 7965 if (rcStrict == VINF_SUCCESS) 7966 7966 { … … 7999 7999 * value), @a iEffSeg will indicate if it's a memory 8000 8000 * operand. 8001 * @param u64 FieldEnc The VMCS field encoding.8001 * @param u64VmcsField The VMCS field. 8002 8002 * @param pExitInfo Pointer to the VM-exit information. Optional, can be 8003 8003 * NULL. 8004 8004 */ 8005 IEM_STATIC VBOXSTRICTRC iemVmxVmwrite(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, uint64_t u64Val, uint64_t u64 FieldEnc,8005 IEM_STATIC VBOXSTRICTRC iemVmxVmwrite(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, uint64_t u64Val, uint64_t u64VmcsField, 8006 8006 PCVMXVEXITINFO pExitInfo) 8007 8007 { 8008 8008 /* Nested-guest intercept. */ 8009 8009 if ( IEM_VMX_IS_NON_ROOT_MODE(pVCpu) 8010 && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMWRITE, u64 FieldEnc))8010 && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMWRITE, u64VmcsField)) 8011 8011 { 8012 8012 if (pExitInfo) … … 8077 8077 8078 8078 /* Supported VMCS field. */ 8079 if (iemVmxIsVmcsFieldValid(pVCpu, u64 FieldEnc))8079 if (iemVmxIsVmcsFieldValid(pVCpu, u64VmcsField)) 8080 8080 { /* likely */ } 8081 8081 else 8082 8082 { 8083 Log(("vmwrite: VMCS field %#RX64 invalid -> VMFail\n", u64 FieldEnc));8083 Log(("vmwrite: VMCS field %#RX64 invalid -> VMFail\n", u64VmcsField)); 8084 8084 pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmwrite_FieldInvalid; 8085 8085 iemVmxVmFail(pVCpu, VMXINSTRERR_VMWRITE_INVALID_COMPONENT); … … 8089 8089 8090 8090 /* Read-only VMCS field. */ 8091 bool const fIsFieldReadOnly = HMVmxIsVmcsFieldReadOnly(u64 FieldEnc);8091 bool const fIsFieldReadOnly = HMVmxIsVmcsFieldReadOnly(u64VmcsField); 8092 8092 if ( !fIsFieldReadOnly 8093 8093 || IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fVmxVmwriteAll) … … 8095 8095 else 8096 8096 { 8097 Log(("vmwrite: Write to read-only VMCS component %#RX64 -> VMFail\n", u64 FieldEnc));8097 Log(("vmwrite: Write to read-only VMCS component %#RX64 -> VMFail\n", u64VmcsField)); 8098 8098 pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmwrite_FieldRo; 8099 8099 iemVmxVmFail(pVCpu, VMXINSTRERR_VMWRITE_RO_COMPONENT); … … 8112 8112 Assert(pbVmcs); 8113 8113 8114 VMXVMCSFIELD ENC FieldEnc;8115 FieldEnc.u = u64FieldEnc;8116 uint8_t const uWidth = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_WIDTH);8117 uint8_t const uType = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_TYPE);8114 VMXVMCSFIELD VmcsField; 8115 VmcsField.u = u64VmcsField; 8116 uint8_t const uWidth = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_WIDTH); 8117 uint8_t const uType = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_TYPE); 8118 8118 uint8_t const uWidthType = (uWidth << 2) | uType; 8119 uint8_t const uIndex = RT_BF_GET( FieldEnc.u, VMX_BF_VMCS_ENC_INDEX);8119 uint8_t const uIndex = RT_BF_GET(VmcsField.u, VMX_BF_VMCS_ENC_INDEX); 8120 8120 AssertReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_2); 8121 8121 uint16_t const offField = g_aoffVmcsMap[uWidthType][uIndex]; … … 8129 8129 */ 8130 8130 uint8_t *pbField = pbVmcs + offField; 8131 uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff( FieldEnc.u);8131 uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(VmcsField.u); 8132 8132 switch (uEffWidth) 8133 8133 { … … 9011 9011 * Implements 'VMWRITE' register. 9012 9012 */ 9013 IEM_CIMPL_DEF_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64 FieldEnc)9014 { 9015 return iemVmxVmwrite(pVCpu, cbInstr, UINT8_MAX /* iEffSeg */, u64Val, u64 FieldEnc, NULL /* pExitInfo */);9013 IEM_CIMPL_DEF_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64VmcsField) 9014 { 9015 return iemVmxVmwrite(pVCpu, cbInstr, UINT8_MAX /* iEffSeg */, u64Val, u64VmcsField, NULL /* pExitInfo */); 9016 9016 } 9017 9017 … … 9020 9020 * Implements 'VMWRITE' memory. 9021 9021 */ 9022 IEM_CIMPL_DEF_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64 FieldEnc)9023 { 9024 return iemVmxVmwrite(pVCpu, cbInstr, iEffSeg, GCPtrVal, u64 FieldEnc, NULL /* pExitInfo */);9022 IEM_CIMPL_DEF_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64VmcsField) 9023 { 9024 return iemVmxVmwrite(pVCpu, cbInstr, iEffSeg, GCPtrVal, u64VmcsField, NULL /* pExitInfo */); 9025 9025 } 9026 9026 … … 9029 9029 * Implements 'VMREAD' register (64-bit). 9030 9030 */ 9031 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64 FieldEnc)9032 { 9033 return iemVmxVmreadReg64(pVCpu, cbInstr, pu64Dst, u64 FieldEnc, NULL /* pExitInfo */);9031 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField) 9032 { 9033 return iemVmxVmreadReg64(pVCpu, cbInstr, pu64Dst, u64VmcsField, NULL /* pExitInfo */); 9034 9034 } 9035 9035 … … 9038 9038 * Implements 'VMREAD' register (32-bit). 9039 9039 */ 9040 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg32, uint32_t *, pu32Dst, uint32_t, u32 FieldEnc)9041 { 9042 return iemVmxVmreadReg32(pVCpu, cbInstr, pu32Dst, u32 FieldEnc, NULL /* pExitInfo */);9040 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg32, uint32_t *, pu32Dst, uint32_t, u32VmcsField) 9041 { 9042 return iemVmxVmreadReg32(pVCpu, cbInstr, pu32Dst, u32VmcsField, NULL /* pExitInfo */); 9043 9043 } 9044 9044 … … 9047 9047 * Implements 'VMREAD' memory, 64-bit register. 9048 9048 */ 9049 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64 FieldEnc)9050 { 9051 return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u64 FieldEnc, NULL /* pExitInfo */);9049 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64VmcsField) 9050 { 9051 return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u64VmcsField, NULL /* pExitInfo */); 9052 9052 } 9053 9053 … … 9056 9056 * Implements 'VMREAD' memory, 32-bit register. 9057 9057 */ 9058 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32 FieldEnc)9059 { 9060 return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u32 FieldEnc, NULL /* pExitInfo */);9058 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32VmcsField) 9059 { 9060 return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u32VmcsField, NULL /* pExitInfo */); 9061 9061 } 9062 9062
Note:
See TracChangeset
for help on using the changeset viewer.