Skip to content

Commit b635a84

Browse files
covanampalmer-dabbelt
authored andcommitted
riscv: remove limit on the size of read-only section for XIP kernel
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. This causes build failures if the kernel gets too big [1]. Remove this limit. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected] [1] Signed-off-by: Nam Cao <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/3bf3a77be10ebb0d8086c028500baa16e7a8e648.1717789719.git.namcao@linutronix.de Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent a7cfb99 commit b635a84

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@
107107

108108
#endif
109109

110-
#ifdef CONFIG_XIP_KERNEL
111-
#define XIP_OFFSET SZ_32M
112-
#define XIP_OFFSET_MASK (SZ_32M - 1)
113-
#else
114-
#define XIP_OFFSET 0
115-
#endif
116-
117110
#ifndef __ASSEMBLY__
118111

119112
#include <asm/page.h>

arch/riscv/include/asm/set_memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool kernel_page_present(struct page *page);
4646

4747
#endif /* __ASSEMBLY__ */
4848

49-
#ifdef CONFIG_STRICT_KERNEL_RWX
49+
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_XIP_KERNEL)
5050
#ifdef CONFIG_64BIT
5151
#define SECTION_ALIGN (1 << 21)
5252
#else

arch/riscv/kernel/vmlinux-xip.lds.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/page.h>
1515
#include <asm/cache.h>
1616
#include <asm/thread_info.h>
17+
#include <asm/set_memory.h>
1718

1819
OUTPUT_ARCH(riscv)
1920
ENTRY(_start)
@@ -65,10 +66,10 @@ SECTIONS
6566
* From this point, stuff is considered writable and will be copied to RAM
6667
*/
6768
__data_loc = ALIGN(PAGE_SIZE); /* location in file */
68-
. = KERNEL_LINK_ADDR + XIP_OFFSET; /* location in memory */
69+
. = ALIGN(SECTION_ALIGN); /* location in memory */
6970

7071
#undef LOAD_OFFSET
71-
#define LOAD_OFFSET (KERNEL_LINK_ADDR + XIP_OFFSET - (__data_loc & XIP_OFFSET_MASK))
72+
#define LOAD_OFFSET (KERNEL_LINK_ADDR + _sdata - __data_loc)
7273

7374
_sdata = .; /* Start of data section */
7475
_data = .;

0 commit comments

Comments
 (0)