linux-user/ppc/target_proc.h | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
From: Helge Deller <deller@gmx.de>
I've tried to mimic what I've seen on two debian porterboxes (ppc64 and
ppc64le), which are running via KVM/QEMU. I assume the model type of
pSeries and such doesn't make much sense for some older ppc chips, so
any better suggestions here are welcome.
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: qemu-ppc@nongnu.org
---
linux-user/ppc/target_proc.h | 38 +++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/linux-user/ppc/target_proc.h b/linux-user/ppc/target_proc.h
index 43fe29ca72..fa965c0e69 100644
--- a/linux-user/ppc/target_proc.h
+++ b/linux-user/ppc/target_proc.h
@@ -1 +1,37 @@
-/* No target-specific /proc support */
+/*
+ * ppc specific proc functions for linux-user
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef PPC_TARGET_PROC_H
+#define PPC_TARGET_PROC_H
+
+static int open_cpuinfo(CPUArchState *cpu_env, int fd)
+{
+ int i, num_cpus;
+
+ PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(env_cpu(cpu_env));
+ DeviceClass *dc = DEVICE_CLASS(ppc_cpu_get_family_class(pcc));
+
+ num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ for (i = 0; i < num_cpus; i++) {
+ dprintf(fd, "processor:\t: %d\n", i);
+ dprintf(fd, "cpu:\t\t: %s%s\n",
+ dc->desc,
+ pcc->insns_flags & PPC_ALTIVEC ? ", altivec supported":"");
+ dprintf(fd, "clock\t\t: 3425.000000MHz\n");
+ dprintf(fd, "revision\t: %d.%d (pvr %04x %04x)\n\n",
+ (pcc->pvr >> 8) & 0x0f, pcc->pvr & 0x0f,
+ pcc->pvr >> 16, pcc->pvr & 0xffff);
+ }
+
+ dprintf(fd, "timebase\t: 512000000\n");
+ dprintf(fd, "platform\t: pSeries\n");
+ dprintf(fd, "model\t\t: IBM pSeries (QEMU user v" QEMU_VERSION ")\n");
+ dprintf(fd, "machine\t\t: CHRP IBM pSeries\n");
+
+ return 0;
+}
+#define HAVE_ARCH_PROC_CPUINFO
+
+#endif /* PPC_TARGET_PROC_H */
--
2.54.0
Built and tested qemu-ppc64le on ppc64le host Test environment: - Host: ppc64le Linux (POWER10) - QEMU version: v11.0.50 (v11.0.0-1849-g193963218a-dirty) - upstream qemu with patch applied - Target: ppc64le-linux-user Manual tests performed: - Verified /proc/cpuinfo is readable by PPC binaries under qemu-user - Verified qemu-ppc64le -cpu POWER10 /bin/cat /proc/cpuinfo returns the expected PPC-specific cpuinfo output - Tested POWER8, POWER9, and POWER10 CPU models - Confirmed different PVR values for different CPU types - Verified all required fields present (processor, cpu, clock, revision, timebase, platform, model, machine) - CPU count correctly reported (48 online CPUs) - Tested with both custom test program and system binaries (/bin/cat) Test Logs: 1. POWER9 CPU model test: $ qemu-ppc64le -cpu POWER9 /tmp/test-cpuinfo | head -10 === /proc/cpuinfo via qemu-user === processor: : 0 cpu: : POWER9, altivec supported clock : 3425.000000MHz revision : 2.2 (pvr 004e 1202) processor: : 1 cpu: : POWER9, altivec supported clock : 3425.000000MHz revision : 2.2 (pvr 004e 1202) 2. POWER10 CPU model test: $ qemu-ppc64le -cpu POWER10 /tmp/test-cpuinfo | head -10 === /proc/cpuinfo via qemu-user === processor: : 0 cpu: : POWER10, altivec supported clock : 3425.000000MHz revision : 2.0 (pvr 0080 0200) processor: : 1 cpu: : POWER10, altivec supported clock : 3425.000000MHz revision : 2.0 (pvr 0080 0200) 3. System binary test: $ qemu-ppc64le -cpu POWER9 /bin/cat /proc/cpuinfo | tail -5 timebase : 512000000 platform : pSeries model : IBM pSeries (QEMU user v11.0.50) machine : CHRP IBM pSeries Qemu Unit tests: make check: 118/118 tests PASSED Ok: 118 Fail: 0 All tests passed. The patch correctly implements /proc/cpuinfo for PPC user-mode emulation without breaking existing functionality. Output format is consistent and provides accurate CPU information. Tested-by: Misbah Anjum N <misanjum@linux.ibm.com> Thanks, Misbah Anjum N
On 6/9/26 15:09, Helge Deller wrote:
> From: Helge Deller <deller@gmx.de>
>
> I've tried to mimic what I've seen on two debian porterboxes (ppc64 and
> ppc64le), which are running via KVM/QEMU. I assume the model type of
> pSeries and such doesn't make much sense for some older ppc chips, so
> any better suggestions here are welcome.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Cc: qemu-ppc@nongnu.org
> ---
> linux-user/ppc/target_proc.h | 38 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/ppc/target_proc.h b/linux-user/ppc/target_proc.h
> index 43fe29ca72..fa965c0e69 100644
> --- a/linux-user/ppc/target_proc.h
> +++ b/linux-user/ppc/target_proc.h
> @@ -1 +1,37 @@
> -/* No target-specific /proc support */
> +/*
> + * ppc specific proc functions for linux-user
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#ifndef PPC_TARGET_PROC_H
> +#define PPC_TARGET_PROC_H
> +
> +static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> +{
> + int i, num_cpus;
> +
> + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(env_cpu(cpu_env));
> + DeviceClass *dc = DEVICE_CLASS(ppc_cpu_get_family_class(pcc));
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor:\t: %d\n", i);
> + dprintf(fd, "cpu:\t\t: %s%s\n",
There are extra ':' here. Should be
processor :
cpu :
not
processor: :
cpu: :
> + dc->desc,
> + pcc->insns_flags & PPC_ALTIVEC ? ", altivec supported":"");
> + dprintf(fd, "clock\t\t: 3425.000000MHz\n");
Why hardcoded? Is the clock not accessible to user-only?
> + dprintf(fd, "revision\t: %d.%d (pvr %04x %04x)\n\n",
> + (pcc->pvr >> 8) & 0x0f, pcc->pvr & 0x0f,
> + pcc->pvr >> 16, pcc->pvr & 0xffff);
There's quite a bit of decode of pvr for maj.min in the kernel.
r~
On 6/9/2026 3:09 PM, Helge Deller wrote: > From: Helge Deller <deller@gmx.de> > > I've tried to mimic what I've seen on two debian porterboxes (ppc64 and > ppc64le), which are running via KVM/QEMU. I assume the model type of > pSeries and such doesn't make much sense for some older ppc chips, so > any better suggestions here are welcome. > > Signed-off-by: Helge Deller <deller@gmx.de> > Cc: qemu-ppc@nongnu.org > --- > linux-user/ppc/target_proc.h | 38 +++++++++++++++++++++++++++++++++++- > 1 file changed, 37 insertions(+), 1 deletion(-) > Looks good to me. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Regards, Pierrick
© 2016 - 2026 Red Hat, Inc.