VirtualBox

Changeset 107894 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jan 22, 2025 3:56:33 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167115
Message:

VMM: Check the target platform arch in VM_ASSERT_VALID_EXT_RETURN, VMCPU_ASSERT_VALID_EXT_RETURN and friends. jiraref:VBP-1470

File:
1 edited

Legend:

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

    r107893 r107894  
    11651165
    11661166/** @def VM_IS_VALID_EXT
    1167  * Asserts a the VM handle is valid for external access, i.e. not being destroy
    1168  * or terminated. */
    1169 #define VM_IS_VALID_EXT(pVM) \
    1170         (    RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
    1171          &&  (   (unsigned)(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING \
    1172               || (   (unsigned)(pVM)->enmVMState == (unsigned)VMSTATE_DESTROYING \
    1173                   && VM_IS_EMT(pVM))) )
     1167 * Check that a VM handle is valid for external access, i.e. not being destroy
     1168 * or terminated and matching the target platform architecture (ring-3). */
     1169#ifdef VMTARGET_DEFAULT
     1170# define VM_IS_VALID_EXT(pVM) \
     1171        (   RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
     1172         && (   (unsigned)(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING \
     1173             || (   (unsigned)(pVM)->enmVMState == (unsigned)VMSTATE_DESTROYING \
     1174                 && VM_IS_EMT(pVM))) \
     1175         && (pVM)->enmTarget != VMTARGET_DEFAULT)
     1176#else
     1177# define VM_IS_VALID_EXT(pVM) \
     1178        (   RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
     1179         && (   (unsigned)(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING \
     1180             || (   (unsigned)(pVM)->enmVMState == (unsigned)VMSTATE_DESTROYING \
     1181                 && VM_IS_EMT(pVM))) )
     1182#endif
    11741183
    11751184/** @def VM_ASSERT_VALID_EXT_RETURN
    1176  * Asserts a the VM handle is valid for external access, i.e. not being
    1177  * destroy or terminated.
     1185 * Asserts that a VM handle is valid for external access, i.e. not being destroy
     1186 * or terminated.
    11781187 */
    11791188#define VM_ASSERT_VALID_EXT_RETURN(pVM, rc) \
    11801189        AssertMsgReturn(VM_IS_VALID_EXT(pVM), \
    1181                         ("pVM=%p state %s\n", (pVM), RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
    1182                          ? VMGetStateName(pVM->enmVMState) : ""), \
     1190                        ("pVM=%p state %s enmTarget=%#x\n", (pVM), RT_VALID_ALIGNED_PTR(pVM, PAGE_SIZE) \
     1191                         ? VMGetStateName(pVM->enmVMState) : "", (pVM)->enmTarget), \
    11831192                        (rc))
    11841193
     1194/** @def VMCPU_IS_VALID_EXT
     1195 * Checks that a VMCPU handle is valid for external access, i.e. not being
     1196 * destroy or terminated and matching the target platform architecture (r3). */
     1197#ifdef VMTARGET_DEFAULT
     1198# define VMCPU_IS_VALID_EXT(a_pVCpu) \
     1199        (   RT_VALID_ALIGNED_PTR(a_pVCpu, 64) \
     1200         && RT_VALID_ALIGNED_PTR((a_pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
     1201         && (unsigned)(a_pVCpu)->CTX_SUFF(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING \
     1202         && (pVM)->enmTarget != VMTARGET_DEFAULT)
     1203#else
     1204# define VMCPU_IS_VALID_EXT(a_pVCpu) \
     1205        (   RT_VALID_ALIGNED_PTR(a_pVCpu, 64) \
     1206         && RT_VALID_ALIGNED_PTR((a_pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
     1207         && (unsigned)(a_pVCpu)->CTX_SUFF(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING)
     1208#endif
     1209
    11851210/** @def VMCPU_ASSERT_VALID_EXT_RETURN
    1186  * Asserts a the VMCPU handle is valid for external access, i.e. not being
    1187  * destroy or terminated.
     1211 * Asserts that a VMCPU handle is valid for external access, i.e. not being
     1212 * destroy or terminated and matching the target platform architecutre (r3).
    11881213 */
    11891214#define VMCPU_ASSERT_VALID_EXT_RETURN(pVCpu, rc) \
    1190         AssertMsgReturn(    RT_VALID_ALIGNED_PTR(pVCpu, 64) \
    1191                         &&  RT_VALID_ALIGNED_PTR((pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
    1192                         &&  (unsigned)(pVCpu)->CTX_SUFF(pVM)->enmVMState < (unsigned)VMSTATE_DESTROYING, \
    1193                         ("pVCpu=%p pVM=%p state %s\n", (pVCpu), RT_VALID_ALIGNED_PTR(pVCpu, 64) ? (pVCpu)->CTX_SUFF(pVM) : NULL, \
     1215        AssertMsgReturn(VMCPU_IS_VALID_EXT(pVCpu), \
     1216                        ("pVCpu=%p pVM=%p state %s enmTarget=%#x\n", (pVCpu), \
     1217                        RT_VALID_ALIGNED_PTR(pVCpu, 64) ? (pVCpu)->CTX_SUFF(pVM) : NULL, \
    11941218                         RT_VALID_ALIGNED_PTR(pVCpu, 64) && RT_VALID_ALIGNED_PTR((pVCpu)->CTX_SUFF(pVM), PAGE_SIZE) \
    1195                          ? VMGetStateName((pVCpu)->pVMR3->enmVMState) : ""), \
     1219                         ? VMGetStateName((pVCpu)->pVMR3->enmVMState) : "", (pVCpu)->enmTarget), \
    11961220                        (rc))
    11971221
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette