From 5c35db4324e01a80a7edfa4ee4b77da83ee7d5d1 Mon Sep 17 00:00:00 2001 From: Naresh Solanki Date: Thu, 6 Mar 2025 23:22:28 +0530 Subject: [PATCH] arch/x86/smbios: Enhance processor characteristics detection Improve SMBIOS Type 4 table processor characteristic detection for following: PROCESSOR_MULTI_CORE PROCESSOR_64BIT_CAPABLE PROCESSOR_ENHANCED_VIRTUALIZATION PROCESSOR_POWER_PERFORMANCE_CONTROL Based on following reference: 1. AMD APM 24594 Appendix E (Obtaining Processor Information Via the CPUID Instruction) 2. Intel SDM 325462 Table 3-17(Information Returned by CPUID Instruction) TEST=Build for Glinda SoC & Intel SPR & verified in 'dmidecode -t 4' output. Sample output: Characteristics: 64-bit capable Multi-Core Hardware Thread Execute Protection Enhanced Virtualization Power/Performance Control Change-Id: I2a05724a791ef1df55aa3a759a2dc4b2c69222b3 Signed-off-by: Naresh Solanki Reviewed-on: https://review.coreboot.org/c/coreboot/+/86755 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Rudolph Reviewed-by: Shuo Liu --- src/arch/x86/smbios.c | 29 ++++++++++++++++++++++++++--- src/include/smbios.h | 3 +++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 97d5f24256..a59998e3c0 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -176,17 +176,40 @@ int smbios_write_type4(unsigned long *current, int handle) if (cpu_have_cpuid()) { res = cpuid(1); + if (((res.ebx >> 16) & 0xff) > 1) + characteristics |= PROCESSOR_MULTI_CORE; + if ((res.ecx) & BIT(5)) - characteristics |= BIT(6); /* BIT6: Enhanced Virtualization */ + characteristics |= PROCESSOR_ENHANCED_VIRTUALIZATION; if ((res.edx) & BIT(28)) - characteristics |= BIT(4); /* BIT4: Hardware Thread */ + characteristics |= PROCESSOR_HARDWARE_THREAD; + + if (CONFIG(SOC_INTEL_COMMON) && cpu_cpuid_extended_level() >= 6) { + res = cpuid(6); + if ((res.eax) & BIT(7)) /* Intel HWP*/ + characteristics |= PROCESSOR_POWER_PERFORMANCE_CONTROL; + } if (cpu_cpuid_extended_level() >= 0x80000001) { res = cpuid(0x80000001); if ((res.edx) & BIT(20)) - characteristics |= BIT(5); /* BIT5: Execute Protection */ + characteristics |= PROCESSOR_EXECUTE_PROTECTION; + + if ((res.edx) & BIT(29)) + characteristics |= PROCESSOR_64BIT_CAPABLE; + + /* AMD SVM */ + if (CONFIG(SOC_AMD_COMMON) && (res.ecx) & BIT(2)) + characteristics |= PROCESSOR_ENHANCED_VIRTUALIZATION; + } + + if (CONFIG(SOC_AMD_COMMON) && cpu_cpuid_extended_level() >= 0x80000007) { + res = cpuid(0x80000007); + + if ((res.edx) & BIT(7)) /* Hardware P-state control */ + characteristics |= PROCESSOR_POWER_PERFORMANCE_CONTROL; } } t->processor_characteristics = characteristics | smbios_processor_characteristics(); diff --git a/src/include/smbios.h b/src/include/smbios.h index fd44e098d4..353c3cf40b 100644 --- a/src/include/smbios.h +++ b/src/include/smbios.h @@ -597,6 +597,9 @@ enum smbios_processor_upgrade_field { /* defines for processor characteristics */ #define PROCESSOR_64BIT_CAPABLE (1 << 2) #define PROCESSOR_MULTI_CORE (1 << 3) +#define PROCESSOR_HARDWARE_THREAD (1 << 4) +#define PROCESSOR_EXECUTE_PROTECTION (1 << 5) +#define PROCESSOR_ENHANCED_VIRTUALIZATION (1 << 6) #define PROCESSOR_POWER_PERFORMANCE_CONTROL (1 << 7) /* defines for supported_sram_type/current_sram_type */