mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 22:45:23 +07:00
a256f2e329
Currently, various virtual memory areas of Linux RISC-V are organized in increasing order of their virtual addresses is as follows: 1. User space area (This is lowest area and starts at 0x0) 2. FIXMAP area 3. VMALLOC area 4. Kernel area (This is highest area and starts at PAGE_OFFSET) The maximum size of user space aread is represented by TASK_SIZE. On RV32 systems, TASK_SIZE is defined as VMALLOC_START which causes the user space area to overlap the FIXMAP area. This allows user space apps to potentially corrupt the FIXMAP area and kernel OF APIs will crash whenever they access corrupted FDT in the FIXMAP area. On RV64 systems, TASK_SIZE is set to fixed 256GB and no other areas happen to overlap so we don't see any FIXMAP area corruptions. This patch fixes FIXMAP area corruption on RV32 systems by setting TASK_SIZE to FIXADDR_START. We also move FIXADDR_TOP, FIXADDR_SIZE, and FIXADDR_START defines to asm/pgtable.h so that we can avoid cyclic header includes. Signed-off-by: Anup Patel <anup.patel@wdc.com> Tested-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2019 Western Digital Corporation or its affiliates.
|
|
*/
|
|
|
|
#ifndef _ASM_RISCV_FIXMAP_H
|
|
#define _ASM_RISCV_FIXMAP_H
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/sizes.h>
|
|
#include <asm/page.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
/*
|
|
* Here we define all the compile-time 'special' virtual addresses.
|
|
* The point is to have a constant address at compile time, but to
|
|
* set the physical address only in the boot process.
|
|
*
|
|
* These 'compile-time allocated' memory buffers are page-sized. Use
|
|
* set_fixmap(idx,phys) to associate physical memory with fixmap indices.
|
|
*/
|
|
enum fixed_addresses {
|
|
FIX_HOLE,
|
|
#define FIX_FDT_SIZE SZ_1M
|
|
FIX_FDT_END,
|
|
FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
|
|
FIX_PTE,
|
|
FIX_PMD,
|
|
FIX_EARLYCON_MEM_BASE,
|
|
__end_of_fixed_addresses
|
|
};
|
|
|
|
#define FIXMAP_PAGE_IO PAGE_KERNEL
|
|
|
|
#define __early_set_fixmap __set_fixmap
|
|
|
|
#define __late_set_fixmap __set_fixmap
|
|
#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
|
|
|
|
extern void __set_fixmap(enum fixed_addresses idx,
|
|
phys_addr_t phys, pgprot_t prot);
|
|
|
|
#include <asm-generic/fixmap.h>
|
|
|
|
#endif /* _ASM_RISCV_FIXMAP_H */
|