]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: drop the use of XIP_OFFSET in kernel_mapping_va_to_pa()
authorNam Cao <namcao@linutronix.de>
Fri, 7 Jun 2024 20:22:11 +0000 (22:22 +0200)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 12 Sep 2024 14:23:00 +0000 (07:23 -0700)
XIP_OFFSET is the hard-coded offset of writable data section within the
kernel.

By hard-coding this value, the read-only section of the kernel (which is
placed before the writable data section) is restricted in size.

As a preparation to remove this hard-coded macro XIP_OFFSET entirely,
remove the use of XIP_OFFSET in kernel_mapping_va_to_pa(). The macro
XIP_OFFSET is used in this case to check if the virtual address is mapped
to Flash or to RAM. The same check can be done with kernel_map.xiprom_sz.

Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/644c13d9467525a06f5d63d157875a35b2edb4bc.1717789719.git.namcao@linutronix.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/page.h

index 4d7a8d5bb2d25053f691eb00b842476d9f1b9072..32d308a3355fd413743bdef7cb74f7d46ce3724b 100644 (file)
@@ -159,7 +159,7 @@ phys_addr_t linear_mapping_va_to_pa(unsigned long x);
 #ifdef CONFIG_XIP_KERNEL
 #define kernel_mapping_va_to_pa(y) ({                                          \
        unsigned long _y = (unsigned long)(y);                                  \
-       (_y < kernel_map.virt_addr + XIP_OFFSET) ?                              \
+       (_y < kernel_map.virt_addr + kernel_map.xiprom_sz) ?                    \
                (_y - kernel_map.va_kernel_xip_text_pa_offset) :                \
                (_y - kernel_map.va_kernel_xip_data_pa_offset);                 \
        })