VirtualBox

Ignore:
Timestamp:
Aug 14, 2019 2:34:38 PM (5 years ago)
Author:
vboxsync
Message:

VMM: Refactoring VMMR0/* and VMMRZ/* to use VMCC & VMMCPUCC. bugref:9217

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r80266 r80274  
    2020*   Header Files                                                                                                                 *
    2121*********************************************************************************************************************************/
     22#define VBOX_BUGREF_9217_PART_I
    2223#define LOG_GROUP LOG_GROUP_HM
    2324#define VMCPU_INCL_CPUM_GST_CTX
     
    2526#include <VBox/vmm/pgm.h>
    2627#include "HMInternal.h"
    27 #include <VBox/vmm/vm.h>
     28#include <VBox/vmm/vmcc.h>
    2829#include <VBox/vmm/hm_svm.h>
    2930#include <VBox/vmm/hmvmxinline.h>
     
    8788    /** @name Ring-0 method table for AMD-V and VT-x specific operations.
    8889     * @{ */
    89     DECLR0CALLBACKMEMBER(int,  pfnEnterSession, (PVMCPU pVCpu));
    90     DECLR0CALLBACKMEMBER(void, pfnThreadCtxCallback, (RTTHREADCTXEVENT enmEvent, PVMCPU pVCpu, bool fGlobalInit));
    91     DECLR0CALLBACKMEMBER(int,  pfnExportHostState, (PVMCPU pVCpu));
    92     DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnRunGuestCode, (PVMCPU pVCpu));
    93     DECLR0CALLBACKMEMBER(int,  pfnEnableCpu, (PHMPHYSCPU pHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,
     90    DECLR0CALLBACKMEMBER(int,  pfnEnterSession, (PVMCPUCC pVCpu));
     91    DECLR0CALLBACKMEMBER(void, pfnThreadCtxCallback, (RTTHREADCTXEVENT enmEvent, PVMCPUCC pVCpu, bool fGlobalInit));
     92    DECLR0CALLBACKMEMBER(int,  pfnExportHostState, (PVMCPUCC pVCpu));
     93    DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnRunGuestCode, (PVMCPUCC pVCpu));
     94    DECLR0CALLBACKMEMBER(int,  pfnEnableCpu, (PHMPHYSCPU pHostCpu, PVMCC pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,
    9495                                              bool fEnabledByHost, PCSUPHWVIRTMSRS pHwvirtMsrs));
    9596    DECLR0CALLBACKMEMBER(int,  pfnDisableCpu, (void *pvCpuPage, RTHCPHYS HCPhysCpuPage));
    96     DECLR0CALLBACKMEMBER(int,  pfnInitVM, (PVM pVM));
    97     DECLR0CALLBACKMEMBER(int,  pfnTermVM, (PVM pVM));
    98     DECLR0CALLBACKMEMBER(int,  pfnSetupVM, (PVM pVM));
     97    DECLR0CALLBACKMEMBER(int,  pfnInitVM, (PVMCC pVM));
     98    DECLR0CALLBACKMEMBER(int,  pfnTermVM, (PVMCC pVM));
     99    DECLR0CALLBACKMEMBER(int,  pfnSetupVM, (PVMCC pVM));
    99100    /** @} */
    100101
     
    227228 * @{ */
    228229
    229 static DECLCALLBACK(int) hmR0DummyEnter(PVMCPU pVCpu)
     230static DECLCALLBACK(int) hmR0DummyEnter(PVMCPUCC pVCpu)
    230231{
    231232    RT_NOREF1(pVCpu);
     
    233234}
    234235
    235 static DECLCALLBACK(void) hmR0DummyThreadCtxCallback(RTTHREADCTXEVENT enmEvent, PVMCPU pVCpu, bool fGlobalInit)
     236static DECLCALLBACK(void) hmR0DummyThreadCtxCallback(RTTHREADCTXEVENT enmEvent, PVMCPUCC pVCpu, bool fGlobalInit)
    236237{
    237238    RT_NOREF3(enmEvent, pVCpu, fGlobalInit);
    238239}
    239240
    240 static DECLCALLBACK(int) hmR0DummyEnableCpu(PHMPHYSCPU pHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,
     241static DECLCALLBACK(int) hmR0DummyEnableCpu(PHMPHYSCPU pHostCpu, PVMCC pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,
    241242                                            bool fEnabledBySystem, PCSUPHWVIRTMSRS pHwvirtMsrs)
    242243{
     
    251252}
    252253
    253 static DECLCALLBACK(int) hmR0DummyInitVM(PVM pVM)
     254static DECLCALLBACK(int) hmR0DummyInitVM(PVMCC pVM)
    254255{
    255256    RT_NOREF1(pVM);
     
    257258}
    258259
    259 static DECLCALLBACK(int) hmR0DummyTermVM(PVM pVM)
     260static DECLCALLBACK(int) hmR0DummyTermVM(PVMCC pVM)
    260261{
    261262    RT_NOREF1(pVM);
     
    263264}
    264265
    265 static DECLCALLBACK(int) hmR0DummySetupVM(PVM pVM)
     266static DECLCALLBACK(int) hmR0DummySetupVM(PVMCC pVM)
    266267{
    267268    RT_NOREF1(pVM);
     
    269270}
    270271
    271 static DECLCALLBACK(VBOXSTRICTRC) hmR0DummyRunGuestCode(PVMCPU pVCpu)
     272static DECLCALLBACK(VBOXSTRICTRC) hmR0DummyRunGuestCode(PVMCPUCC pVCpu)
    272273{
    273274    RT_NOREF(pVCpu);
     
    275276}
    276277
    277 static DECLCALLBACK(int) hmR0DummyExportHostState(PVMCPU pVCpu)
     278static DECLCALLBACK(int) hmR0DummyExportHostState(PVMCPUCC pVCpu)
    278279{
    279280    RT_NOREF1(pVCpu);
     
    788789 * @remarks Maybe called with interrupts disabled!
    789790 */
    790 static int hmR0EnableCpu(PVM pVM, RTCPUID idCpu)
     791static int hmR0EnableCpu(PVMCC pVM, RTCPUID idCpu)
    791792{
    792793    PHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu];
     
    824825static DECLCALLBACK(void) hmR0EnableCpuCallback(RTCPUID idCpu, void *pvUser1, void *pvUser2)
    825826{
    826     PVM             pVM      = (PVM)pvUser1;     /* can be NULL! */
     827    PVMCC             pVM      = (PVMCC)pvUser1;     /* can be NULL! */
    827828    PHMR0FIRSTRC    pFirstRc = (PHMR0FIRSTRC)pvUser2;
    828829    AssertReturnVoid(g_HmR0.fGlobalInit);
     
    840841static DECLCALLBACK(int32_t) hmR0EnableAllCpuOnce(void *pvUser)
    841842{
    842     PVM pVM = (PVM)pvUser;
     843    PVMCC pVM = (PVMCC)pvUser;
    843844
    844845    /*
     
    956957 * @param   pVM                 The cross context VM structure.
    957958 */
    958 VMMR0_INT_DECL(int) HMR0EnableAllCpus(PVM pVM)
     959VMMR0_INT_DECL(int) HMR0EnableAllCpus(PVMCC pVM)
    959960{
    960961    /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */
     
    10421043 * @param   enmEvent            The Mp event.
    10431044 * @param   idCpu               The identifier for the CPU the function is called on.
    1044  * @param   pvData              Opaque data (PVM pointer).
     1045 * @param   pvData              Opaque data (PVMCC pointer).
    10451046 */
    10461047static DECLCALLBACK(void) hmR0MpEventCallback(RTMPEVENT enmEvent, RTCPUID idCpu, void *pvData)
     
    11581159 *          vmR3InitRing3().
    11591160 */
    1160 VMMR0_INT_DECL(int) HMR0InitVM(PVM pVM)
     1161VMMR0_INT_DECL(int) HMR0InitVM(PVMCC pVM)
    11611162{
    11621163    AssertReturn(pVM, VERR_INVALID_PARAMETER);
     
    12351236     * Initialize some per-VCPU fields.
    12361237     */
    1237     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1238     {
    1239         PVMCPU pVCpu = &pVM->aCpus[i];
     1238    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     1239    {
     1240        PVMCPUCC pVCpu = VMCC_GET_CPU(pVM, idCpu);
    12401241        pVCpu->hm.s.idEnteredCpu   = NIL_RTCPUID;
    12411242        pVCpu->hm.s.idLastCpu      = NIL_RTCPUID;
     
    12671268 * @param   pVM         The cross context VM structure.
    12681269 */
    1269 VMMR0_INT_DECL(int) HMR0TermVM(PVM pVM)
     1270VMMR0_INT_DECL(int) HMR0TermVM(PVMCC pVM)
    12701271{
    12711272    Log(("HMR0TermVM: %p\n", pVM));
     
    12901291 * @param   pVM         The cross context VM structure.
    12911292 */
    1292 VMMR0_INT_DECL(int) HMR0SetupVM(PVM pVM)
     1293VMMR0_INT_DECL(int) HMR0SetupVM(PVMCC pVM)
    12931294{
    12941295    Log(("HMR0SetupVM: %p\n", pVM));
     
    12991300
    13001301    /* On first entry we'll sync everything. */
    1301     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1302     {
    1303         PVMCPU pVCpu = &pVM->aCpus[i];
    1304         pVCpu->hm.s.fCtxChanged |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
    1305     }
     1302    VMCC_FOR_EACH_VMCPU_STMT(pVM, pVCpu->hm.s.fCtxChanged |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST);
    13061303
    13071304    /*
     
    13511348 * @remarks No-long-jump zone!!!
    13521349 */
    1353 VMMR0_INT_DECL(int) hmR0EnterCpu(PVMCPU pVCpu)
     1350VMMR0_INT_DECL(int) hmR0EnterCpu(PVMCPUCC pVCpu)
    13541351{
    13551352    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     
    13841381 * @remarks This is called with preemption disabled.
    13851382 */
    1386 VMMR0_INT_DECL(int) HMR0Enter(PVMCPU pVCpu)
     1383VMMR0_INT_DECL(int) HMR0Enter(PVMCPUCC pVCpu)
    13871384{
    13881385    /* Make sure we can't enter a session after we've disabled HM in preparation of a suspend. */
     
    14371434 * @remarks No-long-jump zone!!!
    14381435 */
    1439 VMMR0_INT_DECL(int) HMR0LeaveCpu(PVMCPU pVCpu)
     1436VMMR0_INT_DECL(int) HMR0LeaveCpu(PVMCPUCC pVCpu)
    14401437{
    14411438    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     
    14721469VMMR0_INT_DECL(void) HMR0ThreadCtxCallback(RTTHREADCTXEVENT enmEvent, void *pvUser)
    14731470{
    1474     PVMCPU pVCpu = (PVMCPU)pvUser;
     1471    PVMCPUCC pVCpu = (PVMCPUCC)pvUser;
    14751472    Assert(pVCpu);
    14761473    Assert(g_HmR0.pfnThreadCtxCallback);
     
    14911488 *          used!!!
    14921489 */
    1493 VMMR0_INT_DECL(int) HMR0RunGuestCode(PVM pVM, PVMCPU pVCpu)
     1490VMMR0_INT_DECL(int) HMR0RunGuestCode(PVMCC pVM, PVMCPUCC pVCpu)
    14941491{
    14951492    RT_NOREF(pVM);
     
    15271524 * @param   pVCpu   The cross context virtual CPU structure of the calling EMT.
    15281525 */
    1529 VMMR0_INT_DECL(void) HMR0NotifyCpumUnloadedGuestFpuState(PVMCPU pVCpu)
     1526VMMR0_INT_DECL(void) HMR0NotifyCpumUnloadedGuestFpuState(PVMCPUCC pVCpu)
    15301527{
    15311528    ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_GUEST_CR0);
     
    15381535 * @param   pVCpu   The cross context virtual CPU structure of the calling EMT.
    15391536 */
    1540 VMMR0_INT_DECL(void) HMR0NotifyCpumModifiedHostCr0(PVMCPU pVCpu)
     1537VMMR0_INT_DECL(void) HMR0NotifyCpumModifiedHostCr0(PVMCPUCC pVCpu)
    15411538{
    15421539    ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_HOST_CONTEXT);
     
    15611558 * @param   GCVirt      Page to invalidate.
    15621559 */
    1563 VMMR0_INT_DECL(int) HMR0InvalidatePage(PVMCPU pVCpu, RTGCPTR GCVirt)
    1564 {
    1565     PVM pVM = pVCpu->CTX_SUFF(pVM);
     1560VMMR0_INT_DECL(int) HMR0InvalidatePage(PVMCPUCC pVCpu, RTGCPTR GCVirt)
     1561{
     1562    PVMCC pVM = pVCpu->CTX_SUFF(pVM);
    15661563    if (pVM->hm.s.vmx.fSupported)
    15671564        return VMXR0InvalidatePage(pVCpu, GCVirt);
     
    15921589 * @param   fWhat       What to import, CPUMCTX_EXTRN_XXX.
    15931590 */
    1594 VMMR0_INT_DECL(int) HMR0ImportStateOnDemand(PVMCPU pVCpu, uint64_t fWhat)
     1591VMMR0_INT_DECL(int) HMR0ImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat)
    15951592{
    15961593    if (pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fSupported)
     
    17301727 * @param   fFlags  The dumping flags (HM_DUMP_REG_FLAGS_XXX).
    17311728 */
    1732 VMMR0_INT_DECL(void) hmR0DumpRegs(PVMCPU pVCpu, uint32_t fFlags)
     1729VMMR0_INT_DECL(void) hmR0DumpRegs(PVMCPUCC pVCpu, uint32_t fFlags)
    17331730{
    17341731    /*
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