Linux – How to determine CPU features on PowerPC and Power 8 (and above)

aixcpulinuxpowerpc

We can examine /proc/cpuinfo on Intel and ARM machines to learn cpu features, like AES and SHA. I need to do the same for PowerPC under both AIX and Linux.

Testing with Linux is shown below. The output is produced by GCC112 on the compile farm.

$ cat /proc/cpuinfo
processor       : 0
cpu             : POWER8E (raw), altivec supported
clock           : 2061.000000MHz
revision        : 2.1 (pvr 004b 0201)
...

processor       : 159
cpu             : POWER8E (raw), altivec supported
clock           : 2061.000000MHz
revision        : 2.1 (pvr 004b 0201)

timebase        : 512000000
platform        : PowerNV
model           : 8247-22L
machine         : PowerNV 8247-22L
firmware        : OPAL v3

GCC112 is a Power 8 machine. I should be seeing flags like VMX, AES, SHA, PMULL, etc. VMX is roughly the PowerPC equivalent to Intel SSE and ARM NEON.

I've found some related discussions like /proc/cpuinfo on comp.os.linux.powerpc. I also found What do we check on a new system?, but it lacks useful details like cpu features. Finally, there's a related question at What do the flags in /proc/cpuinfo mean?, but it does not discuss PowerPC.

GCC appears to provide the information to C programs through its use of built-ins. For example, there's a vsx test and a vcrypto test. The problem is, I'm working from a Bash script and not a C program.

I also don't know what to use for AIX. AIX is available at GCC119 on the compile farm.

How do I get the PowerPC cpu features on AIX and Linux?

Best Answer

I am not sure why /proc/cpuinfo or lscpu does not reveal flag information. I have found the list of flags known to the linux kernel https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/arch/powerpc/include/asm/cputable.h?id=refs/tags/v4.9

I've just found that you can lookup ELF auxiliary vectors which will show you some hardware capabilities.

$ LD_SHOW_AUXV=1 /bin/true
AT_SYSINFO_EHDR: 0x7ffdcd0e6000
AT_HWCAP:        bfebfbff
AT_PAGESZ:       4096
AT_CLKTCK:       100
AT_PHDR:         0x5591e6663040
AT_PHENT:        56
AT_PHNUM:        9
AT_BASE:         0x7f2ae4f79000
AT_FLAGS:        0x0
AT_ENTRY:        0x5591e6664670
AT_UID:          1000
AT_EUID:         1000
AT_GID:          1000
AT_EGID:         1000
AT_SECURE:       0
AT_RANDOM:       0x7ffdcd044399
AT_HWCAP2:       0x0
AT_EXECFN:       /bin/true
AT_PLATFORM:     x86_64

^^ your AT_HWCAP will have flag info. Masked. I've seen samples on the Internet that have this entry decoded for you. I don't have access to ppc hardware to test on unfortunately.

lscpu should be available on AIX, perhaps it would show CPU flags?

Related Question