Skip to content

Commit a7407a1

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Get rid of riscv_pfn_base variable
Use directly phys_ram_base instead, riscv_pfn_base is just the pfn of the address contained in phys_ram_base. Even if there is no functional change intended in this patch, actually setting phys_ram_base that early changes the behaviour of kernel_mapping_pa_to_va during the early boot: phys_ram_base used to be zero before this patch and now it is set to the physical start address of the kernel. But it does not break the conversion of a kernel physical address into a virtual address since kernel_mapping_pa_to_va should only be used on kernel physical addresses, i.e. addresses greater than the physical start address of the kernel. Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20230324155421.271544-2-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent fe15c26 commit a7407a1

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

arch/riscv/include/asm/page.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ typedef struct page *pgtable_t;
9191
#endif
9292

9393
#ifdef CONFIG_MMU
94-
extern unsigned long riscv_pfn_base;
95-
#define ARCH_PFN_OFFSET (riscv_pfn_base)
94+
#define ARCH_PFN_OFFSET (PFN_DOWN((unsigned long)phys_ram_base))
9695
#else
9796
#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
9897
#endif /* CONFIG_MMU */

arch/riscv/mm/init.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,6 @@ static void __init setup_bootmem(void)
271271
#ifdef CONFIG_MMU
272272
struct pt_alloc_ops pt_ops __initdata;
273273

274-
unsigned long riscv_pfn_base __ro_after_init;
275-
EXPORT_SYMBOL(riscv_pfn_base);
276-
277274
pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
278275
pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
279276
static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
@@ -285,7 +282,6 @@ static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAG
285282

286283
#ifdef CONFIG_XIP_KERNEL
287284
#define pt_ops (*(struct pt_alloc_ops *)XIP_FIXUP(&pt_ops))
288-
#define riscv_pfn_base (*(unsigned long *)XIP_FIXUP(&riscv_pfn_base))
289285
#define trampoline_pg_dir ((pgd_t *)XIP_FIXUP(trampoline_pg_dir))
290286
#define fixmap_pte ((pte_t *)XIP_FIXUP(fixmap_pte))
291287
#define early_pg_dir ((pgd_t *)XIP_FIXUP(early_pg_dir))
@@ -985,7 +981,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
985981
kernel_map.va_pa_offset = PAGE_OFFSET - kernel_map.phys_addr;
986982
kernel_map.va_kernel_pa_offset = kernel_map.virt_addr - kernel_map.phys_addr;
987983

988-
riscv_pfn_base = PFN_DOWN(kernel_map.phys_addr);
984+
phys_ram_base = kernel_map.phys_addr;
989985

990986
/*
991987
* The default maximal physical memory size is KERN_VIRT_SIZE for 32-bit

0 commit comments

Comments
 (0)