hw/mips/malta: Fix the malta machine on big endian hosts
PATCH 1/1 hw/mips/malta: Fix the malta machine on big endian hosts
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.
---
I've checked that both, the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mipsel.tgz
and the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mips.tgz
now boot fine on both, a little endian (x86) and a big endian (s390x) host.
hw/mips/malta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/mips/malta.c +2 -2
@@ -629,9 +629,9 @@ static void bl_setup_gt64120_jump_kernel(void **p, 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 /* setup MEM-to-PCI0 mapping as done by YAMON */
Signature · 1 line
2.31.1
Quoted 24 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>---
I've checked that both, the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mipsel.tgz
and the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mips.tgz
now boot fine on both, a little endian (x86) and a big endian (s390x) host.hw/mips/malta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/mips/malta.c +0
-0
hw/mips/malta.c static void bl_setup_gt64120_jump_kernel(void **p, uint64_t run_addr, · line 635
Quoted 9 lines
hw/mips/malta.c +2
-2@@ -629,9 +629,9 @@ static void bl_setup_gt64120_jump_kernel(void **p, 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
So if we:
* do nothing to the value on a BE host
* swap the value on an LE host
isn't that the same as cpu_to_be32() in both cases?
thanks
-- PMM
Quoted 39 lines · Peter Maydell
Quoted 24 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>---
I've checked that both, the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mipsel.tgz
and the kernel from
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/mips.tgz
now boot fine on both, a little endian (x86) and a big endian (s390x) host.hw/mips/malta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/mips/malta.c +0
-0hw/mips/malta.c static void bl_setup_gt64120_jump_kernel(void **p, uint64_t run_addr, · line 635
Quoted 9 lines
hw/mips/malta.c +2
-2@@ -629,9 +629,9 @@ static void bl_setup_gt64120_jump_kernel(void **p, 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 So if we:
* do nothing to the value on a BE host
* swap the value on an LE host
Quoted 1 line
isn't that the same as
cpu_to_be32()in both cases?
No, it's about the *target*, not the host:
* do nothing to the value for a BE *target*
* swap the value for LE *targets*
It's quite weird and it also took me a while to understand this, but this seems to be the way it's working right with all combinations.
Thomas
Quoted 8 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>
Has this been forgotten?
Thanks,
/mjt
Quoted 8 lines · Michael Tokarev
Quoted 6 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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.
Quoted 4 lines
Quoted 2 lines
Fixes 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>Has this been forgotten?
Looks like it. Too late for 8.0 now (and it wasn't a regression since it looks like it was broken in 7.2 as well); will have to be fixed in 8.1.
thanks
-- PMM
Peter Maydell
Reviewed-byQuoted 10 lines · Peter Maydell
Quoted 8 lines · Michael Tokarev
Quoted 6 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>Has this been forgotten?
Looks like it. Too late for 8.0 now (and it wasn't a regression since it looks like it was broken in 7.2 as well); will have to be fixed in 8.1.
Philippe -- looks like this patch still hasn't been queued ? (It could probably use a Cc: [email protected] at this point.)
It can have my
thanks
-- PMM
Quoted 20 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Michael Tokarev
Quoted 6 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>Has this been forgotten?
Looks like it. Too late for 8.0 now (and it wasn't a regression since it looks like it was broken in 7.2 as well); will have to be fixed in 8.1.
Quoted 5 lines
Philippe -- looks like this patch still hasn't been queued ? (It could probably use a Cc: [email protected] at this point.)
It can have my
Reviewed-by Peter Maydell <[email protected]>
*ping*
Philippe, can you please comment? I think this should be good enough at least for a temporary fix, even if you have more clean ups in this area in mind later...
Thomas
Quoted 24 lines · Thomas Huth
Quoted 23 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Michael Tokarev
Quoted 6 lines · Thomas Huth
Booting a Linux kernel with the malta machine is currently broken on big endian hosts. The
cpu_to_gt32macro 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.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes 0c8427baf0 ("hw/mips/malta: Use bootloader helper to set BAR registers")Signed-off-by Thomas Huth <[email protected]>Has this been forgotten?
Looks like it. Too late for 8.0 now (and it wasn't a regression since it looks like it was broken in 7.2 as well); will have to be fixed in 8.1.
Philippe -- looks like this patch still hasn't been queued ? (It could probably use a Cc: [email protected] at this point.)
Quoted 6 lines
Quoted 2 lines
It can have my
Reviewed-by Peter Maydell <[email protected]>*ping*
Philippe, can you please comment? I think this should be good enough at least for a temporary fix, even if you have more clean ups in this area in mind later...
Philippe, if you don't mind, I'll take this through my s390x tree since this fixes a problem on the big-endian s390x hosts.
Thomas