VirtualBox

Changeset 90380 in vbox


Ignore:
Timestamp:
Jul 28, 2021 9:38:23 PM (3 years ago)
Author:
vboxsync
Message:

VMM: Moved idHostCpu and iHostCpuSet from VMCPU to GVMCPU, removing the VMMR0PERVCPU copies too. bugref:6695

Location:
trunk
Files:
8 edited

Legend:

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

    r90379 r90380  
    5757
    5858    /** VCPU id (0 - (pVM->cCpus - 1). */
    59     VMCPUID         idCpu;
     59    VMCPUID             idCpu;
    6060    /** Padding. */
    61     uint32_t        uPadding;
     61    uint32_t            uPadding0;
    6262
    6363    /** Handle to the EMT thread. */
    64     RTNATIVETHREAD  hEMT;
     64    RTNATIVETHREAD      hEMT;
    6565
    6666    /** Pointer to the global (ring-0) VM structure this CPU belongs to. */
    67     R0PTRTYPE(PGVM) pGVM;
     67    R0PTRTYPE(PGVM)     pGVM;
    6868    /** Pointer to the GVM structure, for CTX_SUFF use in VMMAll code.  */
    69     PGVM            pVMR0;
     69    PGVM                pVMR0;
    7070    /** The ring-3 address of this structure (only VMCPU part). */
    71     PVMCPUR3        pVCpuR3;
     71    PVMCPUR3            pVCpuR3;
     72
     73    /** Padding so the noisy stuff on a 64 byte boundrary.
     74     * @note Keeping this working for 32-bit header syntax checking.  */
     75    uint8_t             abPadding1[HC_ARCH_BITS == 32 ? 40 : 24];
     76
     77    /** Which host CPU ID is this EMT running on.
     78     * Only valid when in RC or HMR0 with scheduling disabled. */
     79    RTCPUID volatile    idHostCpu;
     80    /** The CPU set index corresponding to idHostCpu, UINT32_MAX if not valid.
     81     * @remarks Best to make sure iHostCpuSet shares cache line with idHostCpu! */
     82    uint32_t volatile   iHostCpuSet;
    7283
    7384    /** Padding so gvmm starts on a 64 byte boundrary.
    7485     * @note Keeping this working for 32-bit header syntax checking.  */
    75     uint8_t         abPadding[HC_ARCH_BITS == 32 ? 40 : 24];
     86    uint8_t             abPadding2[56];
    7687
    7788    /** The GVMM per vcpu data. */
     
    109120        struct VMMR0PERVCPU s;
    110121#endif
    111         uint8_t             padding[128];
     122        uint8_t             padding[64];
    112123    } vmmr0;
    113124
    114125    /** Padding the structure size to page boundrary. */
    115126#ifdef VBOX_WITH_NEM_R0
    116     uint8_t                 abPadding2[4096 - 64 - 64 - 1024 - 64 - 128];
     127    uint8_t                 abPadding3[4096 - 64*2 - 64 - 1024 - 64 - 64];
    117128#else
    118     uint8_t                 abPadding2[4096 - 64 - 64 - 1024 - 128];
     129    uint8_t                 abPadding3[4096 - 64*2 - 64 - 1024 - 64];
    119130#endif
    120131} GVMCPU;
  • trunk/include/VBox/vmm/gvm.mac

    r90379 r90380  
    4040
    4141        alignb 64
     42        .idHostCpu          resd 1
     43        .iHostCpuSet        resd 1
     44
     45        alignb 64
    4246        .gvmm               resb 64
    4347        alignb 64
     
    4751%endif
    4852        alignb 64
    49         .vmmr0              resb 128
     53        .vmmr0              resb 64
    5054        alignb 4096
    5155endstruc
  • trunk/include/VBox/vmm/vm.h

    r88348 r90380  
    120120    VMCPUSTATE volatile     enmState;
    121121
    122     /** Which host CPU ID is this EMT running on.
    123      * Only valid when in RC or HMR0 with scheduling disabled. */
    124     RTCPUID volatile        idHostCpu;
    125     /** The CPU set index corresponding to idHostCpu, UINT32_MAX if not valid.
    126      * @remarks Best to make sure iHostCpuSet shares cache line with idHostCpu! */
    127     uint32_t volatile       iHostCpuSet;
    128122    /** Padding up to 64 bytes. */
    129     uint8_t                 abAlignment0[64 - 20];
     123    uint8_t                 abAlignment0[64 - 12];
    130124    /** @} */
    131125
  • trunk/include/VBox/vmm/vm.mac

    r88348 r90380  
    4646    alignb 8
    4747    .enmState               resd 1
    48     .idHostCpu              resd 1
    49     .iHostCpuSet            resd 1
    5048
    5149    alignb 64
  • trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp

    r89087 r90380  
    368368 *                          sync deadline.
    369369 */
    370 DECLINLINE(uint64_t) tmCpuCalcTicksToDeadline(PVMCPU pVCpu, uint64_t cNsToDeadline)
     370DECLINLINE(uint64_t) tmCpuCalcTicksToDeadline(PVMCPUCC pVCpu, uint64_t cNsToDeadline)
    371371{
    372372    AssertCompile(TMCLOCK_FREQ_VIRTUAL <= _4G);
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r90379 r90380  
    368368    {
    369369        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
    370         pGVCpu->vmmr0.s.idHostCpu       = NIL_RTCPUID;
    371         pGVCpu->vmmr0.s.iHostCpuSet     = UINT32_MAX;
     370        Assert(pGVCpu->idHostCpu == NIL_RTCPUID);
     371        Assert(pGVCpu->iHostCpuSet == UINT32_MAX);
    372372        pGVCpu->vmmr0.s.fInHmContext    = false;
    373373        pGVCpu->vmmr0.s.pPreemptState   = NULL;
     
    10061006            RTCPUID idHostCpu;
    10071007            uint32_t iHostCpuSet = RTMpCurSetIndexAndId(&idHostCpu);
    1008             pVCpu->vmmr0.s.iHostCpuSet = iHostCpuSet;
    1009             ASMAtomicWriteU32(&pVCpu->vmmr0.s.idHostCpu, idHostCpu);
    10101008            pVCpu->iHostCpuSet = iHostCpuSet;
    10111009            ASMAtomicWriteU32(&pVCpu->idHostCpu, idHostCpu);
     
    10361034             * have the same host CPU associated with it.
    10371035             */
    1038             pVCpu->vmmr0.s.iHostCpuSet = UINT32_MAX;
    1039             ASMAtomicWriteU32(&pVCpu->vmmr0.s.idHostCpu, NIL_RTCPUID);
    10401036            pVCpu->iHostCpuSet = UINT32_MAX;
    10411037            ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
     
    11091105 * @thread  EMT(pVCpu)
    11101106 *
    1111  * @remarks This also clears VMCPU::idHostCpu, so the mapping is invalid after
     1107 * @remarks This also clears GVMCPU::idHostCpu, so the mapping is invalid after
    11121108 *          this call.  This means you have to be careful with what you do!
    11131109 */
     
    11211117     *      hmR0VmxLeaveSession/hmR0SvmLeaveSession disables context hooks during
    11221118     *      longjmp & normal return to ring-3, which opens a window where we may be
    1123      *      rescheduled without changing VMCPUID::idHostCpu and cause confusion if
     1119     *      rescheduled without changing GVMCPUID::idHostCpu and cause confusion if
    11241120     *      the CPU starts executing a different EMT.  Both functions first disables
    11251121     *      preemption and then calls HMR0LeaveCpu which invalids idHostCpu, leaving
     
    11281124    /** @todo Make HM not need this API!  Then we could leave the hooks enabled
    11291125     *        all the time. */
    1130     /** @todo move this into the context hook disabling if(). */
    1131     ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
    11321126
    11331127    /*
     
    11371131    {
    11381132        Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    1139         ASMAtomicWriteU32(&pVCpu->vmmr0.s.idHostCpu, NIL_RTCPUID);
     1133        ASMAtomicWriteU32(&pVCpu->idHostCpu, NIL_RTCPUID);
    11401134        int rc = RTThreadCtxHookDisable(pVCpu->vmmr0.s.hCtxHook);
    11411135        AssertRC(rc);
     
    14581452                              && SUPIsTscDeltaAvailableForCpuSetIndex(iHostCpuSet)))
    14591453                {
    1460                     pGVCpu->vmmr0.s.iHostCpuSet = iHostCpuSet;
    1461                     ASMAtomicWriteU32(&pGVCpu->vmmr0.s.idHostCpu, idHostCpu);
    1462 
    14631454                    pGVCpu->iHostCpuSet = iHostCpuSet;
    14641455                    ASMAtomicWriteU32(&pGVCpu->idHostCpu, idHostCpu);
     
    15521543                         * hook / restore preemption.
    15531544                         */
    1554                         pGVCpu->vmmr0.s.iHostCpuSet = UINT32_MAX;
    1555                         ASMAtomicWriteU32(&pGVCpu->vmmr0.s.idHostCpu, NIL_RTCPUID);
    1556 
    15571545                        pGVCpu->iHostCpuSet = UINT32_MAX;
    15581546                        ASMAtomicWriteU32(&pGVCpu->idHostCpu, NIL_RTCPUID);
     
    15661554                         */
    15671555                        if (pGVCpu->vmmr0.s.hCtxHook != NIL_RTTHREADCTXHOOK)
    1568                         {
    1569                             ASMAtomicWriteU32(&pGVCpu->idHostCpu, NIL_RTCPUID);
    15701556                            RTThreadCtxHookDisable(pGVCpu->vmmr0.s.hCtxHook);
    1571                         }
    15721557                    }
    15731558                    /*
     
    15761561                    else
    15771562                    {
    1578                         rc = VINF_EM_RAW_INTERRUPT;
    15791563                        pGVCpu->iHostCpuSet = UINT32_MAX;
    15801564                        ASMAtomicWriteU32(&pGVCpu->idHostCpu, NIL_RTCPUID);
     1565                        rc = VINF_EM_RAW_INTERRUPT;
    15811566                    }
    15821567
     
    16181603                {
    16191604                    pGVCpu->vmmr0.s.pPreemptState = NULL;
    1620                     pGVCpu->vmmr0.s.iHostCpuSet = UINT32_MAX;
    1621                     ASMAtomicWriteU32(&pGVCpu->vmmr0.s.idHostCpu, NIL_RTCPUID);
    16221605                    pGVCpu->iHostCpuSet = UINT32_MAX;
    16231606                    ASMAtomicWriteU32(&pGVCpu->idHostCpu, NIL_RTCPUID);
     
    26352618         * Are we in HM context and w/o a context hook?  If so work the context hook.
    26362619         */
    2637         if (pVCpu->vmmr0.s.idHostCpu != NIL_RTCPUID)
    2638         {
    2639             Assert(pVCpu->vmmr0.s.iHostCpuSet != UINT32_MAX);
     2620        if (pVCpu->idHostCpu != NIL_RTCPUID)
     2621        {
     2622            Assert(pVCpu->iHostCpuSet != UINT32_MAX);
    26402623            Assert(pVCpu->vmmr0.s.fInHmContext);
    26412624
  • trunk/src/VBox/VMM/include/VMMInternal.h

    r90379 r90380  
    460460typedef struct VMMR0PERVCPU
    461461{
    462     /** Which host CPU ID is this EMT running on.
    463      * Only valid when in RC or HMR0 with scheduling disabled. */
    464     RTCPUID volatile                    idHostCpu;
    465     /** The CPU set index corresponding to idHostCpu, UINT32_MAX if not valid.
    466      * @remarks Best to make sure iHostCpuSet shares cache line with idHostCpu! */
    467     uint32_t volatile                   iHostCpuSet;
    468462    /** Set if we've entered HM context. */
    469463    bool volatile                       fInHmContext;
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r89088 r90380  
    14581458    GEN_CHECK_OFF(VMCPU, hNativeThread);
    14591459    GEN_CHECK_OFF(VMCPU, hNativeThreadR0);
    1460     GEN_CHECK_OFF(VMCPU, idHostCpu);
    14611460    GEN_CHECK_OFF(VMCPU, fTraceGroups);
    14621461    GEN_CHECK_OFF(VMCPU, uAdHoc);
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