2012-10-10 20:18:11 +02:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Tue, 9 Oct 2012 09:06:49 +0200
|
2019-01-04 22:08:16 +01:00
|
|
|
Subject: linux-user: use target_ulong
|
2012-10-10 20:18:11 +02:00
|
|
|
|
|
|
|
Linux syscalls pass pointers or data length or other information of that sort
|
|
|
|
to the kernel. This is all stuff you don't want to have sign extended.
|
|
|
|
Otherwise a host 64bit variable parameter with a size parameter will extend
|
|
|
|
it to a negative number, breaking lseek for example.
|
|
|
|
|
|
|
|
Pass syscall arguments as ulong always.
|
|
|
|
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
|
|
---
|
2018-12-06 22:20:59 +01:00
|
|
|
linux-user/qemu.h | 8 ++++----
|
|
|
|
linux-user/syscall.c | 18 +++++++++---------
|
|
|
|
2 files changed, 13 insertions(+), 13 deletions(-)
|
2012-10-10 20:18:11 +02:00
|
|
|
|
|
|
|
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
|
2019-05-02 00:51:10 +02:00
|
|
|
index ef400cb78a..ccb198f666 100644
|
2012-10-10 20:18:11 +02:00
|
|
|
--- a/linux-user/qemu.h
|
|
|
|
+++ b/linux-user/qemu.h
|
2018-12-06 22:20:59 +01:00
|
|
|
@@ -206,10 +206,10 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,
|
2012-10-10 20:18:11 +02:00
|
|
|
void target_set_brk(abi_ulong new_brk);
|
|
|
|
abi_long do_brk(abi_ulong new_brk);
|
|
|
|
void syscall_init(void);
|
|
|
|
-abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|
|
|
- abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
- abi_long arg5, abi_long arg6, abi_long arg7,
|
|
|
|
- abi_long arg8);
|
|
|
|
+abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1,
|
|
|
|
+ abi_ulong arg2, abi_ulong arg3, abi_ulong arg4,
|
|
|
|
+ abi_ulong arg5, abi_ulong arg6, abi_ulong arg7,
|
|
|
|
+ abi_ulong arg8);
|
|
|
|
void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
2018-05-01 17:20:58 +02:00
|
|
|
extern __thread CPUState *thread_cpu;
|
2012-10-10 20:18:11 +02:00
|
|
|
void cpu_loop(CPUArchState *env);
|
|
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
2019-05-02 00:51:10 +02:00
|
|
|
index fade440440..f2d1f8669f 100644
|
2012-10-10 20:18:11 +02:00
|
|
|
--- a/linux-user/syscall.c
|
|
|
|
+++ b/linux-user/syscall.c
|
2019-05-02 00:51:10 +02:00
|
|
|
@@ -6988,10 +6988,10 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
|
2018-12-06 22:20:59 +01:00
|
|
|
* of syscall results, can be performed.
|
|
|
|
* All errnos that do_syscall() returns must be -TARGET_<errcode>.
|
|
|
|
*/
|
|
|
|
-static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
|
|
|
- abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
- abi_long arg5, abi_long arg6, abi_long arg7,
|
|
|
|
- abi_long arg8)
|
|
|
|
+static abi_long do_syscall1(void *cpu_env, int num, abi_ulong arg1,
|
|
|
|
+ abi_ulong arg2, abi_ulong arg3, abi_ulong arg4,
|
|
|
|
+ abi_ulong arg5, abi_ulong arg6, abi_ulong arg7,
|
|
|
|
+ abi_ulong arg8)
|
|
|
|
{
|
|
|
|
CPUState *cpu = ENV_GET_CPU(cpu_env);
|
|
|
|
abi_long ret;
|
2019-05-02 00:51:10 +02:00
|
|
|
@@ -9727,7 +9727,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
2018-12-06 22:20:59 +01:00
|
|
|
*/
|
|
|
|
ret = -TARGET_EINVAL;
|
|
|
|
if (cpu_isar_feature(aa64_sve, arm_env_get_cpu(cpu_env))
|
|
|
|
- && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) {
|
|
|
|
+ && arg2 <= 512 * 16 && !(arg2 & 15)) {
|
|
|
|
CPUARMState *env = cpu_env;
|
|
|
|
ARMCPU *cpu = arm_env_get_cpu(env);
|
|
|
|
uint32_t vq, old_vq;
|
2019-05-02 00:51:10 +02:00
|
|
|
@@ -11630,10 +11630,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
2018-12-06 22:20:59 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-10-10 20:18:11 +02:00
|
|
|
-abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|
|
|
- abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
- abi_long arg5, abi_long arg6, abi_long arg7,
|
|
|
|
- abi_long arg8)
|
|
|
|
+abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1,
|
|
|
|
+ abi_ulong arg2, abi_ulong arg3, abi_ulong arg4,
|
|
|
|
+ abi_ulong arg5, abi_ulong arg6, abi_ulong arg7,
|
|
|
|
+ abi_ulong arg8)
|
|
|
|
{
|
2013-07-30 14:36:48 +02:00
|
|
|
CPUState *cpu = ENV_GET_CPU(cpu_env);
|
2012-10-10 20:18:11 +02:00
|
|
|
abi_long ret;
|