提交 1846ec2c 编写于 作者: B Blue Swirl

user: fix accidental AREG0 use

Global register AREG0 was always assumed to be usable in user-exec.c,
but this is incorrect for several targets.

Fix with #ifdeffery and by using other variables.
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 427a1a2c
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
*/ */
#include "config.h" #include "config.h"
#include "cpu.h" #include "cpu.h"
#ifndef CONFIG_TCG_PASS_AREG0
#include "dyngen-exec.h" #include "dyngen-exec.h"
#endif
#include "disas.h" #include "disas.h"
#include "tcg.h" #include "tcg.h"
...@@ -58,9 +60,11 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc) ...@@ -58,9 +60,11 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)
struct sigcontext *uc = puc; struct sigcontext *uc = puc;
#endif #endif
#ifndef CONFIG_TCG_PASS_AREG0
env = env1; env = env1;
/* XXX: restore cpu registers saved in host registers */ /* XXX: restore cpu registers saved in host registers */
#endif
if (puc) { if (puc) {
/* XXX: use siglongjmp ? */ /* XXX: use siglongjmp ? */
...@@ -74,8 +78,8 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc) ...@@ -74,8 +78,8 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc)
sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL); sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL);
#endif #endif
} }
env->exception_index = -1; env1->exception_index = -1;
longjmp(env->jmp_env, 1); longjmp(env1->jmp_env, 1);
} }
/* 'pc' is the host PC at which the exception was raised. 'address' is /* 'pc' is the host PC at which the exception was raised. 'address' is
...@@ -89,9 +93,11 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, ...@@ -89,9 +93,11 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
TranslationBlock *tb; TranslationBlock *tb;
int ret; int ret;
#ifndef CONFIG_TCG_PASS_AREG0
if (cpu_single_env) { if (cpu_single_env) {
env = cpu_single_env; /* XXX: find a correct solution for multithread */ env = cpu_single_env; /* XXX: find a correct solution for multithread */
} }
#endif
#if defined(DEBUG_SIGNAL) #if defined(DEBUG_SIGNAL)
qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set); pc, address, is_write, *(unsigned long *)old_set);
...@@ -103,7 +109,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, ...@@ -103,7 +109,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
} }
/* see if it is an MMU fault */ /* see if it is an MMU fault */
ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); ret = cpu_handle_mmu_fault(cpu_single_env, address, is_write,
MMU_USER_IDX);
if (ret < 0) { if (ret < 0) {
return 0; /* not an MMU fault */ return 0; /* not an MMU fault */
} }
...@@ -115,13 +122,13 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, ...@@ -115,13 +122,13 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
if (tb) { if (tb) {
/* the PC is inside the translated code. It means that we have /* the PC is inside the translated code. It means that we have
a virtual CPU fault */ a virtual CPU fault */
cpu_restore_state(tb, env, pc); cpu_restore_state(tb, cpu_single_env, pc);
} }
/* we restore the process signal mask as the sigreturn should /* we restore the process signal mask as the sigreturn should
do it (XXX: use sigsetjmp) */ do it (XXX: use sigsetjmp) */
sigprocmask(SIG_SETMASK, old_set, NULL); sigprocmask(SIG_SETMASK, old_set, NULL);
exception_action(env); exception_action(cpu_single_env);
/* never comes here */ /* never comes here */
return 1; return 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册