Skip to content

Commit f54c7b5

Browse files
RISC-V: Always define XIP_FIXUP
XIP depends on MMU, but XIP_FIXUP is used throughout the kernel in order to avoid excessive ifdefs. This just makes sure to always define XIP_FIXUP, which will fix MMU=n builds. XIP_OFFSET is used by assembly but XIP_FIXUP is C-only, so they're split. Fixes: 44c9225 ("RISC-V: enable XIP") Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com> Tested-by: Alexandre Ghiti <alex@ghiti.fr> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
1 parent 28252e0 commit f54c7b5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

arch/riscv/include/asm/pgtable.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,10 @@
7373
#endif
7474
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
7575

76+
#endif
77+
7678
#ifdef CONFIG_XIP_KERNEL
7779
#define XIP_OFFSET SZ_8M
78-
#define XIP_FIXUP(addr) ({ \
79-
uintptr_t __a = (uintptr_t)(addr); \
80-
(__a >= CONFIG_XIP_PHYS_ADDR && __a < CONFIG_XIP_PHYS_ADDR + SZ_16M) ? \
81-
__a - CONFIG_XIP_PHYS_ADDR + CONFIG_PHYS_RAM_BASE - XIP_OFFSET :\
82-
__a; \
83-
})
84-
#else
85-
#define XIP_FIXUP(addr) (addr)
86-
#endif /* CONFIG_XIP_KERNEL */
87-
8880
#endif
8981

9082
#ifndef __ASSEMBLY__
@@ -101,6 +93,17 @@
10193
#include <asm/pgtable-32.h>
10294
#endif /* CONFIG_64BIT */
10395

96+
#ifdef CONFIG_XIP_KERNEL
97+
#define XIP_FIXUP(addr) ({ \
98+
uintptr_t __a = (uintptr_t)(addr); \
99+
(__a >= CONFIG_XIP_PHYS_ADDR && __a < CONFIG_XIP_PHYS_ADDR + SZ_16M) ? \
100+
__a - CONFIG_XIP_PHYS_ADDR + CONFIG_PHYS_RAM_BASE - XIP_OFFSET :\
101+
__a; \
102+
})
103+
#else
104+
#define XIP_FIXUP(addr) (addr)
105+
#endif /* CONFIG_XIP_KERNEL */
106+
104107
#ifdef CONFIG_MMU
105108
/* Number of entries in the page global directory */
106109
#define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t))

0 commit comments

Comments
 (0)