[PATCH 1/2] target/arm: Remove useless TARGET_BIG_ENDIAN check in armv7m_load_kernel()

Peter Maydell posted 2 patches 3 years, 5 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, "Cédric Le Goater" <clg@kaod.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>, Subbaraya Sundeep <sundeep.lkml@gmail.com>, Alistair Francis <alistair@alistair23.me>, Alexandre Iooss <erdnaxe@crans.org>
[PATCH 1/2] target/arm: Remove useless TARGET_BIG_ENDIAN check in armv7m_load_kernel()
Posted by Peter Maydell 3 years, 5 months ago
Arm system emulation targets always have TARGET_BIG_ENDIAN clear, so
there is no need to have handling in armv7m_load_kernel() for the
case when it is defined.  Remove the unnecessary code.

Side notes:
 * our M-profile implementation is always little-endian (that is, it
   makes the IMPDEF choice that the read-only AIRCR.ENDIANNESS is 0)
 * if we did want to handle big-endian ELF files here we should do it
   the way that hw/arm/boot.c:arm_load_elf() does, by looking at the
   ELF header to see what endianness the file itself is

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/armv7m.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 990861ee5ef..fa4c2c735da 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -572,17 +572,10 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
 {
     ssize_t image_size;
     uint64_t entry;
-    int big_endian;
     AddressSpace *as;
     int asidx;
     CPUState *cs = CPU(cpu);
 
-#if TARGET_BIG_ENDIAN
-    big_endian = 1;
-#else
-    big_endian = 0;
-#endif
-
     if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) {
         asidx = ARMASIdx_S;
     } else {
@@ -593,7 +586,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
     if (kernel_filename) {
         image_size = load_elf_as(kernel_filename, NULL, NULL, NULL,
                                  &entry, NULL, NULL,
-                                 NULL, big_endian, EM_ARM, 1, 0, as);
+                                 NULL, 0, EM_ARM, 1, 0, as);
         if (image_size < 0) {
             image_size = load_image_targphys_as(kernel_filename, 0,
                                                 mem_size, as);
-- 
2.25.1
Re: [PATCH 1/2] target/arm: Remove useless TARGET_BIG_ENDIAN check in armv7m_load_kernel()
Posted by Philippe Mathieu-Daudé via 3 years, 5 months ago
On 23/8/22 18:04, Peter Maydell wrote:
> Arm system emulation targets always have TARGET_BIG_ENDIAN clear, so
> there is no need to have handling in armv7m_load_kernel() for the
> case when it is defined.  Remove the unnecessary code.
> 
> Side notes:
>   * our M-profile implementation is always little-endian (that is, it
>     makes the IMPDEF choice that the read-only AIRCR.ENDIANNESS is 0)
>   * if we did want to handle big-endian ELF files here we should do it
>     the way that hw/arm/boot.c:arm_load_elf() does, by looking at the
>     ELF header to see what endianness the file itself is
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/armv7m.c | 9 +--------
>   1 file changed, 1 insertion(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Re: [PATCH 1/2] target/arm: Remove useless TARGET_BIG_ENDIAN check in armv7m_load_kernel()
Posted by Richard Henderson 3 years, 5 months ago
On 8/23/22 09:04, Peter Maydell wrote:
> Arm system emulation targets always have TARGET_BIG_ENDIAN clear, so
> there is no need to have handling in armv7m_load_kernel() for the
> case when it is defined.  Remove the unnecessary code.
> 
> Side notes:
>   * our M-profile implementation is always little-endian (that is, it
>     makes the IMPDEF choice that the read-only AIRCR.ENDIANNESS is 0)
>   * if we did want to handle big-endian ELF files here we should do it
>     the way that hw/arm/boot.c:arm_load_elf() does, by looking at the
>     ELF header to see what endianness the file itself is
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~