mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
cpuid: handle CPUID(0x80000006): L2 cache information
Fixes: #7341 Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
@@ -56,6 +56,23 @@ func TestHostFeatureSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFixedExtendedState(t *testing.T) {
|
||||
hostFeatures := HostFeatureSet()
|
||||
fixedFeatures := hostFeatures.Fixed()
|
||||
for i, allowed := range allowedBasicFunctions {
|
||||
if !allowed {
|
||||
continue
|
||||
}
|
||||
in := In{Eax: uint32(i) + uint32(extendedStart)}
|
||||
h := hostFeatures.Query(in)
|
||||
f := fixedFeatures.Query(in)
|
||||
if h != f {
|
||||
t.Errorf("native: %x fixed: %x", h, f)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestHasFeature(t *testing.T) {
|
||||
if !justFPU.HasFeature(X86FeatureFPU) {
|
||||
t.Errorf("HasFeature failed, %q should contain %v", justFPU.FlagString(), X86FeatureFPU)
|
||||
|
||||
@@ -62,10 +62,15 @@ const xSaveInfoNumLeaves = 64 // Maximum number of xSaveInfo leaves.
|
||||
|
||||
// The "extended" functions.
|
||||
const (
|
||||
extendedStart cpuidFunction = 0x80000000
|
||||
extendedFunctionInfo cpuidFunction = extendedStart + 0 // Returns highest available extended function in eax.
|
||||
extendedFeatures = extendedStart + 1 // Returns some extended feature bits in edx and ecx.
|
||||
addressSizes = extendedStart + 8 // Physical and virtual address sizes.
|
||||
extendedStart cpuidFunction = 0x80000000
|
||||
extendedFunctionInfo cpuidFunction = extendedStart + 0 // Returns highest available extended function in eax.
|
||||
extendedFeatures = extendedStart + 1 // Returns some extended feature bits in edx and ecx.
|
||||
processorBrandString2 = extendedStart + 2 // Processor Name String Identifier.
|
||||
processorBrandString3 = extendedStart + 3 // Processor Name String Identifier.
|
||||
processorBrandString4 = extendedStart + 4 // Processor Name String Identifier.
|
||||
l1CacheAndTLBInfo = extendedStart + 5 // Returns L2 cache information.
|
||||
l2CacheInfo = extendedStart + 6 // Returns L2 cache information.
|
||||
addressSizes = extendedStart + 8 // Physical and virtual address sizes.
|
||||
)
|
||||
|
||||
var allowedBasicFunctions = [...]bool{
|
||||
@@ -78,9 +83,14 @@ var allowedBasicFunctions = [...]bool{
|
||||
}
|
||||
|
||||
var allowedExtendedFunctions = [...]bool{
|
||||
extendedFunctionInfo - extendedStart: true,
|
||||
extendedFeatures - extendedStart: true,
|
||||
addressSizes - extendedStart: true,
|
||||
extendedFunctionInfo - extendedStart: true,
|
||||
extendedFeatures - extendedStart: true,
|
||||
addressSizes - extendedStart: true,
|
||||
processorBrandString2 - extendedStart: true,
|
||||
processorBrandString3 - extendedStart: true,
|
||||
processorBrandString4 - extendedStart: true,
|
||||
l1CacheAndTLBInfo - extendedStart: true,
|
||||
l2CacheInfo - extendedStart: true,
|
||||
}
|
||||
|
||||
// Function executes a CPUID function.
|
||||
@@ -108,6 +118,8 @@ func (i *In) normalize() {
|
||||
switch cpuidFunction(i.Eax) {
|
||||
case vendorID, featureInfo, intelCacheDescriptors, extendedFunctionInfo, extendedFeatures:
|
||||
i.Ecx = 0 // Ignore.
|
||||
case processorBrandString2, processorBrandString3, processorBrandString4, l1CacheAndTLBInfo, l2CacheInfo:
|
||||
i.Ecx = 0 // Ignore.
|
||||
case intelDeterministicCacheParams, extendedFeatureInfo:
|
||||
// Preserve i.Ecx.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user