@@ -21,9 +21,11 @@ import (
2121 "sync"
2222
2323 "github.com/containerd/log"
24+ amd64variant "github.com/tonistiigi/go-archvariant"
2425)
2526
26- // Present the ARM instruction set architecture, eg: v7, v8
27+ // Present the instruction set architecture, eg: v7, v8 for ARM CPU,
28+ // v3, v4 for AMD64 CPU.
2729// Don't use this value directly; call cpuVariant() instead.
2830var cpuVariantValue string
2931
@@ -33,11 +35,34 @@ func cpuVariant() string {
3335 cpuVariantOnce .Do (func () {
3436 if isArmArch (runtime .GOARCH ) {
3537 var err error
36- cpuVariantValue , err = getCPUVariant ()
38+ cpuVariantValue , err = getArmCPUVariant ()
3739 if err != nil {
38- log .L .Errorf ("Error getCPUVariant for OS %s: %v" , runtime .GOOS , err )
40+ log .L .Errorf ("Error getArmCPUVariant for OS %s: %v" , runtime .GOOS , err )
3941 }
4042 }
4143 })
4244 return cpuVariantValue
4345}
46+
47+ func cpuVariantMaximum () string {
48+ cpuVariantOnce .Do (func () {
49+ if isArmArch (runtime .GOARCH ) {
50+ var err error
51+ cpuVariantValue , err = getArmCPUVariant ()
52+ if err != nil {
53+ log .L .Errorf ("Error getArmCPUVariant for OS %s: %v" , runtime .GOOS , err )
54+ }
55+ } else if isAmd64Arch (runtime .GOARCH ) {
56+ var err error
57+ cpuVariantValue , err = getAmd64MicroArchLevel ()
58+ if err != nil {
59+ log .L .Errorf ("Error getAmd64MicroArchLevel for OS %s: %v" , runtime .GOOS , err )
60+ }
61+ }
62+ })
63+ return cpuVariantValue
64+ }
65+
66+ func getAmd64MicroArchLevel () (string , error ) {
67+ return amd64variant .AMD64Variant (), nil
68+ }
0 commit comments