* [Qemu-devel] [PATCH v2 0/2] mttcg: Handle exception and flags in atomic execution
@ 2017-02-10 18:45 Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 1/2] tcg: Save cpu " Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 2/2] tcg: Set jmp_env for exceptions from " Pranith Kumar
0 siblings, 2 replies; 3+ messages in thread
From: Pranith Kumar @ 2017-02-10 18:45 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Bennée, Richard Henderson, Paolo Bonzini
The previous version, though ideal, needs more work to enable calling
start_exclusive() from cpu_exec() and also does not properly handle
exception from atomic context. Exceptions in atomic context will not
call exclusive_end() and would go to the outer most loop causing a deadlock.
The following patches allow proper handling of flags set and
exceptions from the atomic exectuion context.
Alex, please fold/squash them as you feel necessary.
Pranith Kumar (2):
tcg: Save cpu flags in atomic execution
tcg: Set jmp_env to handle exceptions from atomic execution
cpu-exec.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] tcg: Save cpu flags in atomic execution
2017-02-10 18:45 [Qemu-devel] [PATCH v2 0/2] mttcg: Handle exception and flags in atomic execution Pranith Kumar
@ 2017-02-10 18:45 ` Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 2/2] tcg: Set jmp_env for exceptions from " Pranith Kumar
1 sibling, 0 replies; 3+ messages in thread
From: Pranith Kumar @ 2017-02-10 18:45 UTC (permalink / raw)
To: Paolo Bonzini, Peter Crosthwaite, Richard Henderson, open list:Overall
Cc: Alex Bennée
The current mechanism discards the flags which were set in atomic
execution. Properly save them.
CC: Alex Bennée <alex.bennee@linaro.org>
CC: Richard Henderson <rth@twiddle.net>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
cpu-exec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cpu-exec.c b/cpu-exec.c
index b0ddada8c1..9200c643c2 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -228,6 +228,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,
static void cpu_exec_step(CPUState *cpu)
{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
TranslationBlock *tb;
target_ulong cs_base, pc;
@@ -239,9 +240,13 @@ static void cpu_exec_step(CPUState *cpu)
1 | CF_NOCACHE | CF_IGNORE_ICOUNT);
tb->orig_tb = NULL;
tb_unlock();
+
+ cc->cpu_exec_enter(cpu);
/* execute the generated code */
trace_exec_tb_nocache(tb, pc);
cpu_tb_exec(cpu, tb);
+
+ cc->cpu_exec_exit(cpu);
tb_lock();
tb_phys_invalidate(tb, -1);
tb_free(tb);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] tcg: Set jmp_env for exceptions from atomic execution
2017-02-10 18:45 [Qemu-devel] [PATCH v2 0/2] mttcg: Handle exception and flags in atomic execution Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 1/2] tcg: Save cpu " Pranith Kumar
@ 2017-02-10 18:45 ` Pranith Kumar
1 sibling, 0 replies; 3+ messages in thread
From: Pranith Kumar @ 2017-02-10 18:45 UTC (permalink / raw)
To: Paolo Bonzini, Peter Crosthwaite, Richard Henderson, open list:Overall
Cc: Alex Bennée
The current method of executing atomic code in a guest uses
cpu_exec_step_atomic() from the outermost loop. This causes an abort()
when single stepping over atomic code since debug exception longjmp
will point to the the setlongjmp in cpu_exec(). Properly set jmp_env
so that it jumps back here on an exception.
CC: Alex Bennée <alex.bennee@linaro.org>
CC: Richard Henderson <rth@twiddle.net>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
cpu-exec.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 9200c643c2..e61f5747c8 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -242,9 +242,12 @@ static void cpu_exec_step(CPUState *cpu)
tb_unlock();
cc->cpu_exec_enter(cpu);
- /* execute the generated code */
- trace_exec_tb_nocache(tb, pc);
- cpu_tb_exec(cpu, tb);
+
+ if (sigsetjmp(cpu->jmp_env, 0) == 0) {
+ /* execute the generated code */
+ trace_exec_tb_nocache(tb, pc);
+ cpu_tb_exec(cpu, tb);
+ }
cc->cpu_exec_exit(cpu);
tb_lock();
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-10 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 18:45 [Qemu-devel] [PATCH v2 0/2] mttcg: Handle exception and flags in atomic execution Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 1/2] tcg: Save cpu " Pranith Kumar
2017-02-10 18:45 ` [Qemu-devel] [PATCH v2 2/2] tcg: Set jmp_env for exceptions from " Pranith Kumar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.