VirtualBox

Changeset 74798 in vbox for trunk


Ignore:
Timestamp:
Oct 12, 2018 12:25:41 PM (6 years ago)
Author:
vboxsync
Message:

vm.h,VMM: Prep work for 64-bit VMCPU::fLocalForcedActions. Define VMCPU_WITH_64_BIT_FFS to enable. bugref:9180

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.mac

    r74479 r74798  
    281281    .hwvirt.svm.HCPhysVmcb             RTHCPHYS_RES  1
    282282    .hwvirt.enmHwvirt                  resd          1
     283    .hwvirt.fGif                       resb          1
     284    alignb 8
    283285    .hwvirt.fLocalForcedActions        resd          1
    284     .hwvirt.fGif                       resb          1
    285286    alignb 64
    286287endstruc
  • trunk/include/VBox/vmm/cpumctx.h

    r74753 r74798  
    666666        /** 0x3f0 - Hardware virtualization type currently in use. */
    667667        CPUMHWVIRT              enmHwvirt;
    668         /** 0x3f4 - A subset of guest force flags that are saved while running the
     668        /** 0x3f4 - Global interrupt flag - AMD only (always true on Intel). */
     669        bool                    fGif;
     670        bool                    afPadding1[3];
     671        /** 0x3f8 - A subset of guest force flags that are saved while running the
    669672         *  nested-guest. */
    670673        uint32_t                fLocalForcedActions;
    671         /** 0x3f8 - Global interrupt flag - AMD only (always true on Intel). */
    672         bool                    fGif;
    673         /** 0x3fc - Padding. */
    674         uint8_t                 abPadding1[7];
     674        uint8_t                 abPadding[4];
    675675    } hwvirt;
    676676    /** @} */
     
    775775AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvIoBitmapR0,      8);
    776776AssertCompileMemberOffset(CPUMCTX, hwvirt.enmHwvirt,           0x3f0);
    777 AssertCompileMemberOffset(CPUMCTX, hwvirt.fLocalForcedActions, 0x3f4);
    778 AssertCompileMemberOffset(CPUMCTX, hwvirt.fGif,                0x3f8);
     777AssertCompileMemberOffset(CPUMCTX, hwvirt.fGif,                0x3f4);
     778AssertCompileMemberOffset(CPUMCTX, hwvirt.fLocalForcedActions, 0x3f8);
    779779AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_NM(g.) aGRegs);
    780780AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.)  r0);
  • trunk/include/VBox/vmm/vm.h

    r74797 r74798  
    103103    /** Per CPU forced action.
    104104     * See the VMCPU_FF_* \#defines. Updated atomically. */
     105#ifdef VMCPU_WITH_64_BIT_FFS
     106    uint64_t volatile       fLocalForcedActions;
     107#else
    105108    uint32_t volatile       fLocalForcedActions;
    106109    uint32_t                fForLocalForcedActionsExpansion;
     110#endif
    107111    /** The CPU state. */
    108112    VMCPUSTATE volatile     enmState;
     
    675679 * @sa      VMCPU_FF_SET_MASK
    676680 */
    677 #define VMCPU_FF_SET(pVCpu, fFlag) do { \
     681#ifdef VMCPU_WITH_64_BIT_FFS
     682# define VMCPU_FF_SET(pVCpu, fFlag) do { \
     683        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
     684        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
     685        ASMAtomicBitSet(&(pVCpu)->fLocalForcedActions, fFlag##_BIT); \
     686    } while (0)
     687#else
     688# define VMCPU_FF_SET(pVCpu, fFlag) do { \
    678689        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
    679690        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
    680691        ASMAtomicOrU32(&(pVCpu)->fLocalForcedActions, (fFlag)); \
    681692    } while (0)
     693#endif
    682694
    683695/** @def VMCPU_FF_SET_MASK
     
    688700 * @sa      VMCPU_FF_SET
    689701 */
    690 #define VMCPU_FF_SET_MASK(a_pVCpu, fFlags) \
     702#ifdef VMCPU_WITH_64_BIT_FFS
     703# if ARCH_BITS > 32
     704#  define VMCPU_FF_SET_MASK(a_pVCpu, fFlags) \
     705    do { ASMAtomicOrU64(&a_pVCpu->fLocalForcedActions, (fFlags)); } while (0)
     706# else
     707#  define VMCPU_FF_SET_MASK(a_pVCpu, fFlags) do { \
     708        if (!((fFlags) >> 32)) ASMAtomicOrU32((uint32_t volatile *)&a_pVCpu->fLocalForcedActions, (uint32_t)(fFlags)); \
     709        else ASMAtomicOrU64(&a_pVCpu->fLocalForcedActions, (fFlags)); \
     710    } while (0)
     711# endif
     712#else
     713# define VMCPU_FF_SET_MASK(a_pVCpu, fFlags) \
    691714    do { ASMAtomicOrU32(&a_pVCpu->fLocalForcedActions, (fFlags)); } while (0)
     715#endif
    692716
    693717/** @def VM_FF_CLEAR
     
    709733 * @param   fFlag   The flag to clear.
    710734 */
    711 #define VMCPU_FF_CLEAR(pVCpu, fFlag) do { \
     735#ifdef VMCPU_WITH_64_BIT_FFS
     736# define VMCPU_FF_CLEAR(pVCpu, fFlag) do { \
     737        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
     738        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
     739        ASMAtomicBitClear(&(pVCpu)->fLocalForcedActions, fFlag##_BIT); \
     740    } while (0)
     741#else
     742# define VMCPU_FF_CLEAR(pVCpu, fFlag) do { \
    712743        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
    713744        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
    714745        ASMAtomicAndU32(&(pVCpu)->fLocalForcedActions, ~(fFlag)); \
    715746    } while (0)
     747#endif
    716748
    717749/** @def VMCPU_FF_CLEAR_MASK
     
    721753 * @param   fFlags  The flags to clear.
    722754 */
    723 #define VMCPU_FF_CLEAR_MASK(pVCpu, fFlags) \
     755#ifdef VMCPU_WITH_64_BIT_FFS
     756# if ARCH_BITS > 32
     757# define VMCPU_FF_CLEAR_MASK(pVCpu, fFlags) \
     758    do { ASMAtomicAndU64(&(pVCpu)->fLocalForcedActions, ~(fFlags)); } while (0)
     759# else
     760# define VMCPU_FF_CLEAR_MASK(pVCpu, fFlags) do { \
     761        if (!((fFlags) >> 32)) ASMAtomicAndU32((uint32_t volatile *)&(pVCpu)->fLocalForcedActions, ~(uint32_t)(fFlags)); \
     762        else ASMAtomicAndU64(&(pVCpu)->fLocalForcedActions, ~(fFlags)); \
     763    } while (0)
     764# endif
     765#else
     766# define VMCPU_FF_CLEAR_MASK(pVCpu, fFlags) \
    724767    do { ASMAtomicAndU32(&(pVCpu)->fLocalForcedActions, ~(fFlags)); } while (0)
     768#endif
    725769
    726770/** @def VM_FF_IS_SET
     
    732776 */
    733777#if !defined(VBOX_STRICT) || !defined(RT_COMPILER_SUPPORTS_LAMBDA)
    734 # define VM_FF_IS_SET(pVM, fFlag)           (((pVM)->fGlobalForcedActions & (fFlag)) == (fFlag))
     778# define VM_FF_IS_SET(pVM, fFlag)           RT_BOOL((pVM)->fGlobalForcedActions & (fFlag))
    735779#else
    736780# define VM_FF_IS_SET(pVM, fFlag) \
     
    739783        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
    740784        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
    741         return (a_pVM->fGlobalForcedActions & (fFlag)) == (fFlag); \
     785        return RT_BOOL(a_pVM->fGlobalForcedActions & (fFlag)); \
    742786    }(pVM))
    743787#endif
     
    751795 */
    752796#if !defined(VBOX_STRICT) || !defined(RT_COMPILER_SUPPORTS_LAMBDA)
    753 # define VMCPU_FF_IS_SET(pVCpu, fFlag)      (((pVCpu)->fLocalForcedActions & (fFlag)) == (fFlag))
     797# define VMCPU_FF_IS_SET(pVCpu, fFlag)      RT_BOOL((pVCpu)->fLocalForcedActions & (fFlag))
    754798#else
    755799# define VMCPU_FF_IS_SET(pVCpu, fFlag) \
     
    758802        AssertCompile(RT_IS_POWER_OF_TWO(fFlag)); \
    759803        AssertCompile((fFlag) == RT_BIT_32(fFlag##_BIT)); \
    760         return (a_pVCpu->fLocalForcedActions & (fFlag)) == (fFlag); \
     804        return RT_BOOL(a_pVCpu->fLocalForcedActions & (fFlag)); \
    761805    }(pVCpu))
    762806#endif
  • trunk/src/VBox/VMM/VBoxVMM.d

    r71222 r74798  
    3030    /*^^VMM-ALT-TP: "%04x:%08llx rc=%d", (a_pCtx)->cs, (a_pCtx)->rip, (a_rc) */
    3131
    32     probe em__ff__high(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint32_t a_fLocal, int a_rc);
     32    probe em__ff__high(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint64_t a_fLocal, int a_rc);
    3333    /*^^VMM-ALT-TP: "vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc) */
    3434
    35     probe em__ff__all(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint32_t a_fLocal, int a_rc);
     35    probe em__ff__all(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint64_t a_fLocal, int a_rc);
    3636    /*^^VMM-ALT-TP: "vm=%#x cpu=%#x rc=%d", (a_fGlobal), (a_fLocal), (a_rc) */
    3737
     
    3939    /*^^VMM-ALT-TP: "%d", (a_rc) */
    4040
    41     probe em__ff__raw(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint32_t a_fLocal);
     41    probe em__ff__raw(struct VMCPU *a_pVCpu, uint32_t a_fGlobal, uint64_t a_fLocal);
    4242    /*^^VMM-ALT-TP: "vm=%#x cpu=%#x", (a_fGlobal), (a_fLocal) */
    4343
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r74791 r74798  
    1433714337                    if (RT_LIKELY(pVCpu->iem.s.rcPassUp == VINF_SUCCESS))
    1433814338                    {
    14339                         uint32_t fCpu = pVCpu->fLocalForcedActions
     14339                        uint64_t fCpu = pVCpu->fLocalForcedActions
    1434014340                                      & ( VMCPU_FF_ALL_MASK & ~(  VMCPU_FF_PGM_SYNC_CR3
    1434114341                                                                | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL
     
    1449914499                    if (RT_LIKELY(pVCpu->iem.s.rcPassUp == VINF_SUCCESS))
    1450014500                    {
    14501                         uint32_t fCpu = pVCpu->fLocalForcedActions
     14501                        uint64_t fCpu = pVCpu->fLocalForcedActions
    1450214502                                      & ( VMCPU_FF_ALL_MASK & ~(  VMCPU_FF_PGM_SYNC_CR3
    1450314503                                                                | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplStrInstr.cpp.h

    r74791 r74798  
    8989        else \
    9090        { \
    91             LogFlow(("%s: Leaving early (outer)! ffcpu=%#x ffvm=%#x\n", \
    92                      __FUNCTION__, (a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
     91            LogFlow(("%s: Leaving early (outer)! ffcpu=%#RX64 ffvm=%#x\n", \
     92                     __FUNCTION__, (uint64_t)(a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
    9393            return VINF_SUCCESS; \
    9494        } \
     
    104104        else  \
    105105        { \
    106             LogFlow(("%s: Leaving early (outer)! ffcpu=%#x ffvm=%#x\n", \
    107                      __FUNCTION__, (a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
     106            LogFlow(("%s: Leaving early (outer)! ffcpu=%#RX64 ffvm=%#x\n", \
     107                     __FUNCTION__, (uint64_t)(a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
    108108            return VINF_SUCCESS; \
    109109        } \
     
    124124        else \
    125125        { \
    126             LogFlow(("%s: Leaving early (inner)! ffcpu=%#x ffvm=%#x\n", \
    127                      __FUNCTION__, (a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
     126            LogFlow(("%s: Leaving early (inner)! ffcpu=%#RX64 ffvm=%#x\n", \
     127                     __FUNCTION__, (uint64_t)(a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
    128128            return VINF_SUCCESS; \
    129129        } \
     
    144144        else \
    145145        { \
    146             LogFlow(("%s: Leaving early (inner)! ffcpu=%#x (ffvm=%#x)\n", \
    147                      __FUNCTION__, (a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
     146            LogFlow(("%s: Leaving early (inner)! ffcpu=%#RX64 (ffvm=%#x)\n", \
     147                     __FUNCTION__, (uint64_t)(a_pVCpu)->fLocalForcedActions, (a_pVM)->fGlobalForcedActions)); \
    148148            return VINF_SUCCESS; \
    149149        } \
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r74791 r74798  
    43094309                /** @todo Try handle pending flags, not just return to EM loops.  Take care
    43104310                 *        not to set important RCs here unless we've handled a message. */
    4311                 LogFlow(("NEM/%u: breaking: pending FF (%#x / %#x)\n",
    4312                          pVCpu->idCpu, pVM->fGlobalForcedActions, pVCpu->fLocalForcedActions));
     4311                LogFlow(("NEM/%u: breaking: pending FF (%#x / %#RX64)\n",
     4312                         pVCpu->idCpu, pVM->fGlobalForcedActions, (uint64_t)pVCpu->fLocalForcedActions));
    43134313                STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatBreakOnFFPost);
    43144314            }
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r74791 r74798  
    32363236    /* Please, no longjumps here (any logging shouldn't flush jump back to ring-3). NO LOGGING BEFORE THIS POINT! */
    32373237    VMMRZCallRing3Disable(pVCpu);
    3238     Log4Func(("rcExit=%d LocalFF=%#RX32 GlobalFF=%#RX32\n", rcExit, pVCpu->fLocalForcedActions,
     3238    Log4Func(("rcExit=%d LocalFF=%#RX64 GlobalFF=%#RX32\n", rcExit, (uint64_t)pVCpu->fLocalForcedActions,
    32393239              pVCpu->CTX_SUFF(pVM)->fGlobalForcedActions));
    32403240
  • trunk/src/VBox/VMM/VMMR3/EMR3Nem.cpp

    r74795 r74798  
    309309    if (VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL))
    310310    {
    311         Log(("NEM: TODO: Make VMCPU_FF_PGM_SYNC_CR3 / VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL quiet! (%#x)\n", pVCpu->fLocalForcedActions));
     311        Log(("NEM: TODO: Make VMCPU_FF_PGM_SYNC_CR3 / VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL quiet! (%#RX64)\n", (uint64_t)pVCpu->fLocalForcedActions));
    312312        VMCPU_FF_CLEAR_MASK(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL);
    313313    }
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r74791 r74798  
    11121112        ||  VMCPU_FF_IS_ANY_SET(pVCpu, fMask))
    11131113    {
    1114         LogFlow(("VMR3WaitHalted: returns VINF_SUCCESS (FF %#x FFCPU %#x)\n", pVM->fGlobalForcedActions, pVCpu->fLocalForcedActions));
     1114        LogFlow(("VMR3WaitHalted: returns VINF_SUCCESS (FF %#x FFCPU %#RX64)\n", pVM->fGlobalForcedActions, (uint64_t)pVCpu->fLocalForcedActions));
    11151115        return VINF_SUCCESS;
    11161116    }
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r74790 r74798  
    31033103    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    31043104    {
    3105         const uint32_t fLocalForcedActions = pVM->aCpus[i].fLocalForcedActions;
    3106         pHlp->pfnPrintf(pHlp, "CPU %u FFs: %#RX32", i, fLocalForcedActions);
     3105        const uint64_t fLocalForcedActions = pVM->aCpus[i].fLocalForcedActions;
     3106        pHlp->pfnPrintf(pHlp, "CPU %u FFs: %#RX64", i, fLocalForcedActions);
    31073107
    31083108        /* show the flag mnemonics */
     
    31393139#endif
    31403140        if (f)
    3141             pHlp->pfnPrintf(pHlp, "%s\n    Unknown bits: %#RX32\n", c ? "," : "", f);
     3141            pHlp->pfnPrintf(pHlp, "%s\n    Unknown bits: %#RX64\n", c ? "," : "", f);
    31423142        else
    31433143            pHlp->pfnPrintf(pHlp, "\n");
  • trunk/src/VBox/VMM/include/CPUMInternal.mac

    r74479 r74798  
    254254    .Guest.hwvirt.svm.HCPhysVmcb             RTHCPHYS_RES 1
    255255    .Guest.hwvirt.enmHwvirt                  resd         1
     256    .Guest.hwvirt.fGif                       resb         1
     257    alignb 8
    256258    .Guest.hwvirt.fLocalForcedActions        resd         1
    257     .Guest.hwvirt.fGif                       resb         1
    258259    alignb 64
    259260
     
    542543    .Hyper.hwvirt.svm.HCPhysVmcb             RTHCPHYS_RES 1
    543544    .Hyper.hwvirt.enmHwvirt                  resd         1
     545    .Hyper.hwvirt.fGif                       resb         1
     546    alignb 8
    544547    .Hyper.hwvirt.fLocalForcedActions        resd         1
    545     .Hyper.hwvirt.fGif                       resb         1
    546548    alignb 64
    547549
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r74542 r74798  
    169169    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvMsrBitmapR3);
    170170    GEN_CHECK_OFF(CPUMCTX, hwvirt.enmHwvirt);
     171    GEN_CHECK_OFF(CPUMCTX, hwvirt.fGif);
    171172    GEN_CHECK_OFF(CPUMCTX, hwvirt.fLocalForcedActions);
    172     GEN_CHECK_OFF(CPUMCTX, hwvirt.fGif);
    173173    /** @todo NSTVMX: add rest of hwvirt fields when code is more
    174174     *        finalized. */
  • trunk/src/recompiler/VBoxRecompiler.c

    r74791 r74798  
    11661166                    && !VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_ALL_REM_MASK))
    11671167                    continue;
    1168                 RTLogPrintf("remR3RunLoggingStep: rc=VINF_SUCCESS w/ FFs (%#x/%#x)\n",
    1169                             pVM->fGlobalForcedActions, pVCpu->fLocalForcedActions);
     1168                RTLogPrintf("remR3RunLoggingStep: rc=VINF_SUCCESS w/ FFs (%#x/%#RX64)\n",
     1169                            pVM->fGlobalForcedActions, (uint64_t)pVCpu->fLocalForcedActions);
    11701170                rc = VINF_SUCCESS;
    11711171                break;
     
    12001200                        continue;
    12011201
    1202                     RTLogPrintf("remR3RunLoggingStep: rc=VINF_SUCCESS w/ FFs (%#x/%#x)\n",
    1203                                 pVM->fGlobalForcedActions, pVCpu->fLocalForcedActions);
     1202                    RTLogPrintf("remR3RunLoggingStep: rc=VINF_SUCCESS w/ FFs (%#x/%#RX64)\n",
     1203                                pVM->fGlobalForcedActions, (uint64_t)pVCpu->fLocalForcedActions);
    12041204                    rc = VINF_SUCCESS;
    12051205                }
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