ef69d2559f
riscv establishes 2 virtual mappings: - early_pg_dir maps the kernel which allows to discover the system memory - swapper_pg_dir installs the final mapping (linear mapping included) We used to map the dtb in early_pg_dir using DTB_EARLY_BASE_VA, and this mapping was not carried over in swapper_pg_dir. It happens that early_init_fdt_scan_reserved_mem() must be called before swapper_pg_dir is setup otherwise we could allocate reserved memory defined in the dtb. And this function initializes reserved_mem variable with addresses that lie in the early_pg_dir dtb mapping: when those addresses are reused with swapper_pg_dir, this mapping does not exist and then we trap. The previous "fix" was incorrect as early_init_fdt_scan_reserved_mem() must be called before swapper_pg_dir is set up otherwise we could allocate in reserved memory defined in the dtb. So move the dtb mapping in the fixmap region which is established in early_pg_dir and handed over to swapper_pg_dir. Fixes: 922b0375fc93 ("riscv: Fix memblock reservation for device tree blob") Fixes: 8f3a2b4a96dc ("RISC-V: Move DT mapping outof fixmap") Fixes: 50e63dd8ed92 ("riscv: fix reserved memory setup") Reported-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/all/f8e67f82-103d-156c-deb0-d6d6e2756f5e@microchip.com/ Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Tested-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230329081932.79831-2-alexghiti@rivosinc.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2019 Western Digital Corporation or its affiliates.
|
|
*/
|
|
|
|
#ifndef _ASM_RISCV_FIXMAP_H
|
|
#define _ASM_RISCV_FIXMAP_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/sizes.h>
|
|
#include <linux/pgtable.h>
|
|
#include <asm/page.h>
|
|
|
|
#ifdef CONFIG_MMU
|
|
/*
|
|
* Here we define all the compile-time 'special' virtual addresses.
|
|
* The point is to have a constant address at compile time, but to
|
|
* set the physical address only in the boot process.
|
|
*
|
|
* These 'compile-time allocated' memory buffers are page-sized. Use
|
|
* set_fixmap(idx,phys) to associate physical memory with fixmap indices.
|
|
*/
|
|
enum fixed_addresses {
|
|
FIX_HOLE,
|
|
/*
|
|
* The fdt fixmap mapping must be PMD aligned and will be mapped
|
|
* using PMD entries in fixmap_pmd in 64-bit and a PGD entry in 32-bit.
|
|
*/
|
|
FIX_FDT_END,
|
|
FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
|
|
|
|
/* Below fixmaps will be mapped using fixmap_pte */
|
|
FIX_PTE,
|
|
FIX_PMD,
|
|
FIX_PUD,
|
|
FIX_P4D,
|
|
FIX_TEXT_POKE1,
|
|
FIX_TEXT_POKE0,
|
|
FIX_EARLYCON_MEM_BASE,
|
|
|
|
__end_of_permanent_fixed_addresses,
|
|
/*
|
|
* Temporary boot-time mappings, used by early_ioremap(),
|
|
* before ioremap() is functional.
|
|
*/
|
|
#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE)
|
|
#define FIX_BTMAPS_SLOTS 7
|
|
#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
|
|
|
|
FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
|
|
FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
|
|
|
|
__end_of_fixed_addresses
|
|
};
|
|
|
|
#define __early_set_fixmap __set_fixmap
|
|
|
|
#define __late_set_fixmap __set_fixmap
|
|
#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
|
|
|
|
extern void __set_fixmap(enum fixed_addresses idx,
|
|
phys_addr_t phys, pgprot_t prot);
|
|
|
|
#include <asm-generic/fixmap.h>
|
|
|
|
#endif /* CONFIG_MMU */
|
|
#endif /* _ASM_RISCV_FIXMAP_H */
|