diff options
author | Dimitris Vlachos <[email protected]> | 2024-02-29 21:17:23 +0200 |
---|---|---|
committer | Palmer Dabbelt <[email protected]> | 2024-02-29 12:24:31 -0800 |
commit | a11dd49dcb9376776193e15641f84fcc1e5980c9 (patch) | |
tree | 11fdc053ee4a6ba20c511f63b5e9e36f0e46293c | |
parent | 2b8acd71544aeba0c12967b584f6069328452f9b (diff) |
riscv: Sparse-Memory/vmemmap out-of-bounds fix
Offset vmemmap so that the first page of vmemmap will be mapped
to the first page of physical memory in order to ensure that
vmemmap’s bounds will be respected during
pfn_to_page()/page_to_pfn() operations.
The conversion macros will produce correct SV39/48/57 addresses
for every possible/valid DRAM_BASE inside the physical memory limits.
v2:Address Alex's comments
Suggested-by: Alexandre Ghiti <[email protected]>
Signed-off-by: Dimitris Vlachos <[email protected]>
Reported-by: Dimitris Vlachos <[email protected]>
Closes: https://lore.kernel.org/linux-riscv/[email protected]
Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
Reviewed-by: Alexandre Ghiti <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
-rw-r--r-- | arch/riscv/include/asm/pgtable.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 89f5f1bd6e46..6066822e7396 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -84,7 +84,7 @@ * Define vmemmap for pfn_to_page & page_to_pfn calls. Needed if kernel * is configured with CONFIG_SPARSEMEM_VMEMMAP enabled. */ -#define vmemmap ((struct page *)VMEMMAP_START) +#define vmemmap ((struct page *)VMEMMAP_START - (phys_ram_base >> PAGE_SHIFT)) #define PCI_IO_SIZE SZ_16M #define PCI_IO_END VMEMMAP_START |