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

Pull RISC-V fixes from Palmer Dabbelt:

- avoid dereferencing a null task pointer while walking the stack

- fix the memory size in the HiFive Unleashed device tree

- disable stack protectors when randstruct is enabled, which results in
non-deterministic offsets during module builds

- a pair of fixes to avoid relying on a constant physical memory base
for the non-XIP builds

* tag 'riscv-for-linus-5.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
Revert "riscv: Remove CONFIG_PHYS_RAM_BASE_FIXED"
riscv: Get rid of CONFIG_PHYS_RAM_BASE in kernel physical address conversion
riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
riscv: dts: fix memory size for the SiFive HiFive Unmatched
riscv: stacktrace: Fix NULL pointer dereference

+25 -10
+7
arch/riscv/Kconfig
··· 492 492 493 493 config STACKPROTECTOR_PER_TASK 494 494 def_bool y 495 + depends on !GCC_PLUGIN_RANDSTRUCT 495 496 depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS 497 + 498 + config PHYS_RAM_BASE_FIXED 499 + bool "Explicitly specified physical RAM address" 500 + default n 496 501 497 502 config PHYS_RAM_BASE 498 503 hex "Platform Physical RAM address" 504 + depends on PHYS_RAM_BASE_FIXED 499 505 default "0x80000000" 500 506 help 501 507 This is the physical address of RAM in the system. It has to be ··· 514 508 # This prevents XIP from being enabled by all{yes,mod}config, which 515 509 # fail to build since XIP doesn't support large kernels. 516 510 depends on !COMPILE_TEST 511 + select PHYS_RAM_BASE_FIXED 517 512 help 518 513 Execute-In-Place allows the kernel to run from non-volatile storage 519 514 directly addressable by the CPU, such as NOR flash. This saves RAM
+1 -1
arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
··· 24 24 25 25 memory@80000000 { 26 26 device_type = "memory"; 27 - reg = <0x0 0x80000000 0x2 0x00000000>; 27 + reg = <0x0 0x80000000 0x4 0x00000000>; 28 28 }; 29 29 30 30 soc {
+4 -3
arch/riscv/include/asm/page.h
··· 103 103 }; 104 104 105 105 extern struct kernel_mapping kernel_map; 106 + extern phys_addr_t phys_ram_base; 106 107 107 108 #ifdef CONFIG_64BIT 108 109 #define is_kernel_mapping(x) \ ··· 114 113 #define linear_mapping_pa_to_va(x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset)) 115 114 #define kernel_mapping_pa_to_va(y) ({ \ 116 115 unsigned long _y = y; \ 117 - (_y >= CONFIG_PHYS_RAM_BASE) ? \ 118 - (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET) : \ 119 - (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset); \ 116 + (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \ 117 + (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset) : \ 118 + (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \ 120 119 }) 121 120 #define __pa_to_va_nodebug(x) linear_mapping_pa_to_va(x) 122 121
+1 -1
arch/riscv/kernel/stacktrace.c
··· 27 27 fp = frame_pointer(regs); 28 28 sp = user_stack_pointer(regs); 29 29 pc = instruction_pointer(regs); 30 - } else if (task == current) { 30 + } else if (task == NULL || task == current) { 31 31 fp = (unsigned long)__builtin_frame_address(1); 32 32 sp = (unsigned long)__builtin_frame_address(0); 33 33 pc = (unsigned long)__builtin_return_address(0);
+12 -5
arch/riscv/mm/init.c
··· 36 36 #define kernel_map (*(struct kernel_mapping *)XIP_FIXUP(&kernel_map)) 37 37 #endif 38 38 39 + phys_addr_t phys_ram_base __ro_after_init; 40 + EXPORT_SYMBOL(phys_ram_base); 41 + 39 42 #ifdef CONFIG_XIP_KERNEL 40 43 extern char _xiprom[], _exiprom[]; 41 44 #endif ··· 163 160 phys_addr_t vmlinux_end = __pa_symbol(&_end); 164 161 phys_addr_t vmlinux_start = __pa_symbol(&_start); 165 162 phys_addr_t __maybe_unused max_mapped_addr; 166 - phys_addr_t dram_end; 163 + phys_addr_t phys_ram_end; 167 164 168 165 #ifdef CONFIG_XIP_KERNEL 169 166 vmlinux_start = __pa_symbol(&_sdata); ··· 184 181 #endif 185 182 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); 186 183 187 - dram_end = memblock_end_of_DRAM(); 188 184 185 + phys_ram_end = memblock_end_of_DRAM(); 189 186 #ifndef CONFIG_64BIT 187 + #ifndef CONFIG_XIP_KERNEL 188 + phys_ram_base = memblock_start_of_DRAM(); 189 + #endif 190 190 /* 191 191 * memblock allocator is not aware of the fact that last 4K bytes of 192 192 * the addressable memory can not be mapped because of IS_ERR_VALUE ··· 200 194 * be done in create_kernel_page_table. 201 195 */ 202 196 max_mapped_addr = __pa(~(ulong)0); 203 - if (max_mapped_addr == (dram_end - 1)) 197 + if (max_mapped_addr == (phys_ram_end - 1)) 204 198 memblock_set_current_limit(max_mapped_addr - 4096); 205 199 #endif 206 200 207 - min_low_pfn = PFN_UP(memblock_start_of_DRAM()); 208 - max_low_pfn = max_pfn = PFN_DOWN(dram_end); 201 + min_low_pfn = PFN_UP(phys_ram_base); 202 + max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end); 209 203 210 204 dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn)); 211 205 set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET); ··· 564 558 kernel_map.xiprom = (uintptr_t)CONFIG_XIP_PHYS_ADDR; 565 559 kernel_map.xiprom_sz = (uintptr_t)(&_exiprom) - (uintptr_t)(&_xiprom); 566 560 561 + phys_ram_base = CONFIG_PHYS_RAM_BASE; 567 562 kernel_map.phys_addr = (uintptr_t)CONFIG_PHYS_RAM_BASE; 568 563 kernel_map.size = (uintptr_t)(&_end) - (uintptr_t)(&_sdata); 569 564