forked from Minki/linux
RISC-V Fixes for 5.14-rc5
* A fix to avoid dereferencing a null task pointer while walking the stack. * A fix to the memory size in the HiFive Unleashed device tree. * A fix to 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. -----BEGIN PGP SIGNATURE----- iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmEOqYETHHBhbG1lckBk YWJiZWx0LmNvbQAKCRAuExnzX7sYiTstD/0STPUiXhCyrkrMCFDJ+Q+TSsoLJcw0 UbELuUDVrDzDPQDvVw52HiqKoec9Q2iW5B+W3A7/h2xfcVfvGM3Fy0Wt24mTxS3G tAxlpqmmNPHNZChA77o3zMbuoq8KNRN8b/rvWHoyzW4qUg5HZJ2hwuoySWav3wRb 3h0j8tp/vsk7GtIkJX/E8yB/rtab9aM4zFU7n5/6n89CY6gDrm12nGQMTYwpfUH2 G+Z3+kFC3FYThGXaJkaJuQq/J685T5sDzMKZBb0it02fDSZoD7tIMsSptKCNtiEx Mqjy4LN81QCSoYsvAfVGk2La5B8niEyCQnTfXvjBYTDgonGrXFPG7R2PRRZeKK1U ZfXAZGJIaE4za0Kmcl9ONl9OwgN7WfB8+DbY0aPZQqG+c25AxzTvzOCeD2unClM0 Z46LVVxxiVRg7n6zLMsrXxotZ3BCW9vCVbrrqiUMyKzvYEEEmUMz3JTEL1k48GI2 T3srXBzOG9RRPv6mcrSJjyzJlPj9Nue/JMRsjvZPCvMdDmlkt7jNRfCkIFFh4B3C ctnVav++VRwnX+dFPpYJLbI/i0gPaP0R/HXqn6VVcByqHBsM3qkURPXuyExcJbUs G07jOJ1rp2Fc/2/HQrn0ePBH78IqGBK5T6f2LqTY3rBBR7SFRXsF5k8dhv6TZoMm Ie7UkqPfFETVeA== =yf+K -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
0b6684ba5f
@ -492,10 +492,16 @@ config CC_HAVE_STACKPROTECTOR_TLS
|
||||
|
||||
config STACKPROTECTOR_PER_TASK
|
||||
def_bool y
|
||||
depends on !GCC_PLUGIN_RANDSTRUCT
|
||||
depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
|
||||
|
||||
config PHYS_RAM_BASE_FIXED
|
||||
bool "Explicitly specified physical RAM address"
|
||||
default n
|
||||
|
||||
config PHYS_RAM_BASE
|
||||
hex "Platform Physical RAM address"
|
||||
depends on PHYS_RAM_BASE_FIXED
|
||||
default "0x80000000"
|
||||
help
|
||||
This is the physical address of RAM in the system. It has to be
|
||||
@ -508,6 +514,7 @@ config XIP_KERNEL
|
||||
# This prevents XIP from being enabled by all{yes,mod}config, which
|
||||
# fail to build since XIP doesn't support large kernels.
|
||||
depends on !COMPILE_TEST
|
||||
select PHYS_RAM_BASE_FIXED
|
||||
help
|
||||
Execute-In-Place allows the kernel to run from non-volatile storage
|
||||
directly addressable by the CPU, such as NOR flash. This saves RAM
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
memory@80000000 {
|
||||
device_type = "memory";
|
||||
reg = <0x0 0x80000000 0x2 0x00000000>;
|
||||
reg = <0x0 0x80000000 0x4 0x00000000>;
|
||||
};
|
||||
|
||||
soc {
|
||||
|
@ -103,6 +103,7 @@ struct kernel_mapping {
|
||||
};
|
||||
|
||||
extern struct kernel_mapping kernel_map;
|
||||
extern phys_addr_t phys_ram_base;
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#define is_kernel_mapping(x) \
|
||||
@ -113,9 +114,9 @@ extern struct kernel_mapping kernel_map;
|
||||
#define linear_mapping_pa_to_va(x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset))
|
||||
#define kernel_mapping_pa_to_va(y) ({ \
|
||||
unsigned long _y = y; \
|
||||
(_y >= CONFIG_PHYS_RAM_BASE) ? \
|
||||
(void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET) : \
|
||||
(void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset); \
|
||||
(IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \
|
||||
(void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset) : \
|
||||
(void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \
|
||||
})
|
||||
#define __pa_to_va_nodebug(x) linear_mapping_pa_to_va(x)
|
||||
|
||||
|
@ -27,7 +27,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
|
||||
fp = frame_pointer(regs);
|
||||
sp = user_stack_pointer(regs);
|
||||
pc = instruction_pointer(regs);
|
||||
} else if (task == current) {
|
||||
} else if (task == NULL || task == current) {
|
||||
fp = (unsigned long)__builtin_frame_address(1);
|
||||
sp = (unsigned long)__builtin_frame_address(0);
|
||||
pc = (unsigned long)__builtin_return_address(0);
|
||||
|
@ -36,6 +36,9 @@ EXPORT_SYMBOL(kernel_map);
|
||||
#define kernel_map (*(struct kernel_mapping *)XIP_FIXUP(&kernel_map))
|
||||
#endif
|
||||
|
||||
phys_addr_t phys_ram_base __ro_after_init;
|
||||
EXPORT_SYMBOL(phys_ram_base);
|
||||
|
||||
#ifdef CONFIG_XIP_KERNEL
|
||||
extern char _xiprom[], _exiprom[];
|
||||
#endif
|
||||
@ -160,7 +163,7 @@ static void __init setup_bootmem(void)
|
||||
phys_addr_t vmlinux_end = __pa_symbol(&_end);
|
||||
phys_addr_t vmlinux_start = __pa_symbol(&_start);
|
||||
phys_addr_t __maybe_unused max_mapped_addr;
|
||||
phys_addr_t dram_end;
|
||||
phys_addr_t phys_ram_end;
|
||||
|
||||
#ifdef CONFIG_XIP_KERNEL
|
||||
vmlinux_start = __pa_symbol(&_sdata);
|
||||
@ -181,9 +184,12 @@ static void __init setup_bootmem(void)
|
||||
#endif
|
||||
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
|
||||
|
||||
dram_end = memblock_end_of_DRAM();
|
||||
|
||||
phys_ram_end = memblock_end_of_DRAM();
|
||||
#ifndef CONFIG_64BIT
|
||||
#ifndef CONFIG_XIP_KERNEL
|
||||
phys_ram_base = memblock_start_of_DRAM();
|
||||
#endif
|
||||
/*
|
||||
* memblock allocator is not aware of the fact that last 4K bytes of
|
||||
* the addressable memory can not be mapped because of IS_ERR_VALUE
|
||||
@ -194,12 +200,12 @@ static void __init setup_bootmem(void)
|
||||
* be done in create_kernel_page_table.
|
||||
*/
|
||||
max_mapped_addr = __pa(~(ulong)0);
|
||||
if (max_mapped_addr == (dram_end - 1))
|
||||
if (max_mapped_addr == (phys_ram_end - 1))
|
||||
memblock_set_current_limit(max_mapped_addr - 4096);
|
||||
#endif
|
||||
|
||||
min_low_pfn = PFN_UP(memblock_start_of_DRAM());
|
||||
max_low_pfn = max_pfn = PFN_DOWN(dram_end);
|
||||
min_low_pfn = PFN_UP(phys_ram_base);
|
||||
max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end);
|
||||
|
||||
dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
|
||||
set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET);
|
||||
@ -558,6 +564,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
|
||||
kernel_map.xiprom = (uintptr_t)CONFIG_XIP_PHYS_ADDR;
|
||||
kernel_map.xiprom_sz = (uintptr_t)(&_exiprom) - (uintptr_t)(&_xiprom);
|
||||
|
||||
phys_ram_base = CONFIG_PHYS_RAM_BASE;
|
||||
kernel_map.phys_addr = (uintptr_t)CONFIG_PHYS_RAM_BASE;
|
||||
kernel_map.size = (uintptr_t)(&_end) - (uintptr_t)(&_sdata);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user