Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2024 16:45:30 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 54cf1499a33a - stable/14 - arm64: Clean up finding our load address
Message-ID:  <202402191645.41JGjUkn096579@gitrepo.freebsd.org>

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

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

commit 54cf1499a33af463c656a2fb6555cfb5a1f2afa0
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-11-13 15:39:06 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-02-19 13:17:18 +0000

    arm64: Clean up finding our load address
    
    Use the linker to pre-calculate the offset of a known symbol from
    KERNBASE, and use this to find the physical address KERNBASE should
    map to.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D42568
    
    (cherry picked from commit 61f14f1da37b4e6db8f9efe40c6b544c855fb9bd)
    (cherry picked from commit 257b04454818c80d9b85a840e3ea8db1ea891265)
---
 sys/arm64/arm64/locore.S | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index ee3404958789..f7e0b4023aed 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -365,21 +365,13 @@ LEND(drop_to_el1)
  * Get the physical address the kernel was loaded at.
  */
 LENTRY(get_load_phys_addr)
-	/* Load the physical address of virt_map */
-	adrp	x29, virt_map
-	add	x29, x29, :lo12:virt_map
-	/* Load the virtual address of virt_map stored in virt_map */
-	ldr	x28, [x29]
-	/* Find PA - VA as PA' = VA' - VA + PA = VA' + (PA - VA) = VA' + x29 */
-	sub	x29, x29, x28
-	/* Find the load address for the kernel */
-	mov	x28, #(KERNBASE)
-	add	x28, x28, x29
+	/* Load the offset of get_load_phys_addr from KERNBASE */
+	ldr	x28, =(get_load_phys_addr - KERNBASE)
+	/* Load the physical address of get_load_phys_addr */
+	adr	x29, get_load_phys_addr
+	/* Find the physical address of KERNBASE, i.e. our load address */
+	sub	x28, x29, x28
 	ret
-
-	.align 3
-virt_map:
-	.quad	virt_map
 LEND(get_load_phys_addr)
 
 /*



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