VirtualBox

Changeset 79078 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Jun 11, 2019 6:36:07 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131238
Message:

VMM/IEM: Nested VMX: bugref:9180 VMXVMCSFIELDENC rename, adjustments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r79059 r79078  
    190190 *
    191191 * The first array dimension is VMCS field encoding of Width OR'ed with Type and the
    192  * second dimension is the Index, see VMXVMCSFIELDENC.
     192 * second dimension is the Index, see VMXVMCSFIELD.
    193193 */
    194194uint16_t const g_aoffVmcsMap[16][VMX_V_VMCS_MAX_INDEX + 1] =
     
    445445 *
    446446 * @param   pVCpu           The cross context virtual CPU structure.
    447  * @param   u64FieldEnc     The VMCS field encoding.
     447 * @param   u64VmcsField    The VMCS field.
    448448 *
    449449 * @remarks This takes into account the CPU features exposed to the guest.
    450450 */
    451 IEM_STATIC bool iemVmxIsVmcsFieldValid(PCVMCPU pVCpu, uint64_t u64FieldEnc)
    452 {
    453     uint32_t const uFieldEncHi = RT_HI_U32(u64FieldEnc);
    454     uint32_t const uFieldEncLo = RT_LO_U32(u64FieldEnc);
     451IEM_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);
    455455    if (!uFieldEncHi)
    456456    { /* likely */ }
     
    77837783 * @param   pu64Dst         Where to write the VMCS value (only updated when
    77847784 *                          VINF_SUCCESS is returned).
    7785  * @param   u64FieldEnc     The VMCS field encoding.
     7785 * @param   u64VmcsField    The VMCS field.
    77867786 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
    77877787 *                          NULL.
    77887788 */
    7789 IEM_STATIC VBOXSTRICTRC iemVmxVmreadCommon(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64FieldEnc,
     7789IEM_STATIC VBOXSTRICTRC iemVmxVmreadCommon(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64VmcsField,
    77907790                                           PCVMXVEXITINFO pExitInfo)
    77917791{
    77927792    /* Nested-guest intercept. */
    77937793    if (   IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
    7794         && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMREAD, u64FieldEnc))
     7794        && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMREAD, u64VmcsField))
    77957795    {
    77967796        if (pExitInfo)
     
    78367836
    78377837    /* Supported VMCS field. */
    7838     if (iemVmxIsVmcsFieldValid(pVCpu, u64FieldEnc))
     7838    if (iemVmxIsVmcsFieldValid(pVCpu, u64VmcsField))
    78397839    { /* likely */ }
    78407840    else
    78417841    {
    7842         Log(("vmread: VMCS field %#RX64 invalid -> VMFail\n", u64FieldEnc));
     7842        Log(("vmread: VMCS field %#RX64 invalid -> VMFail\n", u64VmcsField));
    78437843        pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmread_FieldInvalid;
    78447844        iemVmxVmFail(pVCpu, VMXINSTRERR_VMREAD_INVALID_COMPONENT);
     
    78577857    Assert(pbVmcs);
    78587858
    7859     VMXVMCSFIELDENC 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);
    78637863    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);
    78657865    AssertReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_2);
    78667866    uint16_t const offField   = g_aoffVmcsMap[uWidthType][uIndex];
     
    78787878     */
    78797879    uint8_t      *pbField   = pbVmcs + offField;
    7880     uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(FieldEnc.u);
     7880    uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(VmcsField.u);
    78817881    switch (uEffWidth)
    78827882    {
     
    78977897 * @param   cbInstr         The instruction length in bytes.
    78987898 * @param   pu64Dst         Where to store the VMCS field's value.
    7899  * @param   u64FieldEnc     The VMCS field encoding.
     7899 * @param   u64VmcsField    The VMCS field.
    79007900 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
    79017901 *                          NULL.
    79027902 */
    7903 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg64(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64FieldEnc,
     7903IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg64(PVMCPU pVCpu, uint8_t cbInstr, uint64_t *pu64Dst, uint64_t u64VmcsField,
    79047904                                          PCVMXVEXITINFO pExitInfo)
    79057905{
    7906     VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, pu64Dst, u64FieldEnc, pExitInfo);
     7906    VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, pu64Dst, u64VmcsField, pExitInfo);
    79077907    if (rcStrict == VINF_SUCCESS)
    79087908    {
     
    79237923 * @param   cbInstr         The instruction length in bytes.
    79247924 * @param   pu32Dst         Where to store the VMCS field's value.
    7925  * @param   u32FieldEnc     The VMCS field encoding.
     7925 * @param   u32VmcsField    The VMCS field.
    79267926 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
    79277927 *                          NULL.
    79287928 */
    7929 IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg32(PVMCPU pVCpu, uint8_t cbInstr, uint32_t *pu32Dst, uint64_t u32FieldEnc,
     7929IEM_STATIC VBOXSTRICTRC iemVmxVmreadReg32(PVMCPU pVCpu, uint8_t cbInstr, uint32_t *pu32Dst, uint64_t u32VmcsField,
    79307930                                          PCVMXVEXITINFO pExitInfo)
    79317931{
    79327932    uint64_t u64Dst;
    7933     VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u32FieldEnc, pExitInfo);
     7933    VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u32VmcsField, pExitInfo);
    79347934    if (rcStrict == VINF_SUCCESS)
    79357935    {
     
    79547954 * @param   GCPtrDst        The guest linear address to store the VMCS field's
    79557955 *                          value.
    7956  * @param   u64FieldEnc     The VMCS field encoding.
     7956 * @param   u64VmcsField    The VMCS field.
    79577957 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
    79587958 *                          NULL.
    79597959 */
    7960 IEM_STATIC VBOXSTRICTRC iemVmxVmreadMem(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDst, uint64_t u64FieldEnc,
     7960IEM_STATIC VBOXSTRICTRC iemVmxVmreadMem(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDst, uint64_t u64VmcsField,
    79617961                                        PCVMXVEXITINFO pExitInfo)
    79627962{
    79637963    uint64_t u64Dst;
    7964     VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u64FieldEnc, pExitInfo);
     7964    VBOXSTRICTRC rcStrict = iemVmxVmreadCommon(pVCpu, cbInstr, &u64Dst, u64VmcsField, pExitInfo);
    79657965    if (rcStrict == VINF_SUCCESS)
    79667966    {
     
    79997999 *                          value), @a iEffSeg will indicate if it's a memory
    80008000 *                          operand.
    8001  * @param   u64FieldEnc     The VMCS field encoding.
     8001 * @param   u64VmcsField    The VMCS field.
    80028002 * @param   pExitInfo       Pointer to the VM-exit information. Optional, can be
    80038003 *                          NULL.
    80048004 */
    8005 IEM_STATIC VBOXSTRICTRC iemVmxVmwrite(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, uint64_t u64Val, uint64_t u64FieldEnc,
     8005IEM_STATIC VBOXSTRICTRC iemVmxVmwrite(PVMCPU pVCpu, uint8_t cbInstr, uint8_t iEffSeg, uint64_t u64Val, uint64_t u64VmcsField,
    80068006                                      PCVMXVEXITINFO pExitInfo)
    80078007{
    80088008    /* Nested-guest intercept. */
    80098009    if (   IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
    8010         && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMWRITE, u64FieldEnc))
     8010        && CPUMIsGuestVmxVmreadVmwriteInterceptSet(pVCpu, VMX_EXIT_VMWRITE, u64VmcsField))
    80118011    {
    80128012        if (pExitInfo)
     
    80778077
    80788078    /* Supported VMCS field. */
    8079     if (iemVmxIsVmcsFieldValid(pVCpu, u64FieldEnc))
     8079    if (iemVmxIsVmcsFieldValid(pVCpu, u64VmcsField))
    80808080    { /* likely */ }
    80818081    else
    80828082    {
    8083         Log(("vmwrite: VMCS field %#RX64 invalid -> VMFail\n", u64FieldEnc));
     8083        Log(("vmwrite: VMCS field %#RX64 invalid -> VMFail\n", u64VmcsField));
    80848084        pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmwrite_FieldInvalid;
    80858085        iemVmxVmFail(pVCpu, VMXINSTRERR_VMWRITE_INVALID_COMPONENT);
     
    80898089
    80908090    /* Read-only VMCS field. */
    8091     bool const fIsFieldReadOnly = HMVmxIsVmcsFieldReadOnly(u64FieldEnc);
     8091    bool const fIsFieldReadOnly = HMVmxIsVmcsFieldReadOnly(u64VmcsField);
    80928092    if (   !fIsFieldReadOnly
    80938093        ||  IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fVmxVmwriteAll)
     
    80958095    else
    80968096    {
    8097         Log(("vmwrite: Write to read-only VMCS component %#RX64 -> VMFail\n", u64FieldEnc));
     8097        Log(("vmwrite: Write to read-only VMCS component %#RX64 -> VMFail\n", u64VmcsField));
    80988098        pVCpu->cpum.GstCtx.hwvirt.vmx.enmDiag = kVmxVDiag_Vmwrite_FieldRo;
    80998099        iemVmxVmFail(pVCpu, VMXINSTRERR_VMWRITE_RO_COMPONENT);
     
    81128112    Assert(pbVmcs);
    81138113
    8114     VMXVMCSFIELDENC 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);
    81188118    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);
    81208120    AssertReturn(uIndex <= VMX_V_VMCS_MAX_INDEX, VERR_IEM_IPE_2);
    81218121    uint16_t const offField   = g_aoffVmcsMap[uWidthType][uIndex];
     
    81298129     */
    81308130    uint8_t      *pbField   = pbVmcs + offField;
    8131     uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(FieldEnc.u);
     8131    uint8_t const uEffWidth = HMVmxGetVmcsFieldWidthEff(VmcsField.u);
    81328132    switch (uEffWidth)
    81338133    {
     
    90119011 * Implements 'VMWRITE' register.
    90129012 */
    9013 IEM_CIMPL_DEF_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64FieldEnc)
    9014 {
    9015     return iemVmxVmwrite(pVCpu, cbInstr, UINT8_MAX /* iEffSeg */, u64Val, u64FieldEnc, NULL /* pExitInfo */);
     9013IEM_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 */);
    90169016}
    90179017
     
    90209020 * Implements 'VMWRITE' memory.
    90219021 */
    9022 IEM_CIMPL_DEF_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64FieldEnc)
    9023 {
    9024     return iemVmxVmwrite(pVCpu, cbInstr, iEffSeg, GCPtrVal, u64FieldEnc,  NULL /* pExitInfo */);
     9022IEM_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 */);
    90259025}
    90269026
     
    90299029 * Implements 'VMREAD' register (64-bit).
    90309030 */
    9031 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64FieldEnc)
    9032 {
    9033     return iemVmxVmreadReg64(pVCpu, cbInstr, pu64Dst, u64FieldEnc, NULL /* pExitInfo */);
     9031IEM_CIMPL_DEF_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField)
     9032{
     9033    return iemVmxVmreadReg64(pVCpu, cbInstr, pu64Dst, u64VmcsField, NULL /* pExitInfo */);
    90349034}
    90359035
     
    90389038 * Implements 'VMREAD' register (32-bit).
    90399039 */
    9040 IEM_CIMPL_DEF_2(iemCImpl_vmread_reg32, uint32_t *, pu32Dst, uint32_t, u32FieldEnc)
    9041 {
    9042     return iemVmxVmreadReg32(pVCpu, cbInstr, pu32Dst, u32FieldEnc, NULL /* pExitInfo */);
     9040IEM_CIMPL_DEF_2(iemCImpl_vmread_reg32, uint32_t *, pu32Dst, uint32_t, u32VmcsField)
     9041{
     9042    return iemVmxVmreadReg32(pVCpu, cbInstr, pu32Dst, u32VmcsField, NULL /* pExitInfo */);
    90439043}
    90449044
     
    90479047 * Implements 'VMREAD' memory, 64-bit register.
    90489048 */
    9049 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64FieldEnc)
    9050 {
    9051     return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u64FieldEnc, NULL /* pExitInfo */);
     9049IEM_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 */);
    90529052}
    90539053
     
    90569056 * Implements 'VMREAD' memory, 32-bit register.
    90579057 */
    9058 IEM_CIMPL_DEF_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32FieldEnc)
    9059 {
    9060     return iemVmxVmreadMem(pVCpu, cbInstr, iEffSeg, GCPtrDst, u32FieldEnc, NULL /* pExitInfo */);
     9058IEM_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 */);
    90619061}
    90629062
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette