From b8ac60acc1e849d7a8c2429820dfa54fbeccaaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 20 May 2021 19:35:01 +0300 Subject: [PATCH 1/2] [cpu][linux] more info for ARM processors https://developer.arm.com/documentation/ddi0337/h/system-control/register-descriptions/cpuid-base-register--cpuid --- cpu/cpu_linux.go | 8 ++++++-- v3/cpu/cpu_linux.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index 81f1962..f3f1e24 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -141,9 +141,13 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CPU = int32(t) case "vendorId", "vendor_id": c.VendorID = value + case "CPU implementer": + if value == "0x41" { + c.VendorID = "ARM" + } case "cpu family": c.Family = value - case "model": + case "model", "CPU part": c.Model = value case "model name", "cpu": c.ModelName = value @@ -153,7 +157,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.Family = "POWER" c.VendorID = "IBM" } - case "stepping", "revision": + case "stepping", "revision", "CPU revision": val := value if key == "revision" { diff --git a/v3/cpu/cpu_linux.go b/v3/cpu/cpu_linux.go index bf6cbcf..89c5250 100644 --- a/v3/cpu/cpu_linux.go +++ b/v3/cpu/cpu_linux.go @@ -141,9 +141,13 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.CPU = int32(t) case "vendorId", "vendor_id": c.VendorID = value + case "CPU implementer": + if value == "0x41" { + c.VendorID = "ARM" + } case "cpu family": c.Family = value - case "model": + case "model", "CPU part": c.Model = value case "model name", "cpu": c.ModelName = value @@ -153,7 +157,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.Family = "POWER" c.VendorID = "IBM" } - case "stepping", "revision": + case "stepping", "revision", "CPU revision": val := value if key == "revision" { From 47f2f0eee56958670163c56f98a3598e58a08023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 30 May 2021 15:39:19 +0300 Subject: [PATCH 2/2] [cpu][linux] add more ARM hw implementers --- cpu/cpu_linux.go | 35 +++++++++++++++++++++++++++++++++-- v3/cpu/cpu_linux.go | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index f3f1e24..21006bc 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -142,8 +142,39 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { case "vendorId", "vendor_id": c.VendorID = value case "CPU implementer": - if value == "0x41" { - c.VendorID = "ARM" + if v, err := strconv.ParseUint(value, 0, 8); err == nil { + switch v { + case 0x41: + c.VendorID = "ARM" + case 0x42: + c.VendorID = "Broadcom" + case 0x43: + c.VendorID = "Cavium" + case 0x44: + c.VendorID = "DEC" + case 0x46: + c.VendorID = "Fujitsu" + case 0x48: + c.VendorID = "HiSilicon" + case 0x49: + c.VendorID = "Infineon" + case 0x4d: + c.VendorID = "Motorola/Freescale" + case 0x4e: + c.VendorID = "NVIDIA" + case 0x50: + c.VendorID = "APM" + case 0x51: + c.VendorID = "Qualcomm" + case 0x56: + c.VendorID = "Marvell" + case 0x61: + c.VendorID = "Apple" + case 0x69: + c.VendorID = "Intel" + case 0xc0: + c.VendorID = "Ampere" + } } case "cpu family": c.Family = value diff --git a/v3/cpu/cpu_linux.go b/v3/cpu/cpu_linux.go index 89c5250..54fe4d4 100644 --- a/v3/cpu/cpu_linux.go +++ b/v3/cpu/cpu_linux.go @@ -142,8 +142,39 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { case "vendorId", "vendor_id": c.VendorID = value case "CPU implementer": - if value == "0x41" { - c.VendorID = "ARM" + if v, err := strconv.ParseUint(value, 0, 8); err == nil { + switch v { + case 0x41: + c.VendorID = "ARM" + case 0x42: + c.VendorID = "Broadcom" + case 0x43: + c.VendorID = "Cavium" + case 0x44: + c.VendorID = "DEC" + case 0x46: + c.VendorID = "Fujitsu" + case 0x48: + c.VendorID = "HiSilicon" + case 0x49: + c.VendorID = "Infineon" + case 0x4d: + c.VendorID = "Motorola/Freescale" + case 0x4e: + c.VendorID = "NVIDIA" + case 0x50: + c.VendorID = "APM" + case 0x51: + c.VendorID = "Qualcomm" + case 0x56: + c.VendorID = "Marvell" + case 0x61: + c.VendorID = "Apple" + case 0x69: + c.VendorID = "Intel" + case 0xc0: + c.VendorID = "Ampere" + } } case "cpu family": c.Family = value