Re: [Qemu-devel] [PATCH v12 12/24] tcg: handle EXCP_ATOMIC exception for system emulation

2017-02-13 Thread Richard Henderson

On 02/14/2017 06:33 AM, Pranith Kumar wrote:

On Mon, Feb 13, 2017 at 2:19 PM, Richard Henderson  wrote:

On 02/13/2017 11:10 PM, Alex Bennée wrote:


@@ -239,9 +240,16 @@ static void cpu_exec_step(CPUState *cpu)
  1 | CF_NOCACHE | CF_IGNORE_ICOUNT);
 tb->orig_tb = NULL;
 tb_unlock();
-/* execute the generated code */
-trace_exec_tb_nocache(tb, pc);
-cpu_tb_exec(cpu, tb);
+
+cc->cpu_exec_enter(cpu);
+
+if (sigsetjmp(cpu->jmp_env, 0) == 0) {
+/* execute the generated code */
+trace_exec_tb_nocache(tb, pc);
+cpu_tb_exec(cpu, tb);
+}



I don't understand this, since cpu_tb_exec has its own sigsetjmp.  Where is
the exception supposed to come from that escapes?


cpu_exec() has its own sigsetjmp, not cpu_tb_exec(). The exception is
the debug exception from the generated code. Without this new
sigsetjmp, it'll jump to cpu_exec() instead of coming back here.


Bah.  Sorry, ENOCOFFEE.

Reviewed-by: Richard Henderson 


r~




Re: [Qemu-devel] [PATCH v12 12/24] tcg: handle EXCP_ATOMIC exception for system emulation

2017-02-13 Thread Pranith Kumar
On Mon, Feb 13, 2017 at 2:19 PM, Richard Henderson  wrote:
> On 02/13/2017 11:10 PM, Alex Bennée wrote:
>>
>> @@ -239,9 +240,16 @@ static void cpu_exec_step(CPUState *cpu)
>>   1 | CF_NOCACHE | CF_IGNORE_ICOUNT);
>>  tb->orig_tb = NULL;
>>  tb_unlock();
>> -/* execute the generated code */
>> -trace_exec_tb_nocache(tb, pc);
>> -cpu_tb_exec(cpu, tb);
>> +
>> +cc->cpu_exec_enter(cpu);
>> +
>> +if (sigsetjmp(cpu->jmp_env, 0) == 0) {
>> +/* execute the generated code */
>> +trace_exec_tb_nocache(tb, pc);
>> +cpu_tb_exec(cpu, tb);
>> +}
>
>
> I don't understand this, since cpu_tb_exec has its own sigsetjmp.  Where is
> the exception supposed to come from that escapes?

cpu_exec() has its own sigsetjmp, not cpu_tb_exec(). The exception is
the debug exception from the generated code. Without this new
sigsetjmp, it'll jump to cpu_exec() instead of coming back here.

Thanks,
-- 
Pranith



Re: [Qemu-devel] [PATCH v12 12/24] tcg: handle EXCP_ATOMIC exception for system emulation

2017-02-13 Thread Richard Henderson

On 02/13/2017 11:10 PM, Alex Bennée wrote:

@@ -239,9 +240,16 @@ static void cpu_exec_step(CPUState *cpu)
  1 | CF_NOCACHE | CF_IGNORE_ICOUNT);
 tb->orig_tb = NULL;
 tb_unlock();
-/* execute the generated code */
-trace_exec_tb_nocache(tb, pc);
-cpu_tb_exec(cpu, tb);
+
+cc->cpu_exec_enter(cpu);
+
+if (sigsetjmp(cpu->jmp_env, 0) == 0) {
+/* execute the generated code */
+trace_exec_tb_nocache(tb, pc);
+cpu_tb_exec(cpu, tb);
+}


I don't understand this, since cpu_tb_exec has its own sigsetjmp.  Where is the 
exception supposed to come from that escapes?



+} else if (r == EXCP_ATOMIC) {
+qemu_mutex_unlock_iothread();
+cpu_exec_step_atomic(cpu);
+qemu_mutex_lock_iothread();

...

+case EXCP_ATOMIC:
+qemu_mutex_unlock_iothread();
+cpu_exec_step_atomic(cpu);
+qemu_mutex_lock_iothread();



I just noticed this, but if you have to do a v13, it might be best to move 
these locks inside cpu_exec_step_atomic, as with tcg_cpu_exec.  Otherwise leave 
it for later.



r~