qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32()
@ 2022-12-22 21:55 Philippe Mathieu-Daudé
  2022-12-22 21:55 ` [PATCH 1/6] hw/arm/aspeed: Fix smpboot[] on big-endian hosts Philippe Mathieu-Daudé
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-22 21:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andrew Jeffery, Philippe Mathieu-Daudé, Igor Mitsyanko,
	Joel Stanley, Havard Skinnemoen, Peter Maydell, Edgar E. Iglesias,
	Cédric Le Goater, Alistair Francis, qemu-arm, Tyrone Ting

ARM CPUs fetch instructions in little-endian.

smpboot[] encoded instructions are written in little-endian.

We call tswap32() on the array. tswap32 function swap a 32-bit
value if the target endianness doesn't match the host one.
Otherwise it is a NOP.

* On a little-endian host, the array is stored as it. tswap32()
  is a NOP, and the vCPU fetches the instructions as it, in
  little-endian.

* On a big-endian host, the array is stored as it. tswap32()
  swap the instructions to little-endian, and the vCPU fetches
  the instructions as it, in little-endian.

Using tswap() on system emulation is a bit odd: while the target
particularities might change the system emulation, the host ones
(such its endianness) shouldn't interfere.

We can simplify by using const_le32() to always store the
instructions in the array in little-endian, removing the need
for the dubious tswap().

Two boards which weren't swapping (aspeed and raspi) are fixed.

Tested running ARM avocado tests on x86_64 and s390x.

Philippe Mathieu-Daudé (6):
  hw/arm/aspeed: Fix smpboot[] on big-endian hosts
  hw/arm/raspi: Fix smpboot[] on big-endian hosts
  hw/arm/exynos4210: Remove tswap32() calls and constify smpboot[]
  hw/arm/npcm7xx: Remove tswap32() calls and constify smpboot[]
  hw/arm/xilinx_zynq: Remove tswap32() calls and constify smpboot[]
  hw/arm/boot: Remove tswap32() calls and constify board_setup_blob[]

 hw/arm/aspeed.c      | 28 ++++++++++++------------
 hw/arm/boot.c        | 52 +++++++++++++++++++-------------------------
 hw/arm/exynos4210.c  | 48 ++++++++++++++++++----------------------
 hw/arm/npcm7xx.c     | 49 +++++++++++++++++------------------------
 hw/arm/raspi.c       | 46 +++++++++++++++++++--------------------
 hw/arm/xilinx_zynq.c | 27 ++++++++++-------------
 6 files changed, 112 insertions(+), 138 deletions(-)

-- 
2.38.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-01-04 23:26 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-22 21:55 [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32() Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 1/6] hw/arm/aspeed: Fix smpboot[] on big-endian hosts Philippe Mathieu-Daudé
2022-12-23  7:24   ` Cédric Le Goater
2023-01-03 17:33   ` Peter Maydell
2023-01-04  8:43     ` Cédric Le Goater
2023-01-04 22:35       ` Philippe Mathieu-Daudé
2023-01-04 23:25         ` Cédric Le Goater
2022-12-22 21:55 ` [PATCH 2/6] hw/arm/raspi: " Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 3/6] hw/arm/exynos4210: Remove tswap32() calls and constify smpboot[] Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 4/6] hw/arm/npcm7xx: " Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 5/6] hw/arm/xilinx_zynq: " Philippe Mathieu-Daudé
2022-12-23  3:54   ` Edgar E. Iglesias
2022-12-23 10:01     ` Philippe Mathieu-Daudé
2022-12-23 10:05       ` Philippe Mathieu-Daudé
2022-12-22 21:55 ` [PATCH 6/6] hw/arm/boot: Remove tswap32() calls and constify board_setup_blob[] Philippe Mathieu-Daudé
2022-12-22 21:59 ` [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32() Philippe Mathieu-Daudé
2022-12-24 23:32 ` Richard Henderson
2023-01-03 17:43 ` Peter Maydell
2023-01-04 22:51   ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).