From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
qemu-ppc@nongnu.org, qemu-arm@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: [PATCH v2 1/9] target/xtensa: Remove tswap() calls in semihosting simcall() helper
Date: Thu, 12 Dec 2024 00:03:49 +0100 [thread overview]
Message-ID: <20241211230357.97036-2-philmd@linaro.org> (raw)
In-Reply-To: <20241211230357.97036-1-philmd@linaro.org>
In preparation of heterogeneous emulation where cores with
different endianness can run concurrently, we need to remove
the tswap() calls -- which use a fixed per-binary endianness.
Get the endianness of the CPU accessed using the libisa
xtensa_isa_is_big_endian() call and replace the tswap() calls
by bswap() ones when necessary.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/xtensa/xtensa-semi.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c
index fa21b7e11fc..2ded8e5634e 100644
--- a/target/xtensa/xtensa-semi.c
+++ b/target/xtensa/xtensa-semi.c
@@ -30,6 +30,7 @@
#include "chardev/char-fe.h"
#include "exec/helper-proto.h"
#include "semihosting/semihost.h"
+#include "semihosting/uaccess.h"
#include "qapi/error.h"
#include "qemu/log.h"
@@ -323,15 +324,12 @@ void HELPER(simcall)(CPUXtensaState *env)
uint32_t fd = regs[3];
uint32_t rq = regs[4];
uint32_t target_tv = regs[5];
- uint32_t target_tvv[2];
struct timeval tv = {0};
if (target_tv) {
- cpu_memory_rw_debug(cs, target_tv,
- (uint8_t *)target_tvv, sizeof(target_tvv), 0);
- tv.tv_sec = (int32_t)tswap32(target_tvv[0]);
- tv.tv_usec = (int32_t)tswap32(target_tvv[1]);
+ get_user_u32(tv.tv_sec, target_tv);
+ get_user_u32(tv.tv_sec, target_tv + 4);
}
if (fd < 3 && sim_console) {
if ((fd == 1 || fd == 2) && rq == SELECT_ONE_WRITE) {
@@ -387,11 +385,8 @@ void HELPER(simcall)(CPUXtensaState *env)
const char *str = semihosting_get_arg(i);
int str_size = strlen(str) + 1;
- argptr = tswap32(regs[3] + str_offset);
-
- cpu_memory_rw_debug(cs,
- regs[3] + i * sizeof(uint32_t),
- (uint8_t *)&argptr, sizeof(argptr), 1);
+ put_user_u32(regs[3] + str_offset,
+ regs[3] + i * sizeof(uint32_t));
cpu_memory_rw_debug(cs,
regs[3] + str_offset,
(uint8_t *)str, str_size, 1);
--
2.45.2
next prev parent reply other threads:[~2024-12-11 23:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 23:03 [PATCH v2 0/9] misc: Reduce 'exec/tswap.h' inclusions Philippe Mathieu-Daudé
2024-12-11 23:03 ` Philippe Mathieu-Daudé [this message]
2024-12-11 23:08 ` [PATCH v2 1/9] target/xtensa: Remove tswap() calls in semihosting simcall() helper Philippe Mathieu-Daudé
2024-12-11 23:44 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 2/9] target/mips: Remove tswap() calls in semihosting uhi_fstat_cb() Philippe Mathieu-Daudé
2024-12-11 23:03 ` [PATCH v2 3/9] accel/tcg: Include missing 'exec/tswap.h' header in translator.c Philippe Mathieu-Daudé
2024-12-11 23:47 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 4/9] hw/arm: Include missing 'exec/tswap.h' header Philippe Mathieu-Daudé
2024-12-11 23:53 ` Richard Henderson
2024-12-17 15:20 ` Philippe Mathieu-Daudé
2024-12-11 23:03 ` [PATCH v2 5/9] hw/ppc: " Philippe Mathieu-Daudé
2024-12-12 0:00 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 6/9] hw/mips: " Philippe Mathieu-Daudé
2024-12-12 0:01 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 7/9] hw/sh4/r2d: " Philippe Mathieu-Daudé
2024-12-12 0:02 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 8/9] hw/xtensa: " Philippe Mathieu-Daudé
2024-12-12 0:02 ` Richard Henderson
2024-12-11 23:03 ` [PATCH v2 9/9] exec/cpu-all: Do not include " Philippe Mathieu-Daudé
2024-12-12 0:02 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241211230357.97036-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.