From: Helge Deller <deller@gmx.de>
To: Laurent Vivier <laurent@vivier.eu>,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: [PATCH] linux-user: Emulate /proc/cpuinfo on aarch64 and arm
Date: Tue, 1 Aug 2023 15:57:24 +0200 [thread overview]
Message-ID: <ZMkPRJ3subSuW+Rg@p100> (raw)
Add emulation for /proc/cpuinfo for arm architecture.
The output below mimics output as seen on debian porterboxes.
aarch64 output example:
processor : 0
BogoMIPS : 100.00
Features : fp asimd evtstrm cpuid
CPU implementer : 0x50
CPU architecture: 8
CPU variant : 0x0
CPU part : 0x0
CPU revision : 1
arm output example:
processor : 0
model name : ARMv7 Processor rev 2 (v7l)
BogoMIPS : 50.00
Features : half thumb fastmult vfp edsp thumbee vfpv3 tls idiva idivt vfpd32 lpae
CPU implementer : 0x56
CPU architecture: 7
CPU variant : 0x2
CPU part : 0x584
CPU revision : 2
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dc8266c073..917c388073 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8287,7 +8287,8 @@ void target_exception_dump(CPUArchState *env, const char *fmt, int code)
#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN || \
defined(TARGET_SPARC) || defined(TARGET_M68K) || defined(TARGET_HPPA) || \
- defined(TARGET_RISCV) || defined(TARGET_S390X)
+ defined(TARGET_RISCV) || defined(TARGET_S390X) || defined(TARGET_ARM) || \
+ defined(TARGET_AARCH64)
static int is_proc(const char *filename, const char *entry)
{
return strcmp(filename, entry) == 0;
@@ -8503,6 +8504,33 @@ static int open_hardware(CPUArchState *cpu_env, int fd)
}
#endif
+#if defined(TARGET_AARCH64) || defined(TARGET_ARM)
+static int open_cpuinfo(CPUArchState *cpu_env, int fd)
+{
+ int i, num_cpus;
+ const int is64 = TARGET_ABI_BITS == 64;
+
+ num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ for (i = 0; i < num_cpus; i++) {
+ dprintf(fd, "processor\t: %d\n", i);
+ if (!is64) {
+ dprintf(fd, "model name\t: ARMv7 Processor rev 2 (v7l)\n");
+ }
+ dprintf(fd, "BogoMIPS\t: %d.00\n", is64 ? 100 : 50);
+ dprintf(fd, "Features\t: %s\n",
+ is64 ? "fp asimd evtstrm cpuid"
+ : "half thumb fastmult vfp edsp thumbee vfpv3 " \
+ "tls idiva idivt vfpd32 lpae");
+ dprintf(fd, "CPU implementer\t: 0x%d\n", is64 ? 50 : 56);
+ dprintf(fd, "CPU architecture: %d\n", is64 ? 8 : 7);
+ dprintf(fd, "CPU variant\t: 0x%d\n", is64 ? 0 : 2);
+ dprintf(fd, "CPU part\t: 0x%d\n", is64 ? 0 : 584);
+ dprintf(fd, "CPU revision\t: %d\n\n", is64 ? 1 : 2);
+ }
+ return 0;
+}
+#endif
+
int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname,
int flags, mode_t mode, bool safe)
{
@@ -8522,7 +8550,8 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname,
{ "/proc/net/route", open_net_route, is_proc },
#endif
#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || \
- defined(TARGET_RISCV) || defined(TARGET_S390X)
+ defined(TARGET_RISCV) || defined(TARGET_S390X) || \
+ defined(TARGET_ARM) || defined(TARGET_AARCH64)
{ "/proc/cpuinfo", open_cpuinfo, is_proc },
#endif
#if defined(TARGET_M68K)
next reply other threads:[~2023-08-01 13:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 13:57 Helge Deller [this message]
2023-08-01 14:22 ` [PATCH] linux-user: Emulate /proc/cpuinfo on aarch64 and arm Peter Maydell
2023-08-01 14:41 ` Helge Deller
2023-08-01 14:44 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMkPRJ3subSuW+Rg@p100 \
--to=deller@gmx.de \
--cc=laurent@vivier.eu \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.