Skip to content

Commit

Permalink
Merge tag 'riscv/for-v5.3-rc7' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Aug 31, 2019
2 parents 834354f + a256f2e commit 7fb8670
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions arch/riscv/include/asm/fixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ enum fixed_addresses {
__end_of_fixed_addresses
};

#define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE)
#define FIXADDR_TOP (VMALLOC_START)
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)

#define FIXMAP_PAGE_IO PAGE_KERNEL

#define __early_set_fixmap __set_fixmap
Expand Down
12 changes: 10 additions & 2 deletions arch/riscv/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,22 @@ static inline void pgtable_cache_init(void)
#define VMALLOC_END (PAGE_OFFSET - 1)
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)

#define FIXADDR_TOP VMALLOC_START
#ifdef CONFIG_64BIT
#define FIXADDR_SIZE PMD_SIZE
#else
#define FIXADDR_SIZE PGDIR_SIZE
#endif
#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)

/*
* Task size is 0x4000000000 for RV64 or 0xb800000 for RV32.
* Task size is 0x4000000000 for RV64 or 0x9fc00000 for RV32.
* Note that PGDIR_SIZE must evenly divide TASK_SIZE.
*/
#ifdef CONFIG_64BIT
#define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2)
#else
#define TASK_SIZE VMALLOC_START
#define TASK_SIZE FIXADDR_START
#endif

#include <asm-generic/pgtable.h>
Expand Down

0 comments on commit 7fb8670

Please sign in to comment.