qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Helge Deller <deller@gmx.de>, Michael Cree <mcree@orcon.net.nz>
Subject: [PATCH 03/13] linux-user: Emulate /proc/cpuinfo for Alpha
Date: Wed, 23 Aug 2023 18:02:27 -0700	[thread overview]
Message-ID: <20230824010237.1379735-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230824010237.1379735-1-richard.henderson@linaro.org>

From: Helge Deller <deller@gmx.de>

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           : 0
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

Cc: Michael Cree <mcree@orcon.net.nz>
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230803214450.647040-4-deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/alpha/target_proc.h | 68 +++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/linux-user/alpha/target_proc.h b/linux-user/alpha/target_proc.h
index 43fe29ca72..dac37dffc9 100644
--- a/linux-user/alpha/target_proc.h
+++ b/linux-user/alpha/target_proc.h
@@ -1 +1,67 @@
-/* No target-specific /proc support */
+/*
+ * Alpha specific proc functions for linux-user
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef ALPHA_TARGET_PROC_H
+#define ALPHA_TARGET_PROC_H
+
+static int open_cpuinfo(CPUArchState *cpu_env, int fd)
+{
+    int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+    int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+    unsigned long cpu_mask;
+    char model[32];
+    const char *p, *q;
+    int t;
+
+    p = object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(env_cpu(cpu_env))));
+    q = strchr(p, '-');
+    t = q - p;
+    assert(t < sizeof(model));
+    memcpy(model, p, t);
+    model[t] = 0;
+
+    t = sched_getaffinity(getpid(), sizeof(cpu_mask), (cpu_set_t *)&cpu_mask);
+    if (t < 0) {
+        if (num_cpus >= sizeof(cpu_mask) * 8) {
+            cpu_mask = -1;
+        } else {
+            cpu_mask = (1UL << num_cpus) - 1;
+        }
+    }
+
+    dprintf(fd,
+            "cpu\t\t\t: Alpha\n"
+            "cpu model\t\t: %s\n"
+            "cpu variation\t\t: 0\n"
+            "cpu revision\t\t: 0\n"
+            "cpu serial number\t: JA00000000\n"
+            "system type\t\t: QEMU\n"
+            "system variation\t: QEMU_v" QEMU_VERSION "\n"
+            "system revision\t\t: 0\n"
+            "system serial number\t: AY00000000\n"
+            "cycle frequency [Hz]\t: 250000000\n"
+            "timer frequency [Hz]\t: 250.00\n"
+            "page size [bytes]\t: %d\n"
+            "phys. address bits\t: %d\n"
+            "max. addr. space #\t: 255\n"
+            "BogoMIPS\t\t: 2500.00\n"
+            "kernel unaligned acc\t: 0 (pc=0,va=0)\n"
+            "user unaligned acc\t: 0 (pc=0,va=0)\n"
+            "platform string\t\t: AlphaServer QEMU user-mode VM\n"
+            "cpus detected\t\t: %d\n"
+            "cpus active\t\t: %d\n"
+            "cpu active mask\t\t: %016lx\n"
+            "L1 Icache\t\t: n/a\n"
+            "L1 Dcache\t\t: n/a\n"
+            "L2 cache\t\t: n/a\n"
+            "L3 cache\t\t: n/a\n",
+            model, TARGET_PAGE_SIZE, TARGET_PHYS_ADDR_SPACE_BITS,
+            max_cpus, num_cpus, cpu_mask);
+
+    return 0;
+}
+#define HAVE_ARCH_PROC_CPUINFO
+
+#endif /* ALPHA_TARGET_PROC_H */
-- 
2.34.1



  parent reply	other threads:[~2023-08-24  1:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24  1:02 [PATCH 00/13] linux-user patch queue Richard Henderson
2023-08-24  1:02 ` [PATCH 01/13] linux-user: Split out cpu/target_proc.h Richard Henderson
2023-09-01 14:35   ` Philippe Mathieu-Daudé
2023-08-24  1:02 ` [PATCH 02/13] linux-user: Emulate /proc/cpuinfo on aarch64 and arm Richard Henderson
2023-08-24  1:02 ` Richard Henderson [this message]
2025-01-21 10:39   ` [PATCH 03/13] linux-user: Emulate /proc/cpuinfo for Alpha Philippe Mathieu-Daudé
2023-08-24  1:02 ` [PATCH 04/13] util/selfmap: Use dev_t and ino_t in MapInfo Richard Henderson
2023-08-24  1:02 ` [PATCH 05/13] linux-user: Use walk_memory_regions for open_self_maps Richard Henderson
2023-08-24  1:02 ` [PATCH 06/13] linux-user: Adjust brk for load_bias Richard Henderson
2023-08-24  1:02 ` [PATCH 07/13] linux-user: Show heap address in /proc/pid/maps Richard Henderson
2023-09-01 14:39   ` Philippe Mathieu-Daudé
2023-08-24  1:02 ` [PATCH 08/13] linux-user: Emulate the Anonymous: keyword in /proc/self/smaps Richard Henderson
2023-09-01 14:37   ` Philippe Mathieu-Daudé
2023-08-24  1:02 ` [PATCH 09/13] linux-user: Remove ELF_START_MMAP and image_info.start_mmap Richard Henderson
2023-08-24  1:02 ` [PATCH 10/13] linux-user: Move shmat and shmdt implementations to mmap.c Richard Henderson
2023-08-24  1:02 ` [PATCH 11/13] linux-user: Use WITH_MMAP_LOCK_GUARD in target_{shmat, shmdt} Richard Henderson
2023-09-01 14:58   ` Helge Deller
2023-08-24  1:02 ` [PATCH 12/13] linux-user: Fix shmdt Richard Henderson
2023-09-01 14:38   ` Philippe Mathieu-Daudé
2023-08-24  1:02 ` [PATCH 13/13] linux-user: Track shm regions with an interval tree Richard Henderson
2023-09-01 15:10   ` Helge Deller
2023-09-01  2:32 ` [PATCH 00/13] linux-user patch queue Richard Henderson
2023-09-01 15:12   ` Helge Deller

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=20230824010237.1379735-4-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=deller@gmx.de \
    --cc=mcree@orcon.net.nz \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).