Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'riscv-for-linus-6.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:

- A fix for a missing fence when generating the NOMMU sigreturn
trampoline

- A set of fixes for early DTB handling of reserved memory nodes

* tag 'riscv-for-linus-6.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
riscv: No need to relocate the dtb as it lies in the fixmap region
riscv: Do not set initial_boot_params to the linear address of the dtb
riscv: Move early dtb mapping into the fixmap region
riscv: add icache flush for nommu sigreturn trampoline

+62 -57
+3 -3
Documentation/riscv/vm-layout.rst
··· 47 47 | Kernel-space virtual memory, shared between all processes: 48 48 ____________________________________________________________|___________________________________________________________ 49 49 | | | | 50 - ffffffc6fee00000 | -228 GB | ffffffc6feffffff | 2 MB | fixmap 50 + ffffffc6fea00000 | -228 GB | ffffffc6feffffff | 6 MB | fixmap 51 51 ffffffc6ff000000 | -228 GB | ffffffc6ffffffff | 16 MB | PCI io 52 52 ffffffc700000000 | -228 GB | ffffffc7ffffffff | 4 GB | vmemmap 53 53 ffffffc800000000 | -224 GB | ffffffd7ffffffff | 64 GB | vmalloc/ioremap space ··· 83 83 | Kernel-space virtual memory, shared between all processes: 84 84 ____________________________________________________________|___________________________________________________________ 85 85 | | | | 86 - ffff8d7ffee00000 | -114.5 TB | ffff8d7ffeffffff | 2 MB | fixmap 86 + ffff8d7ffea00000 | -114.5 TB | ffff8d7ffeffffff | 6 MB | fixmap 87 87 ffff8d7fff000000 | -114.5 TB | ffff8d7fffffffff | 16 MB | PCI io 88 88 ffff8d8000000000 | -114.5 TB | ffff8f7fffffffff | 2 TB | vmemmap 89 89 ffff8f8000000000 | -112.5 TB | ffffaf7fffffffff | 32 TB | vmalloc/ioremap space ··· 119 119 | Kernel-space virtual memory, shared between all processes: 120 120 ____________________________________________________________|___________________________________________________________ 121 121 | | | | 122 - ff1bfffffee00000 | -57 PB | ff1bfffffeffffff | 2 MB | fixmap 122 + ff1bfffffea00000 | -57 PB | ff1bfffffeffffff | 6 MB | fixmap 123 123 ff1bffffff000000 | -57 PB | ff1bffffffffffff | 16 MB | PCI io 124 124 ff1c000000000000 | -57 PB | ff1fffffffffffff | 1 PB | vmemmap 125 125 ff20000000000000 | -56 PB | ff5fffffffffffff | 16 PB | vmalloc/ioremap space
+8
arch/riscv/include/asm/fixmap.h
··· 22 22 */ 23 23 enum fixed_addresses { 24 24 FIX_HOLE, 25 + /* 26 + * The fdt fixmap mapping must be PMD aligned and will be mapped 27 + * using PMD entries in fixmap_pmd in 64-bit and a PGD entry in 32-bit. 28 + */ 29 + FIX_FDT_END, 30 + FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1, 31 + 32 + /* Below fixmaps will be mapped using fixmap_pte */ 25 33 FIX_PTE, 26 34 FIX_PMD, 27 35 FIX_PUD,
+6 -2
arch/riscv/include/asm/pgtable.h
··· 87 87 88 88 #define FIXADDR_TOP PCI_IO_START 89 89 #ifdef CONFIG_64BIT 90 - #define FIXADDR_SIZE PMD_SIZE 90 + #define MAX_FDT_SIZE PMD_SIZE 91 + #define FIX_FDT_SIZE (MAX_FDT_SIZE + SZ_2M) 92 + #define FIXADDR_SIZE (PMD_SIZE + FIX_FDT_SIZE) 91 93 #else 92 - #define FIXADDR_SIZE PGDIR_SIZE 94 + #define MAX_FDT_SIZE PGDIR_SIZE 95 + #define FIX_FDT_SIZE MAX_FDT_SIZE 96 + #define FIXADDR_SIZE (PGDIR_SIZE + FIX_FDT_SIZE) 93 97 #endif 94 98 #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 95 99
+1 -5
arch/riscv/kernel/setup.c
··· 278 278 #if IS_ENABLED(CONFIG_BUILTIN_DTB) 279 279 unflatten_and_copy_device_tree(); 280 280 #else 281 - if (early_init_dt_verify(__va(XIP_FIXUP(dtb_early_pa)))) 282 - unflatten_device_tree(); 283 - else 284 - pr_err("No DTB found in kernel mappings\n"); 281 + unflatten_device_tree(); 285 282 #endif 286 - early_init_fdt_scan_reserved_mem(); 287 283 misc_mem_init(); 288 284 289 285 init_resources();
+8 -1
arch/riscv/kernel/signal.c
··· 19 19 #include <asm/signal32.h> 20 20 #include <asm/switch_to.h> 21 21 #include <asm/csr.h> 22 + #include <asm/cacheflush.h> 22 23 23 24 extern u32 __user_rt_sigreturn[2]; 24 25 ··· 182 181 { 183 182 struct rt_sigframe __user *frame; 184 183 long err = 0; 184 + unsigned long __maybe_unused addr; 185 185 186 186 frame = get_sigframe(ksig, regs, sizeof(*frame)); 187 187 if (!access_ok(frame, sizeof(*frame))) ··· 211 209 if (copy_to_user(&frame->sigreturn_code, __user_rt_sigreturn, 212 210 sizeof(frame->sigreturn_code))) 213 211 return -EFAULT; 214 - regs->ra = (unsigned long)&frame->sigreturn_code; 212 + 213 + addr = (unsigned long)&frame->sigreturn_code; 214 + /* Make sure the two instructions are pushed to icache. */ 215 + flush_icache_range(addr, addr + sizeof(frame->sigreturn_code)); 216 + 217 + regs->ra = addr; 215 218 #endif /* CONFIG_MMU */ 216 219 217 220 /*
+36 -46
arch/riscv/mm/init.c
··· 57 57 EXPORT_SYMBOL(empty_zero_page); 58 58 59 59 extern char _start[]; 60 - #define DTB_EARLY_BASE_VA PGDIR_SIZE 61 60 void *_dtb_early_va __initdata; 62 61 uintptr_t _dtb_early_pa __initdata; 63 62 ··· 235 236 set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET); 236 237 237 238 reserve_initrd_mem(); 239 + 240 + /* 241 + * No allocation should be done before reserving the memory as defined 242 + * in the device tree, otherwise the allocation could end up in a 243 + * reserved region. 244 + */ 245 + early_init_fdt_scan_reserved_mem(); 246 + 238 247 /* 239 248 * If DTB is built in, no need to reserve its memblock. 240 249 * Otherwise, do reserve it but avoid using 241 250 * early_init_fdt_reserve_self() since __pa() does 242 251 * not work for DTB pointers that are fixmap addresses 243 252 */ 244 - if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) { 245 - /* 246 - * In case the DTB is not located in a memory region we won't 247 - * be able to locate it later on via the linear mapping and 248 - * get a segfault when accessing it via __va(dtb_early_pa). 249 - * To avoid this situation copy DTB to a memory region. 250 - * Note that memblock_phys_alloc will also reserve DTB region. 251 - */ 252 - if (!memblock_is_memory(dtb_early_pa)) { 253 - size_t fdt_size = fdt_totalsize(dtb_early_va); 254 - phys_addr_t new_dtb_early_pa = memblock_phys_alloc(fdt_size, PAGE_SIZE); 255 - void *new_dtb_early_va = early_memremap(new_dtb_early_pa, fdt_size); 256 - 257 - memcpy(new_dtb_early_va, dtb_early_va, fdt_size); 258 - early_memunmap(new_dtb_early_va, fdt_size); 259 - _dtb_early_pa = new_dtb_early_pa; 260 - } else 261 - memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); 262 - } 253 + if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) 254 + memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); 263 255 264 256 dma_contiguous_reserve(dma32_phys_limit); 265 257 if (IS_ENABLED(CONFIG_64BIT)) ··· 269 279 static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; 270 280 271 281 pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); 272 - static p4d_t __maybe_unused early_dtb_p4d[PTRS_PER_P4D] __initdata __aligned(PAGE_SIZE); 273 - static pud_t __maybe_unused early_dtb_pud[PTRS_PER_PUD] __initdata __aligned(PAGE_SIZE); 274 - static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); 275 282 276 283 #ifdef CONFIG_XIP_KERNEL 277 284 #define pt_ops (*(struct pt_alloc_ops *)XIP_FIXUP(&pt_ops)) ··· 613 626 #define trampoline_pgd_next (pgtable_l5_enabled ? \ 614 627 (uintptr_t)trampoline_p4d : (pgtable_l4_enabled ? \ 615 628 (uintptr_t)trampoline_pud : (uintptr_t)trampoline_pmd)) 616 - #define early_dtb_pgd_next (pgtable_l5_enabled ? \ 617 - (uintptr_t)early_dtb_p4d : (pgtable_l4_enabled ? \ 618 - (uintptr_t)early_dtb_pud : (uintptr_t)early_dtb_pmd)) 619 629 #else 620 630 #define pgd_next_t pte_t 621 631 #define alloc_pgd_next(__va) pt_ops.alloc_pte(__va) ··· 620 636 #define create_pgd_next_mapping(__nextp, __va, __pa, __sz, __prot) \ 621 637 create_pte_mapping(__nextp, __va, __pa, __sz, __prot) 622 638 #define fixmap_pgd_next ((uintptr_t)fixmap_pte) 623 - #define early_dtb_pgd_next ((uintptr_t)early_dtb_pmd) 624 639 #define create_p4d_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0) 625 640 #define create_pud_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0) 626 641 #define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0) ··· 843 860 * this means 2 PMD entries whereas for 32-bit kernel, this is only 1 PGDIR 844 861 * entry. 845 862 */ 846 - static void __init create_fdt_early_page_table(pgd_t *pgdir, uintptr_t dtb_pa) 863 + static void __init create_fdt_early_page_table(pgd_t *pgdir, 864 + uintptr_t fix_fdt_va, 865 + uintptr_t dtb_pa) 847 866 { 848 - #ifndef CONFIG_BUILTIN_DTB 849 867 uintptr_t pa = dtb_pa & ~(PMD_SIZE - 1); 850 868 851 - create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA, 852 - IS_ENABLED(CONFIG_64BIT) ? early_dtb_pgd_next : pa, 853 - PGDIR_SIZE, 854 - IS_ENABLED(CONFIG_64BIT) ? PAGE_TABLE : PAGE_KERNEL); 869 + #ifndef CONFIG_BUILTIN_DTB 870 + /* Make sure the fdt fixmap address is always aligned on PMD size */ 871 + BUILD_BUG_ON(FIX_FDT % (PMD_SIZE / PAGE_SIZE)); 855 872 856 - if (pgtable_l5_enabled) 857 - create_p4d_mapping(early_dtb_p4d, DTB_EARLY_BASE_VA, 858 - (uintptr_t)early_dtb_pud, P4D_SIZE, PAGE_TABLE); 859 - 860 - if (pgtable_l4_enabled) 861 - create_pud_mapping(early_dtb_pud, DTB_EARLY_BASE_VA, 862 - (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE); 863 - 864 - if (IS_ENABLED(CONFIG_64BIT)) { 865 - create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA, 873 + /* In 32-bit only, the fdt lies in its own PGD */ 874 + if (!IS_ENABLED(CONFIG_64BIT)) { 875 + create_pgd_mapping(early_pg_dir, fix_fdt_va, 876 + pa, MAX_FDT_SIZE, PAGE_KERNEL); 877 + } else { 878 + create_pmd_mapping(fixmap_pmd, fix_fdt_va, 866 879 pa, PMD_SIZE, PAGE_KERNEL); 867 - create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA + PMD_SIZE, 880 + create_pmd_mapping(fixmap_pmd, fix_fdt_va + PMD_SIZE, 868 881 pa + PMD_SIZE, PMD_SIZE, PAGE_KERNEL); 869 882 } 870 883 871 - dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PMD_SIZE - 1)); 884 + dtb_early_va = (void *)fix_fdt_va + (dtb_pa & (PMD_SIZE - 1)); 872 885 #else 873 886 /* 874 887 * For 64-bit kernel, __va can't be used since it would return a linear ··· 1034 1055 create_kernel_page_table(early_pg_dir, true); 1035 1056 1036 1057 /* Setup early mapping for FDT early scan */ 1037 - create_fdt_early_page_table(early_pg_dir, dtb_pa); 1058 + create_fdt_early_page_table(early_pg_dir, 1059 + __fix_to_virt(FIX_FDT), dtb_pa); 1038 1060 1039 1061 /* 1040 1062 * Bootime fixmap only can handle PMD_SIZE mapping. Thus, boot-ioremap ··· 1077 1097 u64 i; 1078 1098 1079 1099 /* Setup swapper PGD for fixmap */ 1100 + #if !defined(CONFIG_64BIT) 1101 + /* 1102 + * In 32-bit, the device tree lies in a pgd entry, so it must be copied 1103 + * directly in swapper_pg_dir in addition to the pgd entry that points 1104 + * to fixmap_pte. 1105 + */ 1106 + unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT)); 1107 + 1108 + set_pgd(&swapper_pg_dir[idx], early_pg_dir[idx]); 1109 + #endif 1080 1110 create_pgd_mapping(swapper_pg_dir, FIXADDR_START, 1081 1111 __pa_symbol(fixmap_pgd_next), 1082 1112 PGDIR_SIZE, PAGE_TABLE);