Skip to content

Commit

Permalink
Skip AMD leaf 0x8000001d parsing if no TOPEXT (#118)
Browse files Browse the repository at this point in the history
* Skip AMD leaf 0x8000001d parsing if no TOPEXT

Add flag for TopologyExtensions, use it when detecting.

Fixes #117

* Upgrade CI to Go 1.19
  • Loading branch information
klauspost committed Aug 26, 2022
1 parent b27ab7b commit 976c648
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x]
go-version: [1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v2
Expand Down
8 changes: 5 additions & 3 deletions cpuid.go
Expand Up @@ -192,6 +192,7 @@ const (
SYSCALL // System-Call Extension (SCE): SYSCALL and SYSRET instructions.
SYSEE // SYSENTER and SYSEXIT instructions
TBM // AMD Trailing Bit Manipulation
TOPEXT // TopologyExtensions: topology extensions support. Indicates support for CPUID Fn8000_001D_EAX_x[N:0]-CPUID Fn8000_001E_EDX.
TME // Intel Total Memory Encryption. The following MSRs are supported: IA32_TME_CAPABILITY, IA32_TME_ACTIVATE, IA32_TME_EXCLUDE_MASK, and IA32_TME_EXCLUDE_BASE.
TSCRATEMSR // MSR based TSC rate control. Indicates support for MSR TSC ratio MSRC000_0104
TSXLDTRK // Intel TSX Suspend Load Address Tracking
Expand Down Expand Up @@ -882,7 +883,7 @@ func (c *CPUInfo) cacheSize() {
c.Cache.L2 = int(((ecx >> 16) & 0xFFFF) * 1024)

// CPUID Fn8000_001D_EAX_x[N:0] Cache Properties
if maxExtendedFunction() < 0x8000001D {
if maxExtendedFunction() < 0x8000001D || !c.Has(TOPEXT) {
return
}

Expand Down Expand Up @@ -1180,6 +1181,7 @@ func support() flagSet {
fs.setIf((c&(1<<2)) != 0, SVM)
fs.setIf((c&(1<<6)) != 0, SSE4A)
fs.setIf((c&(1<<10)) != 0, IBS)
fs.setIf((c&(1<<22)) != 0, TOPEXT)

// EDX
fs.setIf(d&(1<<11) != 0, SYSCALL)
Expand All @@ -1195,8 +1197,8 @@ func support() flagSet {
/* XOP and FMA4 use the AVX instruction coding scheme, so they can't be
* used unless the OS has AVX support. */
if fs.inSet(AVX) {
fs.setIf((c&0x00000800) != 0, XOP)
fs.setIf((c&0x00010000) != 0, FMA4)
fs.setIf((c&(1<<11)) != 0, XOP)
fs.setIf((c&(1<<16)) != 0, FMA4)
}

}
Expand Down
93 changes: 47 additions & 46 deletions featureid_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 976c648

Please sign in to comment.