Skip to contentSkip to conversation

riscv: move kaslr_offset() to page.h as a static inline function

PATCH In review Austin Kim 2 participants 2 messages Feb 11 – Feb 13 RISC-V

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/2 riscv: move kaslr_offset() to page.h as a static inline function

From: Austin Kim <[email protected]>

The kaslr_offset() function is a simple accessor that returns kernel_map.virt_offset. This commit change also ensures that kaslr_offset() is consistently available across various kernel configurations without requiring explicit linkage to mm/init.c.

---
 arch/riscv/include/asm/page.h | 5 ++++-
 arch/riscv/mm/init.c          | 5 -----
 2 files changed, 4 insertions(+), 6 deletions(-)
arch/riscv/include/asm/page.h +4 -1
index 187aad0a7..813b6da57 100644
@@ -190,7 +190,10 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
 
 #define sym_to_pfn(x)           __phys_to_pfn(__pa_symbol(x))
 
-unsigned long kaslr_offset(void);
+static inline unsigned long kaslr_offset(void)
+{
+	return kernel_map.virt_offset;
+}
 
 static __always_inline void *pfn_to_kaddr(unsigned long pfn)
 {
arch/riscv/mm/init.c +0 -5
index 811e03786..257df6bd2 100644
@@ -1078,11 +1078,6 @@ static int __init print_nokaslr(char *p)
 	return 0;
 }
 early_param("nokaslr", print_nokaslr);
-
-unsigned long kaslr_offset(void)
-{
-	return kernel_map.virt_offset;
-}
 #endif
 
 asmlinkage void __init setup_vm(uintptr_t dtb_pa)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 8 lines · Austin Kim

From: Austin Kim <[email protected]>

The kaslr_offset() function is a simple accessor that returns kernel_map.virt_offset. This commit change also ensures that kaslr_offset() is consistently available across various kernel configurations without requiring explicit linkage to mm/init.c.

Thanks, queued for v7.0-rc.

- Paul