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-5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:

- SPDX comment style fix

- ignore memory that is unusable

- avoid setting a kernel text offset for the !MMU kernels, where
skipping the first page of memory is both unnecessary and costly

- avoid passing the flag bits in satp to pfn_to_virt()

- fix __put_kernel_nofault, where we had the arguments to
__put_user_nocheck reversed

- workaround for a bug in the FU540 to avoid triggering PMP issues
during early boot

- change to how we pull symbols out of the vDSO. The old mechanism was
removed from binutils-2.35 (and has been backported to Debian's 2.34)

* tag 'riscv-for-linus-5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
RISC-V: Fix the VDSO symbol generaton for binutils-2.35+
RISC-V: Use non-PGD mappings for early DTB access
riscv: uaccess: fix __put_kernel_nofault()
riscv: fix pfn_to_virt err in do_page_fault().
riscv: Set text_offset correctly for M-Mode
RISC-V: Remove any memblock representing unusable memory area
risc-v: kernel: ftrace: Fixes improper SPDX comment style

+47 -23
+1 -1
arch/riscv/include/asm/uaccess.h
··· 476 476 do { \ 477 477 long __kr_err; \ 478 478 \ 479 - __put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \ 479 + __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \ 480 480 if (unlikely(__kr_err)) \ 481 481 goto err_label; \ 482 482 } while (0)
+1 -1
arch/riscv/kernel/ftrace.c
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 3 * Copyright (C) 2013 Linaro Limited 4 4 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
+5
arch/riscv/kernel/head.S
··· 35 35 .word 0 36 36 #endif 37 37 .balign 8 38 + #ifdef CONFIG_RISCV_M_MODE 39 + /* Image load offset (0MB) from start of RAM for M-mode */ 40 + .dword 0 41 + #else 38 42 #if __riscv_xlen == 64 39 43 /* Image load offset(2MB) from start of RAM */ 40 44 .dword 0x200000 41 45 #else 42 46 /* Image load offset(4MB) from start of RAM */ 43 47 .dword 0x400000 48 + #endif 44 49 #endif 45 50 /* Effective size of kernel image */ 46 51 .dword _end - _start
+1
arch/riscv/kernel/vdso/.gitignore
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 vdso.lds 3 3 *.tmp 4 + vdso-syms.S
+9 -9
arch/riscv/kernel/vdso/Makefile
··· 43 43 SYSCFLAGS_vdso.so.dbg = $(c_flags) 44 44 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE 45 45 $(call if_changed,vdsold) 46 + SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ 47 + -Wl,--build-id -Wl,--hash-style=both 46 48 47 49 # We also create a special relocatable object that should mirror the symbol 48 50 # table and layout of the linked DSO. With ld --just-symbols we can then 49 51 # refer to these symbols in the kernel code rather than hand-coded addresses. 50 - 51 - SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \ 52 - -Wl,--build-id=sha1 -Wl,--hash-style=both 53 - $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE 54 - $(call if_changed,vdsold) 55 - 56 - LDFLAGS_vdso-syms.o := -r --just-symbols 57 - $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE 58 - $(call if_changed,ld) 52 + $(obj)/vdso-syms.S: $(obj)/vdso.so FORCE 53 + $(call if_changed,so2s) 59 54 60 55 # strip rule for the .so file 61 56 $(obj)/%.so: OBJCOPYFLAGS := -S ··· 67 72 $(CROSS_COMPILE)objcopy \ 68 73 $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \ 69 74 rm $@.tmp 75 + 76 + # Extracts symbol offsets from the VDSO, converting them into an assembly file 77 + # that contains the same symbols at the same offsets. 78 + quiet_cmd_so2s = SO2S $@ 79 + cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@ 70 80 71 81 # install commands for the unstripped file 72 82 quiet_cmd_vdso_install = INSTALL $@
+6
arch/riscv/kernel/vdso/so2s.sh
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0+ 3 + # Copyright 2020 Palmer Dabbelt <palmerdabbelt@google.com> 4 + 5 + sed 's!\([0-9a-f]*\) T \([a-z0-9_]*\)\(@@LINUX_4.15\)*!.global \2\n.set \2,0x\1!' \ 6 + | grep '^\.'
+3 -1
arch/riscv/mm/fault.c
··· 86 86 pmd_t *pmd, *pmd_k; 87 87 pte_t *pte_k; 88 88 int index; 89 + unsigned long pfn; 89 90 90 91 /* User mode accesses just cause a SIGSEGV */ 91 92 if (user_mode(regs)) ··· 101 100 * of a task switch. 102 101 */ 103 102 index = pgd_index(addr); 104 - pgd = (pgd_t *)pfn_to_virt(csr_read(CSR_SATP)) + index; 103 + pfn = csr_read(CSR_SATP) & SATP_PPN; 104 + pgd = (pgd_t *)pfn_to_virt(pfn) + index; 105 105 pgd_k = init_mm.pgd + index; 106 106 107 107 if (!pgd_present(*pgd_k)) {
+21 -11
arch/riscv/mm/init.c
··· 154 154 155 155 void __init setup_bootmem(void) 156 156 { 157 - phys_addr_t mem_size = 0; 158 - phys_addr_t total_mem = 0; 159 - phys_addr_t mem_start, start, end = 0; 157 + phys_addr_t mem_start = 0; 158 + phys_addr_t start, end = 0; 160 159 phys_addr_t vmlinux_end = __pa_symbol(&_end); 161 160 phys_addr_t vmlinux_start = __pa_symbol(&_start); 162 161 u64 i; ··· 163 164 /* Find the memory region containing the kernel */ 164 165 for_each_mem_range(i, &start, &end) { 165 166 phys_addr_t size = end - start; 166 - if (!total_mem) 167 + if (!mem_start) 167 168 mem_start = start; 168 169 if (start <= vmlinux_start && vmlinux_end <= end) 169 170 BUG_ON(size == 0); 170 - total_mem = total_mem + size; 171 171 } 172 172 173 173 /* 174 - * Remove memblock from the end of usable area to the 175 - * end of region 174 + * The maximal physical memory size is -PAGE_OFFSET. 175 + * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed 176 + * as it is unusable by kernel. 176 177 */ 177 - mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET); 178 - if (mem_start + mem_size < end) 179 - memblock_remove(mem_start + mem_size, 180 - end - mem_start - mem_size); 178 + memblock_enforce_memory_limit(mem_start - PAGE_OFFSET); 181 179 182 180 /* Reserve from the start of the kernel to the end of the kernel */ 183 181 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); ··· 293 297 #define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE) 294 298 #endif 295 299 pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE); 300 + pmd_t early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE); 296 301 297 302 static pmd_t *__init get_pmd_virt_early(phys_addr_t pa) 298 303 { ··· 491 494 load_pa + (va - PAGE_OFFSET), 492 495 map_size, PAGE_KERNEL_EXEC); 493 496 497 + #ifndef __PAGETABLE_PMD_FOLDED 498 + /* Setup early PMD for DTB */ 499 + create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA, 500 + (uintptr_t)early_dtb_pmd, PGDIR_SIZE, PAGE_TABLE); 501 + /* Create two consecutive PMD mappings for FDT early scan */ 502 + pa = dtb_pa & ~(PMD_SIZE - 1); 503 + create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA, 504 + pa, PMD_SIZE, PAGE_KERNEL); 505 + create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA + PMD_SIZE, 506 + pa + PMD_SIZE, PMD_SIZE, PAGE_KERNEL); 507 + dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PMD_SIZE - 1)); 508 + #else 494 509 /* Create two consecutive PGD mappings for FDT early scan */ 495 510 pa = dtb_pa & ~(PGDIR_SIZE - 1); 496 511 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA, ··· 510 501 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA + PGDIR_SIZE, 511 502 pa + PGDIR_SIZE, PGDIR_SIZE, PAGE_KERNEL); 512 503 dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PGDIR_SIZE - 1)); 504 + #endif 513 505 dtb_early_pa = dtb_pa; 514 506 515 507 /*