[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 3/3] linux-user: Emulate /proc/cpuinfo for Alpha
From: |
Helge Deller |
Subject: |
[PATCH v3 3/3] linux-user: Emulate /proc/cpuinfo for Alpha |
Date: |
Thu, 3 Aug 2023 22:48:03 +0200 |
Add emulation for /proc/cpuinfo for the alpha architecture.
alpha output example:
(alpha-chroot)root@p100:/# cat /proc/cpuinfo
cpu : Alpha
cpu model : ev67
cpu variation : 7
cpu revision : 0
cpu serial number : JA00000000
system type : QEMU
system variation : QEMU_v8.0.92
system revision : 0
system serial number : AY00000000
cycle frequency [Hz] : 250000000
timer frequency [Hz] : 250.00
page size [bytes] : 8192
phys. address bits : 44
max. addr. space # : 255
BogoMIPS : 2500.00
platform string : AlphaServer QEMU user-mode VM
cpus detected : 8
cpus active : 4
cpu active mask : 0000000000000095
L1 Icache : n/a
L1 Dcache : n/a
L2 cache : n/a
L3 cache : n/a
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Michael Cree <mcree@orcon.net.nz>
v2:
- revised platform string and system variation output
- show cpus detected/active/active mask based on
current physical machine configuration
---
linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bac764f502..a4d597ac05 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8324,7 +8324,7 @@ 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_ARM) || \
- defined(TARGET_AARCH64)
+ defined(TARGET_AARCH64) || defined(TARGET_ALPHA)
static int is_proc(const char *filename, const char *entry)
{
return strcmp(filename, entry) == 0;
@@ -8376,6 +8376,57 @@ static int open_net_route(CPUArchState *cpu_env, int fd)
}
#endif
+#if defined(TARGET_ALPHA)
+static int open_cpuinfo(CPUArchState *cpu_env, int fd)
+{
+ int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+ int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+ uint64_t cpu_mask;
+ char model[32];
+ char *p;
+ AlphaCPU *cpu = env_archcpu(cpu_env);
+ CPUAlphaState *env = &cpu->env;
+
+ g_strlcpy(model, object_class_get_name(
+ OBJECT_CLASS(CPU_GET_CLASS(env_cpu(cpu_env)))),
+ sizeof(model));
+ p = strchr(model, '-');
+ if (p) {
+ *p = '\0';
+ }
+ if (sched_getaffinity(getpid(), sizeof(cpu_mask),
+ (cpu_set_t *) &cpu_mask) < 0) {
+ cpu_mask = (1ULL << num_cpus) - 1;
+ }
+
+ dprintf(fd, "cpu\t\t\t: Alpha\n");
+ dprintf(fd, "cpu model\t\t: %s\n", model);
+ dprintf(fd, "cpu variation\t\t: %d\n", env->implver + 5);
+ dprintf(fd, "cpu revision\t\t: 0\n");
+ dprintf(fd, "cpu serial number\t: JA00000000\n");
+ dprintf(fd, "system type\t\t: QEMU\n");
+ dprintf(fd, "system variation\t: QEMU_v%s\n", QEMU_VERSION);
+ dprintf(fd, "system revision\t\t: 0\n");
+ dprintf(fd, "system serial number\t: AY00000000\n");
+ dprintf(fd, "cycle frequency [Hz]\t: 250000000\n");
+ dprintf(fd, "timer frequency [Hz]\t: 250.00\n");
+ dprintf(fd, "page size [bytes]\t: %d\n", TARGET_PAGE_SIZE);
+ dprintf(fd, "phys. address bits\t: %d\n", TARGET_PHYS_ADDR_SPACE_BITS);
+ dprintf(fd, "max. addr. space #\t: 255\n");
+ dprintf(fd, "BogoMIPS\t\t: 2500.00\n");
+ dprintf(fd, "platform string\t\t: AlphaServer QEMU user-mode VM\n");
+ dprintf(fd, "cpus detected\t\t: %d\n", max_cpus);
+ dprintf(fd, "cpus active\t\t: %d\n", num_cpus);
+ dprintf(fd, "cpu active mask\t\t: %016llx\n", (unsigned long long)
cpu_mask);
+ dprintf(fd, "L1 Icache\t\t: n/a\n");
+ dprintf(fd, "L1 Dcache\t\t: n/a\n");
+ dprintf(fd, "L2 cache\t\t: n/a\n");
+ dprintf(fd, "L3 cache\t\t: n/a\n");
+ return 0;
+}
+#endif
+
+
#if defined(TARGET_SPARC)
static int open_cpuinfo(CPUArchState *cpu_env, int fd)
{
@@ -8633,7 +8684,8 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd,
const char *fname,
#endif
#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || \
defined(TARGET_RISCV) || defined(TARGET_S390X) || \
- defined(TARGET_ARM) || defined(TARGET_AARCH64)
+ defined(TARGET_ARM) || defined(TARGET_AARCH64) || \
+ defined(TARGET_ALPHA)
{ "/proc/cpuinfo", open_cpuinfo, is_proc },
#endif
#if defined(TARGET_M68K)
--
2.41.0