* [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa
@ 2022-12-28 21:09 Helge Deller
2022-12-29 7:51 ` Philippe Mathieu-Daudé
2023-01-26 15:30 ` Laurent Vivier
0 siblings, 2 replies; 7+ messages in thread
From: Helge Deller @ 2022-12-28 21:09 UTC (permalink / raw)
To: Laurent Vivier, Richard Henderson, qemu-devel
The sparc and hppa architectures provide an own output for the emulated
/proc/cpuinfo file.
Some userspace applications count (even if that's not the recommended
way) the number of lines which start with "processor:" and assume that
this number then reflects the number of online CPUs. Since those 3
architectures don't provide any such line, applications may assume "0"
CPUs. One such issue can be seen in debian bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
Avoid such issues by adding a "processor:" line for each of the online
CPUs.
Signed-off-by: Helge Deller <deller@gmx.de>
---
v3:
- add trailing newline at end of /proc/cpuinfo file (needed by procps)
v2:
- drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
- change commit message
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index afb24fd0b9..5ec11a3683 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8310,7 +8310,13 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
#if defined(TARGET_SPARC)
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
- dprintf(fd, "type\t\t: sun4u\n");
+ int i, num_cpus;
+
+ num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ for (i = 0; i < num_cpus; i++) {
+ dprintf(fd, "processor\t: %d\n", i);
+ dprintf(fd, "type\t\t: sun4u\n\n");
+ }
return 0;
}
#endif
@@ -8318,11 +8324,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
#if defined(TARGET_HPPA)
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
- dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
- dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
- dprintf(fd, "capabilities\t: os32\n");
- dprintf(fd, "model\t\t: 9000/778/B160L\n");
- dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
+ int i, num_cpus;
+
+ num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ for (i = 0; i < num_cpus; i++) {
+ dprintf(fd, "processor\t: %d\n", i);
+ dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
+ dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
+ dprintf(fd, "capabilities\t: os32\n");
+ dprintf(fd, "model\t\t: 9000/778/B160L - "
+ "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
+ }
return 0;
}
#endif
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa
2022-12-28 21:09 [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa Helge Deller
@ 2022-12-29 7:51 ` Philippe Mathieu-Daudé
2023-01-26 15:30 ` Laurent Vivier
1 sibling, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-29 7:51 UTC (permalink / raw)
To: Helge Deller, Laurent Vivier, Richard Henderson, qemu-devel
On 28/12/22 22:09, Helge Deller wrote:
> The sparc and hppa architectures provide an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs. One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
> ---
> v3:
> - add trailing newline at end of /proc/cpuinfo file (needed by procps)
>
> v2:
> - drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
> - change commit message
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index afb24fd0b9..5ec11a3683 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8310,7 +8310,13 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_SPARC)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "type\t\t: sun4u\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "type\t\t: sun4u\n\n");
> + }
> return 0;
> }
> #endif
> @@ -8318,11 +8324,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_HPPA)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> - dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> - dprintf(fd, "capabilities\t: os32\n");
> - dprintf(fd, "model\t\t: 9000/778/B160L\n");
> - dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> + dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> + dprintf(fd, "capabilities\t: os32\n");
> + dprintf(fd, "model\t\t: 9000/778/B160L - "
> + "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
> + }
> return 0;
> }
> #endif
I'd rather have common code in a single open_cpuinfo() and
a per-arch dprintf_cpuinfo():
static void dprintf_cpuinfo(CPUArchState *cpu_env, int fd,
unsigned cpuid)
{
dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
dprintf(fd, "capabilities\t: os32\n");
dprintf(fd, "model\t\t: 9000/778/B160L - "
"Merlin L2 160 QEMU (9000/778/B160L)\n");
}
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
int i, num_cpus;
num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
for (i = 0; i < num_cpus; i++) {
dprintf(fd, "processor\t: %d\n", i);
dprintf_cpuinfo(cpu_env, fd, i);
dprintf(fd, "\n");
}
return 0;
}
Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa
2022-12-28 21:09 [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa Helge Deller
2022-12-29 7:51 ` Philippe Mathieu-Daudé
@ 2023-01-26 15:30 ` Laurent Vivier
2023-01-27 20:10 ` [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa Helge Deller
1 sibling, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2023-01-26 15:30 UTC (permalink / raw)
To: Helge Deller, Richard Henderson, qemu-devel
Le 28/12/2022 à 22:09, Helge Deller a écrit :
> The sparc and hppa architectures provide an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs. One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
> ---
> v3:
> - add trailing newline at end of /proc/cpuinfo file (needed by procps)
>
> v2:
> - drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
> - change commit message
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index afb24fd0b9..5ec11a3683 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8310,7 +8310,13 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_SPARC)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "type\t\t: sun4u\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "type\t\t: sun4u\n\n");
> + }
I'm sorry, kernel on real hardware doesn't use the "processor:" entry on sparc.
See show_cpuinfo() in arch/sparc/kernel/cpu.c.
In this case, fix the userspace application, as it would not work on the real hardware too.
> return 0;
> }
> #endif
> @@ -8318,11 +8324,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_HPPA)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> - dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> - dprintf(fd, "capabilities\t: os32\n");
> - dprintf(fd, "model\t\t: 9000/778/B160L\n");
> - dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> + dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> + dprintf(fd, "capabilities\t: os32\n");
> + dprintf(fd, "model\t\t: 9000/778/B160L - "
> + "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
> + }
> return 0;
> }
> #endif
It's good for hppa. Please, send a v4 with only hppa.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa
2023-01-26 15:30 ` Laurent Vivier
@ 2023-01-27 20:10 ` Helge Deller
2023-01-27 22:53 ` Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Helge Deller @ 2023-01-27 20:10 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Helge Deller, Richard Henderson, qemu-devel
The hppa architectures provides an own output for the emulated
/proc/cpuinfo file.
Some userspace applications count (even if that's not the recommended
way) the number of lines which start with "processor:" and assume that
this number then reflects the number of online CPUs. Since those 3
architectures don't provide any such line, applications may assume "0"
CPUs. One such issue can be seen in debian bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
Avoid such issues by adding a "processor:" line for each of the online
CPUs.
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v4:
- Drop sparc changes
v3:
- add trailing newline at end of /proc/cpuinfo file (needed by procps)
v2:
- drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
- change commit message
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index afb24fd0b9..5fa2ae6c8a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8318,11 +8318,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
#if defined(TARGET_HPPA)
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
- dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
- dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
- dprintf(fd, "capabilities\t: os32\n");
- dprintf(fd, "model\t\t: 9000/778/B160L\n");
- dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
+ int i, num_cpus;
+
+ num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ for (i = 0; i < num_cpus; i++) {
+ dprintf(fd, "processor\t: %d\n", i);
+ dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
+ dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
+ dprintf(fd, "capabilities\t: os32\n");
+ dprintf(fd, "model\t\t: 9000/778/B160L - "
+ "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
+ }
return 0;
}
#endif
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa
2023-01-27 20:10 ` [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa Helge Deller
@ 2023-01-27 22:53 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:48 ` Laurent Vivier
2 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2023-01-27 22:53 UTC (permalink / raw)
To: Helge Deller, Laurent Vivier; +Cc: qemu-devel
On 1/27/23 10:10, Helge Deller wrote:
> The hppa architectures provides an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs. One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller<deller@gmx.de>
> Reviewed-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa
2023-01-27 20:10 ` [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa Helge Deller
2023-01-27 22:53 ` Richard Henderson
@ 2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:48 ` Laurent Vivier
2 siblings, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2023-01-30 8:42 UTC (permalink / raw)
To: Helge Deller; +Cc: Richard Henderson, qemu-devel
Le 27/01/2023 à 21:10, Helge Deller a écrit :
> The hppa architectures provides an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs. One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v4:
> - Drop sparc changes
>
> v3:
> - add trailing newline at end of /proc/cpuinfo file (needed by procps)
>
> v2:
> - drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
> - change commit message
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index afb24fd0b9..5fa2ae6c8a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8318,11 +8318,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_HPPA)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> - dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> - dprintf(fd, "capabilities\t: os32\n");
> - dprintf(fd, "model\t\t: 9000/778/B160L\n");
> - dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> + dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> + dprintf(fd, "capabilities\t: os32\n");
> + dprintf(fd, "model\t\t: 9000/778/B160L - "
> + "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
> + }
> return 0;
> }
> #endif
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa
2023-01-27 20:10 ` [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa Helge Deller
2023-01-27 22:53 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
@ 2023-01-30 8:48 ` Laurent Vivier
2 siblings, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2023-01-30 8:48 UTC (permalink / raw)
To: Helge Deller; +Cc: Richard Henderson, qemu-devel
Le 27/01/2023 à 21:10, Helge Deller a écrit :
> The hppa architectures provides an own output for the emulated
> /proc/cpuinfo file.
>
> Some userspace applications count (even if that's not the recommended
> way) the number of lines which start with "processor:" and assume that
> this number then reflects the number of online CPUs. Since those 3
> architectures don't provide any such line, applications may assume "0"
> CPUs. One such issue can be seen in debian bug report:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1024653
>
> Avoid such issues by adding a "processor:" line for each of the online
> CPUs.
>
> Signed-off-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v4:
> - Drop sparc changes
>
> v3:
> - add trailing newline at end of /proc/cpuinfo file (needed by procps)
>
> v2:
> - drop m68k part (based on feedback from Laurent Vivier <laurent@vivier.eu>)
> - change commit message
>
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index afb24fd0b9..5fa2ae6c8a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8318,11 +8318,17 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> #if defined(TARGET_HPPA)
> static int open_cpuinfo(CPUArchState *cpu_env, int fd)
> {
> - dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> - dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> - dprintf(fd, "capabilities\t: os32\n");
> - dprintf(fd, "model\t\t: 9000/778/B160L\n");
> - dprintf(fd, "model name\t: Merlin L2 160 QEMU (9000/778/B160L)\n");
> + int i, num_cpus;
> +
> + num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> + for (i = 0; i < num_cpus; i++) {
> + dprintf(fd, "processor\t: %d\n", i);
> + dprintf(fd, "cpu family\t: PA-RISC 1.1e\n");
> + dprintf(fd, "cpu\t\t: PA7300LC (PCX-L2)\n");
> + dprintf(fd, "capabilities\t: os32\n");
> + dprintf(fd, "model\t\t: 9000/778/B160L - "
> + "Merlin L2 160 QEMU (9000/778/B160L)\n\n");
> + }
> return 0;
> }
> #endif
>
Applied to my linux-user-for-8.0 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-30 8:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28 21:09 [PATCH v3] linux-user: Fix /proc/cpuinfo output for sparc and hppa Helge Deller
2022-12-29 7:51 ` Philippe Mathieu-Daudé
2023-01-26 15:30 ` Laurent Vivier
2023-01-27 20:10 ` [PATCH v4] linux-user: Fix /proc/cpuinfo output for hppa Helge Deller
2023-01-27 22:53 ` Richard Henderson
2023-01-30 8:42 ` Laurent Vivier
2023-01-30 8:48 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.