gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/cpuid/cpuid_parse_amd64_test.go (about)

     1  // Copyright 2019 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  //go:build amd64
    16  // +build amd64
    17  
    18  package cpuid
    19  
    20  import "gvisor.dev/gvisor/pkg/hostos"
    21  
    22  func archSkipFeature(feature Feature, version hostos.Version) bool {
    23  	switch {
    24  	// Block 0.
    25  	case feature == X86FeatureSDBG && version.AtLeast(4, 3):
    26  		// SDBG only exposed in
    27  		// b1c599b8ff80ea79b9f8277a3f9f36a7b0cfedce (4.3).
    28  		return true
    29  	// Block 2.
    30  	case feature == X86FeatureRDT && version.AtLeast(4, 10):
    31  		// RDT only exposed in
    32  		// 4ab1586488cb56ed8728e54c4157cc38646874d9 (4.10).
    33  		return true
    34  	// Block 3.
    35  	case feature == X86FeatureAVX512VBMI && version.AtLeast(4, 10):
    36  		// AVX512VBMI only exposed in
    37  		// a8d9df5a509a232a959e4ef2e281f7ecd77810d6 (4.10).
    38  		return true
    39  	case feature == X86FeatureUMIP && version.AtLeast(4, 15):
    40  		// UMIP only exposed in
    41  		// 3522c2a6a4f341058b8291326a945e2a2d2aaf55 (4.15).
    42  		return true
    43  	case feature == X86FeaturePKU && version.AtLeast(4, 9):
    44  		// PKU only exposed in
    45  		// dfb4a70f20c5b3880da56ee4c9484bdb4e8f1e65 (4.9).
    46  		return true
    47  	// Block 4.
    48  	case feature == X86FeatureXSAVES && version.AtLeast(4, 8):
    49  		// XSAVES only exposed in
    50  		// b8be15d588060a03569ac85dc4a0247460988f5b (4.8).
    51  		return true
    52  	// Block 5.
    53  	case feature == X86FeaturePERFCTR_LLC && version.AtLeast(4, 14):
    54  		// PERFCTR_LLC renamed in
    55  		// 910448bbed066ab1082b510eef1ae61bb792d854 (4.14).
    56  		return true
    57  	// Block 7.
    58  	case feature == X86FeatureARCH_CAPABILITIES:
    59  		// This feature is sometimes added by CPU microcode loaded by the
    60  		// kernel, in which case it will appear in CPUID but not /proc/cpuinfo.
    61  		// This can be detected from a "x86/CPU: CPU features have changed
    62  		// after loading microcode, but might not take effect" message printed
    63  		// to dmesg by arch/x86/kernel/cpu/common.c:microcode_check().
    64  		return true
    65  	default:
    66  		return false
    67  	}
    68  }