linux-user: Fix AT_PLATFORM for arm
v2 cover linux-user: Fix AT_PLATFORM for arm
With 5 minutes more thought I would have checked the values that the 64-bit kernel supplies for arm32 in compat mode. In the process I noticed that we don't get the right string for arm64 in big-endian mode.
r~
Richard Henderson (2):
linux-user: Add ELF_PLATFORM for arm
linux-user: Fix ELF_PLATFORM for aarch64_be-linux-user
linux-user/elfload.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.2
PATCH v2 1/2 linux-user: Add ELF_PLATFORM for arm
The 32-bit kernel has strings for v4, v5, v6, v7, v7m. The 64-bit kernel, in compat mode, has strings for v8.
---
v2: Include v8.
--- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
linux-user/elfload.c +31 -0
@@ -500,6 +500,37 @@ static uint32_t get_elf_hwcap2(void)#undef GET_FEATURE#undef GET_FEATURE_ID +#define ELF_PLATFORM get_elf_platform() + +static const char *get_elf_platform (void ) +{ +CPUARMState *env = thread_cpu->env_ptr; + +#ifdef TARGET_WORDS_BIGENDIAN +# define END "b" +#else +# define END "l" +#endif + +if (arm_feature (env,ARM_FEATURE_V8 )) { +return "v8" END ; + }else if (arm_feature (env,ARM_FEATURE_V7 )) { +if (arm_feature (env,ARM_FEATURE_M )) { +return "v7m" END ; + }else { +return "v7" END ; + } + }else if (arm_feature (env,ARM_FEATURE_V6 )) { +return "v6" END ; + }else if (arm_feature (env,ARM_FEATURE_V5 )) { +return "v5" END ; + }else { +return "v4" END ; + } + +#undef END +} +#else /* 64 bit ARM definitions */ #define ELF_START_MMAP 0x80000000
Signature · 1 line
2.17.2
Re: [Qemu-arm] [PATCH v2 1/2] linux-user: Add ELF_PLATFORM for arm
Quoted 36 lines · Richard Henderson
The 32-bit kernel has strings for v4, v5, v6, v7, v7m. The 64-bit kernel, in compat mode, has strings for v8.
Signed-off-by Richard Henderson <[email protected]>---
v2: Include v8.--- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)linux-user/elfload.c +17
-0@@ -500,6 +500,37 @@ static uint32_t get_elf_hwcap2(void)#undef GET_FEATURE#undef GET_FEATURE_ID +#define ELF_PLATFORM get_elf_platform() + +static const char *get_elf_platform (void ) +{ +CPUARMState *env = thread_cpu->env_ptr; + +#ifdef TARGET_WORDS_BIGENDIAN +# define END "b" +#else +# define END "l" +#endif + +if (arm_feature (env,ARM_FEATURE_V8 )) { +return "v8" END ; + }else if (arm_feature (env,ARM_FEATURE_V7 )) { +if (arm_feature (env,ARM_FEATURE_M )) { +return "v7m" END ;
linux-user/elfload.c static uint32_t get_elf_hwcap2(void) · line 529
Quoted 10 lines
linux-user/elfload.c +10
-0+ }else { +return "v7" END ; + } + }else if (arm_feature (env,ARM_FEATURE_V6 )) { +return "v6" END ; + }else if (arm_feature (env,ARM_FEATURE_V5 )) { +return "v5" END ; + }else { +return "v4" END ; + }
I know nothing about ARM, but in kernel we have also a "v5t" (cpu_elf_name) and in QEMU we have a ARM_FEATURE_V4T which is set with ARM_FEATURE_V5. Is it related?
Thanks,
Laurent
Re: [Qemu-devel] [PATCH v2 1/2] linux-user: Add ELF_PLATFORM for arm
Quoted 5 lines · Laurent Vivier
I know nothing about ARM, but in kernel we have also a "v5t" (
cpu_elf_name) and in QEMU we have aARM_FEATURE_V4Twhich is set withARM_FEATURE_V5. Is it related?From the ARM ARM (DDI 0406C, page A1-30):
The valid variants of ARMv4, ARMv5, and ARMv6 are as follows:
ARMv4, ARMv4T, ARMv5T, ARMv5TE, ARMv5TEJ, ARMv6, ARMv6K, ARMv6T2
So all v5 are "t". The use of "v5t" within the kernel seems to be an outlier and perhaps a bug to be squashed:
$ grep -r cpu_elf_name . | grep v5 ./mm/proc-xsc3.S: string cpu_elf_name, "v5" ./mm/proc-arm1020.S: string cpu_elf_name, "v5" ./mm/proc-arm946.S: string cpu_elf_name, "v5t" ./mm/proc-arm1020e.S: string cpu_elf_name, "v5" ./mm/proc-arm1022.S: string cpu_elf_name, "v5" ./mm/proc-feroceon.S: string cpu_elf_name, "v5" ./mm/proc-xscale.S: string cpu_elf_name, "v5" ./mm/proc-mohawk.S: string cpu_elf_name, "v5" ./mm/proc-arm926.S: string cpu_elf_name, "v5" ./mm/proc-arm1026.S: string cpu_elf_name, "v5"
r~
Laurent Vivier
AppliedRe: [Qemu-devel] [PATCH v2 1/2] linux-user: Add ELF_PLATFORM for arm
In reply to Richard HendersonQuoted 10 lines · Richard Henderson
The 32-bit kernel has strings for v4, v5, v6, v7, v7m. The 64-bit kernel, in compat mode, has strings for v8.
Signed-off-by Richard Henderson <[email protected]>---
v2: Include v8.--- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Applied to my linux-user branch.
Thanks,
Laurent
PATCH v2 2/2 linux-user: Fix ELF_PLATFORM for aarch64_be-linux-user
In reply to Richard Henderson--- linux-user/elfload.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/elfload.c +5 -1
@@ -537,7 +537,11 @@ static const char *get_elf_platform(void)#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64 -#define ELF_PLATFORM "aarch64" +#ifdef TARGET_WORDS_BIGENDIAN +# define ELF_PLATFORM "aarch64_be" +#else +# define ELF_PLATFORM "aarch64" +#endif static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 2/2] linux-user: Fix ELF_PLATFORM for aarch64_be-linux-user
Quoted 13 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)linux-user/elfload.c +0
-0@@ -537,7 +537,11 @@ static const char *get_elf_platform(void)#define ELF_ARCH EM_AARCH64
linux-user/elfload.c static const char *get_elf_platform(void) · line 547
Quoted 10 lines
linux-user/elfload.c +5
-1#define ELF_CLASS ELFCLASS64 -#define ELF_PLATFORM "aarch64" +#ifdef TARGET_WORDS_BIGENDIAN +# define ELF_PLATFORM "aarch64_be" +#else +# define ELF_PLATFORM "aarch64" +#endif static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
Laurent Vivier
AppliedRe: [Qemu-arm] [Qemu-devel] [PATCH v2 2/2] linux-user: Fix ELF_PLATFORM for aarch64_be-linux-user
In reply to Richard HendersonQuoted 13 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- linux-user/elfload.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)linux-user/elfload.c +0
-0@@ -537,7 +537,11 @@ static const char *get_elf_platform(void)#define ELF_ARCH EM_AARCH64
linux-user/elfload.c static const char *get_elf_platform(void) · line 547
Quoted 10 lines
linux-user/elfload.c +5
-1#define ELF_CLASS ELFCLASS64 -#define ELF_PLATFORM "aarch64" +#ifdef TARGET_WORDS_BIGENDIAN +# define ELF_PLATFORM "aarch64_be" +#else +# define ELF_PLATFORM "aarch64" +#endif static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop)
Applied to my linux-user branch.
Thanks,
Laurent