Subject: bug#74731: guix/cpu should parse /sys/devices/system/cpu/modalias

From: Efraim Flashner <[email-masked]>
Date: Sun, 8 Dec 2024 09:25:59 +0200

I saw a post by Marcan¹ of Asahi Linux the other day about not parsing
/proc/cpuinfo and remembered that's what we're doing in (guix cpu).

I've included a couple of dumps below and some notes regarding future
implementation:

// My machine
(ins)efraim@3900XT ~$ cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0002fam0017mod0071:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0017,0018,0019,001A,001C,0020,0021,0022,0023,0024,0025,0026,0027,0028,0029,002B,002C,002D,002E,002F,0030,0031,0034,0036,0037,0038,0039,003A,003B,003D,0064,0068,006E,0070,0074,0075,0076,0078,0079,007A,007C,007D,0080,0081,0083,0089,008C,008D,0093,0094,0095,0096,0097,0099,009A,009B,009C,009D,009E,00C0,00C1,00C3,00C4,00C5,00C6,00C7,00C8,00C9,00CA,00CC,00CD,00D1,00D6,00D7,00D8,00DA,00DC,00DD,00DE,00E2,00E4,00E6,00E8,00EA,00ED,00F0,00F1,00F2,00F3,00F5,00FA,00FB,00FC,010F,0120,0123,0125,0127,0128,012C,012F,0132,0133,0134,0137,0138,013D,0140,0141,0142,0160,0161,0162,0163,0165,016C,016E,016F,0170,0178,017C,01A0,01A1,01A2,01A4,01A6,01A9,01AA,01AC,01AD,01AF,01B2,01B3,01B8,01C2,01E0,01E1,01E2,01E3,01E4,01E5,01E6,01E7,01EA,01EB,01EC,01ED,01EF,01F0,01F1,01F4,0202,0216,0220,0221,0223,0224,0261,0262,0263,0270,0282,029C

// Berlin, aka ci.guix.gnu.org
(ins)efraim@berlin ~$ cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0002fam0017mod0001:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0017,0018,0019,001A,001C,0020,0021,0022,0023,0024,0025,0026,0027,0028,0029,002B,002C,002D,002E,002F,0030,0031,0034,0036,0037,0038,0039,003A,003B,003D,0064,0068,006E,0070,0074,0075,0078,0079,007A,007B,007C,007D,0080,0081,0083,0089,008C,008D,0093,0094,0096,0097,0099,009A,009B,009C,009D,009E,00C0,00C1,00C2,00C3,00C4,00C5,00C6,00C7,00C8,00C9,00CC,00CD,00D1,00D6,00D7,00D8,00DA,00DC,00DD,00E2,00E8,00EA,00ED,00F1,00F3,00F5,00F8,00FA,00FC,010F,0120,0123,0125,0127,0128,0132,0133,0134,0137,013D,0140,0141,0142,0143,0165,016C,016E,016F,0170,0178,017F,01A0,01A1,01A2,01AC,01C2,01E0,01E1,01E2,01E3,01E4,01E5,01E6,01E7,01EA,01EB,01EC,01ED,01EF,01F0,0220,0221,0223,0224,0261,0262,0263,0282,029C

// pine64, kickstarter addition
(ins)efraim@3900XT ~$ ssh pine64 cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,000B

// rock64
(ins)efraim@3900XT ~$ ssh rock64 cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,000B

// raspberry pi 5b
(ins)efraim@3900XT ~$ ssh ubuntu.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
[email-masked]: Permission denied (publickey).
(ins)efraim@3900XT ~$ ssh [email-masked] cat /sys/devices/system/cpu/modalias
cpu:type:aarch64:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000A,000B,000C,000F,0010,0014

// power9 machine from OSU for ci.guix.gnu.org
(ins)efraim@3900XT ~$ ssh guixp9 cat /sys/devices/system/cpu/modalias
cpu:type:power9:feature:,0001,0006,0007,0008,000A,000D,000E,001A,001B,001C,001E,001F,0034,0035,0036,0037,0039,003A,003B,003C,003D,003F

// rpi 1b
(ins)efraim@3900XT ~$ ssh 192.168.68.50 cat /sys/devices/system/cpu/modalias
cpu:type:v6l:feature:,0001,0002,0004,0006,0007,0008,000F

// hifive unmatched, riscv64
(ins)efraim@3900XT ~$ ssh 192.168.68.51 cat /sys/devices/system/cpu/modalias
cat: /sys/devices/system/cpu/modalias: No such file or directory

// macbook 4,1 I think
(ins)efraim@3900XT ~$ ssh israel.unicorn-typhon.ts.net cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0000fam0006mod0017:feature:,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000B,000C,000D,000E,000F,0010,0011,0013,0015,0016,0017,0018,0019,001A,001C,001D,001F,002B,0034,003D,0068,006B,006C,006D,006F,0070,0072,0074,0075,0079,007C,0080,0082,0083,0084,0085,0087,0088,0089,008D,008E,008F,0093,00C0,00EB,00ED,00F3,00FD,00FF,0100,0101,0102,0104,0165,016C,0172,01C0

arch/x86/include/asm/cpufeatures.h
list of CPU features for x86 and x86_64

I haven't been able to find the table for other architectures yet.

¹ https://social.treehouse.systems/@marcan/113548772069263164

-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted