From 7c3c2b05f38f20ddd5be5e5f2d5828c36ba95528 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Thu, 27 Jul 2023 10:44:34 -0500 Subject: [PATCH] arch-x86: Add extended state CPUID function The extended state CPUID function is used to set the values of the XCR0 register as well as specify the size of storage for context switching storage for x87 and AVX+. This function is iterative and therefore requires (1) marking it as such in the hsaSignificantIndex function (2) setting multiple sets of 4-tuples for the default CPUID values where the last 4-tuple ends with all zeros. Change-Id: Ib6a43925afb1cae75f61d8acff52a3cc26ce17c8 --- src/arch/x86/X86ISA.py | 14 ++++++++++++++ src/arch/x86/cpuid.cc | 12 ++++++++++++ src/arch/x86/cpuid.hh | 1 + src/arch/x86/isa.cc | 1 + 4 files changed, 28 insertions(+) diff --git a/src/arch/x86/X86ISA.py b/src/arch/x86/X86ISA.py index aa5c29a98e..aa48d1aa6e 100644 --- a/src/arch/x86/X86ISA.py +++ b/src/arch/x86/X86ISA.py @@ -85,6 +85,20 @@ class X86ISA(BaseISA): ExtendedFeatures = VectorParam.UInt32( [0x00000000, 0x01800000, 0x00000000, 0x00000000], "feature flags" ) + # 0000_000Dh - This uses ECX index, so the last entry must be all zeros + ExtendedState = VectorParam.UInt32( + [ + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + ], + "extended state enumeration", + ) # 8000_0001h FamilyModelSteppingBrandFeatures = VectorParam.UInt32( [0x00020F51, 0x00000405, 0xEBD3FBFF, 0x00020001], diff --git a/src/arch/x86/cpuid.cc b/src/arch/x86/cpuid.cc index 75e69735c1..2ce9ec9289 100644 --- a/src/arch/x86/cpuid.cc +++ b/src/arch/x86/cpuid.cc @@ -146,6 +146,18 @@ X86CPUID::stringToRegister(const char *str) bool X86CPUID::hasSignificantIndex(uint32_t function) { + uint16_t family = bits(function, 31, 16); + uint16_t funcNum = bits(function, 15, 0); + + if (family == 0x0000) { + switch (funcNum) { + case ExtendedState: + return true; + default: + return false; + } + } + return false; } diff --git a/src/arch/x86/cpuid.hh b/src/arch/x86/cpuid.hh index 71e8d3c626..1c932980d2 100644 --- a/src/arch/x86/cpuid.hh +++ b/src/arch/x86/cpuid.hh @@ -52,6 +52,7 @@ enum StandardCpuidFunction MonitorMwait, ThermalPowerMgmt, ExtendedFeatures, + ExtendedState = 0xD, NumStandardCpuidFuncs }; diff --git a/src/arch/x86/isa.cc b/src/arch/x86/isa.cc index cf1ff9f593..9e6082a268 100644 --- a/src/arch/x86/isa.cc +++ b/src/arch/x86/isa.cc @@ -157,6 +157,7 @@ ISA::ISA(const X86ISAParams &p) cpuid->addStandardFunc(FamilyModelStepping, p.FamilyModelStepping); cpuid->addStandardFunc(CacheParams, p.CacheParams); cpuid->addStandardFunc(ExtendedFeatures, p.ExtendedFeatures); + cpuid->addStandardFunc(ExtendedState, p.ExtendedState); cpuid->addExtendedFunc(FamilyModelSteppingBrandFeatures, p.FamilyModelSteppingBrandFeatures);