diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2023-11-13 15:39:06 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2023-11-15 18:05:08 +0000 |
commit | 61f14f1da37b4e6db8f9efe40c6b544c855fb9bd (patch) | |
tree | b0f2970a267181b5d3649b4db894fc9c347e20c4 | |
parent | ba31362694fe465b88a025ac7c35ad7f378efc86 (diff) | |
download | src-61f14f1da37b4e6db8f9efe40c6b544c855fb9bd.tar.gz src-61f14f1da37b4e6db8f9efe40c6b544c855fb9bd.zip |
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
-rw-r--r-- | sys/arm64/arm64/locore.S | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index cea2f690b60f..ffd13610ec02 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -359,21 +359,13 @@ LEND(drop_to_el1) * Get the physical address the kernel was loaded at. */ LENTRY(get_load_phys_addr) + /* Load the offset of get_load_phys_addr from KERNBASE */ + ldr x28, =(get_load_phys_addr - KERNBASE) /* 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 + 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) /* |