VirtualBox

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


Ignore:
Timestamp:
May 18, 2018 2:10:08 PM (7 years ago)
Author:
vboxsync
Message:

NEM/win: Intercept all (for now) CPUIDs. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r72255 r72262  
    14221422
    14231423    /*
    1424      * Whatever we do, we must clear pending event ejection upon resume.
     1424     * Whatever we do, we must clear pending event injection upon resume.
    14251425     */
    14261426    if (pMsg->Header.ExecutionState.InterruptionPending)
     
    15621562
    15631563/**
     1564 * Deals with CPUID intercept message.
     1565 *
     1566 * @returns Strict VBox status code.
     1567 * @param   pVCpu           The cross context per CPU structure.
     1568 * @param   pMsg            The message.
     1569 * @param   pCtx            The register context.
     1570 */
     1571NEM_TMPL_STATIC VBOXSTRICTRC nemHCWinHandleMessageCpuId(PVMCPU pVCpu, HV_X64_CPUID_INTERCEPT_MESSAGE const *pMsg, PCPUMCTX pCtx)
     1572{
     1573    //Assert(   pMsg->AccessInfo.AccessSize == 1
     1574    //       || pMsg->AccessInfo.AccessSize == 2
     1575    //       || pMsg->AccessInfo.AccessSize == 4);
     1576    //Assert(   pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_READ
     1577    //       || pMsg->Header.InterceptAccessType == HV_INTERCEPT_ACCESS_WRITE);
     1578    AssertMsg(pMsg->Header.InstructionLength < 0x10, ("%#x\n", pMsg->Header.InstructionLength));
     1579
     1580    /*
     1581     * Soak up state and execute the instruction.
     1582     *
     1583     * Note! If this grows slightly more complicated, combine into an IEMExecDecodedCpuId
     1584     *       function and make everyone use it.
     1585     */
     1586    /** @todo Combine implementations into IEMExecDecodedCpuId as this will
     1587     *        only get weirder with nested VT-x and AMD-V support. */
     1588    nemHCWinCopyStateFromX64Header(pVCpu, pCtx, &pMsg->Header);
     1589
     1590    /* Copy in the low register values (top is always cleared). */
     1591    pCtx->rax = (uint32_t)pMsg->Rax;
     1592    pCtx->rcx = (uint32_t)pMsg->Rcx;
     1593    pCtx->rdx = (uint32_t)pMsg->Rdx;
     1594    pCtx->rbx = (uint32_t)pMsg->Rbx;
     1595    pCtx->fExtrn &= ~(CPUMCTX_EXTRN_RAX | CPUMCTX_EXTRN_RCX | CPUMCTX_EXTRN_RDX | CPUMCTX_EXTRN_RBX);
     1596
     1597    /* Get the correct values. */
     1598    CPUMGetGuestCpuId(pVCpu, pCtx->eax, pCtx->ecx, &pCtx->eax, &pCtx->ebx, &pCtx->ecx, &pCtx->edx);
     1599
     1600    Log4(("CpuIdExit/%u: %04x:%08RX64: rax=%08RX64 / rcx=%08RX64 / rdx=%08RX64 / rbx=%08RX64 -> %08RX32 / %08RX32 / %08RX32 / %08RX32 (hv: %08RX64 / %08RX64 / %08RX64 / %08RX64)\n",
     1601          pVCpu->idCpu, pMsg->Header.CsSegment.Selector, pMsg->Header.Rip,
     1602          pMsg->Rax,                           pMsg->Rcx,              pMsg->Rdx,              pMsg->Rbx,
     1603          pCtx->eax,                           pCtx->ecx,              pCtx->edx,              pCtx->ebx,
     1604          pMsg->DefaultResultRax, pMsg->DefaultResultRcx, pMsg->DefaultResultRdx, pMsg->DefaultResultRbx));
     1605
     1606    /* Move RIP and we're done. */
     1607    nemHCWinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pMsg->Header);
     1608
     1609    return VINF_SUCCESS;
     1610}
     1611
     1612
     1613
     1614
     1615/**
    15641616 * Deals with unrecoverable exception (triple fault).
    15651617 *
     
    16351687                return nemHCWinHandleMessageInterruptWindow(pVM, pVCpu, &pMsg->X64InterruptWindow, pCtx, pGVCpu);
    16361688
     1689            case HvMessageTypeX64CpuidIntercept:
     1690                Assert(pMsg->Header.PayloadSize == sizeof(pMsg->X64CpuIdIntercept));
     1691                return nemHCWinHandleMessageCpuId(pVCpu, &pMsg->X64CpuIdIntercept, pCtx);
     1692
    16371693            case HvMessageTypeUnrecoverableException:
    16381694                Assert(pMsg->Header.PayloadSize == sizeof(pMsg->X64InterceptHeader));
     
    16471703
    16481704            case HvMessageTypeX64MsrIntercept:
    1649             case HvMessageTypeX64CpuidIntercept:
    16501705            case HvMessageTypeX64ExceptionIntercept:
    16511706            case HvMessageTypeX64ApicEoi:
     
    16571712            case HvMessageTimerExpired:
    16581713                LogRel(("Unexpected msg:\n%.*Rhxd\n", (int)sizeof(*pMsg), pMsg));
    1659                 AssertLogRelMsgFailedReturn(("Unexpected message on CPU #%u: #x\n", pVCpu->idCpu, pMsg->Header.MessageType),
     1714                AssertLogRelMsgFailedReturn(("Unexpected message on CPU #%u: %#x\n", pVCpu->idCpu, pMsg->Header.MessageType),
    16601715                                            VERR_INTERNAL_ERROR_2);
    16611716
    16621717            default:
    16631718                LogRel(("Unknown msg:\n%.*Rhxd\n", (int)sizeof(*pMsg), pMsg));
    1664                 AssertLogRelMsgFailedReturn(("Unknown message on CPU #%u: #x\n", pVCpu->idCpu, pMsg->Header.MessageType),
     1719                AssertLogRelMsgFailedReturn(("Unknown message on CPU #%u: %#x\n", pVCpu->idCpu, pMsg->Header.MessageType),
    16651720                                            VERR_INTERNAL_ERROR_2);
    16661721        }
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