diff options
author | Palmer Dabbelt <palmerdabbelt@google.com> | 2021-06-01 21:17:08 -0700 |
---|---|---|
committer | Palmer Dabbelt <palmerdabbelt@google.com> | 2021-06-01 21:17:08 -0700 |
commit | 160ce364167fabf8df5bebfff1b38fd5d8c146c9 (patch) | |
tree | 4dd0ae0b32d22a2a31348b489e42adf0980d27f0 /arch | |
parent | da2d48808fbd1eddefefe245c6c0e92a9195df8b (diff) | |
parent | 8a4102a0cf07cc76a18f373f6b49485258cc6af4 (diff) | |
download | linux-stable-160ce364167fabf8df5bebfff1b38fd5d8c146c9.tar.gz linux-stable-160ce364167fabf8df5bebfff1b38fd5d8c146c9.tar.bz2 linux-stable-160ce364167fabf8df5bebfff1b38fd5d8c146c9.zip |
Merge remote-tracking branch 'riscv/riscv-wx-mappings' into fixes
This single commit is shared between fixes and for-next, as it fixes a
concrete bug while likely conflicting with a more invasive cleanup to
avoid these oddball mappings entirely.
* riscv/riscv-wx-mappings:
riscv: mm: Fix W+X mappings at boot
Diffstat (limited to 'arch')
-rw-r--r-- | arch/riscv/mm/init.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 4faf8bd157ea..4c4c92ce0bb8 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -746,14 +746,18 @@ void __init protect_kernel_text_data(void) unsigned long init_data_start = (unsigned long)__init_data_begin; unsigned long rodata_start = (unsigned long)__start_rodata; unsigned long data_start = (unsigned long)_data; - unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); +#if defined(CONFIG_64BIT) && defined(CONFIG_MMU) + unsigned long end_va = kernel_virt_addr + load_sz; +#else + unsigned long end_va = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); +#endif set_memory_ro(text_start, (init_text_start - text_start) >> PAGE_SHIFT); set_memory_ro(init_text_start, (init_data_start - init_text_start) >> PAGE_SHIFT); set_memory_nx(init_data_start, (rodata_start - init_data_start) >> PAGE_SHIFT); /* rodata section is marked readonly in mark_rodata_ro */ set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); - set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT); + set_memory_nx(data_start, (end_va - data_start) >> PAGE_SHIFT); } void mark_rodata_ro(void) |