qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] arm-linux-user: fix elfload.c's AT_HWCAP reflec


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] arm-linux-user: fix elfload.c's AT_HWCAP reflected cpu features.
Date: Wed, 9 Nov 2011 14:01:19 +0000

2011/11/9 Benoît Canet <address@hidden>:
> +static uint32_t get_elf_hwcap(void)
> +{
> +    CPUState *e = thread_env;
> +    uint32_t hwcaps = 0;
> +
> +    hwcaps |= ARM_HWCAP_ARM_SWP;
> +    hwcaps |= ARM_HWCAP_ARM_HALF;
> +    hwcaps |= ARM_HWCAP_ARM_THUMB;
> +    hwcaps |= ARM_HWCAP_ARM_FAST_MULT;
> +    hwcaps |= ARM_HWCAP_ARM_FPA;

After looking at the Linux kernel code I've changed my mind on this one:
we shouldn't set the FPA hwcap, because we don't model any CPU with FPA
hardware and the kernel doesn't set this hwcap even if it is providing
emulated FPA via nwfpe, so we shouldn't either.

> +    /* prove for the extra features */
> +#define GET_FEATURE(feat, hwcap) \
> +    do {if (arm_feature(e, feat)) { hwcaps |= hwcap; } } while (0)
> +    GET_FEATURE(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP);
> +    GET_FEATURE(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT);
> +    GET_FEATURE(ARM_FEATURE_THUMB2EE, ARM_HWCAP_ARM_THUMBEE);
> +    GET_FEATURE(ARM_FEATURE_NEON, ARM_HWCAP_ARM_NEON);
> +    GET_FEATURE(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3);
> +    GET_FEATURE(ARM_FEATURE_VFP_FP16, ARM_HWCAP_ARM_VFPv3D16);

As Andreas says, this one's wrong. We don't currently implement
any CPUs with VFPv3D16 (ie only 16 double registers) so we never
need to set this hwcap. (ARM_FEATURE_VP_FP16 means "we implement
half-precision VFP".)

Missing:
   /* Strictly should be ARM_FEATURE_V5TE but we don't distinguish
    * as all our v5 cores are v5TE at the moment
    */
   GET_FEATURE(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP);

(although maybe we should just bite the bullet and define the feature
bit...)

> +#undef GET_FEATURE
> +
> +    return hwcaps;
> +}

While we're here we might as well update the hwcaps list
based on the most recent kernel:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/arm/kernel/setup.c;h=7e7977ab994ff92ee4ded30ee728d92ed6c3a520;hb=HEAD#l986

So that's
    ARM_HWCAP_ARM_TLS       = 1 << 14,
    ARM_HWCAP_ARM_VFPv4     = 1 << 15,
    ARM_HWCAP_ARM_IDIVA     = 1 << 16,
    ARM_HWCAP_ARM_IDIVT     = 1 << 17,

and
    GET_FEATURE(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS);
    GET_FEATURE(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4);
    GET_FEATURE(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA);
    GET_FEATURE(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT);

-- PMM



reply via email to

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