VirtualBox

Changeset 78438 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 7, 2019 3:57:37 PM (6 years ago)
Author:
vboxsync
Message:

VMM: More refactoring of GVM & VM structures for bugref:9217

Location:
trunk/src/VBox/VMM
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Config.kmk

    r78431 r78438  
    8282 VMM_COMMON_DEFS += VBOX_WITH_MORE_RING0_MEM_MAPPINGS
    8383endif
     84ifdef VBOX_WITH_NATIVE_NEM
     85 if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.amd64)
     86  VMM_COMMON_DEFS += VBOX_WITH_NATIVE_NEM VBOX_WITH_NEM_R0
     87 endif
     88endif
    8489ifdef VBOX_BUGREF_9217
    8590 VMM_COMMON_DEFS += VBOX_BUGREF_9217
  • trunk/src/VBox/VMM/Makefile.kmk

    r76553 r78438  
    972972                        \
    973973                        -e '/^g_VM\>/d'\
     974                        -e '/^g_VCpu0\>/d'\
    974975                        -e '/^g_CPUM\>/d'\
    975976                        -e '/^g_Logger\>/d'\
  • trunk/src/VBox/VMM/VMMAll/VMMAll.cpp

    r76553 r78438  
    2424#include "VMMInternal.h"
    2525#include <VBox/vmm/vm.h>
     26#ifdef IN_RING0
     27# include <VBox/vmm/gvm.h>
     28#endif
    2629#include <VBox/vmm/hm.h>
    2730#include <VBox/vmm/vmcpuset.h>
     
    203206    if (pVM->cCpus == 1)
    204207        return 0;
     208# ifdef VBOX_BUGREF_9217
     209    PGVM          pGVM  = (PGVM)pVM;
     210    VMCPUID const cCpus = pGVM->cCpusSafe;
     211# else
     212    VMCPUID const cCpus = pVM->cCpus;
     213# endif
    205214
    206215    /* Search first by host cpu id (most common case)
     
    215224
    216225        /** @todo optimize for large number of VCPUs when that becomes more common. */
    217         for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     226        for (VMCPUID idCpu = 0; idCpu < cCpus; idCpu++)
    218227        {
     228# ifdef VBOX_BUGREF_9217
     229            PVMCPU pVCpu = &pGVM->aCpus[idCpu];
     230# else
    219231            PVMCPU pVCpu = &pVM->aCpus[idCpu];
     232# endif
    220233
    221234            if (pVCpu->idHostCpu == idHostCpu)
     
    228241
    229242    /** @todo optimize for large number of VCPUs when that becomes more common. */
    230     for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    231     {
     243    for (VMCPUID idCpu = 0; idCpu < cCpus; idCpu++)
     244    {
     245# ifdef VBOX_BUGREF_9217
     246        PVMCPU pVCpu = &pGVM->aCpus[idCpu];
     247# else
    232248        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     249# endif
    233250
    234251        if (pVCpu->hNativeThreadR0 == hThread)
     
    259276        return NULL;
    260277    Assert(idCpu < pVM->cCpus);
     278# ifdef VBOX_BUGREF_9217
     279    return pVM->apCpus[idCpu];
     280# else
    261281    return &pVM->aCpus[idCpu];
     282# endif
    262283
    263284#elif defined(IN_RING0)
     285# ifdef VBOX_BUGREF_9217
     286    PGVM          pGVM  = (PGVM)pVM;
     287    VMCPUID const cCpus = pGVM->cCpusSafe;
     288# else
     289    VMCPUID const cCpus = pVM->cCpus;
     290# endif
    264291    if (pVM->cCpus == 1)
     292# ifdef VBOX_BUGREF_9217
     293        return &pGVM->aCpus[0];
     294# else
    265295        return &pVM->aCpus[0];
     296# endif
    266297
    267298    /*
     
    277308
    278309        /** @todo optimize for large number of VCPUs when that becomes more common. */
    279         for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
     310        for (VMCPUID idCpu = 0; idCpu < cCpus; idCpu++)
    280311        {
     312# ifdef VBOX_BUGREF_9217
     313            PVMCPU pVCpu = &pGVM->aCpus[idCpu];
     314# else
    281315            PVMCPU pVCpu = &pVM->aCpus[idCpu];
    282 
     316# endif
    283317            if (pVCpu->idHostCpu == idHostCpu)
    284318                return pVCpu;
     
    291325    /** @todo optimize for large number of VCPUs when that becomes more common.
    292326     * Use a map like GIP does that's indexed by the host CPU index.  */
    293     for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    294     {
     327    for (VMCPUID idCpu = 0; idCpu < cCpus; idCpu++)
     328    {
     329# ifdef VBOX_BUGREF_9217
     330        PVMCPU pVCpu = &pGVM->aCpus[idCpu];
     331# else
    295332        PVMCPU pVCpu = &pVM->aCpus[idCpu];
    296 
     333# endif
    297334        if (pVCpu->hNativeThreadR0 == hThread)
    298335            return pVCpu;
     
    301338
    302339#else /* RC: Always EMT(0) */
    303     return &pVM->aCpus[0];
     340    RT_NOREF(pVM);
     341    return &g_VCpu0;
    304342#endif /* IN_RING0 */
    305343}
     
    316354{
    317355    Assert(pVM->cCpus == 1);
     356#ifdef VBOX_BUGREF_9217
     357# ifdef IN_RING3
     358    return pVM->apCpus[0];
     359# elif defined(IN_RING0)
     360    return &((PGVM)pVM)->aCpus[0];
     361# else /* RC  */
     362    RT_NOREF(pVM);
     363    return &g_VCpu0;
     364# endif
     365#else
    318366    return &pVM->aCpus[0];
     367#endif
    319368}
    320369
     
    332381{
    333382    AssertReturn(idCpu < pVM->cCpus, NULL);
     383#ifdef VBOX_BUGREF_9217
     384# ifdef IN_RING3
     385    return pVM->apCpus[idCpu];
     386# elif defined(IN_RING0)
     387    return &((PGVM)pVM)->aCpus[0];
     388# else /* RC  */
     389    RT_NOREF(pVM, idCpu);
     390    Assert(idCpu == 0);
     391    return &g_VCpu0;
     392# endif
     393#else
    334394    return &pVM->aCpus[idCpu];
     395#endif
    335396}
    336397
  • trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp

    r76553 r78438  
    362362        if (!strcmp(pszSymbol, "g_VM"))
    363363            *pValue = pVM->pVMRC;
     364        else if (!strcmp(pszSymbol, "g_VCpu0"))
     365            *pValue = pVM->pVMRC + pVM->offVMCPU;
    364366        else if (!strcmp(pszSymbol, "g_CPUM"))
    365367            *pValue = VM_RC_ADDR(pVM, &pVM->cpum);
  • trunk/src/VBox/VMM/VMMRC/PDMRCDevice.cpp

    r76553 r78438  
    453453{
    454454    PDMDEV_ASSERT_DEVINS(pDevIns);
     455#ifdef VBOX_BUGREF_9217
     456    PVMCPU pVCpu = &g_VCpu0;        /* for PIC we always deliver to CPU 0, MP use APIC */
     457#else
    455458    PVM pVM = pDevIns->Internal.s.pVMRC;
    456459    PVMCPU pVCpu = &pVM->aCpus[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     460#endif
    457461    /** @todo r=ramshankar: Propagating rcRZ and make all callers handle it? */
    458462    APICLocalInterrupt(pVCpu, 0 /* u8Pin */, 1 /* u8Level */, VINF_SUCCESS /* rcRZ */);
     
    464468{
    465469    PDMDEV_ASSERT_DEVINS(pDevIns);
     470#ifdef VBOX_BUGREF_9217
     471    PVMCPU pVCpu = &g_VCpu0;        /* for PIC we always deliver to CPU 0, MP use APIC */
     472#else
    466473    PVM pVM = pDevIns->Internal.s.CTX_SUFF(pVM);
    467474    PVMCPU pVCpu = &pVM->aCpus[0];  /* for PIC we always deliver to CPU 0, MP use APIC */
     475#endif
    468476    /** @todo r=ramshankar: Propagating rcRZ and make all callers handle it? */
    469477    APICLocalInterrupt(pVCpu, 0 /* u8Pin */, 0 /* u8Level */, VINF_SUCCESS /* rcRZ */);
  • trunk/src/VBox/VMM/VMMRC/VMMRCBuiltin.def

    r76553 r78438  
    2020    ; data
    2121    g_VM                            DATA
     22    g_VCpu0                         DATA
    2223    g_CPUM                          DATA
    2324    g_TRPM                          DATA
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