Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Nov 2023 18:12:19 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ba31362694fe - main - arm64: Make kern_delta unneeded in the boot params
Message-ID:  <202311151812.3AFICJ3T077468@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew:

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

commit ba31362694fe465b88a025ac7c35ad7f378efc86
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-11-13 15:29:30 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-11-15 18:05:08 +0000

    arm64: Make kern_delta unneeded in the boot params
    
    Use pmap_early_vtophys to translate from a virtual to physical where
    we were previously using the calculated delta. This means that, while
    we still calculate it, we don't need to pass it to initarm or either
    pmap bootstrap functions.
    
    While here remove an unneeded printf that indirectly used it or was
    related to the previous printf.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D42567
---
 sys/arm64/arm64/genassym.c  |  1 -
 sys/arm64/arm64/locore.S    | 13 ++++---------
 sys/arm64/arm64/machdep.c   |  2 +-
 sys/arm64/arm64/pmap.c      | 14 ++++----------
 sys/arm64/include/machdep.h |  1 -
 sys/arm64/include/pmap.h    |  2 +-
 6 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c
index 0fb00d8aceba..d4970177ab71 100644
--- a/sys/arm64/arm64/genassym.c
+++ b/sys/arm64/arm64/genassym.c
@@ -40,7 +40,6 @@
 ASSYM(BOOTPARAMS_SIZE, roundup2(sizeof(struct arm64_bootparams),
     STACKALIGNBYTES + 1));
 ASSYM(BP_MODULEP, offsetof(struct arm64_bootparams, modulep));
-ASSYM(BP_KERN_DELTA, offsetof(struct arm64_bootparams, kern_delta));
 ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack));
 ASSYM(BP_KERN_TTBR0, offsetof(struct arm64_bootparams, kern_ttbr0));
 ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el));
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 2d4501d4bfea..cea2f690b60f 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -77,11 +77,10 @@ ENTRY(_start)
 	msr	contextidr_el1, xzr
 
 	/* Get the virt -> phys offset */
-	bl	get_virt_delta
+	bl	get_load_phys_addr
 
 	/*
 	 * At this point:
-	 * x29 = PA - VA
 	 * x28 = Our physical load address
 	 */
 
@@ -136,10 +135,8 @@ virtdone:
 	mov	x0, sp
 
 	/* Negate the delta so it is VA -> PA */
-	neg	x29, x29
 
 	str	x1,  [x0, #BP_MODULEP]
-	str	x29, [x0, #BP_KERN_DELTA]
 	adrp	x25, initstack
 	add	x25, x25, :lo12:initstack
 	str	x25, [x0, #BP_KERN_STACK]
@@ -359,11 +356,9 @@ LENTRY(drop_to_el1)
 LEND(drop_to_el1)
 
 /*
- * Get the delta between the physical address we were loaded to and the
- * virtual address we expect to run from. This is used when building the
- * initial page table.
+ * Get the physical address the kernel was loaded at.
  */
-LENTRY(get_virt_delta)
+LENTRY(get_load_phys_addr)
 	/* Load the physical address of virt_map */
 	adrp	x29, virt_map
 	add	x29, x29, :lo12:virt_map
@@ -379,7 +374,7 @@ LENTRY(get_virt_delta)
 	.align 3
 virt_map:
 	.quad	virt_map
-LEND(get_virt_delta)
+LEND(get_load_phys_addr)
 
 /*
  * This builds the page tables containing the identity map, and the kernel
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 7aa20357acf4..01896c15e650 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -957,7 +957,7 @@ initarm(struct arm64_bootparams *abp)
 	pan_setup();
 
 	/* Bootstrap enough of pmap  to enter the kernel proper */
-	pmap_bootstrap(KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
+	pmap_bootstrap(lastaddr - KERNBASE);
 	/* Exclude entries needed in the DMAP region, but not phys_avail */
 	if (efihdr != NULL)
 		exclude_efi_map_entries(efihdr);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 3dc74626f01b..adb5e3312e50 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -1258,22 +1258,16 @@ pmap_bootstrap_allocate_kasan_l2(vm_paddr_t start_pa, vm_paddr_t end_pa,
  *	Bootstrap the system enough to run with virtual memory.
  */
 void
-pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen)
+pmap_bootstrap(vm_size_t kernlen)
 {
 	vm_offset_t dpcpu, msgbufpv;
 	vm_paddr_t start_pa, pa, min_pa;
-	uint64_t kern_delta;
 	int i;
 
 	/* Verify that the ASID is set through TTBR0. */
 	KASSERT((READ_SPECIALREG(tcr_el1) & TCR_A1) == 0,
 	    ("pmap_bootstrap: TCR_EL1.A1 != 0"));
 
-	kern_delta = KERNBASE - kernstart;
-
-	printf("pmap_bootstrap %lx %lx\n", kernstart, kernlen);
-	printf("%lx\n", (KERNBASE >> L1_SHIFT) & Ln_ADDR_MASK);
-
 	/* Set this early so we can use the pagetable walking functions */
 	kernel_pmap_store.pm_l0 = pagetable_l0_ttbr1;
 	PMAP_LOCK_INIT(kernel_pmap);
@@ -1288,7 +1282,7 @@ pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen)
 	kernel_pmap->pm_asid_set = &asids;
 
 	/* Assume the address we were loaded to is a valid physical address */
-	min_pa = KERNBASE - kern_delta;
+	min_pa = pmap_early_vtophys(KERNBASE);
 
 	physmap_idx = physmem_avail(physmap, nitems(physmap));
 	physmap_idx /= 2;
@@ -1316,7 +1310,7 @@ pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen)
 	 */
 	bs_state.table_attrs &= ~TATTR_PXN_TABLE;
 
-	start_pa = pa = KERNBASE - kern_delta;
+	start_pa = pa = pmap_early_vtophys(KERNBASE);
 
 	/*
 	 * Create the l2 tables up to VM_MAX_KERNEL_ADDRESS.  We assume that the
@@ -7848,7 +7842,7 @@ void __nosanitizeaddress
 pmap_san_bootstrap(struct arm64_bootparams *abp)
 {
 
-	pmap_san_early_kernstart = KERNBASE - abp->kern_delta;
+	pmap_san_early_kernstart = pmap_early_vtophys(KERNBASE);
 	kasan_init_early(abp->kern_stack, KSTACK_PAGES * PAGE_SIZE);
 }
 
diff --git a/sys/arm64/include/machdep.h b/sys/arm64/include/machdep.h
index 026a64e0a350..80cb28bcfbeb 100644
--- a/sys/arm64/include/machdep.h
+++ b/sys/arm64/include/machdep.h
@@ -31,7 +31,6 @@
 
 struct arm64_bootparams {
 	vm_offset_t	modulep;
-	uint64_t	kern_delta;
 	vm_offset_t	kern_stack;
 	vm_paddr_t	kern_ttbr0;
 	uint64_t	hcr_el2;
diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h
index ad9aa409815a..efbf7eaaae91 100644
--- a/sys/arm64/include/pmap.h
+++ b/sys/arm64/include/pmap.h
@@ -144,7 +144,7 @@ extern vm_offset_t virtual_end;
 #define	pmap_vm_page_alloc_check(m)
 
 void	pmap_activate_vm(pmap_t);
-void	pmap_bootstrap(vm_paddr_t, vm_size_t);
+void	pmap_bootstrap(vm_size_t);
 int	pmap_change_attr(vm_offset_t va, vm_size_t size, int mode);
 int	pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot);
 void	pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311151812.3AFICJ3T077468>