VirtualBox

Changeset 74798 in vbox for trunk/include/VBox/vmm


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/include/VBox/vmm
Files:
3 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
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