mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 15:19:51 +00:00
RISC-V Fixes for the Merge Window, Part 2
* A fix to avoid over-allocating the kernel's mapping on !MMU systems, which could lead to up to 2MiB of lost memory. * The SiFive address extension errata only manifest on rv64, they are now disabled on rv32 where they are unnecessary. There are also a pair of late-landing cleanups. -----BEGIN PGP SIGNATURE----- iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmCWw5QTHHBhbG1lckBk YWJiZWx0LmNvbQAKCRAuExnzX7sYiRKiEACIVsjL+QmsgpAxAK9z4YokneXl+bBw PN401kDpyijVhHCmwXHr1eNilwc2FMkVsfjtGGp4mIgjYnzEoMd8wfaI9b7/1+Rk 73uYF6V/oJCrWvLQ/gIULp8D385F5vjGQDjuFm9mlQuhR1kpGTbvvliVoYwevQ8B PqVn+zWPqqGyFUEnNNLXhVtTRntGrfZwIz/bxpZOtn/IN3BE1oEQW51+5rbfXpFr eK59b808lfd5qlbSJ4Dgpwv1TAa01gM9TPYpxqSO/4mo9C1eZsBqS2/LxaJHDqBQ CENkujqd0qMDq4CP/SN4pBxHWTFyR9wfE8u2d4hqrNwhJivFHM9+yP84ayElfBXh IhM6PiMnW2N618DeMq92bqpGwrNAUdAVby+B38jpo9z+GCKVqgdMeAnTaBO4ApLx Hgo6pOknJZxnta6Wmsog8/hNnONSkGDBrzcP7+bdNvsCG6j07P5wLtvsf05yPnIe 6BB/xGePYxaSWtFwebBenSrOYU5mEKV44yOnHvWuy9TwFx6khxb5xCGKtB8I16vy f3kUG9TXJx6CqDmhsl12YGYHdT13l3YttRAN1MzMazFmzSKcbsmsDDsEmmN/zmXh qkAXk0yRVxwBqxvehNw2PE0ViNYTpS31qmOHns7pcA85VEzAJSC0yD/k+qZcRuus a/+f66xSe2KqbQ== =mEPT -----END PGP SIGNATURE----- Merge tag 'riscv-for-linus-5.13-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux Pull RISC-V fixes from Palmer Dabbelt: - A fix to avoid over-allocating the kernel's mapping on !MMU systems, which could lead to up to 2MiB of lost memory - The SiFive address extension errata only manifest on rv64, they are now disabled on rv32 where they are unnecessary - A pair of late-landing cleanups * tag 'riscv-for-linus-5.13-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: remove unused handle_exception symbol riscv: Consistify protect_kernel_linear_mapping_text_rodata() use riscv: enable SiFive errata CIP-453 and CIP-1200 Kconfig only if CONFIG_64BIT=y riscv: Only extend kernel reservation if mapped read-only
This commit is contained in:
commit
b741596468
@ -21,7 +21,7 @@ config ERRATA_SIFIVE
|
||||
|
||||
config ERRATA_SIFIVE_CIP_453
|
||||
bool "Apply SiFive errata CIP-453"
|
||||
depends on ERRATA_SIFIVE
|
||||
depends on ERRATA_SIFIVE && 64BIT
|
||||
default y
|
||||
help
|
||||
This will apply the SiFive CIP-453 errata to add sign extension
|
||||
@ -32,7 +32,7 @@ config ERRATA_SIFIVE_CIP_453
|
||||
|
||||
config ERRATA_SIFIVE_CIP_1200
|
||||
bool "Apply SiFive errata CIP-1200"
|
||||
depends on ERRATA_SIFIVE
|
||||
depends on ERRATA_SIFIVE && 64BIT
|
||||
default y
|
||||
help
|
||||
This will apply the SiFive CIP-1200 errata to repalce all
|
||||
|
@ -17,7 +17,6 @@ int set_memory_x(unsigned long addr, int numpages);
|
||||
int set_memory_nx(unsigned long addr, int numpages);
|
||||
int set_memory_rw_nx(unsigned long addr, int numpages);
|
||||
void protect_kernel_text_data(void);
|
||||
void protect_kernel_linear_mapping_text_rodata(void);
|
||||
#else
|
||||
static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
|
||||
static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
|
||||
@ -27,6 +26,12 @@ static inline void protect_kernel_text_data(void) {}
|
||||
static inline int set_memory_rw_nx(unsigned long addr, int numpages) { return 0; }
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_64BIT) && defined(CONFIG_STRICT_KERNEL_RWX)
|
||||
void protect_kernel_linear_mapping_text_rodata(void);
|
||||
#else
|
||||
static inline void protect_kernel_linear_mapping_text_rodata(void) {}
|
||||
#endif
|
||||
|
||||
int set_direct_map_invalid_noflush(struct page *page);
|
||||
int set_direct_map_default_noflush(struct page *page);
|
||||
bool kernel_page_present(struct page *page);
|
||||
|
@ -293,9 +293,7 @@ void __init setup_arch(char **cmdline_p)
|
||||
|
||||
if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) {
|
||||
protect_kernel_text_data();
|
||||
#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) && !defined(CONFIG_XIP_KERNEL)
|
||||
protect_kernel_linear_mapping_text_rodata();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SWIOTLB
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
int show_unhandled_signals = 1;
|
||||
|
||||
extern asmlinkage void handle_exception(void);
|
||||
|
||||
static DEFINE_SPINLOCK(die_lock);
|
||||
|
||||
void die(struct pt_regs *regs, const char *str)
|
||||
|
@ -135,11 +135,16 @@ void __init setup_bootmem(void)
|
||||
|
||||
/*
|
||||
* Reserve from the start of the kernel to the end of the kernel
|
||||
* and make sure we align the reservation on PMD_SIZE since we will
|
||||
*/
|
||||
#if defined(CONFIG_64BIT) && defined(CONFIG_STRICT_KERNEL_RWX)
|
||||
/*
|
||||
* Make sure we align the reservation on PMD_SIZE since we will
|
||||
* map the kernel in the linear mapping as read-only: we do not want
|
||||
* any allocation to happen between _end and the next pmd aligned page.
|
||||
*/
|
||||
memblock_reserve(vmlinux_start, (vmlinux_end - vmlinux_start + PMD_SIZE - 1) & PMD_MASK);
|
||||
vmlinux_end = (vmlinux_end + PMD_SIZE - 1) & PMD_MASK;
|
||||
#endif
|
||||
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
|
||||
|
||||
/*
|
||||
* memblock allocator is not aware of the fact that last 4K bytes of
|
||||
@ -640,7 +645,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CONFIG_64BIT) && !defined(CONFIG_XIP_KERNEL)
|
||||
#if defined(CONFIG_64BIT) && defined(CONFIG_STRICT_KERNEL_RWX)
|
||||
void protect_kernel_linear_mapping_text_rodata(void)
|
||||
{
|
||||
unsigned long text_start = (unsigned long)lm_alias(_start);
|
||||
|
Loading…
x
Reference in New Issue
Block a user