Skip to content

Commit 7fb8670

Browse files
committed
Merge tag 'riscv/for-v5.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fix from Paul Walmsley: "One significant fix for 32-bit RISC-V systems: Fix the RV32 memory map to prevent userspace from corrupting the FIXMAP area. Without this patch, the system can crash very early during the boot" * tag 'riscv/for-v5.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: RISC-V: Fix FIXMAP area corruption on RV32 systems
2 parents 834354f + a256f2e commit 7fb8670

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

arch/riscv/include/asm/fixmap.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ enum fixed_addresses {
3030
__end_of_fixed_addresses
3131
};
3232

33-
#define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE)
34-
#define FIXADDR_TOP (VMALLOC_START)
35-
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
36-
3733
#define FIXMAP_PAGE_IO PAGE_KERNEL
3834

3935
#define __early_set_fixmap __set_fixmap

arch/riscv/include/asm/pgtable.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,22 @@ static inline void pgtable_cache_init(void)
420420
#define VMALLOC_END (PAGE_OFFSET - 1)
421421
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
422422

423+
#define FIXADDR_TOP VMALLOC_START
424+
#ifdef CONFIG_64BIT
425+
#define FIXADDR_SIZE PMD_SIZE
426+
#else
427+
#define FIXADDR_SIZE PGDIR_SIZE
428+
#endif
429+
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
430+
423431
/*
424-
* Task size is 0x4000000000 for RV64 or 0xb800000 for RV32.
432+
* Task size is 0x4000000000 for RV64 or 0x9fc00000 for RV32.
425433
* Note that PGDIR_SIZE must evenly divide TASK_SIZE.
426434
*/
427435
#ifdef CONFIG_64BIT
428436
#define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2)
429437
#else
430-
#define TASK_SIZE VMALLOC_START
438+
#define TASK_SIZE FIXADDR_START
431439
#endif
432440

433441
#include <asm-generic/pgtable.h>

0 commit comments

Comments
 (0)