aboutsummaryrefslogtreecommitdiff
path: root/semihosting/arm-compat-semi.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-03-24 14:33:33 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-03-24 14:33:33 +0000
commitf0b6a6a1a94cfbba87db98dd2edbc29b30e54f76 (patch)
tree5631bf62f53662da23378aaf78514795d2f1b966 /semihosting/arm-compat-semi.c
parent01874b15d36e3f9a3506c47941a92ccf8d8bed98 (diff)
parenta9eb2df27f117bbac9f370bf8cb79532005f19c2 (diff)
Merge remote-tracking branch 'remotes/stsquad/tags/pull-6.0-rc0-fixed-240321-1' into staging
Various fixes for 6.0: - include kernel-doc API reference for plugins - fix semihosting SYS_HEAPINFO - various tweaks to improve CI runtime - more stroz fixes - fix iotest CI regressions # gpg: Signature made Wed 24 Mar 2021 14:28:24 GMT # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full] # Primary key fingerprint: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * remotes/stsquad/tags/pull-6.0-rc0-fixed-240321-1: (22 commits) gitlab: default to not building the documentation iotests: iothreads need ioeventfd iotests: test m68k with the virt machine iotests: Revert "iotests: use -ccw on s390x for 040, 139, and 182" blockdev: with -drive if=virtio, use generic virtio-blk m68k: add the virtio devices aliases qdev: define list of archs with virtio-pci or virtio-ccw gitlab: extend timeouts for CFI builds utils: Work around mingw strto*l bug with 0x utils: Tighter tests for qemu_strtosz cirrus.yml: Update the FreeBSD task to version 12.2 configure: Don't use the __atomic_*_16 functions for testing 128-bit support gitlab-ci.yml: Merge the trace-backend testing into other jobs tests/tcg: add HeapInfo checking to semihosting test linux-user/riscv: initialise the TaskState heap/stack info semihosting/arm-compat-semi: don't use SET_ARG to report SYS_HEAPINFO semihosting/arm-compat-semi: unify GET/SET_ARG helpers semihosting: move semihosting tests to multiarch tools/virtiofsd: include --socket-group in help docs/devel: expand style section of memory management ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'semihosting/arm-compat-semi.c')
-rw-r--r--semihosting/arm-compat-semi.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 94950b6c56..fe079ca93a 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -767,15 +767,28 @@ static const GuestFDFunctions guestfd_fns[] = {
},
};
-/* Read the input value from the argument block; fail the semihosting
- * call if the memory read fails.
+/*
+ * Read the input value from the argument block; fail the semihosting
+ * call if the memory read fails. Eventually we could use a generic
+ * CPUState helper function here.
*/
-#ifdef TARGET_ARM
+static inline bool is_64bit_semihosting(CPUArchState *env)
+{
+#if defined(TARGET_ARM)
+ return is_a64(env);
+#elif defined(TARGET_RISCV)
+ return !riscv_cpu_is_32bit(env);
+#else
+#error un-handled architecture
+#endif
+}
+
+
#define GET_ARG(n) do { \
- if (is_a64(env)) { \
+ if (is_64bit_semihosting(env)) { \
if (get_user_u64(arg ## n, args + (n) * 8)) { \
errno = EFAULT; \
- return set_swi_errno(cs, -1); \
+ return set_swi_errno(cs, -1); \
} \
} else { \
if (get_user_u32(arg ## n, args + (n) * 4)) { \
@@ -786,41 +799,10 @@ static const GuestFDFunctions guestfd_fns[] = {
} while (0)
#define SET_ARG(n, val) \
- (is_a64(env) ? \
+ (is_64bit_semihosting(env) ? \
put_user_u64(val, args + (n) * 8) : \
put_user_u32(val, args + (n) * 4))
-#endif
-#ifdef TARGET_RISCV
-
-/*
- * get_user_ual is defined as get_user_u32 in softmmu-semi.h,
- * we need a macro that fetches a target_ulong
- */
-#define get_user_utl(arg, p) \
- ((sizeof(target_ulong) == 8) ? \
- get_user_u64(arg, p) : \
- get_user_u32(arg, p))
-
-/*
- * put_user_ual is defined as put_user_u32 in softmmu-semi.h,
- * we need a macro that stores a target_ulong
- */
-#define put_user_utl(arg, p) \
- ((sizeof(target_ulong) == 8) ? \
- put_user_u64(arg, p) : \
- put_user_u32(arg, p))
-
-#define GET_ARG(n) do { \
- if (get_user_utl(arg ## n, args + (n) * sizeof(target_ulong))) { \
- errno = EFAULT; \
- return set_swi_errno(cs, -1); \
- } \
- } while (0)
-
-#define SET_ARG(n, val) \
- put_user_utl(val, args + (n) * sizeof(target_ulong))
-#endif
/*
* Do a semihosting call.
@@ -1232,7 +1214,11 @@ target_ulong do_common_semihosting(CPUState *cs)
for (i = 0; i < ARRAY_SIZE(retvals); i++) {
bool fail;
- fail = SET_ARG(i, retvals[i]);
+ if (is_64bit_semihosting(env)) {
+ fail = put_user_u64(retvals[i], arg0 + i * 8);
+ } else {
+ fail = put_user_u32(retvals[i], arg0 + i * 4);
+ }
if (fail) {
/* Couldn't write back to argument block */