+static inline int
+VMP_CS_FOR_OFFSET(
+ vm_map_offset_t fault_phys_offset)
+{
+ assertf(fault_phys_offset < PAGE_SIZE &&
+ !(fault_phys_offset & FOURK_PAGE_MASK),
+ "offset 0x%llx\n", (uint64_t)fault_phys_offset);
+ return 1 << (fault_phys_offset >> FOURK_PAGE_SHIFT);
+}
+static inline bool
+VMP_CS_VALIDATED(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (fault_page_size == PAGE_SIZE) {
+ return p->vmp_cs_validated == VMP_CS_ALL_TRUE;
+ }
+ return p->vmp_cs_validated & VMP_CS_FOR_OFFSET(fault_phys_offset);
+}
+static inline bool
+VMP_CS_TAINTED(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (fault_page_size == PAGE_SIZE) {
+ return p->vmp_cs_tainted != VMP_CS_ALL_FALSE;
+ }
+ return p->vmp_cs_tainted & VMP_CS_FOR_OFFSET(fault_phys_offset);
+}
+static inline bool
+VMP_CS_NX(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (fault_page_size == PAGE_SIZE) {
+ return p->vmp_cs_nx != VMP_CS_ALL_FALSE;
+ }
+ return p->vmp_cs_nx & VMP_CS_FOR_OFFSET(fault_phys_offset);
+}
+static inline void
+VMP_CS_SET_VALIDATED(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset,
+ boolean_t value)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (value) {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_validated = VMP_CS_ALL_TRUE;
+ }
+ p->vmp_cs_validated |= VMP_CS_FOR_OFFSET(fault_phys_offset);
+ } else {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_validated = VMP_CS_ALL_FALSE;
+ }
+ p->vmp_cs_validated &= ~VMP_CS_FOR_OFFSET(fault_phys_offset);
+ }
+}
+static inline void
+VMP_CS_SET_TAINTED(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset,
+ boolean_t value)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (value) {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_tainted = VMP_CS_ALL_TRUE;
+ }
+ p->vmp_cs_tainted |= VMP_CS_FOR_OFFSET(fault_phys_offset);
+ } else {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_tainted = VMP_CS_ALL_FALSE;
+ }
+ p->vmp_cs_tainted &= ~VMP_CS_FOR_OFFSET(fault_phys_offset);
+ }
+}
+static inline void
+VMP_CS_SET_NX(
+ vm_page_t p,
+ vm_map_size_t fault_page_size,
+ vm_map_offset_t fault_phys_offset,
+ boolean_t value)
+{
+ assertf(fault_page_size <= PAGE_SIZE,
+ "fault_page_size 0x%llx fault_phys_offset 0x%llx\n",
+ (uint64_t)fault_page_size, (uint64_t)fault_phys_offset);
+ if (value) {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_nx = VMP_CS_ALL_TRUE;
+ }
+ p->vmp_cs_nx |= VMP_CS_FOR_OFFSET(fault_phys_offset);
+ } else {
+ if (fault_page_size == PAGE_SIZE) {
+ p->vmp_cs_nx = VMP_CS_ALL_FALSE;
+ }
+ p->vmp_cs_nx &= ~VMP_CS_FOR_OFFSET(fault_phys_offset);
+ }
+}
+