Skip to content

Commit 976c648

Browse files
authored
Skip AMD leaf 0x8000001d parsing if no TOPEXT (#118)
* Skip AMD leaf 0x8000001d parsing if no TOPEXT Add flag for TopologyExtensions, use it when detecting. Fixes #117 * Upgrade CI to Go 1.19
1 parent b27ab7b commit 976c648

3 files changed

Lines changed: 54 additions & 51 deletions

File tree

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
go-version: [1.16.x, 1.17.x, 1.18.x]
13+
go-version: [1.17.x, 1.18.x, 1.19.x]
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
runs-on: ubuntu-latest
1616
steps:
@@ -38,7 +38,7 @@ jobs:
3838
- name: Set up Go
3939
uses: actions/setup-go@v2
4040
with:
41-
go-version: 1.18.x
41+
go-version: 1.19.x
4242

4343
- name: Checkout code
4444
uses: actions/checkout@v2

cpuid.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ const (
192192
SYSCALL // System-Call Extension (SCE): SYSCALL and SYSRET instructions.
193193
SYSEE // SYSENTER and SYSEXIT instructions
194194
TBM // AMD Trailing Bit Manipulation
195+
TOPEXT // TopologyExtensions: topology extensions support. Indicates support for CPUID Fn8000_001D_EAX_x[N:0]-CPUID Fn8000_001E_EDX.
195196
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.
196197
TSCRATEMSR // MSR based TSC rate control. Indicates support for MSR TSC ratio MSRC000_0104
197198
TSXLDTRK // Intel TSX Suspend Load Address Tracking
@@ -882,7 +883,7 @@ func (c *CPUInfo) cacheSize() {
882883
c.Cache.L2 = int(((ecx >> 16) & 0xFFFF) * 1024)
883884

884885
// CPUID Fn8000_001D_EAX_x[N:0] Cache Properties
885-
if maxExtendedFunction() < 0x8000001D {
886+
if maxExtendedFunction() < 0x8000001D || !c.Has(TOPEXT) {
886887
return
887888
}
888889

@@ -1180,6 +1181,7 @@ func support() flagSet {
11801181
fs.setIf((c&(1<<2)) != 0, SVM)
11811182
fs.setIf((c&(1<<6)) != 0, SSE4A)
11821183
fs.setIf((c&(1<<10)) != 0, IBS)
1184+
fs.setIf((c&(1<<22)) != 0, TOPEXT)
11831185

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

12021204
}

featureid_string.go

Lines changed: 47 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)