From 2fc9372c0d13f96e8bc3326fdcbb55624b664879 Mon Sep 17 00:00:00 2001 From: Wang Zhimin Date: Wed, 2 Apr 2025 22:53:13 -0400 Subject: [PATCH] anolis: mm: Add quirk for phytium ps23064 SoC ANBZ: #20068 Enabling KASAN in the Phytium ps23064 SoC will result in a reduction in linear mapping space, leading to a failure and panic in allocating percpu variables. This patch avoid this problem throuth removing high physical addresses, but it should be note that device should not be attach to die 5-7. Signed-off-by: Huang Shaobo Signed-off-by: Wang Zhimin --- arch/arm64/include/asm/cputype.h | 2 ++ arch/arm64/mm/init.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index 9b390f1b5920..5403eb3adde8 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -100,6 +100,7 @@ #define PHYTIUM_CPU_PART_2000PLUS 0x662 #define PHYTIUM_CPU_PART_2004 0x663 #define PHYTIUM_CPU_PART_2500 0x663 +#define PHYTIUM_CPU_PART_FTC862 0x862 #define CAVIUM_CPU_PART_THUNDERX 0x0A1 #define CAVIUM_CPU_PART_THUNDERX_81XX 0x0A2 @@ -153,6 +154,7 @@ #define MIDR_FT_2004 MIDR_CPU_MODEL(ARM_CPU_IMP_PHYTIUM, PHYTIUM_CPU_PART_2004) #define MIDR_FT_2500 MIDR_CPU_MODEL(ARM_CPU_IMP_PHYTIUM, PHYTIUM_CPU_PART_2500) #define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1) +#define MIDR_PHYTIUM_FTC862 MIDR_CPU_MODEL(ARM_CPU_IMP_PHYTIUM, PHYTIUM_CPU_PART_FTC862) #ifndef __ASSEMBLY__ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index e8f3ff4c8658..09f06599a518 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -459,6 +459,19 @@ static void __init fdt_enforce_memory_region(void) memblock_cap_memory_ranges(usablemem.regions, usablemem.cnt); } +#ifdef CONFIG_ARCH_PHYTIUM +#define SOCID_PS23064 0x8 +#define RMV_PS23064 0x510783f00000 +static inline void phytium_ps23064_quirk(void) +{ + if (read_sysreg_s(SYS_AIDR_EL1) == SOCID_PS23064 && + read_cpuid_id() == MIDR_PHYTIUM_FTC862) { + pr_warn("Enable Phytium S5000C-128 Core quirk\n"); + memblock_remove(RMV_PS23064, (1ULL << PHYS_MASK_SHIFT) - RMV_PS23064); + } +} +#endif + void __init arm64_memblock_init(void) { const s64 linear_region_size = -(s64)PAGE_OFFSET; @@ -468,7 +481,10 @@ void __init arm64_memblock_init(void) /* Remove memory above our supported physical address size */ memblock_remove(1ULL << PHYS_MASK_SHIFT, ULLONG_MAX); - +#ifdef CONFIG_ARCH_PHYTIUM + if (IS_ENABLED(CONFIG_KASAN)) + phytium_ps23064_quirk(); +#endif /* * Ensure that the linear region takes up exactly half of the kernel * virtual address space. This way, we can distinguish a linear address -- Gitee