]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/exc_guard.h
xnu-6153.11.26.tar.gz
[apple/xnu.git] / osfmk / kern / exc_guard.h
index 8486ec569a5c92e9f0ea53e9fb1100d94b32923f..1084cdf0d21bc077114989201c6aad5c19d9e759 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- * 
+ *
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
  * unlawful or unlicensed copies of an Apple operating system, or to
  * circumvent, violate, or enable the circumvention or violation of, any
  * terms of an Apple operating system software license agreement.
- * 
+ *
  * Please obtain a copy of the License at
  * http://www.opensource.apple.com/apsl/ and read it before using this file.
- * 
+ *
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  * Please see the License for the specific language governing rights and
  * limitations under the License.
- * 
+ *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
-/* 
+/*
  * Mach Operating System
  * Copyright (c) 1989 Carnegie-Mellon University
  * Copyright (c) 1988 Carnegie-Mellon University
  */
 
 #define EXC_GUARD_DECODE_GUARD_TYPE(code) \
-       (((code) >> 61) & 0x7ull)
+       ((((uint64_t)(code)) >> 61) & 0x7ull)
 #define EXC_GUARD_DECODE_GUARD_FLAVOR(code) \
-       (((code) >> 32) & 0x1fffffff)
+       ((((uint64_t)(code)) >> 32) & 0x1fffffff)
 #define EXC_GUARD_DECODE_GUARD_TARGET(code) \
        ((uint32_t)(code))
 
 /* EXC_GUARD types */
 
+#define GUARD_TYPE_NONE         0x0
+
 /*
  * Mach port guards use the exception codes like this:
  *
@@ -94,7 +96,7 @@
  * +----------------------------------------------------------------+
  */
 
-#define        GUARD_TYPE_FD           0x2     /* guarded file descriptor */
+#define GUARD_TYPE_FD           0x2     /* guarded file descriptor */
 
 /*
  * User generated guards use the exception codes this:
  * +----------------------------------------------------------------+
  */
 
-#define        GUARD_TYPE_USER         0x3     /* Userland assertions */
+#define GUARD_TYPE_USER         0x3     /* Userland assertions */
 
 /*
  * Vnode guards use the exception codes like this:
  * +----------------------------------------------------------------+
  */
 
-#define GUARD_TYPE_VN          0x4     /* guarded vnode */
+#define GUARD_TYPE_VN           0x4     /* guarded vnode */
+
+/*
+ * VM guards use the exception codes like this:
+ *
+ * code:
+ * +-------------------------------+----------------+-----------------+
+ * |[63:61] GUARD_TYPE_VIRT_MEMORY | [60:32] flavor | [31:0] unused   |
+ * +-------------------------------+----------------+-----------------+
+ *
+ * subcode:
+ * +----------------------------------------------------------------+
+ * |[63:0] offset                                                   |
+ * +----------------------------------------------------------------+
+ */
+
+#define GUARD_TYPE_VIRT_MEMORY  0x5     /* VM operation violating guard */
 
 #ifdef KERNEL
 
 #define EXC_GUARD_ENCODE_FLAVOR(code, flavor) \
        ((code) |= (((uint64_t)(flavor) & 0x1fffffffull) << 32))
 #define EXC_GUARD_ENCODE_TARGET(code, target) \
-        ((code) |= (((uint64_t)(target) & 0xffffffffull)))
+       ((code) |= (((uint64_t)(target) & 0xffffffffull)))
 
 #endif /* KERNEL */