@@ -20,6 +20,7 @@ const (
2020 msvm // Microsoft Hyper-V or Windows Virtual PC
2121 vmware
2222 xenhvm
23+ hygon
2324)
2425
2526const (
@@ -466,6 +467,11 @@ func (c cpuInfo) amd() bool {
466467 return c .vendorid == amd
467468}
468469
470+ // Hygon returns true if vendor is recognized as Hygon
471+ func (c cpuInfo ) hygon () bool {
472+ return c .vendorid == hygon
473+ }
474+
469475// Transmeta returns true if vendor is recognized as Transmeta
470476func (c cpuInfo ) transmeta () bool {
471477 return c .vendorid == transmeta
@@ -619,7 +625,7 @@ func logicalCores() int {
619625 }
620626 _ , b , _ , _ := cpuidex (0xb , 1 )
621627 return int (b & 0xffff )
622- case amd :
628+ case amd , hygon :
623629 _ , b , _ , _ := cpuid (1 )
624630 return int ((b >> 16 ) & 0xff )
625631 default :
@@ -641,7 +647,7 @@ func physicalCores() int {
641647 switch vendorID () {
642648 case intel :
643649 return logicalCores () / threadsPerCore ()
644- case amd :
650+ case amd , hygon :
645651 if maxExtendedFunction () >= 0x80000008 {
646652 _ , _ , c , _ := cpuid (0x80000008 )
647653 return int (c & 0xff ) + 1
@@ -664,6 +670,7 @@ var vendorMapping = map[string]vendor{
664670 "Microsoft Hv" : msvm ,
665671 "VMwareVMware" : vmware ,
666672 "XenVMMXenVMM" : xenhvm ,
673+ "HygonGenuine" : hygon ,
667674}
668675
669676func vendorID () vendor {
@@ -736,7 +743,7 @@ func (c *cpuInfo) cacheSize() {
736743 c .cache .l3 = size
737744 }
738745 }
739- case amd :
746+ case amd , hygon :
740747 // Untested.
741748 if maxExtendedFunction () < 0x80000005 {
742749 return
0 commit comments