Skip to content

Commit

Permalink
hw/mips/malta: Fix the malta machine on big endian hosts
Browse files Browse the repository at this point in the history
Booting a Linux kernel with the malta machine is currently broken
on big endian hosts. The cpu_to_gt32 macro wants to byteswap a value
for little endian targets only, but uses the wrong way to do this:
cpu_to_[lb]e32 works the other way round on big endian hosts! Fix
it by using the same ways on both, big and little endian hosts.

Fixes: 0c8427b ("hw/mips/malta: Use bootloader helper to set BAR registers")
Cc: qemu-stable@nongnu.org
Message-Id: <20230330152613.232082-1-thuth@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit dc96009)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: adjust context for before v7.2.0-677-g0e45355c5c)
  • Loading branch information
huth authored and Michael Tokarev committed Dec 20, 2023
1 parent adfe37a commit a386866
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/mips/malta.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,9 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr,

/* Bus endianess is always reversed */
#if TARGET_BIG_ENDIAN
#define cpu_to_gt32 cpu_to_le32
#define cpu_to_gt32(x) (x)
#else
#define cpu_to_gt32 cpu_to_be32
#define cpu_to_gt32(x) bswap32(x)
#endif

/* move GT64120 registers from 0x14000000 to 0x1be00000 */
Expand Down

0 comments on commit a386866

Please sign in to comment.