Skip to content

Commit 2c0391b

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Allow NOMMU kernels to access all of RAM
NOMMU kernels currently cannot access memory below the kernel link address. Remove this restriction by setting PAGE_OFFSET to the actual start of RAM, as determined from the devicetree. The kernel link address must be a constant, so keep using CONFIG_PAGE_OFFSET for that purpose. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Jesse Taube <mr.bossman075@gmail.com> Link: https://lore.kernel.org/r/20241026171441.3047904-3-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent bffada8 commit 2c0391b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

arch/riscv/include/asm/page.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
* When not using MMU this corresponds to the first free page in
2525
* physical memory (aligned on a page boundary).
2626
*/
27-
#ifdef CONFIG_64BIT
2827
#ifdef CONFIG_MMU
28+
#ifdef CONFIG_64BIT
2929
#define PAGE_OFFSET kernel_map.page_offset
30-
#else
31-
#define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
32-
#endif
3330
/*
3431
* By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
3532
* define the PAGE_OFFSET value for SV48 and SV39.
@@ -39,6 +36,9 @@
3936
#else
4037
#define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
4138
#endif /* CONFIG_64BIT */
39+
#else
40+
#define PAGE_OFFSET ((unsigned long)phys_ram_base)
41+
#endif /* CONFIG_MMU */
4242

4343
#ifndef __ASSEMBLY__
4444

@@ -95,11 +95,7 @@ typedef struct page *pgtable_t;
9595
#define MIN_MEMBLOCK_ADDR 0
9696
#endif
9797

98-
#ifdef CONFIG_MMU
9998
#define ARCH_PFN_OFFSET (PFN_DOWN((unsigned long)phys_ram_base))
100-
#else
101-
#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
102-
#endif /* CONFIG_MMU */
10399

104100
struct kernel_mapping {
105101
unsigned long page_offset;

arch/riscv/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <asm/pgtable-bits.h>
1313

1414
#ifndef CONFIG_MMU
15-
#define KERNEL_LINK_ADDR PAGE_OFFSET
15+
#define KERNEL_LINK_ADDR _AC(CONFIG_PAGE_OFFSET, UL)
1616
#define KERN_VIRT_SIZE (UL(-1))
1717
#else
1818

0 commit comments

Comments
 (0)