Skip to contentSkip to conversation

linux-user: use arm features based on cpu model

PATCH Superseded Lars Munch 2 participants 3 messages Mar 15, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lars Munch

author
#0 lore raw

PATCH 1/1 linux-user: use arm features based on cpu model

Use arm features based on cpu model. The hardcoded feature list gave problems in the setjmp/longjmp functions of glibc since it tried to use VFP instructions even though I specified a pxa270 as cpu model.

---
 linux-user/elfload.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
linux-user/elfload.c +6 -4
index 91eea62..79af51d 100644
@@ -333,10 +333,12 @@ enum
   ARM_HWCAP_ARM_VFPv3D16  = 1 << 13,
 };
 
-#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)
+{
+    return thread_env->features;
+}
 
 #endif
 
Signature · 1 line
1.7.0
#1 lore raw

linux-user/elfload.c enum · line 341

Quoted 4 lines
linux-user/elfload.c +4 -0
+static uint32_t get_elf_hwcap(void)
+{
+    return thread_env->features;
+}

No. These values are not the same.

Paul

author
#2 lore raw
Quoted 9 lines · Paul Brook

Review

Quoted 4 lines
(quoted diff) +4 -0
+static uint32_t get_elf_hwcap(void)
+{
+    return thread_env->features;
+}

No. These values are not the same.

Paul

Yes, these values are indeed not the same. Below is an updated patch with a function similar to the PPC get_elf_hwcap function. I am unsure if I have too many or too few features as I do not know the details on all the capability flags, so comments are more than welcome.

---
 linux-user/elfload.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
linux-user/elfload.c +20 -4
index 91eea62..6364176 100644
@@ -333,10 +333,26 @@ enum
   ARM_HWCAP_ARM_VFPv3D16  = 1 << 13,
 };
 
-#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)
+{
+    CPUARMState *e = thread_env;
+    uint32_t features = ARM_HWCAP_ARM_SWP | ARM_HWCAP_ARM_HALF
+      | ARM_HWCAP_ARM_THUMB | ARM_HWCAP_ARM_FAST_MULT
+      | ARM_HWCAP_ARM_FPA;
+
+#define GET_FEATURE(flag, feature)              \
+    do {if (e->features & flag) features |= feature; } while(0)
+    GET_FEATURE(ARM_FEATURE_VFP, ARM_HWCAP_ARM_VFP);
+    GET_FEATURE(ARM_FEATURE_IWMMXT, ARM_HWCAP_ARM_IWMMXT);
+    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);
+#undef GET_FEATURE
+
+    return features;
+}
 
 #endif
 
Signature · 1 line
1.7.0