Message ID | Y9QvyRSq1I1k5/JW@p100 (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v4] linux-user: Fix /proc/cpuinfo output for hppa | expand |
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~
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>
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
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