mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 06:23:17 +07:00
b089c31c51
To cope with the variety in ARM architectures and configurations, the pagetable attributes for kernel memory are generated at runtime to match the system the kernel finds itself on. This calculated value is stored in pgprot_kernel. However, when early fixmap support was added for ARM (commita5f4c561b3
) the attributes used for mappings were hard coded because pgprot_kernel is not set up early enough. Unfortunately, when fixmap is used after early boot this means the memory being mapped can have different attributes to existing mappings, potentially leading to unpredictable behaviour. A specific problem also exists due to the hard coded values not include the 'shareable' attribute which means on systems where this matters (e.g. those with multiple CPU clusters) the cache contents for a memory location can become inconsistent between CPUs. To resolve these issues we change fixmap to use the same memory attributes (from pgprot_kernel) that the rest of the kernel uses. To enable this we need to refactor the initialisation code so build_mem_type_table() is called early enough. Note, that relies on early param parsing for memory type overrides passed via the kernel command line, so we need to make sure this call is still after parse_early_params(). [ardb: keep early_fixmap_init() before param parsing, for earlycon] Fixes:a5f4c561b3
("ARM: 8415/1: early fixmap support for earlycon") Cc: <stable@vger.kernel.org> # v4.3+ Tested-by: afzal mohammed <afzal.mohd.ma@gmail.com> Signed-off-by: Jon Medhurst <tixy@linaro.org> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
66 lines
1.8 KiB
C
66 lines
1.8 KiB
C
#ifndef _ASM_FIXMAP_H
|
|
#define _ASM_FIXMAP_H
|
|
|
|
#define FIXADDR_START 0xffc00000UL
|
|
#define FIXADDR_END 0xfff00000UL
|
|
#define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE)
|
|
|
|
#include <asm/kmap_types.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
enum fixed_addresses {
|
|
FIX_EARLYCON_MEM_BASE,
|
|
__end_of_permanent_fixed_addresses,
|
|
|
|
FIX_KMAP_BEGIN = __end_of_permanent_fixed_addresses,
|
|
FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
|
|
|
|
/* Support writing RO kernel text via kprobes, jump labels, etc. */
|
|
FIX_TEXT_POKE0,
|
|
FIX_TEXT_POKE1,
|
|
|
|
__end_of_fixmap_region,
|
|
|
|
/*
|
|
* Share the kmap() region with early_ioremap(): this is guaranteed
|
|
* not to clash since early_ioremap() is only available before
|
|
* paging_init(), and kmap() only after.
|
|
*/
|
|
#define NR_FIX_BTMAPS 32
|
|
#define FIX_BTMAPS_SLOTS 7
|
|
#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
|
|
|
|
FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
|
|
FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
|
|
__end_of_early_ioremap_region
|
|
};
|
|
|
|
static const enum fixed_addresses __end_of_fixed_addresses =
|
|
__end_of_fixmap_region > __end_of_early_ioremap_region ?
|
|
__end_of_fixmap_region : __end_of_early_ioremap_region;
|
|
|
|
#define FIXMAP_PAGE_COMMON (L_PTE_YOUNG | L_PTE_PRESENT | L_PTE_XN | L_PTE_DIRTY)
|
|
|
|
#define FIXMAP_PAGE_NORMAL (pgprot_kernel | L_PTE_XN)
|
|
#define FIXMAP_PAGE_RO (FIXMAP_PAGE_NORMAL | L_PTE_RDONLY)
|
|
|
|
/* Used by set_fixmap_(io|nocache), both meant for mapping a device */
|
|
#define FIXMAP_PAGE_IO (FIXMAP_PAGE_COMMON | L_PTE_MT_DEV_SHARED | L_PTE_SHARED)
|
|
#define FIXMAP_PAGE_NOCACHE FIXMAP_PAGE_IO
|
|
|
|
#define __early_set_fixmap __set_fixmap
|
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
|
|
void __init early_fixmap_init(void);
|
|
|
|
#include <asm-generic/fixmap.h>
|
|
|
|
#else
|
|
|
|
static inline void early_fixmap_init(void) { }
|
|
|
|
#endif
|
|
#endif
|