mirror of
https://github.com/qemu/qemu.git
synced 2026-04-05 21:50:33 +00:00
semihosting/uaccess: Use the cpu_internal_tswap() functions
The semihosting ABI [1] states: > Multi-byte values in memory must be formatted as pure little-endian or pure > big-endian to match the endianness mapping configuration of the processor. This commits ensures that semihosting data is properly byte-swapped if the guest's CPU is currently in a different runtime-configurable endianness than the host's CPU. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3258 Buglink: https://github.com/taiki-e/semihosting/issues/18 [1]: https://github.com/ARM-software/abi-aa/blob/2025Q1/semihosting/semihosting.rst#the-semihosting-interface Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20260311-semihosting-cpu-tswap-v3-3-8e239575ec08@eonerc.rwth-aachen.de Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
committed by
Peter Maydell
parent
c24e94fd15
commit
c400bd4058
@@ -28,7 +28,7 @@
|
||||
({ uint64_t val_ = 0; \
|
||||
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
|
||||
&val_, sizeof(val_), 0); \
|
||||
(val) = tswap64(val_); ret_; })
|
||||
(val) = cpu_internal_tswap64(cs, val_); ret_; })
|
||||
|
||||
/**
|
||||
* get_user_u32:
|
||||
@@ -39,7 +39,7 @@
|
||||
({ uint32_t val_ = 0; \
|
||||
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
|
||||
&val_, sizeof(val_), 0); \
|
||||
(val) = tswap32(val_); ret_; })
|
||||
(val) = cpu_internal_tswap32(cs, val_); ret_; })
|
||||
|
||||
/**
|
||||
* get_user_u8:
|
||||
@@ -65,7 +65,7 @@
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
#define put_user_u64(val, addr) \
|
||||
({ uint64_t val_ = tswap64(val); \
|
||||
({ uint64_t val_ = cpu_internal_tswap64(cs, val); \
|
||||
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
#define put_user_u32(val, addr) \
|
||||
({ uint32_t val_ = tswap32(val); \
|
||||
({ uint32_t val_ = cpu_internal_tswap32(cs, val); \
|
||||
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user