]> git.saurik.com Git - apple/xnu.git/blobdiff - san/kasan-arm64.c
xnu-4570.20.62.tar.gz
[apple/xnu.git] / san / kasan-arm64.c
index 49137763c8f17a5a1c4c00ce656733b0a37f9a22..3fbb9827b64e1ff7a59294671c7716082958a46c 100644 (file)
@@ -104,10 +104,19 @@ alloc_zero_page(void)
        return mem;
 }
 
+static void
+align_to_page(vm_offset_t *addrp, vm_offset_t *sizep)
+{
+       vm_offset_t addr_aligned = vm_map_trunc_page(*addrp, ARM_PGMASK);
+       *sizep = vm_map_round_page(*sizep + (*addrp - addr_aligned), ARM_PGMASK);
+       *addrp = addr_aligned;
+}
+
 static void
 kasan_map_shadow_internal(vm_offset_t address, vm_size_t size, bool is_zero, bool back_page)
 {
-       size = vm_map_round_page(size, ARM_PGMASK);
+       align_to_page(&address, &size);
+
        vm_size_t j;
        uint64_t *pte;
 
@@ -189,7 +198,8 @@ kasan_map_shadow(vm_offset_t address, vm_size_t size, bool is_zero)
 static void
 kasan_map_shadow_early(vm_offset_t address, vm_size_t size, bool is_zero)
 {
-       size = vm_map_round_page(size, ARM_PGMASK);
+       align_to_page(&address, &size);
+
        vm_size_t j;
        uint64_t *pte;