Linux user for 7.0 patches
The following changes since commit 64c01c7da449bcafc614b27ecf1325bb08031c84:
Merge remote-tracking branch 'remotes/philmd/tags/sdmmc-20220108' into staging (2022-01-11 11:39:31 +0000)
are available in the Git repository at:
https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.0-pull-request
for you to fetch changes up to 4f4e5567f856d9b841494b3b5216a37d2952ee54:
linux-user: Implement capability prctls (2022-01-11 18:40:44 +0100)
----------------------------------------------------------------
linux-user pull request 20220111siginfo_t cleanup
more prtctl() updatetarget_struct.h cleanup
----------------------------------------------------------------
Richard Henderson (30):
linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND linux-user/alpha: Use force_sig_fault linux-user/cris: Use force_sig_fault
linux-user/hppa: Use force_sig_fault
linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG,
OVERFLOW
linux-user: Remove TARGET_NSIGFPE
linux-user/hppa: Set FPE_CONDTRAP for COND linux-user/i386: Split out maybe_handle_vm86_trap linux-user/i386: Use force_sig, force_sig_fault linux-user/m68k: Use force_sig_fault linux-user/microblaze: Use force_sig_fault linux-user/microblaze: Fix SIGFPE si_codes linux-user/mips: Improve do_break
linux-user/mips: Use force_sig_fault
target/mips: Extract break code into env->error_code target/mips: Extract trap code into env->error_code linux-user/openrisc: Use force_sig_fault linux-user/ppc: Use force_sig_fault
linux-user/riscv: Use force_sig_fault linux-user/s390x: Use force_sig_fault
linux-user/sh4: Use force_sig_fault
linux-user/sparc: Use force_sig_fault linux-user/xtensa: Use force_sig_fault linux-user/arm: Move target_oabi_flock64 out of target_structs.h
linux-user: Move target_struct.h generic definitions to generic/
linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
linux-user: Map signal number in PR_GET_PDEATHSIG
linux-user: Implement PR_SET_PDEATHSIG
linux-user: Implement capability prctls
linux-user/aarch64/target_structs.h | 59 +------- linux-user/alpha/cpu_loop.c | 61 +++----- linux-user/arm/target_structs.h | 60 +------- linux-user/cris/cpu_loop.c | 12 +- linux-user/cris/target_structs.h | 59 +------- linux-user/generic/target_structs.h | 58 ++++++++ linux-user/hexagon/target_structs.h | 55 +------ linux-user/hppa/cpu_loop.c | 26 ++-- linux-user/i386/cpu_loop.c | 78 +++++----- linux-user/i386/target_structs.h | 59 +------- linux-user/m68k/cpu_loop.c | 24 +--- linux-user/m68k/target_structs.h | 59 +------- linux-user/microblaze/cpu_loop.c | 71 +++++---- linux-user/microblaze/target_structs.h | 59 +------- linux-user/mips/cpu_loop.c | 166 +++++----------------- linux-user/nios2/target_structs.h | 59 +------- linux-user/openrisc/cpu_loop.c | 18 +-- linux-user/openrisc/target_structs.h | 59 +------- linux-user/ppc/cpu_loop.c | 136 ++++-------------- linux-user/riscv/cpu_loop.c | 31 +--- linux-user/riscv/target_structs.h | 47 +----- linux-user/s390x/cpu_loop.c | 7 +- linux-user/sh4/cpu_loop.c | 6 +- linux-user/sh4/target_structs.h | 59 +------- linux-user/sparc/cpu_loop.c | 14 +- linux-user/syscall.c | 19 ++- linux-user/syscall_defs.h | 3 +- linux-user/x86_64/target_structs.h | 36 +---- linux-user/xtensa/cpu_loop.c | 26 ++-- target/mips/tcg/micromips_translate.c.inc | 10 +- target/mips/tcg/mips16e_translate.c.inc | 2 +- target/mips/tcg/nanomips_translate.c.inc | 4 +- target/mips/tcg/translate.c | 36 ++++- target/mips/tcg/translate.h | 1 + 34 files changed, 318 insertions(+), 1161 deletions(-) create mode 100644 linux-user/generic/target_structs.h
Signature · 1 line
2.33.1
[PULL 01/30] linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap
From: Richard Henderson <[email protected]>
These si_codes were changed in 535906c684fca, for linux 4.17.
Message-Id: <[email protected]>
--- linux-user/alpha/cpu_loop.c | 4 ++-- linux-user/syscall_defs.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
linux-user/alpha/cpu_loop.c +2 -2
@@ -86,7 +86,7 @@ void cpu_loop(CPUAlphaState *env)/* BUGCHK */ info.si_signo =TARGET_SIGTRAP ; info.si_errno =0 ; - info.si_code =0 ; + info.si_code =TARGET_TRAP_UNK ; info._sifields._sigfault._addr = env->pc;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;
@@ -155,7 +155,7 @@ void cpu_loop(CPUAlphaState *env)break ;default : info.si_signo =TARGET_SIGTRAP ; - info.si_code =0 ; + info.si_code =TARGET_TRAP_UNK ;break ; } info.si_errno =0 ;
linux-user/syscall_defs.h +1 -0
@@ -715,6 +715,7 @@ typedef struct target_siginfo {#define TARGET_TRAP_TRACE (2)/* process trace trap */ #define TARGET_TRAP_BRANCH (3)/* process taken branch trap */ #define TARGET_TRAP_HWBKPT (4)/* hardware breakpoint/watchpoint */ +#define TARGET_TRAP_UNK (5)/* undiagnosed trap */ struct target_rlimit {abi_ulong rlim_cur;
Signature · 1 line
2.33.1
[PULL 05/30] linux-user/hppa: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP and missing si_code for SIGBUS.
Message-Id: <[email protected]>
--- linux-user/hppa/cpu_loop.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
linux-user/hppa/cpu_loop.c +3 -15
@@ -110,7 +110,6 @@ static abi_ulong hppa_lws(CPUHPPAState *env)void cpu_loop (CPUHPPAState *env) {CPUState *cs =env_cpu (env); -target_siginfo_t info;abi_ulong ret;int trapnr;
@@ -147,26 +146,15 @@ void cpu_loop(CPUHPPAState *env)case EXCP_ILL :case EXCP_PRIV_OPR :case EXCP_PRIV_REG : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPN ; - info._sifields._sigfault._addr = env->iaoq_f; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->iaoq_f);break ;case EXCP_OVERFLOW :case EXCP_COND :case EXCP_ASSIST : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =0 ; - info._sifields._sigfault._addr = env->iaoq_f; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE ,0 , env->iaoq_f);break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->iaoq_f);break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */
Signature · 1 line
2.33.1
[PULL 07/30] linux-user: Remove TARGET_NSIGFPE
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
This define is unused, and we have no similar define for the other signal sub-codes.
Message-Id: <[email protected]>
--- linux-user/syscall_defs.h | 1 - 1 file changed, 1 deletion(-)
linux-user/syscall_defs.h +0 -1
@@ -688,7 +688,6 @@ typedef struct target_siginfo {#define TARGET_FPE_FLTINV (7)/* floating point invalid operation */ #define TARGET_FPE_FLTSUB (8)/* subscript out of range */ #define TARGET_FPE_FLTUNK (14)/* undiagnosed fp exception */ -#define TARGET_NSIGFPE 15/* * SIGSEGV si_codes
Signature · 1 line
2.33.1
[PULL 02/30] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
This si_code was changed in 4cc13e4f6d441, for linux 4.17.
Message-Id: <[email protected]>
--- linux-user/alpha/cpu_loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/alpha/cpu_loop.c +1 -1
@@ -151,7 +151,7 @@ void cpu_loop(CPUAlphaState *env) info.si_code =TARGET_FPE_FLTRES ;break ;case TARGET_GEN_ROPRAND : - info.si_code =0 ; + info.si_code =TARGET_FPE_FLTUNK ;break ;default : info.si_signo =TARGET_SIGTRAP ;
Signature · 1 line
2.33.1
[PULL 06/30] linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOW
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
These si_codes have been properly set by the kernel since the beginning.
Message-Id: <[email protected]>
--- linux-user/hppa/cpu_loop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/hppa/cpu_loop.c +7 -1
@@ -144,11 +144,17 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_b = env->gr[31 ] +4 ;break ;case EXCP_ILL : +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->iaoq_f); +break ;case EXCP_PRIV_OPR : +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_PRVOPC , env->iaoq_f); +break ;case EXCP_PRIV_REG : -force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->iaoq_f); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_PRVREG , env->iaoq_f);break ;case EXCP_OVERFLOW : +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTOVF , env->iaoq_f); +break ;case EXCP_COND :case EXCP_ASSIST :force_sig_fault (TARGET_SIGFPE ,0 , env->iaoq_f);
Signature · 1 line
2.33.1
[PULL 03/30] linux-user/alpha: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal.
Message-Id: <[email protected]>
--- linux-user/alpha/cpu_loop.c | 61 ++++++++++++------------------------- 1 file changed, 19 insertions(+), 42 deletions(-)
linux-user/alpha/cpu_loop.c +19 -42
@@ -27,8 +27,7 @@void cpu_loop (CPUAlphaState *env) {CPUState *cs =env_cpu (env); -int trapnr; -target_siginfo_t info; +int trapnr, si_code;abi_long sysret;while (1 ) {
@@ -56,18 +55,10 @@ void cpu_loop(CPUAlphaState *env)break ;case EXCP_OPCDEC : do_sigill: - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPC ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , env->pc);break ;case EXCP_ARITH : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_FLTINV ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_FLTINV , env->pc);break ;case EXCP_FEN :/* No-op. Linux simply re-enables the FPU. */
@@ -76,20 +67,10 @@ void cpu_loop(CPUAlphaState *env)switch (env->error_code) {case 0x80 :/* BPT */ - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ; + goto do_sigtrap_brkpt;case 0x81 :/* BUGCHK */ - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_UNK ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ; + goto do_sigtrap_unk;case 0x83 :/* CALLSYS */ trapnr = env->ir[IR_V0 ];
@@ -130,47 +111,43 @@ void cpu_loop(CPUAlphaState *env)abort ();case 0xAA :/* GENTRAP */ - info.si_signo =TARGET_SIGFPE ;switch (env->ir[IR_A0 ]) {case TARGET_GEN_INTOVF : - info.si_code =TARGET_FPE_INTOVF ; + si_code =TARGET_FPE_INTOVF ;break ;case TARGET_GEN_INTDIV : - info.si_code =TARGET_FPE_INTDIV ; + si_code =TARGET_FPE_INTDIV ;break ;case TARGET_GEN_FLTOVF : - info.si_code =TARGET_FPE_FLTOVF ; + si_code =TARGET_FPE_FLTOVF ;break ;case TARGET_GEN_FLTUND : - info.si_code =TARGET_FPE_FLTUND ; + si_code =TARGET_FPE_FLTUND ;break ;case TARGET_GEN_FLTINV : - info.si_code =TARGET_FPE_FLTINV ; + si_code =TARGET_FPE_FLTINV ;break ;case TARGET_GEN_FLTINE : - info.si_code =TARGET_FPE_FLTRES ; + si_code =TARGET_FPE_FLTRES ;break ;case TARGET_GEN_ROPRAND : - info.si_code =TARGET_FPE_FLTUNK ; + si_code =TARGET_FPE_FLTUNK ;break ;default : - info.si_signo =TARGET_SIGTRAP ; - info.si_code =TARGET_TRAP_UNK ; -break ; + goto do_sigtrap_unk; } - info.si_errno =0 ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE , si_code, env->pc);break ;default : goto do_sigill; }break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); + do_sigtrap_brkpt: +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc); +break ; + do_sigtrap_unk: +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_UNK , env->pc);break ;case EXCP_INTERRUPT :/* Just indicate that signals should be handled asap. */
Signature · 1 line
2.33.1
[PULL 17/30] target/mips: Extract trap code into env->error_code
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Simplify cpu_loop by doing all of the decode in translate.
Message-Id: <[email protected]>
--- linux-user/mips/cpu_loop.c | 41 +---------------------- target/mips/tcg/micromips_translate.c.inc | 4 +-- target/mips/tcg/nanomips_translate.c.inc | 4 +-- target/mips/tcg/translate.c | 24 ++++++++++--- 4 files changed, 25 insertions(+), 48 deletions(-)
linux-user/mips/cpu_loop.c +1 -40
@@ -197,51 +197,12 @@ done_syscall:do_tr_or_bp (env, code, false);break ;case EXCP_TRAP : - { -abi_ulong trap_instr; -unsigned int code =0 ; - -/* -* FIXME: It would be better to decode the trap number -* during translate, and store it in error_code while -* raising the exception. We should not be re-reading -* the opcode here. -*/ - -if (env->hflags &MIPS_HFLAG_M16 ) { -/* microMIPS mode */ -abi_ulong instr[2 ]; - - ret =get_user_u16 (instr[0 ], env->active_tc.PC) || -get_user_u16 (instr[1 ], env->active_tc.PC +2 ); - - trap_instr = (instr[0 ] <<16 ) | instr[1 ]; - }else { - ret =get_user_u32 (trap_instr, env->active_tc.PC); - } - -if (ret !=0 ) { - goto error; - } - -/* The immediate versions don't provide a code. */ -if (!(trap_instr &0xFC000000 )) { -if (env->hflags &MIPS_HFLAG_M16 ) { -/* microMIPS mode */ - code = ((trap_instr >>12 ) & ((1 <<4 ) -1 )); - }else { - code = ((trap_instr >>6 ) & ((1 <<10 ) -1 )); - } - } - -do_tr_or_bp (env, code, true); - } +do_tr_or_bp (env, env->error_code, true);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);break ;default : -error:EXCP_DUMP (env,"qemu: unhandled CPU exception 0x%x - aborting\n" , trapnr);abort (); }
target/mips/tcg/micromips_translate.c.inc +2 -2
@@ -1047,7 +1047,7 @@ static void gen_pool32axf(CPUMIPSState *env, DisasContext *ctx, int rt, int rs) case TNE: mips32_op = OPC_TNE; do_trap: - gen_trap(ctx, mips32_op, rs, rt, -1); + gen_trap(ctx, mips32_op, rs, rt, -1, extract32(ctx->opcode, 12, 4)); break; #ifndef CONFIG_USER_ONLY case MFC0:
@@ -2439,7 +2439,7 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_TEQI; do_trapi: - gen_trap(ctx, mips32_op, rs, -1, imm); + gen_trap(ctx, mips32_op, rs, -1, imm, 0); break; case BNEZC:
target/mips/tcg/nanomips_translate.c.inc +2 -2
@@ -1268,11 +1268,11 @@ static void gen_pool32a0_nanomips_insn(CPUMIPSState *env, DisasContext *ctx) switch (extract32(ctx->opcode, 10, 1)) { case NM_TEQ: check_nms(ctx); - gen_trap(ctx, OPC_TEQ, rs, rt, -1); + gen_trap(ctx, OPC_TEQ, rs, rt, -1, rd); break; case NM_TNE: check_nms(ctx); - gen_trap(ctx, OPC_TNE, rs, rt, -1); + gen_trap(ctx, OPC_TNE, rs, rt, -1, rd); break; } break;
target/mips/tcg/translate.c +20 -4
@@ -4733,7 +4733,7 @@ static void gen_loongson_lsdc2(DisasContext *ctx, int rt,/* Traps */ static void gen_trap (DisasContext *ctx,uint32_t opc, -int rs,int rt,int16_t imm) +int rs,int rt,int16_t imm,int code) {int cond;TCGv t0 =tcg_temp_new ();
@@ -4778,6 +4778,11 @@ static void gen_trap(DisasContext *ctx, uint32_t opc,case OPC_TGEU :/* rs >= rs unsigned */ case OPC_TGEIU :/* r0 >= 0 unsigned */ /* Always trap */ +#ifdef CONFIG_USER_ONLY +/* Pass the break code along to cpu_loop. */ +tcg_gen_st_i32 (tcg_constant_i32 (code), cpu_env, + offsetof(CPUMIPSState , error_code)); +#endif generate_exception_end (ctx,EXCP_TRAP );break ;case OPC_TLT :/* rs < rs */
@@ -4818,6 +4823,18 @@ static void gen_trap(DisasContext *ctx, uint32_t opc,tcg_gen_brcond_tl (TCG_COND_EQ , t0, t1, l1);break ; } +#ifdef CONFIG_USER_ONLY +/* Pass the break code along to cpu_loop. */ +tcg_gen_st_i32 (tcg_constant_i32 (code), cpu_env, + offsetof(CPUMIPSState , error_code)); +#endif +/* Like save_cpu_state, only don't update saved values. */ +if (ctx->base.pc_next != ctx->saved_pc) { +gen_save_pc (ctx->base.pc_next); + } +if (ctx->hflags != ctx->saved_hflags) { +tcg_gen_movi_i32 (hflags, ctx->hflags); + }generate_exception (ctx,EXCP_TRAP );gen_set_label (l1); }
@@ -14155,7 +14172,7 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)case OPC_TEQ :case OPC_TNE :check_insn (ctx,ISA_MIPS2 ); -gen_trap (ctx, op1, rs, rt,-1 ); +gen_trap (ctx, op1, rs, rt,-1 ,extract32 (ctx->opcode,6 ,10 ));break ;case OPC_PMON :/* Pmon entry point, also R4010 selsl */
@@ -15289,11 +15306,10 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx)case OPC_TLTI :case OPC_TLTIU :case OPC_TEQI : -case OPC_TNEI :check_insn (ctx,ISA_MIPS2 );check_insn_opc_removed (ctx,ISA_MIPS_R6 ); -gen_trap (ctx, op1, rs,-1 , imm); +gen_trap (ctx, op1, rs,-1 , imm,0 );break ;case OPC_SIGRIE :check_insn (ctx,ISA_MIPS_R6 );
Signature · 1 line
2.33.1
[PULL 11/30] linux-user/m68k: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/m68k/cpu_loop.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-)
linux-user/m68k/cpu_loop.c +4 -20
@@ -29,7 +29,6 @@ void cpu_loop(CPUM68KState *env)CPUState *cs =env_cpu (env);int trapnr;unsigned int n; -target_siginfo_t info;for (;;) {cpu_exec_start (cs);
@@ -46,25 +45,13 @@ void cpu_loop(CPUM68KState *env)case EXCP_ILLEGAL :case EXCP_LINEA :case EXCP_LINEF : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPN ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->pc);break ;case EXCP_CHK : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_INTOVF ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTOVF , env->pc);break ;case EXCP_DIV0 : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_INTDIV ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTDIV , env->pc);break ;case EXCP_TRAP0 : {
@@ -91,10 +78,7 @@ void cpu_loop(CPUM68KState *env)/* just indicate that signals should be handled asap */ break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 10/30] linux-user/i386: Use force_sig, force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Replace the local gen_signal with the generic functions that match how the kernel raises signals. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/i386/cpu_loop.c | 47 +++++++++++++++----------------------- 1 file changed, 18 insertions(+), 29 deletions(-)
linux-user/i386/cpu_loop.c +18 -29
@@ -84,17 +84,6 @@ static void set_idt(int n, unsigned int dpl) }#endif -static void gen_signal (CPUX86State *env,int sig,int code,abi_ptr addr) -{ -target_siginfo_t info = { - .si_signo = sig, - .si_code = code, - ._sifields._sigfault._addr = addr - }; - -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -} -#ifdef TARGET_X86_64 static bool write_ok_or_segv (CPUX86State *env,abi_ptr addr,size_t len) {
@@ -107,7 +96,7 @@ static bool write_ok_or_segv(CPUX86State *env, abi_ptr addr, size_t len) } env->error_code =PG_ERROR_W_MASK |PG_ERROR_U_MASK ; -gen_signal (env,TARGET_SIGSEGV ,TARGET_SEGV_MAPERR , addr); +force_sig_fault (TARGET_SIGSEGV ,TARGET_SEGV_MAPERR , addr);return false; }
@@ -193,8 +182,7 @@ static void emulate_vsyscall(CPUX86State *env)return ; sigsegv: -/* Like force_sig(SIGSEGV). */ - gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); + force_sig(TARGET_SIGSEGV); }#endif
@@ -266,53 +254,54 @@ void cpu_loop(CPUX86State *env)#endif case EXCP0B_NOSEG :case EXCP0C_STACK : -gen_signal (env,TARGET_SIGBUS ,TARGET_SI_KERNEL ,0 ); +force_sig (TARGET_SIGBUS );break ;case EXCP0D_GPF :/* XXX: potential problem if ABI32 */ if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -gen_signal (env,TARGET_SIGSEGV ,TARGET_SI_KERNEL ,0 ); +force_sig (TARGET_SIGSEGV );break ;case EXCP0E_PAGE : -gen_signal (env,TARGET_SIGSEGV , - (env->error_code &1 ? -TARGET_SEGV_ACCERR :TARGET_SEGV_MAPERR ), - env->cr[2 ]); +force_sig_fault (TARGET_SIGSEGV , + (env->error_code &PG_ERROR_P_MASK ? +TARGET_SEGV_ACCERR :TARGET_SEGV_MAPERR ), + env->cr[2 ]);break ;case EXCP00_DIVZ :if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -gen_signal (env,TARGET_SIGFPE ,TARGET_FPE_INTDIV , env->eip); +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTDIV , env->eip);break ;case EXCP01_DB : -case EXCP03_INT3 :if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -if (trapnr ==EXCP01_DB ) { -gen_signal (env,TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->eip); - }else { -gen_signal (env,TARGET_SIGTRAP ,TARGET_SI_KERNEL ,0 ); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->eip); +break ; +case EXCP03_INT3 : +if (maybe_handle_vm86_trap (env, trapnr)) { +break ; } +force_sig (TARGET_SIGTRAP );break ;case EXCP04_INTO :case EXCP05_BOUND :if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -gen_signal (env,TARGET_SIGSEGV ,TARGET_SI_KERNEL ,0 ); +force_sig (TARGET_SIGSEGV );break ;case EXCP06_ILLOP : -gen_signal (env,TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->eip); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPN , env->eip);break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ;case EXCP_DEBUG : -gen_signal (env,TARGET_SIGTRAP ,TARGET_TRAP_BRKPT ,0 ); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->eip);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 04/30] linux-user/cris: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/cris/cpu_loop.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
linux-user/cris/cpu_loop.c +4 -8
@@ -28,8 +28,7 @@ void cpu_loop(CPUCRISState *env) {CPUState *cs =env_cpu (env);int trapnr, ret; -target_siginfo_t info; - +while (1 ) {cpu_exec_start (cs); trapnr =cpu_exec (cs);
@@ -38,8 +37,8 @@ void cpu_loop(CPUCRISState *env)switch (trapnr) {case EXCP_INTERRUPT : -/* just indicate that signals should be handled asap */ -break ; +/* just indicate that signals should be handled asap */ +break ;case EXCP_BREAK : ret = do_syscall(env, env->regs[9],
@@ -57,10 +56,7 @@ void cpu_loop(CPUCRISState *env) }break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 21/30] linux-user/s390x: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal.
Message-Id: <[email protected]>
--- linux-user/s390x/cpu_loop.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
linux-user/s390x/cpu_loop.c +1 -6
@@ -58,7 +58,6 @@ void cpu_loop(CPUS390XState *env) {CPUState *cs =env_cpu (env);int trapnr, n, sig; -target_siginfo_t info;target_ulong addr;abi_long ret;
@@ -158,11 +157,7 @@ void cpu_loop(CPUS390XState *env)*/ env->psw.addr += env->int_pgm_ilen; do_signal: - info.si_signo = sig; - info.si_errno =0 ; - info.si_code = n; - info._sifields._sigfault._addr = addr; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (sig, n, addr);break ;case EXCP_ATOMIC :
Signature · 1 line
2.33.1
[PULL 13/30] linux-user/microblaze: Fix SIGFPE si_codes
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Fix a typo for ESR_EC_DIVZERO, which is integral not floating-point. Fix the if ladder for decoding floating-point exceptions.
Message-Id: <[email protected]>
--- linux-user/microblaze/cpu_loop.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
linux-user/microblaze/cpu_loop.c +15 -5
@@ -77,15 +77,25 @@ void cpu_loop(CPUMBState *env) env->iflags &= ~(IMM_FLAG |D_FLAG );switch (env->esr &31 ) {case ESR_EC_DIVZERO : - si_code =TARGET_FPE_FLTDIV ; + si_code =TARGET_FPE_INTDIV ;break ;case ESR_EC_FPU : - si_code =0 ; -if (env->fsr &FSR_IO ) { +/* +* Note that the kernel passes along fsr as si_code +* if there's no recognized bit set. Possibly this +* implies that si_code is 0, but follow the structure. +*/ + si_code = env->fsr; +if (si_code &FSR_IO ) { si_code =TARGET_FPE_FLTINV ; - } -if (env->fsr &FSR_DZ ) { + }else if (si_code &FSR_OF ) { + si_code =TARGET_FPE_FLTOVF ; + }else if (si_code &FSR_UF ) { + si_code =TARGET_FPE_FLTUND ; + }else if (si_code &FSR_DZ ) { si_code =TARGET_FPE_FLTDIV ; + }else if (si_code &FSR_DO ) { + si_code =TARGET_FPE_FLTRES ; }break ;default :
Signature · 1 line
2.33.1
[PULL 09/30] linux-user/i386: Split out maybe_handle_vm86_trap
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Reduce the number of ifdefs within cpu_loop().
Message-Id: <[email protected]>
--- linux-user/i386/cpu_loop.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
linux-user/i386/cpu_loop.c +15 -16
@@ -198,6 +198,17 @@ static void emulate_vsyscall(CPUX86State *env) }#endif +static bool maybe_handle_vm86_trap (CPUX86State *env,int trapnr) +{ +#ifndef TARGET_X86_64 +if (env->eflags &VM_MASK ) { +handle_vm86_trap (env, trapnr); +return true; + } +#endif +return false; +} +void cpu_loop (CPUX86State *env) {CPUState *cs =env_cpu (env);
@@ -259,12 +270,9 @@ void cpu_loop(CPUX86State *env)break ;case EXCP0D_GPF :/* XXX: potential problem if ABI32 */ -#ifndef TARGET_X86_64 -if (env->eflags &VM_MASK ) { -handle_vm86_fault (env); +if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -#endif gen_signal (env,TARGET_SIGSEGV ,TARGET_SI_KERNEL ,0 );break ;case EXCP0E_PAGE :
@@ -274,22 +282,16 @@ void cpu_loop(CPUX86State *env) env->cr[2]);break ;case EXCP00_DIVZ : -#ifndef TARGET_X86_64 -if (env->eflags &VM_MASK ) { -handle_vm86_trap (env, trapnr); +if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -#endif gen_signal (env,TARGET_SIGFPE ,TARGET_FPE_INTDIV , env->eip);break ;case EXCP01_DB :case EXCP03_INT3 : -#ifndef TARGET_X86_64 -if (env->eflags &VM_MASK ) { -handle_vm86_trap (env, trapnr); +if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -#endif if (trapnr ==EXCP01_DB ) {gen_signal (env,TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->eip); }else {
@@ -298,12 +300,9 @@ void cpu_loop(CPUX86State *env)break ;case EXCP04_INTO :case EXCP05_BOUND : -#ifndef TARGET_X86_64 -if (env->eflags &VM_MASK ) { -handle_vm86_trap (env, trapnr); +if (maybe_handle_vm86_trap (env, trapnr)) {break ; } -#endif gen_signal (env,TARGET_SIGSEGV ,TARGET_SI_KERNEL ,0 );break ;case EXCP06_ILLOP :
Signature · 1 line
2.33.1
[PULL 12/30] linux-user/microblaze: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/microblaze/cpu_loop.c | 61 +++++++++++++------------------- 1 file changed, 25 insertions(+), 36 deletions(-)
linux-user/microblaze/cpu_loop.c +25 -36
@@ -27,9 +27,8 @@void cpu_loop (CPUMBState *env) {CPUState *cs =env_cpu (env); -int trapnr, ret; -target_siginfo_t info; - +int trapnr, ret, si_code; +while (1 ) {cpu_exec_start (cs); trapnr =cpu_exec (cs);
@@ -38,8 +37,8 @@ void cpu_loop(CPUMBState *env)switch (trapnr) {case EXCP_INTERRUPT : -/* just indicate that signals should be handled asap */ -break ; +/* just indicate that signals should be handled asap */ +break ;case EXCP_SYSCALL :/* Return address is 4 bytes after the call. */ env->regs[14 ] +=4 ;
@@ -67,6 +66,7 @@ void cpu_loop(CPUMBState *env)*/ env->regs[14 ] = env->pc;break ; +case EXCP_HW_EXCP : env->regs[17 ] = env->pc +4 ;if (env->iflags &D_FLAG ) {
@@ -74,42 +74,31 @@ void cpu_loop(CPUMBState *env) env->pc -=4 ;/* FIXME: if branch was immed, replay the imm as well. */ } - env->iflags &= ~(IMM_FLAG |D_FLAG ); -switch (env->esr &31 ) { -case ESR_EC_DIVZERO : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_FLTDIV ; - info._sifields._sigfault._addr =0 ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ; -case ESR_EC_FPU : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; -if (env->fsr &FSR_IO ) { - info.si_code =TARGET_FPE_FLTINV ; - } -if (env->fsr &FSR_DZ ) { - info.si_code =TARGET_FPE_FLTDIV ; - } - info._sifields._sigfault._addr =0 ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ; -default : -fprintf (stderr,"Unhandled hw-exception: 0x%x\n" , - env->esr &ESR_EC_MASK ); -cpu_dump_state (cs, stderr,0 ); -exit (EXIT_FAILURE ); -break ; +case ESR_EC_DIVZERO : + si_code =TARGET_FPE_FLTDIV ; +break ; +case ESR_EC_FPU : + si_code =0 ; +if (env->fsr &FSR_IO ) { + si_code =TARGET_FPE_FLTINV ; + } +if (env->fsr &FSR_DZ ) { + si_code =TARGET_FPE_FLTDIV ; + } +break ; +default : +fprintf (stderr,"Unhandled hw-exception: 0x%x\n" , + env->esr &ESR_EC_MASK ); +cpu_dump_state (cs, stderr,0 ); +exit (EXIT_FAILURE ); } +force_sig_fault (TARGET_SIGFPE , si_code, env->pc);break ; +case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 24/30] linux-user/xtensa: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/xtensa/cpu_loop.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
linux-user/xtensa/cpu_loop.c +9 -17
@@ -126,7 +126,6 @@ static void xtensa_underflow12(CPUXtensaState *env)void cpu_loop (CPUXtensaState *env) {CPUState *cs =env_cpu (env); -target_siginfo_t info;abi_ulong ret;int trapnr;
@@ -163,14 +162,12 @@ void cpu_loop(CPUXtensaState *env)case EXC_USER :switch (env->sregs[EXCCAUSE ]) {case ILLEGAL_INSTRUCTION_CAUSE : +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , + env->sregs[EPC1 ]); +break ;case PRIVILEGED_CAUSE : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code = - env->sregs[EXCCAUSE ] ==ILLEGAL_INSTRUCTION_CAUSE ? -TARGET_ILL_ILLOPC :TARGET_ILL_PRVOPC ; - info._sifields._sigfault._addr = env->sregs[EPC1 ]; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_PRVOPC , + env->sregs[EPC1 ]);break ;case SYSCALL_CAUSE :
@@ -219,11 +216,8 @@ void cpu_loop(CPUXtensaState *env)break ;case INTEGER_DIVIDE_BY_ZERO_CAUSE : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_INTDIV ; - info._sifields._sigfault._addr = env->sregs[EPC1 ]; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTDIV , + env->sregs[EPC1 ]);break ;default :
@@ -232,10 +226,8 @@ void cpu_loop(CPUXtensaState *env) }break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , + env->sregs[EPC1 ]);break ;case EXC_DEBUG :default :
Signature · 1 line
2.33.1
[PULL 20/30] linux-user/riscv: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fix missing PC from EXCP_DEBUG by merging the case with EXCP_BREAKPOINT.
Message-Id: <[email protected]>
--- linux-user/riscv/cpu_loop.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-)
linux-user/riscv/cpu_loop.c +5 -26
@@ -30,8 +30,7 @@void cpu_loop (CPURISCVState *env) {CPUState *cs =env_cpu (env); -int trapnr, signum, sigcode; -target_ulong sigaddr; +int trapnr;target_ulong ret;for (;;) {
@@ -40,10 +39,6 @@ void cpu_loop(CPURISCVState *env)cpu_exec_end (cs);process_queued_cpu_work (cs); - signum =0 ; - sigcode =0 ; - sigaddr =0 ; -switch (trapnr) {case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */
@@ -79,39 +74,23 @@ void cpu_loop(CPURISCVState *env) }break ;case RISCV_EXCP_ILLEGAL_INST : - signum =TARGET_SIGILL ; - sigcode =TARGET_ILL_ILLOPC ; +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , env->pc);break ;case RISCV_EXCP_BREAKPOINT : - signum =TARGET_SIGTRAP ; - sigcode =TARGET_TRAP_BRKPT ; - sigaddr = env->pc; +case EXCP_DEBUG : + gdbstep: +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case RISCV_EXCP_SEMIHOST : env->gpr[xA0] =do_common_semihosting (cs); env->pc +=4 ;break ; -case EXCP_DEBUG : - gdbstep: - signum =TARGET_SIGTRAP ; - sigcode =TARGET_TRAP_BRKPT ; -break ;default :EXCP_DUMP (env,"\nqemu: unhandled CPU exception %#x - aborting\n" , trapnr);exit (EXIT_FAILURE ); } -if (signum) { -target_siginfo_t info = { - .si_signo = signum, - .si_errno =0 , - .si_code = sigcode, - ._sifields._sigfault._addr = sigaddr - }; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); - } -process_pending_signals (env); } }
Signature · 1 line
2.33.1
[PULL 15/30] linux-user/mips: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP and SIGFPE; use force_sig (SI_KERNEL) for EXCP_DSPDIS.
Message-Id: <[email protected]>
--- linux-user/mips/cpu_loop.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-)
linux-user/mips/cpu_loop.c +13 -25
@@ -64,8 +64,7 @@ static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap)void cpu_loop (CPUMIPSState *env) {CPUState *cs =env_cpu (env); -target_siginfo_t info; -int trapnr; +int trapnr, si_code;abi_long ret;# ifdef TARGET_ABI_MIPSO32 unsigned int syscall_num;
@@ -156,43 +155,32 @@ done_syscall:break ;case EXCP_CpU:case EXCP_RI : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =0 ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +case EXCP_DSPDIS : +force_sig (TARGET_SIGILL );break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */ break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ; -case EXCP_DSPDIS : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPC ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , + env->active_tc.PC);break ;case EXCP_FPE : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; - info.si_code =TARGET_FPE_FLTUNK ; + si_code =TARGET_FPE_FLTUNK ;if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INVALID ) { - info.si_code =TARGET_FPE_FLTINV ; + si_code =TARGET_FPE_FLTINV ; }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_DIV0 ) { - info.si_code =TARGET_FPE_FLTDIV ; + si_code =TARGET_FPE_FLTDIV ; }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_OVERFLOW ) { - info.si_code =TARGET_FPE_FLTOVF ; + si_code =TARGET_FPE_FLTOVF ; }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_UNDERFLOW ) { - info.si_code =TARGET_FPE_FLTUND ; + si_code =TARGET_FPE_FLTUND ; }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INEXACT ) { - info.si_code =TARGET_FPE_FLTRES ; + si_code =TARGET_FPE_FLTRES ; } -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGFPE , si_code, env->active_tc.PC);break ; +/* The code below was inspired by the MIPS Linux kernel trap * handling code in arch/mips/kernel/traps.c. */
Signature · 1 line
2.33.1
[PULL 18/30] linux-user/openrisc: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/openrisc/cpu_loop.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
linux-user/openrisc/cpu_loop.c +3 -15
@@ -29,7 +29,6 @@ void cpu_loop(CPUOpenRISCState *env)CPUState *cs =env_cpu (env);int trapnr;abi_long ret; -target_siginfo_t info;for (;;) {cpu_exec_start (cs);
@@ -55,27 +54,16 @@ void cpu_loop(CPUOpenRISCState *env) }break ;case EXCP_ALIGN : - info.si_signo =TARGET_SIGBUS ; - info.si_errno =0 ; - info.si_code =TARGET_BUS_ADRALN ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGBUS ,TARGET_BUS_ADRALN , env->eear);break ;case EXCP_ILLEGAL : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPC ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , env->pc);break ;case EXCP_INTERRUPT :/* We processed the pending cpu work above. */ break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 08/30] linux-user/hppa: Set FPE_CONDTRAP for COND
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
This si_code was changed in 75abf64287cab, for linux 4.17.
Message-Id: <[email protected]>
--- linux-user/hppa/cpu_loop.c | 2 ++ linux-user/syscall_defs.h | 1 + 2 files changed, 3 insertions(+)
linux-user/hppa/cpu_loop.c +2 -0
@@ -156,6 +156,8 @@ void cpu_loop(CPUHPPAState *env)force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTOVF , env->iaoq_f);break ;case EXCP_COND : +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_CONDTRAP , env->iaoq_f); +break ;case EXCP_ASSIST :force_sig_fault (TARGET_SIGFPE ,0 , env->iaoq_f);break ;
linux-user/syscall_defs.h +1 -0
@@ -688,6 +688,7 @@ typedef struct target_siginfo {#define TARGET_FPE_FLTINV (7)/* floating point invalid operation */ #define TARGET_FPE_FLTSUB (8)/* subscript out of range */ #define TARGET_FPE_FLTUNK (14)/* undiagnosed fp exception */ +#define TARGET_FPE_CONDTRAP (15)/* trap on condition */ /* * SIGSEGV si_codes
Signature · 1 line
2.33.1
[PULL 19/30] linux-user/ppc: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP. The fault address for POWERPC_EXCP_ISI is nip exactly, not nip - 4.
Message-Id: <[email protected]>
--- linux-user/ppc/cpu_loop.c | 136 ++++++++------------------------------ 1 file changed, 28 insertions(+), 108 deletions(-)
linux-user/ppc/cpu_loop.c +28 -108
@@ -76,8 +76,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val)void cpu_loop (CPUPPCState *env) {CPUState *cs =env_cpu (env); -target_siginfo_t info; -int trapnr; +int trapnr, si_signo, si_code;target_ulong ret;for (;;) {
@@ -102,61 +101,10 @@ void cpu_loop(CPUPPCState *env) "Aborting\n");break ;case POWERPC_EXCP_DSI :/* Data storage exception */ -/* XXX: check this. Seems bugged */ -switch (env->error_code &0xFF000000 ) { -case 0x40000000 : -case 0x42000000 : - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_MAPERR ; -break ; -case 0x04000000 : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLADR ; -break ; -case 0x08000000 : - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_ACCERR ; -break ; -default : -/* Let's send a regular segfault... */ -EXCP_DUMP (env,"Invalid segfault errno (%02x)\n" , - env->error_code); - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_MAPERR ; -break ; - } - info._sifields._sigfault._addr = env->spr[SPR_DAR ]; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ -/* XXX: check this */ -switch (env->error_code &0xFF000000 ) { -case 0x40000000 : - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_MAPERR ; -break ; -case 0x10000000 : -case 0x08000000 : - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_ACCERR ; -break ; -default : -/* Let's send a regular segfault... */ -EXCP_DUMP (env,"Invalid segfault errno (%02x)\n" , - env->error_code); - info.si_signo =TARGET_SIGSEGV ; - info.si_errno =0 ; - info.si_code =TARGET_SEGV_MAPERR ; -break ; - } - info._sifields._sigfault._addr = env->nip -4 ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +/* FIXME: handle maperr in ppc_cpu_record_sigsegv. */ +force_sig_fault (TARGET_SIGSEGV ,TARGET_SEGV_MAPERR , + env->spr[SPR_DAR ]);break ;case POWERPC_EXCP_EXTERNAL :/* External input */ cpu_abort(cs, "External interrupt while in user mode. "
@@ -167,24 +115,23 @@ void cpu_loop(CPUPPCState *env)/* XXX: check this */ switch (env->error_code & ~0xF ) {case POWERPC_EXCP_FP : - info.si_signo =TARGET_SIGFPE ; - info.si_errno =0 ; + si_signo =TARGET_SIGFPE ;switch (env->error_code &0xF ) {case POWERPC_EXCP_FP_OX : - info.si_code =TARGET_FPE_FLTOVF ; + si_code =TARGET_FPE_FLTOVF ;break ;case POWERPC_EXCP_FP_UX : - info.si_code =TARGET_FPE_FLTUND ; + si_code =TARGET_FPE_FLTUND ;break ;case POWERPC_EXCP_FP_ZX :case POWERPC_EXCP_FP_VXZDZ : - info.si_code =TARGET_FPE_FLTDIV ; + si_code =TARGET_FPE_FLTDIV ;break ;case POWERPC_EXCP_FP_XX : - info.si_code =TARGET_FPE_FLTRES ; + si_code =TARGET_FPE_FLTRES ;break ;case POWERPC_EXCP_FP_VXSOFT : - info.si_code =TARGET_FPE_FLTINV ; + si_code =TARGET_FPE_FLTINV ;break ;case POWERPC_EXCP_FP_VXSNAN :case POWERPC_EXCP_FP_VXISI :
@@ -193,51 +140,50 @@ void cpu_loop(CPUPPCState *env)case POWERPC_EXCP_FP_VXVC :case POWERPC_EXCP_FP_VXSQRT :case POWERPC_EXCP_FP_VXCVI : - info.si_code =TARGET_FPE_FLTSUB ; + si_code =TARGET_FPE_FLTSUB ;break ;default :EXCP_DUMP (env,"Unknown floating point exception (%02x)\n" , env->error_code); + si_code =0 ;break ; }break ;case POWERPC_EXCP_INVAL : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; + si_signo =TARGET_SIGILL ;switch (env->error_code &0xF ) {case POWERPC_EXCP_INVAL_INVAL : - info.si_code =TARGET_ILL_ILLOPC ; + si_code =TARGET_ILL_ILLOPC ;break ;case POWERPC_EXCP_INVAL_LSWX : - info.si_code =TARGET_ILL_ILLOPN ; + si_code =TARGET_ILL_ILLOPN ;break ;case POWERPC_EXCP_INVAL_SPR : - info.si_code =TARGET_ILL_PRVREG ; + si_code =TARGET_ILL_PRVREG ;break ;case POWERPC_EXCP_INVAL_FP : - info.si_code =TARGET_ILL_COPROC ; + si_code =TARGET_ILL_COPROC ;break ;default :EXCP_DUMP (env,"Unknown invalid operation (%02x)\n" , env->error_code &0xF ); - info.si_code =TARGET_ILL_ILLADR ; + si_code =TARGET_ILL_ILLADR ;break ; }break ;case POWERPC_EXCP_PRIV : - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; + si_signo =TARGET_SIGILL ;switch (env->error_code &0xF ) {case POWERPC_EXCP_PRIV_OPC : - info.si_code =TARGET_ILL_PRVOPC ; + si_code =TARGET_ILL_PRVOPC ;break ;case POWERPC_EXCP_PRIV_REG : - info.si_code =TARGET_ILL_PRVREG ; + si_code =TARGET_ILL_PRVREG ;break ;default :EXCP_DUMP (env,"Unknown privilege violation (%02x)\n" , env->error_code &0xF ); - info.si_code =TARGET_ILL_PRVOPC ; + si_code =TARGET_ILL_PRVOPC ;break ; }break ;
@@ -250,28 +196,19 @@ void cpu_loop(CPUPPCState *env) env->error_code);break ; } - info._sifields._sigfault._addr = env->nip; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (si_signo, si_code, env->nip);break ;case POWERPC_EXCP_FPU :/* Floating-point unavailable exception */ - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_COPROC ; - info._sifields._sigfault._addr = env->nip; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ +case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavail. */ +case POWERPC_EXCP_VPU :/* Vector unavailable exception */ +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_COPROC , env->nip);break ;case POWERPC_EXCP_SYSCALL :/* System call exception */ case POWERPC_EXCP_SYSCALL_VECTORED :cpu_abort (cs,"Syscall exception while in user mode. " "Aborting\n" );break ; -case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_COPROC ; - info._sifields._sigfault._addr = env->nip; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ;case POWERPC_EXCP_DECR :/* Decrementer exception */ cpu_abort (cs,"Decrementer interrupt while in user mode. " "Aborting\n" );
@@ -292,13 +229,6 @@ void cpu_loop(CPUPPCState *env)cpu_abort (cs,"Instruction TLB exception while in user mode. " "Aborting\n" );break ; -case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavail. */ - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_COPROC ; - info._sifields._sigfault._addr = env->nip; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ;case POWERPC_EXCP_EFPDI :/* Embedded floating-point data IRQ */ cpu_abort (cs,"Embedded floating-point data IRQ not handled\n" );break ;
@@ -355,13 +285,6 @@ void cpu_loop(CPUPPCState *env)cpu_abort (cs,"Hypervisor instruction segment exception " "while in user mode. Aborting\n" );break ; -case POWERPC_EXCP_VPU :/* Vector unavailable exception */ - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_COPROC ; - info._sifields._sigfault._addr = env->nip; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); -break ;case POWERPC_EXCP_PIT :/* Programmable interval timer IRQ */ cpu_abort (cs,"Programmable interval timer interrupt " "while in user mode. Aborting\n" );
@@ -444,10 +367,7 @@ void cpu_loop(CPUPPCState *env) env->gpr[3 ] = ret;break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->nip);break ;case EXCP_INTERRUPT :/* just indicate that signals should be handled asap */
Signature · 1 line
2.33.1
[PULL 23/30] linux-user/sparc: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/sparc/cpu_loop.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
linux-user/sparc/cpu_loop.c +2 -12
@@ -155,7 +155,6 @@ void cpu_loop (CPUSPARCState *env)CPUState *cs =env_cpu (env);int trapnr;abi_long ret; -target_siginfo_t info;while (1 ) {cpu_exec_start (cs);
@@ -241,19 +240,10 @@ void cpu_loop (CPUSPARCState *env)/* just indicate that signals should be handled asap */ break ;case TT_ILL_INSN : - { - info.si_signo =TARGET_SIGILL ; - info.si_errno =0 ; - info.si_code =TARGET_ILL_ILLOPC ; - info._sifields._sigfault._addr = env->pc; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); - } +force_sig_fault (TARGET_SIGILL ,TARGET_ILL_ILLOPC , env->pc);break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 22/30] linux-user/sh4: Use force_sig_fault
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP.
Message-Id: <[email protected]>
--- linux-user/sh4/cpu_loop.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
linux-user/sh4/cpu_loop.c +1 -5
@@ -28,7 +28,6 @@ void cpu_loop(CPUSH4State *env) {CPUState *cs =env_cpu (env);int trapnr, ret; -target_siginfo_t info;while (1 ) {bool arch_interrupt = true;
@@ -60,10 +59,7 @@ void cpu_loop(CPUSH4State *env)/* just indicate that signals should be handled asap */ break ;case EXCP_DEBUG : - info.si_signo =TARGET_SIGTRAP ; - info.si_errno =0 ; - info.si_code =TARGET_TRAP_BRKPT ; -queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , env->pc);break ;case EXCP_ATOMIC :cpu_exec_step_atomic (cs);
Signature · 1 line
2.33.1
[PULL 27/30] linux-user: Do not special-case NULL for PR_GET_PDEATHSIG
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
The kernel does not special-case arg2 != NULL, so
neither should we.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -6444,7 +6444,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,int deathsig; ret =get_errno (prctl (PR_GET_PDEATHSIG , &deathsig, arg3, arg4, arg5)); -if (!is_error (ret) && arg2 &&put_user_s32 (deathsig, arg2)) { +if (!is_error (ret) &&put_user_s32 (deathsig, arg2)) {return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.33.1
[PULL 28/30] linux-user: Map signal number in PR_GET_PDEATHSIG
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Convert the host signal number to guest signal number before returning the value to the guest.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -6444,7 +6444,8 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,int deathsig; ret =get_errno (prctl (PR_GET_PDEATHSIG , &deathsig, arg3, arg4, arg5)); -if (!is_error (ret) &&put_user_s32 (deathsig, arg2)) { +if (!is_error (ret) && +put_user_s32 (host_to_target_signal (deathsig), arg2)) {return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.33.1
[PULL 29/30] linux-user: Implement PR_SET_PDEATHSIG
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
linux-user/syscall.c +3 -0
@@ -6450,6 +6450,9 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, }return ret; } +case PR_SET_PDEATHSIG : +return get_errno (prctl (PR_SET_PDEATHSIG ,target_to_host_signal (arg2), + arg3, arg4, arg5));case PR_GET_NAME : {void *name =lock_user (VERIFY_WRITE , arg2,16 ,1 );
Signature · 1 line
2.33.1
[PULL 14/30] linux-user/mips: Improve do_break
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Rename to do_tr_or_bp, as per the kernel function.
Add a 'trap' argument, akin to the kernel's si_code, but clearer. The return value is always 0, so change the return value to void. Use force_sig and force_sig_fault.
Message-Id: <[email protected]>
--- linux-user/mips/cpu_loop.c | 46 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-)
linux-user/mips/cpu_loop.c +26 -20
@@ -40,29 +40,25 @@ enum { BRK_DIVZERO = 7 }; -static int do_break (CPUMIPSState *env,target_siginfo_t *info, -unsigned int code) +static void do_tr_or_bp (CPUMIPSState *env,unsigned int code,bool trap) { -int ret =-1 ; +target_ulong pc = env->active_tc.PC;switch (code) {case BRK_OVERFLOW : +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTOVF , pc); +break ;case BRK_DIVZERO : - info->si_signo =TARGET_SIGFPE ; - info->si_errno =0 ; - info->si_code = (code ==BRK_OVERFLOW ) ?FPE_INTOVF :FPE_INTDIV ; -queue_signal (env, info->si_signo,QEMU_SI_FAULT , &*info); - ret =0 ; +force_sig_fault (TARGET_SIGFPE ,TARGET_FPE_INTDIV , pc);break ;default : - info->si_signo =TARGET_SIGTRAP ; - info->si_errno =0 ; -queue_signal (env, info->si_signo,QEMU_SI_FAULT , &*info); - ret =0 ; +if (trap) { +force_sig (TARGET_SIGTRAP ); + }else { +force_sig_fault (TARGET_SIGTRAP ,TARGET_TRAP_BRKPT , pc); + }break ; } - -return ret; }void cpu_loop (CPUMIPSState *env)
@@ -205,6 +201,13 @@ done_syscall:abi_ulong trap_instr;unsigned int code; +/* +* FIXME: It would be better to decode the trap number +* during translate, and store it in error_code while +* raising the exception. We should not be re-reading +* the opcode here. +*/ +if (env->hflags &MIPS_HFLAG_M16 ) {if (env->insn_flags &ASE_MICROMIPS ) {/* microMIPS mode */
@@ -257,9 +260,7 @@ done_syscall: } } -if (do_break (env, &info, code) !=0 ) { - goto error; - } +do_tr_or_bp (env, code, false); }break ;case EXCP_TRAP :
@@ -267,6 +268,13 @@ done_syscall:abi_ulong trap_instr;unsigned int code =0 ; +/* +* FIXME: It would be better to decode the trap number +* during translate, and store it in error_code while +* raising the exception. We should not be re-reading +* the opcode here. +*/ +if (env->hflags &MIPS_HFLAG_M16 ) {/* microMIPS mode */ abi_ulong instr[2 ];
@@ -293,9 +301,7 @@ done_syscall: } } -if (do_break (env, &info, code) !=0 ) { - goto error; - } +do_tr_or_bp (env, code, true); }break ;case EXCP_ATOMIC :
Signature · 1 line
2.33.1
[PULL 26/30] linux-user: Move target_struct.h generic definitions to generic/
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Most targets share the same generic ipc structure definitions.
Message-Id: <[email protected]>
--- linux-user/aarch64/target_structs.h | 59 +------------------------- linux-user/arm/target_structs.h | 52 +---------------------- linux-user/cris/target_structs.h | 59 +------------------------- linux-user/generic/target_structs.h | 58 +++++++++++++++++++++++++ linux-user/hexagon/target_structs.h | 55 +----------------------- linux-user/i386/target_structs.h | 59 +------------------------- linux-user/m68k/target_structs.h | 59 +------------------------- linux-user/microblaze/target_structs.h | 59 +------------------------- linux-user/nios2/target_structs.h | 59 +------------------------- linux-user/openrisc/target_structs.h | 59 +------------------------- linux-user/riscv/target_structs.h | 47 +------------------- linux-user/sh4/target_structs.h | 59 +------------------------- linux-user/x86_64/target_structs.h | 36 +--------------- 13 files changed, 70 insertions(+), 650 deletions(-) create mode 100644 linux-user/generic/target_structs.h
linux-user/aarch64/target_structs.h +1 -58
@@ -1,58 +1 @@ -/* -* ARM AArch64 specific structures for linux-user -* -* Copyright (c) 2013 Fabrice Bellard -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ -#ifndef AARCH64_TARGET_STRUCTS_H -#define AARCH64_TARGET_STRUCTS_H - -struct target_ipc_perm { -abi_int __key;/* Key. */ -abi_uint uid;/* Owner's user ID. */ -abi_uint gid;/* Owner's group ID. */ -abi_uint cuid;/* Creator's user ID. */ -abi_uint cgid;/* Creator's group ID. */ -abi_ushort mode;/* Read/write permission. */ -abi_ushort __pad1; -abi_ushort __seq;/* Sequence number. */ -abi_ushort __pad2; -abi_ulong __unused1; -abi_ulong __unused2; -}; - -struct target_shmid_ds { -struct target_ipc_perm shm_perm;/* operation permission struct */ -abi_long shm_segsz;/* size of segment in bytes */ -abi_ulong shm_atime;/* time of last shmat() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused1; -#endif -abi_ulong shm_dtime;/* time of last shmdt() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused2; -#endif -abi_ulong shm_ctime;/* time of last change by shmctl() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused3; -#endif -abi_int shm_cpid;/* pid of creator */ -abi_int shm_lpid;/* pid of last shmop */ -abi_ulong shm_nattch;/* number of current attaches */ -abi_ulong __unused4; -abi_ulong __unused5; -}; - -#endif +#include "../generic/target_structs.h"
linux-user/arm/target_structs.h +1 -51
52 lines not on this page · raw message
linux-user/cris/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/generic/target_structs.h new file +58 -0
58 lines not on this page · raw message
linux-user/hexagon/target_structs.h +1 -54
55 lines not on this page · raw message
linux-user/i386/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/m68k/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/microblaze/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/nios2/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/openrisc/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/riscv/target_structs.h +1 -46
47 lines not on this page · raw message
linux-user/sh4/target_structs.h +1 -58
59 lines not on this page · raw message
linux-user/x86_64/target_structs.h +1 -35
@@ -19,41 +19,7 @@#ifndef X86_64_TARGET_STRUCTS_H #define X86_64_TARGET_STRUCTS_H -struct target_ipc_perm { -abi_int __key;/* Key. */ -abi_uint uid;/* Owner's user ID. */ -abi_uint gid;/* Owner's group ID. */ -abi_uint cuid;/* Creator's user ID. */ -abi_uint cgid;/* Creator's group ID. */ -abi_ushort mode;/* Read/write permission. */ -abi_ushort __pad1; -abi_ushort __seq;/* Sequence number. */ -abi_ushort __pad2; -abi_ulong __unused1; -abi_ulong __unused2; -}; - -struct target_shmid_ds { -struct target_ipc_perm shm_perm;/* operation permission struct */ -abi_long shm_segsz;/* size of segment in bytes */ -abi_ulong shm_atime;/* time of last shmat() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused1; -#endif -abi_ulong shm_dtime;/* time of last shmdt() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused2; -#endif -abi_ulong shm_ctime;/* time of last change by shmctl() */ -#if TARGET_ABI_BITS ==32 -abi_ulong __unused3; -#endif -abi_int shm_cpid;/* pid of creator */ -abi_int shm_lpid;/* pid of last shmop */ -abi_ulong shm_nattch;/* number of current attaches */ -abi_ulong __unused4; -abi_ulong __unused5; -}; +#include "../generic/target_structs.h" /* The x86 definition differs from the generic one in that the * two padding fields exist whether the ABI is 32 bits or 64 bits.
Signature · 1 line
2.33.1
[PULL 16/30] target/mips: Extract break code into env->error_code
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Simplify cpu_loop by doing all of the decode in translate.
This fixes a bug in that cpu_loop was not handling the different layout of the R6 version of break16. This fixes a bug in that cpu_loop extracted the wrong bits for the mips16e break16 instruction.
Message-Id: <[email protected]>
--- linux-user/mips/cpu_loop.c | 73 +++-------------------- target/mips/tcg/micromips_translate.c.inc | 6 +- target/mips/tcg/mips16e_translate.c.inc | 2 +- target/mips/tcg/translate.c | 12 +++- target/mips/tcg/translate.h | 1 + 5 files changed, 25 insertions(+), 69 deletions(-)
linux-user/mips/cpu_loop.c +9 -64
@@ -65,6 +65,7 @@ void cpu_loop(CPUMIPSState *env) {CPUState *cs =env_cpu (env);int trapnr, si_code; +unsigned int code;abi_long ret;# ifdef TARGET_ABI_MIPSO32 unsigned int syscall_num;
@@ -185,71 +186,15 @@ done_syscall:* handling code in arch/mips/kernel/traps.c. */ case EXCP_BREAK : - { -abi_ulong trap_instr; -unsigned int code; - -/* -* FIXME: It would be better to decode the trap number -* during translate, and store it in error_code while -* raising the exception. We should not be re-reading -* the opcode here. -*/ - -if (env->hflags &MIPS_HFLAG_M16 ) { -if (env->insn_flags &ASE_MICROMIPS ) { -/* microMIPS mode */ - ret =get_user_u16 (trap_instr, env->active_tc.PC); -if (ret !=0 ) { - goto error; - } - -if ((trap_instr >>10 ) ==0x11 ) { -/* 16-bit instruction */ - code = trap_instr &0xf ; - }else { -/* 32-bit instruction */ -abi_ulong instr_lo; - - ret =get_user_u16 (instr_lo, - env->active_tc.PC +2 ); -if (ret !=0 ) { - goto error; - } - trap_instr = (trap_instr <<16 ) | instr_lo; - code = ((trap_instr >>6 ) & ((1 <<20 ) -1 )); -/* Unfortunately, microMIPS also suffers from -the old assembler bug... */ -if (code >= (1 <<10 )) { - code >>=10 ; - } - } - }else { -/* MIPS16e mode */ - ret =get_user_u16 (trap_instr, env->active_tc.PC); -if (ret !=0 ) { - goto error; - } - code = (trap_instr >>6 ) &0x3f ; - } - }else { - ret =get_user_u32 (trap_instr, env->active_tc.PC); -if (ret !=0 ) { - goto error; - } - -/* As described in the original Linux kernel code, the -* below checks on 'code' are to work around an old -* assembly bug. -*/ - code = ((trap_instr >>6 ) & ((1 <<20 ) -1 )); -if (code >= (1 <<10 )) { - code >>=10 ; - } - } - -do_tr_or_bp (env, code, false); +/* +* As described in the original Linux kernel code, the below +* checks on 'code' are to work around an old assembly bug. +*/ + code = env->error_code; +if (code >= (1 <<10 )) { + code >>=10 ; } +do_tr_or_bp (env, code, false);break ;case EXCP_TRAP : {
target/mips/tcg/micromips_translate.c.inc +3 -3
@@ -822,7 +822,7 @@ static void gen_pool16c_insn(DisasContext *ctx) gen_HILO(ctx, OPC_MFLO, 0, uMIPS_RS5(ctx->opcode)); break; case BREAK16: - generate_exception_end(ctx, EXCP_BREAK); + generate_exception_break(ctx, extract32(ctx->opcode, 0, 4)); break; case SDBBP16: if (is_uhi(extract32(ctx->opcode, 0, 4))) {
@@ -937,7 +937,7 @@ static void gen_pool16c_r6_insn(DisasContext *ctx) break; case R6_BREAK16: /* BREAK16 */ - generate_exception(ctx, EXCP_BREAK); + generate_exception_break(ctx, extract32(ctx->opcode, 6, 4)); break; case R6_SDBBP16: /* SDBBP16 */
@@ -1812,7 +1812,7 @@ static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) gen_pool32axf(env, ctx, rt, rs); break; case BREAK32: - generate_exception_end(ctx, EXCP_BREAK); + generate_exception_break(ctx, extract32(ctx->opcode, 6, 20)); break; case SIGRIE: check_insn(ctx, ISA_MIPS_R6);
target/mips/tcg/mips16e_translate.c.inc +1 -1
@@ -969,7 +969,7 @@ static int decode_ase_mips16e(CPUMIPSState *env, DisasContext *ctx) gen_slt(ctx, OPC_SLTU, 24, rx, ry); break; case RR_BREAK: - generate_exception_end(ctx, EXCP_BREAK); + generate_exception_break(ctx, extract32(ctx->opcode, 5, 6)); break; case RR_SLLV: gen_shift(ctx, OPC_SLLV, ry, rx, ry);
target/mips/tcg/translate.c +11 -1
@@ -1367,6 +1367,16 @@ void generate_exception_end(DisasContext *ctx, int excp)generate_exception_err (ctx, excp,0 ); } +void generate_exception_break (DisasContext *ctx,int code) +{ +#ifdef CONFIG_USER_ONLY +/* Pass the break code along to cpu_loop. */ +tcg_gen_st_i32 (tcg_constant_i32 (code), cpu_env, + offsetof(CPUMIPSState , error_code)); +#endif +generate_exception_end (ctx,EXCP_BREAK ); +} +void gen_reserved_instruction (DisasContext *ctx) {generate_exception_end (ctx,EXCP_RI );
@@ -14160,7 +14170,7 @@ static void decode_opc_special(CPUMIPSState *env, DisasContext *ctx)generate_exception_end (ctx,EXCP_SYSCALL );break ;case OPC_BREAK : -generate_exception_end (ctx,EXCP_BREAK ); +generate_exception_break (ctx,extract32 (ctx->opcode,6 ,20 ));break ;case OPC_SYNC :check_insn (ctx,ISA_MIPS2 );
target/mips/tcg/translate.h +1 -0
@@ -129,6 +129,7 @@ enum {void generate_exception (DisasContext *ctx,int excp);void generate_exception_err (DisasContext *ctx,int excp,int err);void generate_exception_end (DisasContext *ctx,int excp); +void generate_exception_break (DisasContext *ctx,int code);void gen_reserved_instruction (DisasContext *ctx);void check_insn (DisasContext *ctx,uint64_t flags);
Signature · 1 line
2.33.1
[PULL 25/30] linux-user/arm: Move target_oabi_flock64 out of target_structs.h
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
Place it next to copy_from/to_user_oabi_flock64, the only users, inside the existing target-specific ifdef. This leaves only generic ipc structs in target_structs.h.
Message-Id: <[email protected]>
--- linux-user/arm/target_structs.h | 8 -------- linux-user/syscall.c | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-)
linux-user/arm/target_structs.h +0 -8
@@ -48,12 +48,4 @@ struct target_shmid_ds {abi_ulong __unused4; abi_ulong __unused5; }; - -struct target_oabi_flock64 { -abi_short l_type; -abi_short l_whence; -abi_llong l_start; -abi_llong l_len; -abi_int l_pid; -}QEMU_PACKED ;#endif
linux-user/syscall.c +8 -0
@@ -6927,6 +6927,14 @@ typedef abi_long from_flock64_fn(struct flock64 *fl, abi_ulong target_addr);typedef abi_long to_flock64_fn (abi_ulong target_addr,const struct flock64 *fl);#if defined(TARGET_ARM ) &&TARGET_ABI_BITS ==32 +struct target_oabi_flock64 { +abi_short l_type; +abi_short l_whence; +abi_llong l_start; +abi_llong l_len; +abi_int l_pid; +}QEMU_PACKED ; +static inline abi_long copy_from_user_oabi_flock64 (struct flock64 *fl,abi_ulong target_flock_addr) {
Signature · 1 line
2.33.1
[PULL 30/30] linux-user: Implement capability prctls
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
This is PR_CAPBSET_READ, PR_CAPBSET_DROP and the "legacy" PR_CAP_AMBIENT PR_GET_SECUREBITS, PR_SET_SECUREBITS.
All of these arguments are integer values only, and do not require mapping of values between host and guest.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+)
linux-user/syscall.c +5 -0
@@ -6504,10 +6504,15 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,case PR_SET_UNALIGN :return do_prctl_set_unalign (env, arg2); +case PR_CAP_AMBIENT : +case PR_CAPBSET_READ : +case PR_CAPBSET_DROP :case PR_GET_DUMPABLE :case PR_SET_DUMPABLE :case PR_GET_KEEPCAPS :case PR_SET_KEEPCAPS : +case PR_GET_SECUREBITS : +case PR_SET_SECUREBITS :case PR_GET_TIMING :case PR_SET_TIMING :case PR_GET_TIMERSLACK :
Signature · 1 line
2.33.1
Peter Maydell
AppliedQuoted 11 lines · Laurent Vivier
The following changes since commit
64c01c7da449bcafc614b27ecf1325bb08031c84:Merge remote-tracking branch 'remotes/philmd/tags/sdmmc-20220108' into staging (2022-01-11 11:39:31 +0000)
are available in the Git repository at:
https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.0-pull-request
for you to fetch changes up to
4f4e5567f856d9b841494b3b5216a37d2952ee54:
Quoted 8 lines
linux-user: Implement capability prctls (2022-01-11 18:40:44 +0100)
----------------------------------------------------------------
linux-user pull request 20220111siginfo_tcleanup
moreprtctl()updatetarget_struct.hcleanup
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.0
for any user-visible changes.
-- PMM