qemu-devel
[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: Peter Maydell
Subject: Re: [PATCH] linux-user: Emulate /proc/cpuinfo on aarch64 and arm
Date: Tue, 1 Aug 2023 15:22:31 +0100

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.)

> +    }
> +    return 0;
> +}

thanks
-- PMM



reply via email to

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