Message ID | 20190212074840.13542-2-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | linux-user: Fix AT_PLATFORM for arm | expand |
On 12/02/2019 08:48, Richard Henderson wrote: > The 32-bit kernel has strings for v4, v5, v6, v7, v7m. > The 64-bit kernel, in compat mode, has strings for v8. > > Fixes: https://bugs.launchpad.net/bugs/1813034 > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > v2: Include v8. > --- > linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > index 775a36ccdd..d796d51ec6 100644 > --- a/linux-user/elfload.c > +++ b/linux-user/elfload.c > @@ -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; > + } 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? Reviewed-by: Laurent Vivier <laurent@vivier.eu> Thanks, Laurent
On 2/12/19 12:31 AM, Laurent Vivier wrote: > 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? >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~
On 12/02/2019 08:48, Richard Henderson wrote: > The 32-bit kernel has strings for v4, v5, v6, v7, v7m. > The 64-bit kernel, in compat mode, has strings for v8. > > Fixes: https://bugs.launchpad.net/bugs/1813034 > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > v2: Include v8. > --- > linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) Applied to my linux-user branch. Thanks, Laurent
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 775a36ccdd..d796d51ec6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -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
The 32-bit kernel has strings for v4, v5, v6, v7, v7m. The 64-bit kernel, in compat mode, has strings for v8. Fixes: https://bugs.launchpad.net/bugs/1813034 Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- v2: Include v8. --- linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- 2.17.2