linux-user/e2k: do nothing if wsz is zero in syscall

This commit is contained in:
Denis Drakhnia 2023-12-26 15:00:57 +02:00
parent 7885b8558a
commit 39039c5554

View File

@ -73,26 +73,30 @@ void cpu_loop(CPUE2KState *env)
switch (trapnr) { switch (trapnr) {
case E2K_EXCP_SYSCALL: { case E2K_EXCP_SYSCALL: {
abi_ullong args[E2K_SYSCALL_MAX_ARGS] = { 0 }; int psize = MIN(E2K_SYSCALL_MAX_ARGS, env->wd.size);
int i, psize = MIN(E2K_SYSCALL_MAX_ARGS, env->wd.size);
abi_ulong ret;
// TODO: check what happens if env->wd.size is zero if (psize) {
for (i = 0; i < psize; i++) { abi_ullong ret, args[E2K_SYSCALL_MAX_ARGS] = { 0 };
args[i] = env->regs[i].lo; int i;
}
ret = do_syscall(env, args[0], args[1], args[2], args[3], for (i = 0; i < psize; i++) {
args[4], args[5], args[6], args[7], args[8]); args[i] = env->regs[i].lo;
}
if (ret == -QEMU_ERESTARTSYS) { ret = do_syscall(env, args[0], args[1], args[2], args[3],
/* do not set sysret address and syscall will be restarted */ args[4], args[5], args[6], args[7], args[8]);
} else if (ret != -QEMU_ESIGRETURN && env->wd.psize > 0) {
memset(env->tags, E2K_TAG_NON_NUMBER64,
psize * sizeof(env->tags[0]));
env->regs[0].lo = ret; if (ret == -QEMU_ERESTARTSYS) {
env->tags[0] = E2K_TAG_NUMBER64; /* do not set sysret address and syscall will be restarted */
} else if (ret != -QEMU_ESIGRETURN && env->wd.psize > 0) {
memset(env->tags, E2K_TAG_NON_NUMBER64,
psize * sizeof(env->tags[0]));
env->regs[0].lo = ret;
env->tags[0] = E2K_TAG_NUMBER64;
env->ip = E2K_SYSRET_ADDR;
}
} else {
env->ip = E2K_SYSRET_ADDR; env->ip = E2K_SYSRET_ADDR;
} }
break; break;