qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] linux-user: Emulate /proc/cpuinfo on aarch64 and arm


From: Helge Deller
Subject: Re: [PATCH] linux-user: Emulate /proc/cpuinfo on aarch64 and arm
Date: Tue, 1 Aug 2023 16:41:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/1/23 16:22, Peter Maydell wrote:
On Tue, 1 Aug 2023 at 14:57, Helge Deller <deller@gmx.de> wrote:

Add emulation for /proc/cpuinfo for arm architecture.
The output below mimics output as seen on debian porterboxes.


+#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);

If you want to do this you should hook it up to what the
CPU being emulated actually is and what features it has.
(Compare how we set the hwcaps.)

Nice!
I didn't know about those elf hwcaps...
I'll respin.

Thanks,
Helge




reply via email to

[Prev in Thread] Current Thread [Next in Thread]