git: 5fae53589eac - main - arm64: Use pmap_early_vtophys in pmap_bootstrap_san

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Wed, 15 Nov 2023 18:12:18 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=5fae53589eacbf65855419922c881b3a25a68e03

commit 5fae53589eacbf65855419922c881b3a25a68e03
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-11-13 16:34:56 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-11-15 18:05:08 +0000

    arm64: Use pmap_early_vtophys in pmap_bootstrap_san
    
    Use pmap_early_vtophys to find the physical address of the kernel base
    rather than using the calculated offset as it will be removed in a
    latter commit.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D42566
---
 sys/arm64/arm64/machdep.c | 2 +-
 sys/arm64/arm64/pmap.c    | 5 ++++-
 sys/arm64/include/pmap.h  | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index bb7689c19101..7aa20357acf4 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -973,7 +973,7 @@ initarm(struct arm64_bootparams *abp)
 	 * segments also get excluded from phys_avail.
 	 */
 #if defined(KASAN)
-	pmap_bootstrap_san(KERNBASE - abp->kern_delta);
+	pmap_bootstrap_san();
 #endif
 
 	physmem_init_kernel_globals();
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 8c2c6f9d7b81..3dc74626f01b 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -1365,11 +1365,14 @@ pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen)
  * - Map that entire range using L2 superpages.
  */
 void
-pmap_bootstrap_san(vm_paddr_t kernstart)
+pmap_bootstrap_san(void)
 {
 	vm_offset_t va;
+	vm_paddr_t kernstart;
 	int i, shadow_npages, nkasan_l2;
 
+	kernstart = pmap_early_vtophys(KERNBASE);
+
 	/*
 	 * Rebuild physmap one more time, we may have excluded more regions from
 	 * allocation since pmap_bootstrap().
diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h
index 1789588210c3..ad9aa409815a 100644
--- a/sys/arm64/include/pmap.h
+++ b/sys/arm64/include/pmap.h
@@ -192,7 +192,7 @@ pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused)
 #if defined(KASAN) || defined(KMSAN)
 struct arm64_bootparams;
 
-void	pmap_bootstrap_san(vm_paddr_t);
+void	pmap_bootstrap_san(void);
 void	pmap_san_enter(vm_offset_t);
 void	pmap_san_bootstrap(struct arm64_bootparams *);
 #endif