mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
linux-user/nios2: Properly emulate EXCP_TRAP
The real kernel has to load the instruction and extract the imm5 field; for qemu, modify the translator to do this. The use of R_AT for this in cpu_loop was a bug. Handle the other trap numbers as per the kernel's trap_table. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20211221025012.1057923-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
e13685a6e5
commit
87d7bfdba1
3 changed files with 39 additions and 20 deletions
|
@ -636,6 +636,21 @@ static void divu(DisasContext *dc, uint32_t code, uint32_t flags)
|
|||
tcg_temp_free(t0);
|
||||
}
|
||||
|
||||
static void trap(DisasContext *dc, uint32_t code, uint32_t flags)
|
||||
{
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
/*
|
||||
* The imm5 field is not stored anywhere on real hw; the kernel
|
||||
* has to load the insn and extract the field. But we can make
|
||||
* things easier for cpu_loop if we pop this into env->error_code.
|
||||
*/
|
||||
R_TYPE(instr, code);
|
||||
tcg_gen_st_i32(tcg_constant_i32(instr.imm5), cpu_env,
|
||||
offsetof(CPUNios2State, error_code));
|
||||
#endif
|
||||
t_gen_helper_raise_exception(dc, EXCP_TRAP);
|
||||
}
|
||||
|
||||
static const Nios2Instruction r_type_instructions[] = {
|
||||
INSTRUCTION_ILLEGAL(),
|
||||
INSTRUCTION(eret), /* eret */
|
||||
|
@ -682,7 +697,7 @@ static const Nios2Instruction r_type_instructions[] = {
|
|||
INSTRUCTION_ILLEGAL(),
|
||||
INSTRUCTION_ILLEGAL(),
|
||||
INSTRUCTION_ILLEGAL(),
|
||||
INSTRUCTION_FLG(gen_excp, EXCP_TRAP), /* trap */
|
||||
INSTRUCTION(trap), /* trap */
|
||||
INSTRUCTION(wrctl), /* wrctl */
|
||||
INSTRUCTION_ILLEGAL(),
|
||||
INSTRUCTION_FLG(gen_cmpxx, TCG_COND_LTU), /* cmpltu */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue