diff options
Diffstat (limited to 'pkg/cpuid/cpuid_x86.go')
-rw-r--r-- | pkg/cpuid/cpuid_x86.go | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/pkg/cpuid/cpuid_x86.go b/pkg/cpuid/cpuid_x86.go index 333ca0a04..562f8f405 100644 --- a/pkg/cpuid/cpuid_x86.go +++ b/pkg/cpuid/cpuid_x86.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build i386 amd64 +// +build 386 amd64 package cpuid @@ -235,7 +235,9 @@ const ( X86FeaturePERFCTR_TSC X86FeaturePERFCTR_LLC X86FeatureMWAITX - // ECX[31:30] are reserved. + // TODO(b/152776797): Some CPUs set this but it is not documented anywhere. + X86FeatureBlock5Bit30 + _ // ecx bit 31 is reserved. ) // Block 6 constants are the extended feature bits in @@ -438,6 +440,9 @@ var x86FeatureParseOnlyStrings = map[Feature]string{ // Block 3. X86FeaturePREFETCHWT1: "prefetchwt1", + + // Block 5. + X86FeatureBlock5Bit30: "block5_bit30", } // intelCacheDescriptors describe the caches and TLBs on the system. They are @@ -725,6 +730,18 @@ func vendorIDFromRegs(bx, cx, dx uint32) string { return string(bytes) } +var maxXsaveSize = func() uint32 { + // Leaf 0 of xsaveinfo function returns the size for currently + // enabled xsave features in ebx, the maximum size if all valid + // features are saved with xsave in ecx, and valid XCR0 bits in + // edx:eax. + // + // If xSaveInfo isn't supported, cpuid will not fault but will + // return bogus values. + _, _, maxXsaveSize, _ := HostID(uint32(xSaveInfo), 0) + return maxXsaveSize +}() + // ExtendedStateSize returns the number of bytes needed to save the "extended // state" for this processor and the boundary it must be aligned to. Extended // state includes floating point registers, and other cpu state that's not @@ -736,12 +753,7 @@ func vendorIDFromRegs(bx, cx, dx uint32) string { // about 2.5K worst case, with avx512). func (fs *FeatureSet) ExtendedStateSize() (size, align uint) { if fs.UseXsave() { - // Leaf 0 of xsaveinfo function returns the size for currently - // enabled xsave features in ebx, the maximum size if all valid - // features are saved with xsave in ecx, and valid XCR0 bits in - // edx:eax. - _, _, maxSize, _ := HostID(uint32(xSaveInfo), 0) - return uint(maxSize), 64 + return uint(maxXsaveSize), 64 } // If we don't support xsave, we fall back to fxsave, which requires |