VirtualBox

Changeset 71184 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Mar 3, 2018 3:01:59 PM (7 years ago)
Author:
vboxsync
Message:

CPUM,NEM: Introduced CPUMCTX field for tracking state that's not in the structure. Made NEM/win only get/set the register it needs. New NEM runloop based on low level messages, skipping translations. bugref:9044

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r71152 r71184  
    210210# define WHvGetVirtualProcessorRegisters            g_pfnWHvGetVirtualProcessorRegisters
    211211# define WHvSetVirtualProcessorRegisters            g_pfnWHvSetVirtualProcessorRegisters
     212
     213# define VidMessageSlotHandleAndGetNext             g_pfnVidMessageSlotHandleAndGetNext
     214# define VidStartVirtualProcessor                    g_pfnVidStartVirtualProcessor
     215# define VidStopVirtualProcessor                    g_pfnVidStopVirtualProcessor
     216
    212217#endif
    213218
     
    13371342}
    13381343
    1339 
    1340 #ifdef LOG_ENABLED
    1341 
     1344#ifndef NEM_WIN_USE_OUR_OWN_RUN_API
     1345
     1346# ifdef LOG_ENABLED
    13421347/**
    13431348 * Log the full details of an exit reason.
     
    13921397            break;
    13931398
    1394 # if 0
     1399#  if 0
    13951400        case WHvRunVpExitReasonUnrecoverableException:
    13961401        case WHvRunVpExitReasonInvalidVpRegisterValue:
     
    14101415            WHV_X64_UNSUPPORTED_FEATURE_CONTEXT UnsupportedFeature;
    14111416            WHV_RUN_VP_CANCELED_CONTEXT CancelReason;
    1412 #endif
     1417#  endif
    14131418
    14141419        case WHvRunVpExitReasonNone:
     
    14551460    }
    14561461}
    1457 
    1458 #endif /* LOG_ENABLED */
     1462# endif /* LOG_ENABLED */
     1463
     1464
     1465/**
     1466 * Advances the guest RIP and clear EFLAGS.RF.
     1467 *
     1468 * This may clear VMCPU_FF_INHIBIT_INTERRUPTS.
     1469 *
     1470 * @param   pVCpu           The cross context virtual CPU structure.
     1471 * @param   pCtx            The CPU context to update.
     1472 * @param   pExitCtx        The exit context.
     1473 */
     1474DECLINLINE(void) nemR3WinAdvanceGuestRipAndClearRF(PVMCPU pVCpu, PCPUMCTX pCtx, WHV_VP_EXIT_CONTEXT const *pExitCtx)
     1475{
     1476    /* Advance the RIP. */
     1477    Assert(pExitCtx->InstructionLength > 0 && pExitCtx->InstructionLength < 16);
     1478    pCtx->rip += pExitCtx->InstructionLength;
     1479    pCtx->rflags.Bits.u1RF = 0;
     1480
     1481    /* Update interrupt inhibition. */
     1482    if (!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS))
     1483    { /* likely */ }
     1484    else if (pCtx->rip != EMGetInhibitInterruptsPC(pVCpu))
     1485        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
     1486}
    14591487
    14601488
     
    14671495
    14681496
    1469 #ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1497# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    14701498/**
    14711499 * @callback_method_impl{FNPGMPHYSNEMENUMCALLBACK,
     
    14931521    return VINF_SUCCESS;
    14941522}
    1495 #endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
     1523# endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */
    14961524
    14971525
     
    15871615                                      pIoPortCtx->AccessInfo.AccessSize);
    15881616            if (IOM_SUCCESS(rcStrict))
    1589                 nemHCWinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
     1617                nemR3WinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
    15901618        }
    15911619        else
     
    15971625            {
    15981626                pCtx->eax = (pCtx->eax & ~fAndMask) | (uValue & fAndMask);
    1599                 nemHCWinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
     1627                nemR3WinAdvanceGuestRipAndClearRF(pVCpu, pCtx, &pIoPortCtx->VpContext);
    16001628            }
    16011629        }
     
    16921720VBOXSTRICTRC nemR3WinWHvRunGC(PVM pVM, PVMCPU pVCpu)
    16931721{
    1694 #ifdef LOG_ENABLED
     1722# ifdef LOG_ENABLED
    16951723    if (LogIs3Enabled())
    16961724    {
     
    16981726        nemHCWinLogState(pVM, pVCpu);
    16991727    }
    1700 #endif
     1728# endif
    17011729
    17021730    /*
     
    17251753            && !VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HM_TO_R3_MASK))
    17261754        {
    1727 #ifdef NEM_WIN_USE_OUR_OWN_RUN_API
    1728             int rc2 = nemHCWinRunVirtualProcessor(pVM, pVCpu, &ExitReason, sizeof(ExitReason));
    1729             AssertRCBreakStmt(rc2, rcStrict = rc2);
    1730 #else
    17311755            Log8(("Calling WHvRunVirtualProcessor\n"));
    17321756            VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC_NEM, VMCPUSTATE_STARTED);
     
    17391763            Log2(("WHvRunVirtualProcessor -> %#x; exit code %#x (%d) (cpu status %u)\n",
    17401764                  hrc, ExitReason.ExitReason, ExitReason.ExitReason, nemR3WinCpuGetRunningStatus(pVCpu) ));
    1741 #endif
    17421765        }
    17431766        else
     
    17531776        AssertRCBreakStmt(rc2, rcStrict = rc2);
    17541777
    1755 #ifdef LOG_ENABLED
     1778# ifdef LOG_ENABLED
    17561779        /*
    17571780         * Do some logging.
     
    17611784        if (LogIs3Enabled())
    17621785            nemHCWinLogState(pVM, pVCpu);
    1763 #endif
    1764 
    1765 #ifdef VBOX_STRICT
     1786# endif
     1787
     1788# ifdef VBOX_STRICT
    17661789        /* Assert that the VpContext field makes sense. */
    17671790        switch (ExitReason.ExitReason)
     
    17921815            default: break; /* shut up compiler. */
    17931816        }
    1794 #endif
     1817# endif
    17951818
    17961819        /*
     
    18591882        }
    18601883
    1861 #ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
     1884# ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
    18621885        /* Hack alert! */
    18631886        uint32_t const cMappedPages = pVM->nem.s.cMappedPages;
     
    18691892            Log(("nemR3NativeRunGC: Unmapped all; cMappedPages=%u -> %u\n", cMappedPages, pVM->nem.s.cMappedPages));
    18701893        }
    1871 #endif
     1894# endif
    18721895
    18731896        /* If any FF is pending, return to the EM loops.  That's okay for the
     
    18841907}
    18851908
     1909#endif /* !NEM_WIN_USE_OUR_OWN_RUN_API */
     1910
    18861911
    18871912VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu)
    18881913{
    1889 #if 1
     1914#ifndef NEM_WIN_USE_OUR_OWN_RUN_API
    18901915    return nemR3WinWHvRunGC(pVM, pVCpu);
    18911916#elif 1
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