Skip to contentSkip to conversation

Fix : [Bug 887516] [NEW] VFP support reported for the PXA270

PATCH Superseded Benoît Canet 3 participants 5 messages Nov 9, 2011

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Fix : [Bug 887516] [NEW] VFP support reported for the PXA270

A VFP was detected for pxa270 causing an "Illegal instruction" exception.
The eglibc was not receiving the right AT_HWCAP from elfloader.c.

In this version :
Fix reminder
Add comment regarding ARM_FEATURE_V5 to ARM_HWCAP_ARM_EDSP mapping

Benoît Canet (2):
arm-linux-user: fix elfload.c's AT_HWCAP to reflect cpu features.
target-arm: remind to keep arm features in sync with
linux-user/elfload.c

 linux-user/elfload.c |   43 +++++++++++++++++++++++++++++++++++++++----
 target-arm/cpu.h     |    4 ++++
 2 files changed, 43 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/2 arm-linux-user: fix elfload.c's AT_HWCAP to reflect cpu features.

The cpu capabilities passed by the elf loader in AT_HWCAP where a constant.
Make AT_HWCAP reflect the emulated cpu features in order to give correct clues to eglibc.

Fix : [Bug 887516] [NEW] VFP support reported for the PXA270

---
 linux-user/elfload.c |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)
linux-user/elfload.c +39 -4
index a413976..73c939b 100644
@@ -330,6 +330,10 @@ enum
     ARM_HWCAP_ARM_NEON      = 1 << 11,
     ARM_HWCAP_ARM_VFPv3     = 1 << 12,
     ARM_HWCAP_ARM_VFPv3D16  = 1 << 13,
+    ARM_HWCAP_ARM_TLS       = 1 << 14,
+    ARM_HWCAP_ARM_VFPv4     = 1 << 15,
+    ARM_HWCAP_ARM_IDIVA     = 1 << 16,
+    ARM_HWCAP_ARM_IDIVT     = 1 << 17,
 };
 
 #define TARGET_HAS_GUEST_VALIDATE_BASE
@@ -375,10 +379,41 @@ bool guest_validate_base(unsigned long guest_base)
     return 1; /* All good */
 }
 
-#define ELF_HWCAP (ARM_HWCAP_ARM_SWP | ARM_HWCAP_ARM_HALF               \
-                   | ARM_HWCAP_ARM_THUMB | ARM_HWCAP_ARM_FAST_MULT      \
-                   | ARM_HWCAP_ARM_FPA | ARM_HWCAP_ARM_VFP              \
-                   | ARM_HWCAP_ARM_NEON | ARM_HWCAP_ARM_VFPv3 )
+
+#define ELF_HWCAP get_elf_hwcap()
+
+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;
+
+    /* probe for the extra features */
+#define SET_HWCAP(feat, hwcap) \
+    do {if (arm_feature(e, feat)) { hwcaps |= hwcap; } } while (0)
+    SET_HWCAP(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP);
+    SET_HWCAP(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT);
+    SET_HWCAP(ARM_FEATURE_THUMB2EE, ARM_HWCAP_ARM_THUMBEE);
+    SET_HWCAP(ARM_FEATURE_NEON, ARM_HWCAP_ARM_NEON);
+    SET_HWCAP(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3);
+
+    /* Strictly should be ARM_FEATURE_V5TE but we don't distinguish
+     * as all our v5 cores are v5TE at the moment
+     */
+    SET_HWCAP(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP);
+
+    SET_HWCAP(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS);
+    SET_HWCAP(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4);
+    SET_HWCAP(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA);
+    SET_HWCAP(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT);
+#undef SET_HWCAP
+
+    return hwcaps;
+}
 
 #endif
 
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] arm-linux-user: fix elfload.c's AT_HWCAP to reflect cpu features.

Am 09.11.2011 16:02, schrieb Benoît Canet:

Quoted 1 line

The cpu capabilities passed by the elf loader in AT_HWCAP where

were

Quoted 40 lines

a constant.
Make AT_HWCAP reflect the emulated cpu features in order to give correct clues to eglibc.

Fix : [Bug 887516] [NEW] VFP support reported for the PXA270

---
 linux-user/elfload.c |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)
linux-user/elfload.c +10 -4
index a413976..73c939b 100644
@@ -330,6 +330,10 @@ enum
     ARM_HWCAP_ARM_NEON      = 1 << 11,
     ARM_HWCAP_ARM_VFPv3     = 1 << 12,
     ARM_HWCAP_ARM_VFPv3D16  = 1 << 13,
+    ARM_HWCAP_ARM_TLS       = 1 << 14,
+    ARM_HWCAP_ARM_VFPv4     = 1 << 15,
+    ARM_HWCAP_ARM_IDIVA     = 1 << 16,
+    ARM_HWCAP_ARM_IDIVT     = 1 << 17,
 };
 
 #define TARGET_HAS_GUEST_VALIDATE_BASE
@@ -375,10 +379,41 @@ bool guest_validate_base(unsigned long guest_base)
     return 1; /* All good */
 }
 
-#define ELF_HWCAP (ARM_HWCAP_ARM_SWP | ARM_HWCAP_ARM_HALF               \
-                   | ARM_HWCAP_ARM_THUMB | ARM_HWCAP_ARM_FAST_MULT      \
-                   | ARM_HWCAP_ARM_FPA | ARM_HWCAP_ARM_VFP              \
-                   | ARM_HWCAP_ARM_NEON | ARM_HWCAP_ARM_VFPv3 )
+
+#define ELF_HWCAP get_elf_hwcap()
+
+static uint32_t get_elf_hwcap(void)
+{
+    CPUState *e = thread_env;

linux-user/elfload.c bool guest_validate_base(unsigned long guest_base) · line 397

Quoted 10 lines
linux-user/elfload.c +10 -0
+    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;
+
+    /* probe for the extra features */
+#define SET_HWCAP(feat, hwcap) \
+    do {if (arm_feature(e, feat)) { hwcaps |= hwcap; } } while (0)

Small nit: I notice there's a space missing after do {. I wonder if Coding Style applies to macros, too. In that case this should be five lines.

linux-user/elfload.c bool guest_validate_base(unsigned long guest_base) · line 407

Quoted 10 lines
linux-user/elfload.c +10 -0
+    SET_HWCAP(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP);
+    SET_HWCAP(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT);
+    SET_HWCAP(ARM_FEATURE_THUMB2EE, ARM_HWCAP_ARM_THUMBEE);
+    SET_HWCAP(ARM_FEATURE_NEON, ARM_HWCAP_ARM_NEON);
+    SET_HWCAP(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3);
+
+    /* Strictly should be ARM_FEATURE_V5TE but we don't distinguish
+     * as all our v5 cores are v5TE at the moment
+     */
+    SET_HWCAP(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP);

Peter, usually I'd rather have these things fixed for real before they get forgotten, but I take it this one's for 1.0 and a V5TE feature and V5TE => V5 inference rule would better be saved for 1.1? (I had a series adding inference for V7 => V6 etc. removing duplicated code, not sure if I submitted that yet...?)

Andreas

Quoted 11 lines
linux-user/elfload.c +8 -0
+    SET_HWCAP(ARM_FEATURE_V6K, ARM_HWCAP_ARM_TLS);
+    SET_HWCAP(ARM_FEATURE_VFP4, ARM_HWCAP_ARM_VFPv4);
+    SET_HWCAP(ARM_FEATURE_ARM_DIV, ARM_HWCAP_ARM_IDIVA);
+    SET_HWCAP(ARM_FEATURE_THUMB_DIV, ARM_HWCAP_ARM_IDIVT);
+#undef SET_HWCAP
+
+    return hwcaps;
+}
 
 #endif
 
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] arm-linux-user: fix elfload.c's AT_HWCAP to reflect cpu features.

Quoted 7 lines · Andreas Färber

Am 09.11.2011 16:02, schrieb Benoît Canet:

Quoted 2 lines

+#define SET_HWCAP(feat, hwcap) \
+    do {if (arm_feature(e, feat)) { hwcaps |= hwcap; } } while (0)

Small nit: I notice there's a space missing after do {. I wonder if Coding Style applies to macros, too. In that case this should be five lines.

Personally I wouldn't make it five lines...

Quoted 11 lines
Quoted 10 lines

+    SET_HWCAP(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP);
+    SET_HWCAP(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT);
+    SET_HWCAP(ARM_FEATURE_THUMB2EE, ARM_HWCAP_ARM_THUMBEE);
+    SET_HWCAP(ARM_FEATURE_NEON, ARM_HWCAP_ARM_NEON);
+    SET_HWCAP(ARM_FEATURE_VFP3, ARM_HWCAP_ARM_VFPv3);
+
+    /* Strictly should be ARM_FEATURE_V5TE but we don't distinguish
+     * as all our v5 cores are v5TE at the moment
+     */
+    SET_HWCAP(ARM_FEATURE_V5, ARM_HWCAP_ARM_EDSP);

Quoted 5 lines

Peter, usually I'd rather have these things fixed for real before they get forgotten, but I take it this one's for 1.0 and a V5TE feature and V5TE => V5 inference rule would better be saved for 1.1? (I had a series adding inference for V7 => V6 etc. removing duplicated code, not sure if I submitted that yet...?)

I wasn't planning to put this in for 1.0. (The only patch I have that I do want to put in 1.0 is the omap_gpio one.)

I don't think I've seen a patch from you adding the v7->v6->... inferences. I think it would be a good idea, though, ditto adding V5TE (if you do then the ENABLE_ARCH_5TE macro in translate.c should be updated).

-- PMM

#4 lore raw

PATCH 2/2 target-arm: remind to keep arm features in sync with linux-user/elfload.c

In reply to Benoît Canet
---
 target-arm/cpu.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
target-arm/cpu.h +4 -0
index c4d742f..6639c2e 100644
@@ -353,6 +353,10 @@ enum arm_cpu_mode {
 #define ARM_IWMMXT_wCGR2	10
 #define ARM_IWMMXT_wCGR3	11
 
+/* If adding a feature bit which corresponds to a Linux ELF
+ * HWCAP bit, remember to update the feature-bit-to-hwcap
+ * mapping in linux-user/elfload.c:get_elf_hwcap().
+ */
 enum arm_features {
     ARM_FEATURE_VFP,
     ARM_FEATURE_AUXCR,  /* ARM1026 Auxiliary control register.  */
Signature · 1 line
1.7.5.4