VirtualBox

Changeset 49725 in vbox


Ignore:
Timestamp:
Nov 29, 2013 2:03:10 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HM: Use unordered ASM atomics for safely updating HM flags.

Location:
trunk
Files:
2 edited

Legend:

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

    r48591 r49725  
    3838
    3939RT_C_DECLS_BEGIN
    40 
    41 /** @def VMCPU_HMCF_CLEAR
    42  * Clears a HM-context flag for the given VCPU.
    43  *
    44  * @param   pVCpu   Pointer to the VMCPU.
    45  * @param   fFlag   The flag to clear.
    46  */
    47 #define VMCPU_HMCF_CLEAR(pVCpu, fFlag)              ((pVCpu)->hm.s.fContextUseFlags &= ~(fFlag))
    48 
    49 /** @def VMCPU_FF_SET
    50  * Sets a HM-context flag for the given VCPU.
    51  *
    52  * @param   pVCpu   Pointer to the VMCPU.
    53  * @param   fFlag   The flag to set.
    54  */
    55 #define VMCPU_HMCF_SET(pVCpu, fFlag)                ((pVCpu)->hm.s.fContextUseFlags |= (fFlag))
    56 
    57 /** @def VMCPU_HMCF_IS_SET
    58  * Checks if all the flags in the specified HM-context set is pending.
    59  *
    60  * @param   pVCpu   Pointer to the VMCPU.
    61  * @param   fFlag   The flag to check.
    62  */
    63 #define VMCPU_HMCF_IS_SET(pVCpu, fFlag)             (((pVCpu)->hm.s.fContextUseFlags & (fFlag)) == (fFlag))
    64 
    65 /** @def VMCPU_HMCF_IS_PENDING
    66  * Checks if one or more of the flags in the specified HM-context set is
    67  * pending.
    68  *
    69  * @param   pVCpu   Pointer to the VMCPU.
    70  * @param   fFlags  The flags to check for.
    71  */
    72 #define VMCPU_HMCF_IS_PENDING(pVCpu, fFlags)        RT_BOOL((pVCpu)->hm.s.fContextUseFlags & (fFlags))
    73 
    74 /** @def VMCPU_HMCF_IS_PENDING_ONLY
    75  * Checks if -only- one or more of the specified HM-context flags is pending.
    76  *
    77  * @param   pVCpu   Pointer to the VMCPU.
    78  * @param   fFlags  The flags to check for.
    79  */
    80 #define VMCPU_HMCF_IS_PENDING_ONLY(pVCpu, fFlags)   !RT_BOOL((pVCpu)->hm.s.fContextUseFlags & ~(fFlags))
    81 
    82 /** @def VMCPU_HMCF_IS_SET_ONLY
    83  * Checks if -only- all the flags in the specified HM-context set is pending.
    84  *
    85  * @param   pVCpu   Pointer to the VMCPU.
    86  * @param   fFlags  The flags to check for.
    87  */
    88 #define VMCPU_HMCF_IS_SET_ONLY(pVCpu, fFlags)       ((pVCpu)->hm.s.fContextUseFlags == (fFlags))
    89 
    90 /** @def VMCPU_HMCF_RESET_TO
    91  * Resets the HM-context flags to the specified value.
    92  *
    93  * @param   pVCpu   Pointer to the VMCPU.
    94  * @param   fFlags  The new value.
    95  */
    96 #define VMCPU_HMCF_RESET_TO(pVCpu, fFlags)          ((pVCpu)->hm.s.fContextUseFlags = (fFlags))
    97 
    98 /** @def VMCPU_HMCF_VALUE
    99  * Returns the current HM-context flags value.
    100  *
    101  * @param   pVCpu   Pointer to the VMCPU.
    102  */
    103 #define VMCPU_HMCF_VALUE(pVCpu)                     ((pVCpu)->hm.s.fContextUseFlags)
    104 
    10540
    10641/**
  • trunk/src/VBox/VMM/include/HMInternal.h

    r49664 r49725  
    5656 * @{
    5757 */
     58
     59/** @def VMCPU_HMCF_CLEAR
     60 * Clears a HM-context flag for the given VCPU.
     61 *
     62 * @param   pVCpu   Pointer to the VMCPU.
     63 * @param   fFlag   The flag to clear.
     64 */
     65#define VMCPU_HMCF_CLEAR(pVCpu, fFlag)              (ASMAtomicUoAndU32(&(pVCpu)->hm.s.fContextUseFlags, ~(fFlag)))
     66
     67/** @def VMCPU_FF_SET
     68 * Sets a HM-context flag for the given VCPU.
     69 *
     70 * @param   pVCpu   Pointer to the VMCPU.
     71 * @param   fFlag   The flag to set.
     72 */
     73#define VMCPU_HMCF_SET(pVCpu, fFlag)                (ASMAtomicUoOrU32(&(pVCpu)->hm.s.fContextUseFlags, (fFlag)))
     74
     75/** @def VMCPU_HMCF_IS_SET
     76 * Checks if all the flags in the specified HM-context set is pending.
     77 *
     78 * @param   pVCpu   Pointer to the VMCPU.
     79 * @param   fFlag   The flag to check.
     80 */
     81#define VMCPU_HMCF_IS_SET(pVCpu, fFlag)             ((ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags) & (fFlag)) == (fFlag))
     82
     83/** @def VMCPU_HMCF_IS_PENDING
     84 * Checks if one or more of the flags in the specified HM-context set is
     85 * pending.
     86 *
     87 * @param   pVCpu   Pointer to the VMCPU.
     88 * @param   fFlags  The flags to check for.
     89 */
     90#define VMCPU_HMCF_IS_PENDING(pVCpu, fFlags)        RT_BOOL(ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags) & (fFlags))
     91
     92/** @def VMCPU_HMCF_IS_PENDING_ONLY
     93 * Checks if -only- one or more of the specified HM-context flags is pending.
     94 *
     95 * @param   pVCpu   Pointer to the VMCPU.
     96 * @param   fFlags  The flags to check for.
     97 */
     98#define VMCPU_HMCF_IS_PENDING_ONLY(pVCpu, fFlags)   !RT_BOOL(ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags) & ~(fFlags))
     99
     100/** @def VMCPU_HMCF_IS_SET_ONLY
     101 * Checks if -only- all the flags in the specified HM-context set is pending.
     102 *
     103 * @param   pVCpu   Pointer to the VMCPU.
     104 * @param   fFlags  The flags to check for.
     105 */
     106#define VMCPU_HMCF_IS_SET_ONLY(pVCpu, fFlags)       (ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags) == (fFlags))
     107
     108/** @def VMCPU_HMCF_RESET_TO
     109 * Resets the HM-context flags to the specified value.
     110 *
     111 * @param   pVCpu   Pointer to the VMCPU.
     112 * @param   fFlags  The new value.
     113 */
     114#define VMCPU_HMCF_RESET_TO(pVCpu, fFlags)          (ASMAtomicUoWriteU32(&(pVCpu)->hm.s.fContextUseFlags, (fFlags)))
     115
     116/** @def VMCPU_HMCF_VALUE
     117 * Returns the current HM-context flags value.
     118 *
     119 * @param   pVCpu   Pointer to the VMCPU.
     120 */
     121#define VMCPU_HMCF_VALUE(pVCpu)                     (ASMAtomicUoReadU32(&(pVCpu)->hm.s.fContextUseFlags))
    58122
    59123
     
    513577    volatile uint32_t           cWorldSwitchExits;
    514578    /** HM_CHANGED_* flags. */
    515     uint32_t                    fContextUseFlags;
     579    volatile uint32_t           fContextUseFlags;
    516580    /** Id of the last cpu we were executing code on (NIL_RTCPUID for the first
    517581     *  time). */
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