VirtualBox

Changeset 46004 in vbox


Ignore:
Timestamp:
May 13, 2013 9:20:43 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
85665
Message:

VMM/HMVMXR0: DR7 is 32-bit in reality, upper bits are reserved MBZ, so avoid complicated guest-natural width writes and going through the VMCS cache unnecessarily.

Location:
trunk
Files:
2 edited

Legend:

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

    r45964 r46004  
    5151# define VMX_VMCS_GUEST_GDTR_BASE_CACHE_IDX                                   8
    5252# define VMX_VMCS_GUEST_IDTR_BASE_CACHE_IDX                                   9
    53 # define VMX_VMCS_GUEST_DR7_CACHE_IDX                                         10
    54 # define VMX_VMCS_GUEST_RSP_CACHE_IDX                                         11
    55 # define VMX_VMCS_GUEST_RIP_CACHE_IDX                                         12
    56 # define VMX_VMCS_GUEST_SYSENTER_ESP_CACHE_IDX                                13
    57 # define VMX_VMCS_GUEST_SYSENTER_EIP_CACHE_IDX                                14
    58 # define VMX_VMCS_RO_EXIT_QUALIFICATION_CACHE_IDX                             15
     53# define VMX_VMCS_GUEST_RSP_CACHE_IDX                                         10
     54# define VMX_VMCS_GUEST_RIP_CACHE_IDX                                         11
     55# define VMX_VMCS_GUEST_SYSENTER_ESP_CACHE_IDX                                12
     56# define VMX_VMCS_GUEST_SYSENTER_EIP_CACHE_IDX                                13
     57# define VMX_VMCS_RO_EXIT_QUALIFICATION_CACHE_IDX                             14
    5958# define VMX_VMCS_MAX_CACHE_IDX                                               (VMX_VMCS_RO_EXIT_QUALIFICATION_CACHE_IDX + 1)
    60 # define VMX_VMCS_GUEST_CR3_CACHE_IDX                                         16
     59# define VMX_VMCS_GUEST_CR3_CACHE_IDX                                         15
    6160# define VMX_VMCS_MAX_NESTED_PAGING_CACHE_IDX                                 (VMX_VMCS_GUEST_CR3_CACHE_IDX + 1)
    6261#else /* VBOX_WITH_OLD_VTX_CODE */
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r45978 r46004  
    31643164    AssertRCReturn(rc, rc);
    31653165
    3166     /* The guest's view of its DR7 is unblemished. */
    3167     rc = VMXWriteVmcsGstN(VMX_VMCS_GUEST_DR7, pMixedCtx->dr[7]);
     3166    /* The guest's view of its DR7 is unblemished. Use 32-bit write as upper 32-bits MBZ as asserted above. */
     3167    rc = VMXWriteVmcs32(VMX_VMCS_GUEST_DR7, (uint32_t)pMixedCtx->dr[7]);
    31683168    AssertRCReturn(rc, rc);
    31693169
     
    40364036        case VMX_VMCS_GUEST_RIP:
    40374037        case VMX_VMCS_GUEST_RSP:
    4038         case VMX_VMCS_GUEST_DR7:
    40394038        case VMX_VMCS_GUEST_SYSENTER_EIP:
    40404039        case VMX_VMCS_GUEST_SYSENTER_ESP:
     
    42664265    VMXLOCAL_INIT_READ_CACHE_FIELD(pCache, VMX_VMCS_GUEST_GDTR_BASE);
    42674266    VMXLOCAL_INIT_READ_CACHE_FIELD(pCache, VMX_VMCS_GUEST_IDTR_BASE);
    4268     VMXLOCAL_INIT_READ_CACHE_FIELD(pCache, VMX_VMCS_GUEST_DR7);
    42694267    VMXLOCAL_INIT_READ_CACHE_FIELD(pCache, VMX_VMCS_GUEST_RSP);
    42704268    VMXLOCAL_INIT_READ_CACHE_FIELD(pCache, VMX_VMCS_GUEST_RIP);
     
    43834381        case VMX_VMCS_GUEST_GDTR_BASE:
    43844382        case VMX_VMCS_GUEST_IDTR_BASE:
    4385         case VMX_VMCS_GUEST_DR7:
    43864383        case VMX_VMCS_GUEST_RSP:
    43874384        case VMX_VMCS_GUEST_RIP:
     
    53845381    if (!(pVCpu->hm.s.vmx.fUpdatedGuestState & HMVMX_UPDATED_GUEST_DEBUG))
    53855382    {
    5386         RTGCUINTREG uVal;
    5387         rc = VMXReadVmcsGstN(VMX_VMCS_GUEST_DR7, &uVal);          AssertRCReturn(rc, rc);
    5388         pMixedCtx->dr[7] = uVal;
     5383        /* Upper 32-bits are always zero. See Intel spec. 2.7.3 "Loading and Storing Debug Registers". */
     5384        uint32_t u32Val;
     5385        rc = VMXReadVmcs32(VMX_VMCS_GUEST_DR7, &u32Val);        AssertRCReturn(rc, rc);
     5386        pMixedCtx->dr[7] = u32Val;
    53895387
    53905388        pVCpu->hm.s.vmx.fUpdatedGuestState |= HMVMX_UPDATED_GUEST_DEBUG;
     
    66206618     * interrupts and handle returning to ring-3 afterwards, but requires very careful state restoration.
    66216619     */
    6622     /** @todo Rework event evaluation and injection to be complete separate. */
     6620    /** @todo Rework event evaluation and injection to be completely separate. */
    66236621    if (TRPMHasTrap(pVCpu))
    66246622        hmR0VmxTRPMTrapToPendingEvent(pVCpu);
     
    86158613
    86168614        /* Paranoia. */
    8617         pMixedCtx->dr[7] &= 0xffffffff;                                              /* upper 32 bits reserved */
     8615        pMixedCtx->dr[7] &= UINT32_C(0xffffffff);                                    /* upper 32 bits MBZ. */
    86188616        pMixedCtx->dr[7] &= ~(RT_BIT(11) | RT_BIT(12) | RT_BIT(14) | RT_BIT(15));    /* must be zero */
    86198617        pMixedCtx->dr[7] |= 0x400;                                                   /* must be one */
    86208618
    8621         rc |= VMXWriteVmcsGstN(VMX_VMCS_GUEST_DR7, pMixedCtx->dr[7]);
     8619        rc |= VMXWriteVmcs32(VMX_VMCS_GUEST_DR7, (uint32_t)pMixedCtx->dr[7]);
    86228620        AssertRCReturn(rc,rc);
    86238621
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