target/s390: Use tcg unwinding for ilen
v5 cover target/s390: Use tcg unwinding for ilen
Changes since v4:
* Fix a rebase error in patch 2.
* Fix s390_cpu_get_phys_page_debug in patch 9.
* Rebased on David's tree.
Based-on: https://github.com/davidhildenbrand/qemu/tree/mmu
r~
Richard Henderson (18):
target/s390x: Add ilen to unwind data
target/s390x: Remove ilen parameter from tcg_s390_program_interrupt target/s390x: Remove ilen parameter from s390_program_interrupt target/s390x: Use tcg_s390_program_interrupt in TCG helpers target/s390x: Push trigger_pgm_exception lower in s390_cpu_tlb_fill target/s390x: Handle tec in s390_cpu_tlb_fill target/s390x: Return exception from mmu_translate_real target/s390x: Remove exc argument to mmu_translate_asce target/s390x: Return exception from mmu_translate target/s390x: Return exception from translate_pages target/s390x: Remove fail variable from s390_cpu_tlb_fill target/s390x: Simplify helper_lra
target/s390x: Rely on unwinding in s390_cpu_tlb_fill target/s390x: Rely on unwinding in s390_cpu_virt_mem_rw target/s390x: Remove ILEN_AUTO
target/s390x: Remove ilen argument from trigger_access_exception target/s390x: Remove ilen argument from trigger_pgm_exception target/s390x: Remove ILEN_UNWIND
target/s390x/cpu.h | 7 +--- target/s390x/internal.h | 6 +-- target/s390x/tcg_s390x.h | 4 +- hw/s390x/s390-pci-inst.c | 58 +++++++++++++------------- target/s390x/cc_helper.c | 4 +- target/s390x/crypto_helper.c | 7 ++-- target/s390x/diag.c | 14 +++---- target/s390x/excp_helper.c | 60 ++++++++++++-------------- target/s390x/fpu_helper.c | 6 +-- target/s390x/helper.c | 3 +- target/s390x/int_helper.c | 15 +++---- target/s390x/interrupt.c | 9 ++-- target/s390x/ioinst.c | 40 +++++++++--------- target/s390x/mem_helper.c | 61 +++++++++++++-------------- target/s390x/misc_helper.c | 27 ++++-------- target/s390x/mmu_helper.c | 81 +++++++++++++++--------------------- target/s390x/tcg-stub.c | 4 +- target/s390x/translate.c | 20 +++++++-- 18 files changed, 202 insertions(+), 224 deletions(-)
Signature · 1 line
2.17.1
PATCH v5 1/18 target/s390x: Add ilen to unwind data
From: Richard Henderson <[email protected]>
Use ILEN_UNWIND to signal that we have in fact that cpu_restore_state will have been called by the time we arrive in do_program_interrupt.
--- target/s390x/cpu.h | 4 +++- target/s390x/interrupt.c | 5 ++++- target/s390x/translate.c | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-)
target/s390x/cpu.h +3 -1
@@ -34,7 +34,7 @@/* The z/Architecture has a strong memory model with some store-after-load re-ordering */ #define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) -#define TARGET_INSN_START_EXTRA_WORDS 1 +#define TARGET_INSN_START_EXTRA_WORDS 2#define MMU_MODE0_SUFFIX _primary#define MMU_MODE1_SUFFIX _secondary
@@ -804,6 +804,8 @@ int cpu_s390x_signal_handler(int host_signum, void *pinfo, void *puc);void s390_crw_mchk (void );void s390_io_interrupt (uint16_t subchannel_id,uint16_t subchannel_nr,uint32_t io_int_parm,uint32_t io_int_word); +/* instruction length set by unwind info */ +#define ILEN_UNWIND 0/* automatically detect the instruction length */ #define ILEN_AUTO 0xff#define RA_IGNORED 0
target/s390x/interrupt.c +4 -1
@@ -28,7 +28,10 @@ void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen) cs->exception_index =EXCP_PGM ; env->int_pgm_code = code; - env->int_pgm_ilen = ilen; +/* If ILEN_UNWIND, int_pgm_ilen already has the correct value. */ +if (ilen !=ILEN_UNWIND ) { + env->int_pgm_ilen = ilen; + } } void s390_program_interrupt(CPUS390XState *env, uint32_t code, int ilen,
target/s390x/translate.c +17 -3
@@ -6309,6 +6309,9 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)/* Search for the insn in the table. */ insn =extract_insn (env, s, &f); +/* Emit insn_start now that we know the ILEN. */ +tcg_gen_insn_start (s->base.pc_next, s->cc_op, s->ilen); +/* Not found means unimplemented/illegal opcode. */ if (insn ==NULL ) { qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n",
@@ -6463,9 +6466,6 @@ static void s390x_tr_tb_start(DisasContextBase *db, CPUState *cs)static void s390x_tr_insn_start (DisasContextBase *dcbase,CPUState *cs) { -DisasContext *dc =container_of (dcbase, DisasContext, base); - -tcg_gen_insn_start (dc->base.pc_next, dc->cc_op); } static bool s390x_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
@@ -6473,6 +6473,14 @@ static bool s390x_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs, {DisasContext *dc =container_of (dcbase, DisasContext, base); +/* +* Emit an insn_start to accompany the breakpoint exception. +* The ILEN value is a dummy, since this does not result in +* an s390x exception, but an internal qemu exception which +* brings us back to interact with the gdbstub. +*/ +tcg_gen_insn_start (dc->base.pc_next, dc->cc_op,2 ); + dc->base.is_jmp =DISAS_PC_STALE ; dc->do_debug = true;/* The address covered by the breakpoint must be included in
@@ -6567,8 +6575,14 @@ void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb, target_ulong *data) {int cc_op = data[1 ]; + env->psw.addr = data[0 ]; + +/* Update the CC opcode if it is not already up-to-date. */ if ((cc_op !=CC_OP_DYNAMIC ) && (cc_op !=CC_OP_STATIC )) { env->cc_op = cc_op; } + +/* Record ILEN. */ + env->int_pgm_ilen = data[2 ]; }
Signature · 1 line
2.17.1
PATCH v5 2/18 target/s390x: Remove ilen parameter from tcg_s390_program_interrupt
In reply to Richard HendersonSince we begin the operation with an unwind, we have the proper value of ilen immediately available.
--- target/s390x/tcg_s390x.h | 4 ++-- target/s390x/excp_helper.c | 10 +++++----- target/s390x/interrupt.c | 2 +- target/s390x/tcg-stub.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
target/s390x/tcg_s390x.h +2 -2
@@ -14,8 +14,8 @@#define TCG_S390X_H void tcg_s390_tod_updated (CPUState *cs,run_on_cpu_data opaque); -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, -int ilen,uintptr_t ra); +void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, +uint32_t code,uintptr_t ra); void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,uintptr_t ra); void QEMU_NORETURN tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,
target/s390x/excp_helper.c +5 -5
@@ -34,15 +34,15 @@#include "hw/boards.h" #endif -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, -int ilen,uintptr_t ra) +void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, +uint32_t code,uintptr_t ra) {CPUState *cs =env_cpu (env);cpu_restore_state (cs, ra, true);qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , env->psw.addr); -trigger_pgm_exception (env, code, ilen); +trigger_pgm_exception (env, code,ILEN_UNWIND );cpu_loop_exit (cs); }
@@ -60,7 +60,7 @@ void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,if (env->cregs[0 ] &CR0_AFP ) { env->fpc =deposit32 (env->fpc,8 ,8 , dxc); } -tcg_s390_program_interrupt (env,PGM_DATA ,ILEN_AUTO , ra); +tcg_s390_program_interrupt (env,PGM_DATA , ra); } void QEMU_NORETURN tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,
@@ -75,7 +75,7 @@ void QEMU_NORETURN tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,/* Always store the VXC into the FPC, without AFP it is undefined */ env->fpc =deposit32 (env->fpc,8 ,8 , vxc); -tcg_s390_program_interrupt (env,PGM_VECTOR_PROCESSING ,ILEN_AUTO , ra); +tcg_s390_program_interrupt (env,PGM_VECTOR_PROCESSING , ra); }void HELPER (data_exception )(CPUS390XState *env,uint32_t dxc)
target/s390x/interrupt.c +1 -1
@@ -40,7 +40,7 @@ void s390_program_interrupt(CPUS390XState *env, uint32_t code, int ilen,if (kvm_enabled ()) {kvm_s390_program_interrupt (env_archcpu (env), code); }else if (tcg_enabled ()) { -tcg_s390_program_interrupt (env, code, ilen, ra); +tcg_s390_program_interrupt (env, code, ra); }else {g_assert_not_reached (); }
target/s390x/tcg-stub.c +2 -2
@@ -18,8 +18,8 @@void tcg_s390_tod_updated (CPUState *cs,run_on_cpu_data opaque) { } -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, -int ilen,uintptr_t ra) +void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, +uint32_t code,uintptr_t ra) {g_assert_not_reached (); }
Signature · 1 line
2.17.1
PATCH v5 3/18 target/s390x: Remove ilen parameter from s390_program_interrupt
In reply to Richard HendersonThis is no longer used, and many of the existing uses -- particularly within hw/s390x -- seem questionable.
--- target/s390x/cpu.h | 3 +- hw/s390x/s390-pci-inst.c | 58 ++++++++++++++++++------------------ target/s390x/cc_helper.c | 2 +- target/s390x/crypto_helper.c | 4 +-- target/s390x/diag.c | 14 ++++----- target/s390x/excp_helper.c | 2 +- target/s390x/fpu_helper.c | 6 ++-- target/s390x/int_helper.c | 14 ++++----- target/s390x/interrupt.c | 3 +- target/s390x/ioinst.c | 40 ++++++++++++------------- target/s390x/mem_helper.c | 43 +++++++++++++------------- target/s390x/misc_helper.c | 27 ++++++----------- 12 files changed, 102 insertions(+), 114 deletions(-)
target/s390x/cpu.h +1 -2
@@ -809,8 +809,7 @@ void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,/* automatically detect the instruction length */ #define ILEN_AUTO 0xff#define RA_IGNORED 0 -void s390_program_interrupt (CPUS390XState *env,uint32_t code,int ilen, -uintptr_t ra); +void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra);/* service interrupts are floating therefore we must not pass an cpustate */ void s390_sclp_extint (uint32_t parm);
hw/s390x/s390-pci-inst.c +29 -29
219 lines not on this page · raw message
target/s390x/cc_helper.c +1 -1
@@ -588,7 +588,7 @@ void HELPER(sacf)(CPUS390XState *env, uint64_t a1)break ;default :HELPER_LOG ("unknown sacf mode: %" PRIx64"\n" , a1); -s390_program_interrupt (env,PGM_SPECIFICATION ,2 ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ());break ; } }
target/s390x/crypto_helper.c +2 -2
@@ -34,7 +34,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,case S390_FEAT_TYPE_PCKMO :case S390_FEAT_TYPE_PCC :if (mod) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return 0 ; }break ;
@@ -42,7 +42,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,s390_get_feat_block (type, subfunc);if (!test_be_bit (fc, subfunc)) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return 0 ; }
target/s390x/diag.c +7 -7
@@ -61,12 +61,12 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)IplParameterBlock *iplb;if (env->psw.mask &PSW_MASK_PSTATE ) { -s390_program_interrupt (env,PGM_PRIVILEGED ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_PRIVILEGED , ra);return ; }if ((subcode & ~0x0ffffULL ) || (subcode >6 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }
@@ -82,13 +82,13 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)break ;case 5 :if ((r1 &1 ) || (addr &0x0fffULL )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }if (!address_space_access_valid (&address_space_memory, addr,sizeof (IplParameterBlock), false,MEMTXATTRS_UNSPECIFIED )) { -s390_program_interrupt (env,PGM_ADDRESSING ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_ADDRESSING , ra);return ; } iplb =g_new0 (IplParameterBlock,1 );
@@ -112,13 +112,13 @@ out:return ;case 6 :if ((r1 &1 ) || (addr &0x0fffULL )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }if (!address_space_access_valid (&address_space_memory, addr,sizeof (IplParameterBlock), true,MEMTXATTRS_UNSPECIFIED )) { -s390_program_interrupt (env,PGM_ADDRESSING ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_ADDRESSING , ra);return ; } iplb =s390_ipl_get_iplb ();
@@ -130,7 +130,7 @@ out: }return ;default : -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);break ; } }
target/s390x/excp_helper.c +1 -1
@@ -614,7 +614,7 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,S390CPU *cpu =S390_CPU (cs);CPUS390XState *env = &cpu->env; - s390_program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO, retaddr); + s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); }#endif /* CONFIG_USER_ONLY */
target/s390x/fpu_helper.c +3 -3
@@ -825,7 +825,7 @@ void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc) {if (fpc_to_rnd[fpc &0x7 ] ==-1 || fpc &0x03030088u || (!s390_has_feat (S390_FEAT_FLOATING_POINT_EXT ) && fpc &0x4 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); }/* Install everything in the main FPC. */
@@ -843,7 +843,7 @@ void HELPER(sfas)(CPUS390XState *env, uint64_t fpc)if (fpc_to_rnd[fpc &0x7 ] ==-1 || fpc &0x03030088u || (!s390_has_feat (S390_FEAT_FLOATING_POINT_EXT ) && fpc &0x4 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); }/*
@@ -880,7 +880,7 @@ void HELPER(sfas)(CPUS390XState *env, uint64_t fpc)void HELPER (srnm )(CPUS390XState *env,uint64_t rnd) {if (rnd >0x7 || fpc_to_rnd[rnd &0x7 ] ==-1 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } env->fpc =deposit32 (env->fpc,0 ,3 , rnd);
target/s390x/int_helper.c +7 -7
@@ -39,7 +39,7 @@ int64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64)int64_t q;if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } ret = q = a / b;
@@ -47,7 +47,7 @@ int64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64)/* Catch non-representable quotient. */ if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }return ret;
@@ -60,7 +60,7 @@ uint64_t HELPER(divu32)(CPUS390XState *env, uint64_t a, uint64_t b64)uint64_t q;if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } ret = q = a / b;
@@ -68,7 +68,7 @@ uint64_t HELPER(divu32)(CPUS390XState *env, uint64_t a, uint64_t b64)/* Catch non-representable quotient. */ if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }return ret;
@@ -79,7 +79,7 @@ int64_t HELPER(divs64)(CPUS390XState *env, int64_t a, int64_t b) {/* Catch divide by zero, and non-representable quotient (MIN / -1). */ if (b ==0 || (b ==-1 && a == (1ll <<63 ))) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } env->retxl = a % b;return a / b;
@@ -92,7 +92,7 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al,uint64_t ret;/* Signal divide by zero. */ if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }if (ah ==0 ) {/* 64 -> 64/64 case */
@@ -106,7 +106,7 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al, env->retxl = a % b; ret = q;if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }#else /* 32-bit hosts would need special wrapper functionality - just abort if
target/s390x/interrupt.c +1 -2
@@ -34,8 +34,7 @@ void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen) } } -void s390_program_interrupt (CPUS390XState *env,uint32_t code,int ilen, -uintptr_t ra) +void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra) {if (kvm_enabled ()) {kvm_s390_program_interrupt (env_archcpu (env), code);
target/s390x/ioinst.c +20 -20
@@ -44,7 +44,7 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)SubchDev *sch;if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid)) { -s390_program_interrupt (&cpu->env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (&cpu->env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("xsch" , cssid, ssid, schid);
@@ -62,7 +62,7 @@ void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)SubchDev *sch;if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid)) { -s390_program_interrupt (&cpu->env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (&cpu->env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("csch" , cssid, ssid, schid);
@@ -80,7 +80,7 @@ void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)SubchDev *sch;if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid)) { -s390_program_interrupt (&cpu->env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (&cpu->env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("hsch" , cssid, ssid, schid);
@@ -116,7 +116,7 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra) addr =decode_basedisp_s (env, ipb, &ar);if (addr &3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }if (s390_cpu_virt_mem_read (cpu, addr, ar, &schib,sizeof (schib))) {
@@ -125,7 +125,7 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra) }if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid) || !ioinst_schib_valid (&schib)) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("msch" , cssid, ssid, schid);
@@ -173,7 +173,7 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra) addr =decode_basedisp_s (env, ipb, &ar);if (addr &3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }if (s390_cpu_virt_mem_read (cpu, addr, ar, &orig_orb,sizeof (orb))) {
@@ -183,7 +183,7 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra)copy_orb_from_guest (&orb, &orig_orb);if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid) || !ioinst_orb_valid (&orb)) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("ssch" , cssid, ssid, schid);
@@ -205,7 +205,7 @@ void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb, uintptr_t ra) addr =decode_basedisp_s (env, ipb, &ar);if (addr &3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }
@@ -236,7 +236,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, addr =decode_basedisp_s (env, ipb, &ar);if (addr &3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }
@@ -247,7 +247,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb,* access execption if it is not) first. */ if (!s390_cpu_virt_mem_check_write (cpu, addr, ar,sizeof (schib))) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra); }else {s390_cpu_virt_mem_handle_exc (cpu, ra); }
@@ -299,13 +299,13 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra)uint8_t ar;if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid)) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return -EIO ; }trace_ioinst_sch_id ("tsch" , cssid, ssid, schid); addr =decode_basedisp_s (env, ipb, &ar);if (addr &3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return -EIO ; }
@@ -613,7 +613,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra) addr = env->regs[reg];/* Page boundary? */ if (addr &0xfff ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra);return ; }/*
@@ -629,7 +629,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra) len =be16_to_cpu (req->len);/* Length field valid? */ if ((len <16 ) || (len >4088 ) || (len &7 )) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }memset ((char *)req + len,0 ,TARGET_PAGE_SIZE - len);
@@ -678,7 +678,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2,trace_ioinst ("schm" );if (SCHM_REG1_RES (reg1)) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }
@@ -687,7 +687,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2, dct =SCHM_REG1_DCT (reg1);if (update && (reg2 &0x000000000000001f )) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }
@@ -700,7 +700,7 @@ void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)SubchDev *sch;if (ioinst_disassemble_sch_ident (reg1, &m, &cssid, &ssid, &schid)) { -s390_program_interrupt (&cpu->env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (&cpu->env,PGM_OPERAND , ra);return ; }trace_ioinst_sch_id ("rsch" , cssid, ssid, schid);
@@ -724,7 +724,7 @@ void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1, uintptr_t ra)CPUS390XState *env = &cpu->env;if (RCHP_REG1_RES (reg1)) { -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }
@@ -747,7 +747,7 @@ void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1, uintptr_t ra)break ;default :/* Invalid channel subsystem. */ -s390_program_interrupt (env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (env,PGM_OPERAND , ra);return ; }setcc (cpu, cc);
@@ -758,6 +758,6 @@ void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1, uintptr_t ra) {/* We do not provide address limit checking, so let's suppress it. */ if (SAL_REG1_INVALID (reg1) || reg1 &0x000000000000ffff ) { -s390_program_interrupt (&cpu->env,PGM_OPERAND ,4 , ra); +s390_program_interrupt (&cpu->env,PGM_OPERAND , ra); } }
target/s390x/mem_helper.c +21 -22
162 lines not on this page · raw message
target/s390x/misc_helper.c +9 -18
@@ -106,7 +106,7 @@ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)int r =sclp_service_call (env, r1, r2);qemu_mutex_unlock_iothread ();if (r <0 ) { -s390_program_interrupt (env, -r,4 ,GETPC ()); +s390_program_interrupt (env, -r,GETPC ()); }return r; }
@@ -143,7 +143,7 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num) }if (r) { -s390_program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } }
@@ -222,7 +222,7 @@ void HELPER(sckpf)(CPUS390XState *env, uint64_t r0)uint32_t val = r0;if (val &0xffff0000 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,2 ,GETPC ()); +s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } env->todpr = val; }
@@ -266,7 +266,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1) }if ((r0 &STSI_R0_RESERVED_MASK ) || (r1 &STSI_R1_RESERVED_MASK )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra); }if ((r0 &STSI_R0_FC_MASK ) ==STSI_R0_FC_CURRENT ) {
@@ -276,7 +276,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1) }if (a0 & ~TARGET_PAGE_MASK ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra); }/* count the cpus and split them into configured and reserved ones */
@@ -509,7 +509,7 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)LowCore *lowcore;if (addr &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra); }qemu_mutex_lock_iothread ();
@@ -573,17 +573,8 @@ void HELPER(chsc)(CPUS390XState *env, uint64_t inst)#ifndef CONFIG_USER_ONLY void HELPER (per_check_exception )(CPUS390XState *env) { -uint32_t ilen; -if (env->per_perc_atmid) { -/* -* FIXME: ILEN_AUTO is most probably the right thing to use. ilen -* always has to match the instruction referenced in the PSW. E.g. -* if a PER interrupt is triggered via EXECUTE, we have to use ilen -* of EXECUTE, while per_address contains the target of EXECUTE. -*/ - ilen =get_ilen (cpu_ldub_code (env, env->per_address)); -s390_program_interrupt (env,PGM_PER , ilen,GETPC ()); +s390_program_interrupt (env,PGM_PER ,GETPC ()); } }
@@ -673,7 +664,7 @@ uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)int i;if (addr &0x7 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,4 , ra); +s390_program_interrupt (env,PGM_SPECIFICATION , ra); }prepare_stfl ();
@@ -746,7 +737,7 @@ void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)qemu_mutex_unlock_iothread ();/* css_do_sic() may actually return a PGM_xxx value to inject */ if (r) { -s390_program_interrupt (env, -r,4 ,GETPC ()); +s390_program_interrupt (env, -r,GETPC ()); } }
Signature · 1 line
2.17.1
PATCH v5 4/18 target/s390x: Use tcg_s390_program_interrupt in TCG helpers
In reply to Richard HendersonReplace all uses of s390_program_interrupt within files that are marked CONFIG_TCG. These are necessarily tcg-only.
This lets each of these users benefit from the QEMU_NORETURN attribute on tcg_s390_program_interrupt.
--- target/s390x/cc_helper.c | 4 ++-- target/s390x/crypto_helper.c | 7 +++---- target/s390x/excp_helper.c | 2 +- target/s390x/fpu_helper.c | 6 +++--- target/s390x/int_helper.c | 15 +++++++------- target/s390x/mem_helper.c | 40 ++++++++++++++++++------------------ target/s390x/misc_helper.c | 18 ++++++++-------- 7 files changed, 46 insertions(+), 46 deletions(-)
target/s390x/cc_helper.c +2 -2
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "internal.h" +#include "tcg_s390x.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h"
@@ -588,8 +589,7 @@ void HELPER(sacf)(CPUS390XState *env, uint64_t a1)break ;default :HELPER_LOG ("unknown sacf mode: %" PRIx64"\n" , a1); -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); - break; + tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC()); } }#endif
target/s390x/crypto_helper.c +3 -4
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" #include "internal.h" +#include "tcg_s390x.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h"
@@ -34,16 +35,14 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,case S390_FEAT_TYPE_PCKMO :case S390_FEAT_TYPE_PCC :if (mod) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); -return 0 ; +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }break ; }s390_get_feat_block (type, subfunc);if (!test_be_bit (fc, subfunc)) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); -return 0 ; +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }switch (fc) {
target/s390x/excp_helper.c +1 -1
@@ -614,7 +614,7 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,S390CPU *cpu =S390_CPU (cs);CPUS390XState *env = &cpu->env; - s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); + tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); }#endif /* CONFIG_USER_ONLY */
target/s390x/fpu_helper.c +3 -3
@@ -825,7 +825,7 @@ void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc) {if (fpc_to_rnd[fpc &0x7 ] ==-1 || fpc &0x03030088u || (!s390_has_feat (S390_FEAT_FLOATING_POINT_EXT ) && fpc &0x4 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); }/* Install everything in the main FPC. */
@@ -843,7 +843,7 @@ void HELPER(sfas)(CPUS390XState *env, uint64_t fpc)if (fpc_to_rnd[fpc &0x7 ] ==-1 || fpc &0x03030088u || (!s390_has_feat (S390_FEAT_FLOATING_POINT_EXT ) && fpc &0x4 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); }/*
@@ -880,7 +880,7 @@ void HELPER(sfas)(CPUS390XState *env, uint64_t fpc)void HELPER (srnm )(CPUS390XState *env,uint64_t rnd) {if (rnd >0x7 || fpc_to_rnd[rnd &0x7 ] ==-1 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } env->fpc =deposit32 (env->fpc,0 ,3 , rnd);
target/s390x/int_helper.c +8 -7
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "internal.h" +#include "tcg_s390x.h" #include "exec/exec-all.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h"
@@ -39,7 +40,7 @@ int64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64)int64_t q;if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } ret = q = a / b;
@@ -47,7 +48,7 @@ int64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64)/* Catch non-representable quotient. */ if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }return ret;
@@ -60,7 +61,7 @@ uint64_t HELPER(divu32)(CPUS390XState *env, uint64_t a, uint64_t b64)uint64_t q;if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } ret = q = a / b;
@@ -68,7 +69,7 @@ uint64_t HELPER(divu32)(CPUS390XState *env, uint64_t a, uint64_t b64)/* Catch non-representable quotient. */ if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }return ret;
@@ -79,7 +80,7 @@ int64_t HELPER(divs64)(CPUS390XState *env, int64_t a, int64_t b) {/* Catch divide by zero, and non-representable quotient (MIN / -1). */ if (b ==0 || (b ==-1 && a == (1ll <<63 ))) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); } env->retxl = a % b;return a / b;
@@ -92,7 +93,7 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al,uint64_t ret;/* Signal divide by zero. */ if (b ==0 ) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }if (ah ==0 ) {/* 64 -> 64/64 case */
@@ -106,7 +107,7 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al, env->retxl = a % b; ret = q;if (ret != q) { -s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_FIXPT_DIVIDE ,GETPC ()); }#else /* 32-bit hosts would need special wrapper functionality - just abort if
target/s390x/mem_helper.c +20 -20
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "internal.h" +#include "tcg_s390x.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h"
@@ -71,7 +72,7 @@ static inline void check_alignment(CPUS390XState *env, uint64_t v, int wordsize, uintptr_t ra) {if (v % wordsize) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); } }
@@ -730,7 +731,7 @@ void HELPER(srst)(CPUS390XState *env, uint32_t r1, uint32_t r2)/* Bits 32-55 must contain all 0. */ if (env->regs[0 ] &0xffffff00u ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); } str =get_address (env, r2);
@@ -767,7 +768,7 @@ void HELPER(srstu)(CPUS390XState *env, uint32_t r1, uint32_t r2)/* Bits 32-47 of R0 must be zero. */ if (env->regs[0 ] &0xffff0000u ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); } str =get_address (env, r2);
@@ -846,7 +847,7 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint64_t r1, uint64_t r2)S390Access srca, desta;if ((f && s) ||extract64 (r0,12 ,4 )) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } r1 =wrap_address (env, r1 &TARGET_PAGE_MASK );
@@ -879,7 +880,7 @@ uint32_t HELPER(mvst)(CPUS390XState *env, uint32_t r1, uint32_t r2)int i;if (env->regs[0 ] &0xffffff00ull ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }/*
@@ -911,7 +912,7 @@ void HELPER(lam)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)int i;if (a2 &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -931,7 +932,7 @@ void HELPER(stam)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)int i;if (a2 &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -1887,8 +1888,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1,return cc; spec_exception: -s390_program_interrupt (env,PGM_SPECIFICATION , ra); -g_assert_not_reached (); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }uint32_t HELPER (csst )(CPUS390XState *env,uint32_t r3,uint64_t a1,uint64_t a2)
@@ -1911,7 +1911,7 @@ void HELPER(lctlg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)uint32_t i;if (src &0x7 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -1944,7 +1944,7 @@ void HELPER(lctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)uint32_t i;if (src &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -1975,7 +1975,7 @@ void HELPER(stctg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)uint32_t i;if (dest &0x7 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -1995,7 +1995,7 @@ void HELPER(stctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)uint32_t i;if (dest &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }for (i = r1;; i = (i +1 ) %16 ) {
@@ -2225,7 +2225,7 @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, uint64_t r2, uint32_t m4)uint16_t entries, i, index =0 ;if (r2 &0xff000 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }if (!(r2 &0x800 )) {
@@ -2369,7 +2369,7 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)/* XXX incomplete - has more corner cases */ if (!(env->psw.mask &PSW_MASK_64 ) && (addr >>32 )) { -s390_program_interrupt (env,PGM_SPECIAL_OP ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIAL_OP ,GETPC ()); } old_exc = cs->exception_index;
@@ -2538,7 +2538,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t dest, uint64_t src, __func__, dest, src, len);if (!(env->psw.mask &PSW_MASK_DAT )) { -s390_program_interrupt (env,PGM_SPECIAL_OP , ra); +tcg_s390_program_interrupt (env,PGM_SPECIAL_OP , ra); }/* OAC (operand access control) for the first operand -> dest */
@@ -2569,14 +2569,14 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t dest, uint64_t src, }if (dest_a && dest_as ==AS_HOME && (env->psw.mask &PSW_MASK_PSTATE )) { -s390_program_interrupt (env,PGM_SPECIAL_OP , ra); +tcg_s390_program_interrupt (env,PGM_SPECIAL_OP , ra); }if (!(env->cregs[0 ] &CR0_SECONDARY ) && (dest_as ==AS_SECONDARY || src_as ==AS_SECONDARY )) { -s390_program_interrupt (env,PGM_SPECIAL_OP , ra); +tcg_s390_program_interrupt (env,PGM_SPECIAL_OP , ra); }if (!psw_key_valid (env, dest_key) || !psw_key_valid (env, src_key)) { -s390_program_interrupt (env,PGM_PRIVILEGED , ra); +tcg_s390_program_interrupt (env,PGM_PRIVILEGED , ra); } len =wrap_length32 (env, len);
@@ -2590,7 +2590,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t dest, uint64_t src, (env->psw.mask & PSW_MASK_PSTATE)) {qemu_log_mask (LOG_UNIMP ,"%s: AR-mode and PSTATE support missing\n" , __func__); -s390_program_interrupt (env,PGM_ADDRESSING , ra); +tcg_s390_program_interrupt (env,PGM_ADDRESSING , ra); }/* FIXME: Access using correct keys and AR-mode */
target/s390x/misc_helper.c +9 -9
@@ -106,7 +106,7 @@ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)int r =sclp_service_call (env, r1, r2);qemu_mutex_unlock_iothread ();if (r <0 ) { -s390_program_interrupt (env, -r,GETPC ()); +tcg_s390_program_interrupt (env, -r,GETPC ()); }return r; }
@@ -143,7 +143,7 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num) }if (r) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } }
@@ -222,7 +222,7 @@ void HELPER(sckpf)(CPUS390XState *env, uint64_t r0)uint32_t val = r0;if (val &0xffff0000 ) { -s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION ,GETPC ()); } env->todpr = val; }
@@ -266,7 +266,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1) }if ((r0 &STSI_R0_RESERVED_MASK ) || (r1 &STSI_R1_RESERVED_MASK )) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }if ((r0 &STSI_R0_FC_MASK ) ==STSI_R0_FC_CURRENT ) {
@@ -276,7 +276,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1) }if (a0 & ~TARGET_PAGE_MASK ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }/* count the cpus and split them into configured and reserved ones */
@@ -509,7 +509,7 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr)LowCore *lowcore;if (addr &0x3 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }qemu_mutex_lock_iothread ();
@@ -574,7 +574,7 @@ void HELPER(chsc)(CPUS390XState *env, uint64_t inst)void HELPER (per_check_exception )(CPUS390XState *env) {if (env->per_perc_atmid) { -s390_program_interrupt (env,PGM_PER ,GETPC ()); +tcg_s390_program_interrupt (env,PGM_PER ,GETPC ()); } }
@@ -664,7 +664,7 @@ uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr)int i;if (addr &0x7 ) { -s390_program_interrupt (env,PGM_SPECIFICATION , ra); +tcg_s390_program_interrupt (env,PGM_SPECIFICATION , ra); }prepare_stfl ();
@@ -737,7 +737,7 @@ void HELPER(sic)(CPUS390XState *env, uint64_t r1, uint64_t r3)qemu_mutex_unlock_iothread ();/* css_do_sic() may actually return a PGM_xxx value to inject */ if (r) { -s390_program_interrupt (env, -r,GETPC ()); +tcg_s390_program_interrupt (env, -r,GETPC ()); } }
Signature · 1 line
2.17.1
PATCH v5 5/18 target/s390x: Push trigger_pgm_exception lower in s390_cpu_tlb_fill
In reply to Richard HendersonDelay triggering an exception until the end, after we have determined ultimate success or failure, and also taken into account whether this is a non-faulting probe.
--- target/s390x/excp_helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
target/s390x/excp_helper.c +7 -2
@@ -127,7 +127,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,CPUS390XState *env = &cpu->env;target_ulong vaddr, raddr;uint64_t asc; -int prot, fail; +int prot, fail, excp;qemu_log_mask (CPU_LOG_MMU ,"%s: addr 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, address, access_type, mmu_idx);
@@ -141,12 +141,14 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, vaddr &=0x7fffffff ; } fail =mmu_translate (env, vaddr, access_type, asc, &raddr, &prot, true); + excp =0 ;/* exception already raised */ }else if (mmu_idx ==MMU_REAL_IDX ) {/* 31-Bit mode */ if (!(env->psw.mask &PSW_MASK_64 )) { vaddr &=0x7fffffff ; } fail =mmu_translate_real (env, vaddr, access_type, &raddr, &prot); + excp =0 ;/* exception already raised */ }else {g_assert_not_reached (); }
@@ -159,7 +161,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,qemu_log_mask (CPU_LOG_MMU ,"%s: raddr %" PRIx64" > ram_size %" PRIx64"\n" , __func__, (uint64_t )raddr, (uint64_t )ram_size); -trigger_pgm_exception (env,PGM_ADDRESSING ,ILEN_AUTO ); + excp =PGM_ADDRESSING ; fail =1 ; }
@@ -175,6 +177,9 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,return false; } +if (excp) { +trigger_pgm_exception (env, excp,ILEN_AUTO ); + }cpu_restore_state (cs, retaddr, true);/*
Signature · 1 line
2.17.1
PATCH v5 6/18 target/s390x: Handle tec in s390_cpu_tlb_fill
In reply to Richard HendersonAs a step toward moving all excption handling out of mmu_translate, copy handling of the LowCore tec value from trigger_access_exception into s390_cpu_tlb_fill. So far this new plumbing isn't used.
--- target/s390x/excp_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target/s390x/excp_helper.c +6 -1
@@ -126,7 +126,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,S390CPU *cpu =S390_CPU (cs);CPUS390XState *env = &cpu->env;target_ulong vaddr, raddr; -uint64_t asc; +uint64_t asc, tec;int prot, fail, excp; qemu_log_mask(CPU_LOG_MMU, "%s: addr 0x%" VADDR_PRIx " rw %d mmu_idx %d\n",
@@ -162,6 +162,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,"%s: raddr %" PRIx64" > ram_size %" PRIx64"\n" , __func__, (uint64_t)raddr, (uint64_t)ram_size); excp =PGM_ADDRESSING ; + tec =0 ;/* unused */ fail =1 ; }
@@ -178,6 +179,10 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, }if (excp) { +if (excp !=PGM_ADDRESSING ) { +stq_phys (env_cpu (env)->as, + env->psa + offsetof(LowCore , trans_exc_code), tec); + }trigger_pgm_exception (env, excp,ILEN_AUTO ); }cpu_restore_state (cs, retaddr, true);
Signature · 1 line
2.17.1
PATCH v5 7/18 target/s390x: Return exception from mmu_translate_real
In reply to Richard HendersonDo not raise the exception directly within mmu_translate_real, but pass it back so that caller may do so.
--- target/s390x/internal.h | 2 +- target/s390x/excp_helper.c | 4 ++-- target/s390x/mmu_helper.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 11 deletions(-)
target/s390x/internal.h +1 -1
@@ -362,7 +362,7 @@ void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len,int mmu_translate (CPUS390XState *env,target_ulong vaddr,int rw,uint64_t asc,target_ulong *raddr,int *flags,bool exc);int mmu_translate_real (CPUS390XState *env,target_ulong raddr,int rw, -target_ulong *addr,int *flags); +target_ulong *addr,int *flags,uint64_t *tec);/* misc_helper.c */
target/s390x/excp_helper.c +2 -2
@@ -147,8 +147,8 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,if (!(env->psw.mask &PSW_MASK_64 )) { vaddr &=0x7fffffff ; } - fail =mmu_translate_real (env, vaddr, access_type, &raddr, &prot); - excp =0 ;/* exception already raised */ + excp =mmu_translate_real (env, vaddr, access_type, &raddr, &prot, &tec); + fail = excp; }else {g_assert_not_reached (); }
target/s390x/mmu_helper.c +6 -8
@@ -554,14 +554,11 @@ void s390_cpu_virt_mem_handle_exc(S390CPU *cpu, uintptr_t ra)* @param rw 0 = read, 1 = write, 2 = code fetch * @param addr the translated address is stored to this pointer * @param flags the PAGE_READ/WRITE/EXEC flags are stored to this pointer -* @return 0 if the translation was successful, < 0 if a fault occurred +* @return 0 = success, != 0, the exception to raise */ int mmu_translate_real (CPUS390XState *env,target_ulong raddr,int rw, -target_ulong *addr,int *flags) +target_ulong *addr,int *flags,uint64_t *tec) { -/* Code accesses have an undefined ilc, let's use 2 bytes. */ -uint64_t tec = (raddr &TARGET_PAGE_MASK ) | - (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ );const bool lowprot_enabled = env->cregs[0 ] &CR0_LOWPROT ; *flags =PAGE_READ |PAGE_WRITE |PAGE_EXEC ;
@@ -570,9 +567,10 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw, *flags |=PAGE_WRITE_INV ;if (is_low_address (raddr) && rw ==MMU_DATA_STORE ) {/* LAP sets bit 56 */ - tec |=0x80 ; -trigger_access_exception (env,PGM_PROTECTION ,ILEN_AUTO , tec); -return -EACCES ; + *tec = (raddr &TARGET_PAGE_MASK ) + | (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ ) + |0x80 ; +return PGM_PROTECTION ; } }
Signature · 1 line
2.17.1
PATCH v5 8/18 target/s390x: Remove exc argument to mmu_translate_asce
In reply to Richard HendersonNow that mmu_translate_asce returns the exception instead of raising it, the argument is unused.
--- target/s390x/mmu_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/mmu_helper.c +2 -2
@@ -116,7 +116,7 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,static int mmu_translate_asce (CPUS390XState *env,target_ulong vaddr,uint64_t asc,uint64_t asce,target_ulong *raddr, -int *flags,int rw,bool exc) +int *flags,int rw) {const bool edat1 = (env->cregs[0 ] &CR0_EDAT ) &&s390_has_feat (S390_FEAT_EDAT );
@@ -423,7 +423,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, }/* perform the DAT translation */ - r =mmu_translate_asce (env, vaddr, asc, asce, raddr, flags, rw, exc); + r =mmu_translate_asce (env, vaddr, asc, asce, raddr, flags, rw);if (unlikely (r)) {if (exc) {trigger_access_exception (env, r, ilen, tec);
Signature · 1 line
2.17.1
PATCH v5 9/18 target/s390x: Return exception from mmu_translate
In reply to Richard HendersonDo not raise the exception directly within mmu_translate, but pass it back so that caller may do so.
--- target/s390x/internal.h | 2 +- target/s390x/excp_helper.c | 4 +-- target/s390x/helper.c | 3 ++- target/s390x/mem_helper.c | 13 +++++++--- target/s390x/mmu_helper.c | 51 +++++++++++++++----------------------- 5 files changed, 35 insertions(+), 38 deletions(-)
target/s390x/internal.h +1 -1
@@ -360,7 +360,7 @@ void probe_write_access(CPUS390XState *env, uint64_t addr, uint64_t len,/* mmu_helper.c */ int mmu_translate (CPUS390XState *env,target_ulong vaddr,int rw,uint64_t asc, -target_ulong *raddr,int *flags,bool exc); +target_ulong *raddr,int *flags,uint64_t *tec);int mmu_translate_real (CPUS390XState *env,target_ulong raddr,int rw,target_ulong *addr,int *flags,uint64_t *tec);
target/s390x/excp_helper.c +2 -2
@@ -140,8 +140,8 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,if (!(env->psw.mask &PSW_MASK_64 )) { vaddr &=0x7fffffff ; } - fail =mmu_translate (env, vaddr, access_type, asc, &raddr, &prot, true); - excp =0 ;/* exception already raised */ + excp =mmu_translate (env, vaddr, access_type, asc, &raddr, &prot, &tec); + fail = excp; }else if (mmu_idx ==MMU_REAL_IDX ) {/* 31-Bit mode */ if (!(env->psw.mask &PSW_MASK_64 )) {
target/s390x/helper.c +2 -1
@@ -52,6 +52,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)target_ulong raddr;int prot;uint64_t asc = env->psw.mask &PSW_MASK_ASC ; +uint64_t tec;/* 31-Bit mode */ if (!(env->psw.mask &PSW_MASK_64 )) {
@@ -67,7 +68,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)* We want to read code even if IEP is active. Use MMU_DATA_LOAD instead * of MMU_INST_FETCH. */ -if (mmu_translate (env, vaddr,MMU_DATA_LOAD , asc, &raddr, &prot, false)) { +if (mmu_translate (env, vaddr,MMU_DATA_LOAD , asc, &raddr, &prot, &tec)) {return -1 ; }return raddr;
target/s390x/mem_helper.c +10 -3
@@ -2364,8 +2364,8 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)CPUState *cs =env_cpu (env);uint32_t cc =0 ;uint64_t asc = env->psw.mask &PSW_MASK_ASC ; -uint64_t ret; -int old_exc, flags; +uint64_t ret, tec; +int old_exc, flags, exc;/* XXX incomplete - has more corner cases */ if (!(env->psw.mask &PSW_MASK_64 ) && (addr >>32 )) {
@@ -2373,7 +2373,14 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) } old_exc = cs->exception_index; -if (mmu_translate (env, addr,0 , asc, &ret, &flags, true)) { + exc =mmu_translate (env, addr,0 , asc, &ret, &flags, &tec); +if (exc) { +/* +* We don't care about ILEN or TEC, as we're not going to +* deliver the exception -- thus resetting exception_index below. +* TODO: clean this up. +*/ +trigger_pgm_exception (env, exc,ILEN_UNWIND ); cc =3 ; }if (cs->exception_index ==EXCP_PGM ) {
target/s390x/mmu_helper.c +20 -31
91 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v5 10/18 target/s390x: Return exception from translate_pages
In reply to Richard HendersonDo not raise the exception directly within translate_pages, but pass it back so that caller may do so.
--- target/s390x/mmu_helper.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
target/s390x/mmu_helper.c +10 -10
@@ -451,25 +451,22 @@ nodat:* the MEMOP interface. */ static int translate_pages (S390CPU *cpu,vaddr addr,int nr_pages, -target_ulong *pages,bool is_write) +target_ulong *pages,bool is_write,uint64_t *tec) {uint64_t asc = cpu->env.psw.mask &PSW_MASK_ASC ;CPUS390XState *env = &cpu->env;int ret, i, pflags;for (i =0 ; i < nr_pages; i++) { -uint64_t tec; - - ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, &tec); + ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, tec);if (ret) { -trigger_access_exception (env, ret,ILEN_AUTO , tec); -return -EFAULT ; +return ret; }if (!address_space_access_valid (&address_space_memory, pages[i],TARGET_PAGE_SIZE , is_write,MEMTXATTRS_UNSPECIFIED )) { -trigger_access_exception (env,PGM_ADDRESSING ,ILEN_AUTO ,0 ); -return -EFAULT ; + *tec =0 ;/* unused */ +return PGM_ADDRESSING ; } addr +=TARGET_PAGE_SIZE ; }
@@ -497,6 +494,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, {int currlen, nr_pages, i;target_ulong *pages; +uint64_t tec;int ret;if (kvm_enabled ()) {
@@ -510,8 +508,10 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, +1 ; pages =g_malloc (nr_pages *sizeof (*pages)); - ret =translate_pages (cpu, laddr, nr_pages, pages, is_write); -if (ret ==0 && hostbuf !=NULL ) { + ret =translate_pages (cpu, laddr, nr_pages, pages, is_write, &tec); +if (ret) { +trigger_access_exception (&cpu->env, ret,ILEN_AUTO , tec); + }else if (hostbuf !=NULL ) {/* Copy data by stepping through the area page by page */ for (i =0 ; i < nr_pages; i++) { currlen =MIN (len,TARGET_PAGE_SIZE - (laddr %TARGET_PAGE_SIZE ));
Signature · 1 line
2.17.1
PATCH v5 11/18 target/s390x: Remove fail variable from s390_cpu_tlb_fill
In reply to Richard HendersonNow that excp always contains a real exception number, we can use that instead of a separate fail variable. This allows a redundant test to be removed.
--- target/s390x/excp_helper.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
target/s390x/excp_helper.c +7 -12
@@ -127,7 +127,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,CPUS390XState *env = &cpu->env;target_ulong vaddr, raddr;uint64_t asc, tec; -int prot, fail, excp; +int prot, excp;qemu_log_mask (CPU_LOG_MMU ,"%s: addr 0x%" VADDR_PRIx" rw %d mmu_idx %d\n" , __func__, address, access_type, mmu_idx);
@@ -141,20 +141,18 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, vaddr &=0x7fffffff ; } excp =mmu_translate (env, vaddr, access_type, asc, &raddr, &prot, &tec); - fail = excp; }else if (mmu_idx ==MMU_REAL_IDX ) {/* 31-Bit mode */ if (!(env->psw.mask &PSW_MASK_64 )) { vaddr &=0x7fffffff ; } excp =mmu_translate_real (env, vaddr, access_type, &raddr, &prot, &tec); - fail = excp; }else {g_assert_not_reached (); }/* check out of RAM access */ -if (!fail && +if (!excp && !address_space_access_valid (&address_space_memory, raddr,TARGET_PAGE_SIZE , access_type,MEMTXATTRS_UNSPECIFIED )) {
@@ -163,10 +161,9 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, __func__, (uint64_t)raddr, (uint64_t)ram_size); excp =PGM_ADDRESSING ; tec =0 ;/* unused */ - fail =1 ; } -if (!fail) { +if (!excp) {qemu_log_mask (CPU_LOG_MMU ,"%s: set tlb %" PRIx64" -> %" PRIx64" (%x)\n" , __func__, (uint64_t )vaddr, (uint64_t )raddr, prot);
@@ -178,13 +175,11 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,return false; } -if (excp) { -if (excp !=PGM_ADDRESSING ) { -stq_phys (env_cpu (env)->as, - env->psa + offsetof(LowCore , trans_exc_code), tec); - } -trigger_pgm_exception (env, excp,ILEN_AUTO ); +if (excp !=PGM_ADDRESSING ) { +stq_phys (env_cpu (env)->as, + env->psa + offsetof(LowCore , trans_exc_code), tec); } +trigger_pgm_exception (env, excp,ILEN_AUTO );cpu_restore_state (cs, retaddr, true);/*
Signature · 1 line
2.17.1
PATCH v5 12/18 target/s390x: Simplify helper_lra
In reply to Richard HendersonWe currently call trigger_pgm_exception to set cs->exception_index and env->int_pgm_code and then read the values back and then reset cs->exception_index so that the exception is not delivered.
Instead, use the exception type that we already have directly without ever triggering an exception that must be suppressed.
--- target/s390x/mem_helper.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
target/s390x/mem_helper.c +3 -14
@@ -2361,34 +2361,23 @@ void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1)/* load real address */ uint64_t HELPER (lra )(CPUS390XState *env,uint64_t addr) { -CPUState *cs =env_cpu (env); -uint32_t cc =0 ;uint64_t asc = env->psw.mask &PSW_MASK_ASC ;uint64_t ret, tec; -int old_exc, flags, exc; +int flags, exc, cc;/* XXX incomplete - has more corner cases */ if (!(env->psw.mask &PSW_MASK_64 ) && (addr >>32 )) {tcg_s390_program_interrupt (env,PGM_SPECIAL_OP ,GETPC ()); } - old_exc = cs->exception_index; exc =mmu_translate (env, addr,0 , asc, &ret, &flags, &tec);if (exc) { -/* -* We don't care about ILEN or TEC, as we're not going to -* deliver the exception -- thus resetting exception_index below. -* TODO: clean this up. -*/ -trigger_pgm_exception (env, exc,ILEN_UNWIND ); cc =3 ; - } -if (cs->exception_index ==EXCP_PGM ) { - ret = env->int_pgm_code |0x80000000 ; + ret = exc |0x80000000 ; }else { + cc =0 ; ret |= addr & ~TARGET_PAGE_MASK ; } - cs->exception_index = old_exc; env->cc_op = cc;return ret;
Signature · 1 line
2.17.1
PATCH v5 13/18 target/s390x: Rely on unwinding in s390_cpu_tlb_fill
In reply to Richard HendersonWe currently set ilen to AUTO, then overwrite that during unwinding, then overwrite that for the code access case.
This can be simplified to setting ilen to our arbitrary value for the (undefined) code access case, then rely on unwinding to overwrite that with the correct value for the data access case.
--- target/s390x/excp_helper.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
target/s390x/excp_helper.c +7 -16
@@ -96,7 +96,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, {S390CPU *cpu =S390_CPU (cs); -trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_AUTO ); +trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_UNWIND );/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address;
@@ -179,24 +179,15 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,stq_phys (env_cpu (env)->as, env->psa + offsetof(LowCore , trans_exc_code), tec); } -trigger_pgm_exception (env, excp,ILEN_AUTO ); -cpu_restore_state (cs, retaddr, true);/* -* The ILC value for code accesses is undefined. The important -* thing here is to *not* leave env->int_pgm_ilen set to ILEN_AUTO, -* which would cause do_program_interrupt to attempt to read from -* env->psw.addr again. C.f. the condition in trigger_page_fault, -* but is not universally applied. -* -* ??? If we remove ILEN_AUTO, by moving the computation of ILEN -* into cpu_restore_state, then we may remove this entirely. +* For data accesses, ILEN will be filled in from the unwind info, +* within cpu_loop_exit_restore. For code accesses, retaddr == 0, +* and so unwinding will not occur. However, ILEN is also undefined +* for that case -- we choose to set ILEN = 2. */ -if (access_type ==MMU_INST_FETCH ) { - env->int_pgm_ilen =2 ; - } - -cpu_loop_exit (cs); +trigger_pgm_exception (env, excp,2 ); +cpu_loop_exit_restore (cs, retaddr); }static void do_program_interrupt (CPUS390XState *env)
Signature · 1 line
2.17.1
PATCH v5 14/18 target/s390x: Rely on unwinding in s390_cpu_virt_mem_rw
In reply to Richard HendersonFor TCG, we will always call s390_cpu_virt_mem_handle_exc, which will go through the unwinder to set ILEN. For KVM, we do not go through do_program_interrupt, so this argument is unused.
--- target/s390x/mmu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/mmu_helper.c +1 -1
@@ -510,7 +510,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, ret =translate_pages (cpu, laddr, nr_pages, pages, is_write, &tec);if (ret) { -trigger_access_exception (&cpu->env, ret,ILEN_AUTO , tec); +trigger_access_exception (&cpu->env, ret,ILEN_UNWIND , tec); }else if (hostbuf !=NULL ) {/* Copy data by stepping through the area page by page */ for (i =0 ; i < nr_pages; i++) {
Signature · 1 line
2.17.1
PATCH v5 15/18 target/s390x: Remove ILEN_AUTO
In reply to Richard HendersonThis setting is no longer used.
--- target/s390x/cpu.h | 2 -- target/s390x/excp_helper.c | 3 --- 2 files changed, 5 deletions(-)
target/s390x/cpu.h +0 -2
@@ -806,8 +806,6 @@ void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word);/* instruction length set by unwind info */ #define ILEN_UNWIND 0 -/* automatically detect the instruction length */ -#define ILEN_AUTO 0xff#define RA_IGNORED 0void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra);/* service interrupts are floating therefore we must not pass an cpustate */
target/s390x/excp_helper.c +0 -3
@@ -196,9 +196,6 @@ static void do_program_interrupt(CPUS390XState *env)LowCore *lowcore;int ilen = env->int_pgm_ilen; -if (ilen ==ILEN_AUTO ) { - ilen =get_ilen (cpu_ldub_code (env, env->psw.addr)); - }assert (ilen ==2 || ilen ==4 || ilen ==6 );switch (env->int_pgm_code) {
Signature · 1 line
2.17.1
PATCH v5 16/18 target/s390x: Remove ilen argument from trigger_access_exception
In reply to Richard HendersonThe single caller passes ILEN_UNWIND; pass that along to trigger_pgm_exception directly.
--- target/s390x/mmu_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/s390x/mmu_helper.c +3 -3
@@ -33,7 +33,7 @@#define FS_WRITE 0x400static void trigger_access_exception (CPUS390XState *env,uint32_t type, -uint32_t ilen,uint64_t tec) +uint64_t tec) {S390CPU *cpu =env_archcpu (env);
@@ -44,7 +44,7 @@ static void trigger_access_exception(CPUS390XState *env, uint32_t type,if (type !=PGM_ADDRESSING ) {stq_phys (cs->as, env->psa + offsetof(LowCore , trans_exc_code), tec); } -trigger_pgm_exception (env, type, ilen); +trigger_pgm_exception (env, type,ILEN_UNWIND ); } }
@@ -510,7 +510,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, ret =translate_pages (cpu, laddr, nr_pages, pages, is_write, &tec);if (ret) { -trigger_access_exception (&cpu->env, ret,ILEN_UNWIND , tec); +trigger_access_exception (&cpu->env, ret, tec); }else if (hostbuf !=NULL ) {/* Copy data by stepping through the area page by page */ for (i =0 ; i < nr_pages; i++) {
Signature · 1 line
2.17.1
PATCH v5 17/18 target/s390x: Remove ilen argument from trigger_pgm_exception
In reply to Richard HendersonAll but one caller passes ILEN_UNWIND, which is not stored. For the one use case in s390_cpu_tlb_fill, set int_pgm_ilen directly, simply to avoid the assert within do_program_interrupt.
--- target/s390x/internal.h | 2 +- target/s390x/excp_helper.c | 7 ++++--- target/s390x/interrupt.c | 7 ++----- target/s390x/mmu_helper.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-)
target/s390x/internal.h +1 -1
@@ -317,7 +317,7 @@ void cpu_unmap_lowcore(LowCore *lowcore);/* interrupt.c */ -void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen); +void trigger_pgm_exception (CPUS390XState *env,uint32_t code);void cpu_inject_clock_comparator (S390CPU *cpu);void cpu_inject_cpu_timer (S390CPU *cpu);void cpu_inject_emergency_signal (S390CPU *cpu,uint16_t src_cpu_addr);
target/s390x/excp_helper.c +4 -3
@@ -42,7 +42,7 @@ void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env,cpu_restore_state (cs, ra, true);qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , env->psw.addr); -trigger_pgm_exception (env, code,ILEN_UNWIND ); +trigger_pgm_exception (env, code);cpu_loop_exit (cs); }
@@ -96,7 +96,7 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, {S390CPU *cpu =S390_CPU (cs); -trigger_pgm_exception (&cpu->env,PGM_ADDRESSING ,ILEN_UNWIND ); +trigger_pgm_exception (&cpu->env,PGM_ADDRESSING );/* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address;
@@ -186,7 +186,8 @@ bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,* and so unwinding will not occur. However, ILEN is also undefined * for that case -- we choose to set ILEN = 2. */ -trigger_pgm_exception (env, excp,2 ); + env->int_pgm_ilen =2 ; +trigger_pgm_exception (env, excp);cpu_loop_exit_restore (cs, retaddr); }
target/s390x/interrupt.c +2 -5
@@ -22,16 +22,13 @@#endif /* Ensure to exit the TB after this call! */ -void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen) +void trigger_pgm_exception (CPUS390XState *env,uint32_t code) {CPUState *cs =env_cpu (env); cs->exception_index =EXCP_PGM ; env->int_pgm_code = code; -/* If ILEN_UNWIND, int_pgm_ilen already has the correct value. */ -if (ilen !=ILEN_UNWIND ) { - env->int_pgm_ilen = ilen; - } +/* env->int_pgm_ilen is already set, or will be set during unwinding */ }void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra)
target/s390x/mmu_helper.c +1 -1
@@ -44,7 +44,7 @@ static void trigger_access_exception(CPUS390XState *env, uint32_t type,if (type !=PGM_ADDRESSING ) {stq_phys (cs->as, env->psa + offsetof(LowCore , trans_exc_code), tec); } -trigger_pgm_exception (env, type,ILEN_UNWIND ); +trigger_pgm_exception (env, type); } }
Signature · 1 line
2.17.1
PATCH v5 18/18 target/s390x: Remove ILEN_UNWIND
In reply to Richard HendersonThis setting is no longer used.
--- target/s390x/cpu.h | 2 -- 1 file changed, 2 deletions(-)
target/s390x/cpu.h +0 -2
@@ -804,8 +804,6 @@ int cpu_s390x_signal_handler(int host_signum, void *pinfo, void *puc);void s390_crw_mchk (void );void s390_io_interrupt (uint16_t subchannel_id,uint16_t subchannel_nr,uint32_t io_int_parm,uint32_t io_int_word); -/* instruction length set by unwind info */ -#define ILEN_UNWIND 0#define RA_IGNORED 0void s390_program_interrupt (CPUS390XState *env,uint32_t code,uintptr_t ra);/* service interrupts are floating therefore we must not pass an cpustate */
Signature · 1 line
2.17.1
Quoted 42 lines · Richard Henderson
Changes since v4:
* Fix a rebase error in patch 2.
* Fixs390_cpu_get_phys_page_debugin patch 9.
* Rebased on David's tree.Based-on: https://github.com/davidhildenbrand/qemu/tree/mmu
r~
Richard Henderson (18):
target/s390x: Add ilen to unwind data
target/s390x: Remove ilen parameter fromtcg_s390_program_interrupttarget/s390x: Remove ilen parameter froms390_program_interrupttarget/s390x: Usetcg_s390_program_interruptin TCG helpers target/s390x: Pushtrigger_pgm_exceptionlower ins390_cpu_tlb_filltarget/s390x: Handle tec ins390_cpu_tlb_filltarget/s390x: Return exception frommmu_translate_realtarget/s390x: Remove exc argument tommu_translate_ascetarget/s390x: Return exception frommmu_translatetarget/s390x: Return exception fromtranslate_pagestarget/s390x: Remove fail variable froms390_cpu_tlb_filltarget/s390x: Simplifyhelper_lra
target/s390x: Rely on unwinding ins390_cpu_tlb_filltarget/s390x: Rely on unwinding ins390_cpu_virt_mem_rwtarget/s390x: RemoveILEN_AUTO
target/s390x: Remove ilen argument fromtrigger_access_exceptiontarget/s390x: Remove ilen argument fromtrigger_pgm_exceptiontarget/s390x: RemoveILEN_UNWINDtarget/s390x/cpu.h | 7 +--- target/s390x/internal.h | 6 +-- target/s390x/tcg_s390x.h | 4 +- hw/s390x/s390-pci-inst.c | 58 +++++++++++++------------- target/s390x/cc_helper.c | 4 +- target/s390x/crypto_helper.c | 7 ++-- target/s390x/diag.c | 14 +++---- target/s390x/excp_helper.c | 60 ++++++++++++-------------- target/s390x/fpu_helper.c | 6 +-- target/s390x/helper.c | 3 +- target/s390x/int_helper.c | 15 +++----
Quoted 9 lines
target/s390x/interrupt.c | 9 ++-- target/s390x/ioinst.c | 40 +++++++++--------- target/s390x/mem_helper.c | 61 +++++++++++++-------------- target/s390x/misc_helper.c | 27 ++++-------- target/s390x/mmu_helper.c | 81 +++++++++++++++--------------------- target/s390x/tcg-stub.c | 4 +- target/s390x/translate.c | 20 +++++++-- 18 files changed, 202 insertions(+), 224 deletions(-)
Thanks,
Queued to
https://github.com/davidhildenbrand/qemu.git s390-tcg-next
Signature · 3 lines
Thanks, David / dhildenb