semihosting: Return void from do_common_semihosting

Perform the cleanup in the FIXME comment in common_semi_gdb_syscall.
Do not modify guest registers until the syscall is complete,
which in the gdbstub case is asynchronous.

In the synchronous non-gdbstub case, use common_semi_set_ret
to set the result.  Merge set_swi_errno into common_semi_cb.
Rely on the latter for combined return value / errno setting.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2022-06-28 04:35:07 +05:30
parent 4cfeff4ac1
commit ed3a06b10a
8 changed files with 264 additions and 295 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ void cpu_loop(CPUARMState *env)
force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc);
break;
case EXCP_SEMIHOST:
env->xregs[0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->pc += 4;
break;
case EXCP_YIELD:
+1 -1
View File
@@ -449,7 +449,7 @@ void cpu_loop(CPUARMState *env)
}
break;
case EXCP_SEMIHOST:
env->regs[0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->regs[15] += env->thumb ? 2 : 4;
break;
case EXCP_INTERRUPT:
+1 -1
View File
@@ -81,7 +81,7 @@ void cpu_loop(CPURISCVState *env)
force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc);
break;
case RISCV_EXCP_SEMIHOST:
env->gpr[xA0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->pc += 4;
break;
default:
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -34,6 +34,6 @@
#ifndef COMMON_SEMI_H
#define COMMON_SEMI_H
target_ulong do_common_semihosting(CPUState *cs);
void do_common_semihosting(CPUState *cs);
#endif /* COMMON_SEMI_H */
+2 -2
View File
@@ -10515,13 +10515,13 @@ static void handle_semihosting(CPUState *cs)
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%" PRIx64 "\n",
env->xregs[0]);
env->xregs[0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->pc += 4;
} else {
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%x\n",
env->regs[0]);
env->regs[0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->regs[15] += env->thumb ? 2 : 4;
}
}
+1 -1
View File
@@ -2373,7 +2373,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
"...handling as semihosting call 0x%x\n",
env->regs[0]);
#ifdef CONFIG_TCG
env->regs[0] = do_common_semihosting(cs);
do_common_semihosting(cs);
#else
g_assert_not_reached();
#endif
+1 -1
View File
@@ -1347,7 +1347,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
if (cause == RISCV_EXCP_SEMIHOST) {
if (env->priv >= PRV_S) {
env->gpr[xA0] = do_common_semihosting(cs);
do_common_semihosting(cs);
env->pc += 4;
return;
}