From 78927ca072358ec095006d997c2ed36ecb203da3 Mon Sep 17 00:00:00 2001 From: Wenhui Fan Date: Wed, 19 Nov 2025 16:55:03 +0800 Subject: [PATCH] anolis: x86/cpu: Get CPU LLC ID from CPUID 0x8000001d in guest for Hygon processors ANBZ: #27296 In virtualization environments, LLC ID should be obtained directly from CPUID 0x8000001D instead of deriving it from fixed APIC ID bit offsets. This approach ensures accurate LLC ID in virtual machines. Hygon-SIG: commit none hygon anolis: x86/cpu: Get CPU LLC ID from CPUID 0x8000001d in guest for Hygon processors Signed-off-by: Wenhui Fan Cc: hygon-arch@list.openanolis.cn --- arch/x86/kernel/cpu/cacheinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c index 27f83c5b8f2f..1a8d93a08467 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -693,8 +693,9 @@ void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c, int cpu) if (!cpuid_edx(0x80000006)) return; - if (c->x86_model < 0x5 || - (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) { + if ((c->x86_model < 0x5 || + (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) && + !boot_cpu_has(X86_FEATURE_HYPERVISOR)) { /* * LLC is at the core complex level. * Core complex ID is ApicId[3] for these processors. -- Gitee