target-or32: Improve float exception
PATCH 1/1 target-or32: Improve float exception
From: gaofeng <gaofeng@gaofeng-K43SM.(none)>
When float exception raise, can save right pc.
--- target-openrisc/exception.c | 35 ++++++++++++++++++++++++++++-- target-openrisc/exception.h | 8 ++++++- target-openrisc/fpu_helper.c | 48 +++++++++++++++++++++++------------------- target-openrisc/mmu_helper.c | 17 +++------------ 4 files changed, 69 insertions(+), 39 deletions(-)
target-openrisc/exception.c +33 -2
@@ -20,8 +20,39 @@#include "cpu.h" #include "exception.h" -void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp) +void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t exception) { - cpu->env.exception_index = excp; +do_raise_exception_err (cpu, exception,0 ); +} + +void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +TranslationBlock *tb; +#if 1 +if (exception <0x100 ) +qemu_log ("%s: %d\n" , __func__, exception); +#endif + cpu->env.exception_index = exception; + +if (pc) { +/* now we have a real cpu fault */ + tb =tb_find_pc (pc); +if (tb) { +/* the PC is inside the translated code. It means that we have +a virtual CPU fault */ +cpu_restore_state (tb, &cpu->env, pc); + } + } +cpu_loop_exit (&cpu->env); } + +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +do_raise_exception_err (cpu, exception, pc); +} +
target-openrisc/exception.h +7 -1
@@ -23,6 +23,12 @@#include "cpu.h" #include "qemu-common.h" -void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp); +void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t exception); +void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc); +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc);#endif /* QEMU_OPENRISC_EXCP_H */
target-openrisc/fpu_helper.c +26 -22
155 lines not on this page · raw message
target-openrisc/mmu_helper.c +3 -14
@@ -19,6 +19,7 @@*/ #include "cpu.h" +#include "exception.h" #ifndef CONFIG_USER_ONLY #include "softmmu_exec.h"
@@ -39,25 +40,13 @@void tlb_fill (CPUOpenRISCState *env,target_ulong addr,int is_write,int mmu_idx,uintptr_t retaddr) { -TranslationBlock *tb; -unsigned long pc;int ret; +OpenRISCCPU *cpu =OPENRISC_CPU (ENV_GET_CPU (env)); ret =cpu_openrisc_handle_mmu_fault (env, addr, is_write, mmu_idx);if (ret) { -if (retaddr) { -/* now we have a real cpu fault. */ - pc = (unsigned long )retaddr; - tb =tb_find_pc (pc); -if (tb) { -/* the PC is inside the translated code. It means that we -have a virtual CPU fault. */ -cpu_restore_state (tb, env, pc); - } - } -/* Raise Exception. */ -cpu_loop_exit (env); +do_raise_exception_err (cpu, env->exception_index, retaddr); } }#endif
Signature · 1 line
1.7.10.4
Quoted 1 line · Feng Gao
From: gaofeng <gaofeng@gaofeng-K43SM.(none)>
This doesn't look like a valid From line...
Quoted 24 lines
When float exception raise, can save right pc.
Signed-off-by Feng Gao <[email protected]>--- target-openrisc/exception.c | 35 ++++++++++++++++++++++++++++-- target-openrisc/exception.h | 8 ++++++- target-openrisc/fpu_helper.c | 48 +++++++++++++++++++++++------------------- target-openrisc/mmu_helper.c | 17 +++------------ 4 files changed, 69 insertions(+), 39 deletions(-)target-openrisc/exception.c +3
-2@@ -20,8 +20,39 @@#include "cpu.h" #include "exception.h" -void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp) +void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t exception) { - cpu->env.exception_index = excp; +do_raise_exception_err (cpu, exception,0 ); +}
target-openrisc/exception.c line 36
Quoted 10 lines
target-openrisc/exception.c +10
-0+ +void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +TranslationBlock *tb; +#if 1 +if (exception <0x100 ) +qemu_log ("%s: %d\n" , __func__, exception); +#endif
Stray debug tracing?
Quoted 11 lines
target-openrisc/exception.c +11
-0+ cpu->env.exception_index = exception; + +if (pc) { +/* now we have a real cpu fault */ + tb =tb_find_pc (pc); +if (tb) { +/* the PC is inside the translated code. It means that we have +a virtual CPU fault */ +cpu_restore_state (tb, &cpu->env, pc); + } + }
target-openrisc/exception.c line 57
Quoted 10 lines
target-openrisc/exception.c +8
-0+cpu_loop_exit (&cpu->env); } + +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +do_raise_exception_err (cpu, exception, pc); +}
What's this wrapper for?
-- PMM
Quoted 27 lines
target-openrisc/exception.c +24
-2-void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp) +void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t exception) { - cpu->env.exception_index = excp; +do_raise_exception_err (cpu, exception,0 ); +} + +void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +TranslationBlock *tb; +#if 1 +if (exception <0x100 ) +qemu_log ("%s: %d\n" , __func__, exception); +#endif + cpu->env.exception_index = exception; + +if (pc) { +/* now we have a real cpu fault */ + tb =tb_find_pc (pc); +if (tb) { +/* the PC is inside the translated code. It means that we have +a virtual CPU fault */ +cpu_restore_state (tb, &cpu->env, pc); + } + }
target-openrisc/exception.c line 57
Quoted 10 lines
target-openrisc/exception.c +8
-0+cpu_loop_exit (&cpu->env); } + +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +do_raise_exception_err (cpu, exception, pc); +}
I don't see any difference between do_raise_exception_err anddo_raise_exception here. MIPS do have those functions, but function do_raise_exception_err has one more parameter for error code. Please see target-mips/op_helper.c. If you don't need error code, there just one function would be sufficient, I think.
Quoted 7 lines
target-openrisc/exception.h +0
-0@@ -23,6 +23,12 @@#include "cpu.h" #include "qemu-common.h"
target-openrisc/exception.h line 33
Quoted 10 lines
target-openrisc/exception.h +7
-1-void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t excp); +void QEMU_NORETURN raise_exception(OpenRISCCPU *cpu, uint32_t exception); +void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc); +void QEMU_NORETURN do_raise_exception(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc);
Ditto.
Regards,
chenwj
Signature · 5 lines
Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
Quoted 11 lines
target-openrisc/exception.c line 36
Quoted 9 lines
target-openrisc/exception.c +9
-0+void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +TranslationBlock *tb; +#if 1 +if (exception <0x100 ) +qemu_log ("%s: %d\n" , __func__, exception); +#endif Stray debug tracing?
target-mips/op_helper.c also has such "#if 1 .. #endif".
Should we remove it?
Regards,
chenwj
Signature · 5 lines
Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
Quoted 12 lines · 陳韋任 (Wei-Ren Chen)
Quoted 11 lines
target-openrisc/exception.c line 36
Quoted 9 lines
target-openrisc/exception.c +9
-0+void QEMU_NORETURN do_raise_exception_err(OpenRISCCPU *cpu, +uint32_t exception, +uintptr_t pc) +{ +TranslationBlock *tb; +#if 1 +if (exception <0x100 ) +qemu_log ("%s: %d\n" , __func__, exception); +#endif Stray debug tracing?
Quoted 2 lines
target-mips/op_helper.calso has such "#if 1 .. #endif".
Should we remove it?
Well, qemu_log() only actually does anything if logging is enabled [which I had forgotten], so that part is OK. However I don't think we should have the #if 1..#endif. Either we want the code or we don't; #if 1 or #if 0 is rarely a good idea.
Also, (1) why are exceptions < 0x100 the only interesting ones? (2) does this really apply equally to mips and openrisc, or was it just an accidental code copying? (3) braces :-).
-- PMM