From 6560f208abd9e031363f8dea5e21c72a8a1825bf Mon Sep 17 00:00:00 2001 From: Wang Zhimin Date: Wed, 2 Apr 2025 22:39:43 -0400 Subject: [PATCH] anolis: mm: Add quirk for phytium ps23064 SoC ANBZ: #20067 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 3f5ccf2b5c02..11d95cb69431 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -92,6 +92,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 @@ -181,6 +182,7 @@ #define MIDR_FT_2000PLUS MIDR_CPU_MODEL(ARM_CPU_IMP_PHYTIUM, PHYTIUM_CPU_PART_2000PLUS) #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_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 96f870e83062..7f2c3a123323 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -390,6 +390,19 @@ static void __init fdt_enforce_memory_region(void) memblock_add(rgn[i].base, rgn[i].size); } +#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 = BIT(vabits_actual - 1); @@ -399,7 +412,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 /* * Select a suitable value for the base of physical memory. */ -- Gitee