target/s390: Use tcg unwinding for ilen
v4 cover target/s390: Use tcg unwinding for ilen
Based-on: <[email protected]> \
("s390x/mmu: DAT translation rewrite")
Based-on: <[email protected]> \
("s390x/mmu: Implement more facilities") \
With the suggested follow-up for patch 2 re ilen.
Which should mean that this applies on top of David's current s390x tree. ;-)
Changes since v3:
* Dropped the unrelated psw.addr wrapping patch.
* Set ilen to 2 for breakpoints, which means that we can make the assignment within restore_state_to_opc unconditional.
* Remove ILEN_UNWIND. After the penultimate patch, we nowhere play odd games with ILEN. Yay!
Patches without review or ack:
0001-target-s390x-Add-ilen-to-unwind-data 0009-target-s390x-Return-exception-from-mmu_translate 0018-target-s390x-Remove-ILEN_UNWIND (new)
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/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 | 80 +++++++++++++++--------------------- target/s390x/tcg-stub.c | 4 +- target/s390x/translate.c | 20 +++++++-- 17 files changed, 199 insertions(+), 223 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 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
@@ -30,7 +30,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
@@ -803,6 +803,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
Re: [PATCH v4 01/18] target/s390x: Add ilen to unwind data
Quoted 95 lines · Richard Henderson
From: Richard Henderson <[email protected]>
Use
ILEN_UNWINDto signal that we have in fact thatcpu_restore_statewill have been called by the time we arrive indo_program_interrupt.Signed-off-by Richard Henderson <[email protected]>--- 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@@ -30,7 +30,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@@ -803,6 +803,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 0target/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 +12
-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 ]; +
target/s390x/translate.c void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb, · line 6588
Quoted 10 lines
target/s390x/translate.c +5
-0env->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 · 3 lines
Thanks, David / dhildenb
PATCH v4 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 | 8 ++++---- target/s390x/interrupt.c | 2 +- target/s390x/tcg-stub.c | 4 ++-- 4 files changed, 9 insertions(+), 9 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 +4 -4
@@ -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,
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
Re: [PATCH v4 02/18] target/s390x: Remove ilen parameter from tcg_s390_program_interrupt
Quoted 78 lines · Richard Henderson
Since we begin the operation with an unwind, we have the proper value of ilen immediately available.
Reviewed-by David Hildenbrand <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/s390x/tcg_s390x.h | 4 ++-- target/s390x/excp_helper.c | 8 ++++---- target/s390x/interrupt.c | 2 +- target/s390x/tcg-stub.c | 4 ++-- 4 files changed, 9 insertions(+), 9 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 +4
-4@@ -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,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 +0
-0
target/s390x/tcg-stub.c line 25
Quoted 10 lines
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 (); }
[dhildenb@desktop qemu]$ LANG=C make check-qtest-s390x
make[1]: Entering directory '/home/dhildenb/git/qemu/slirp'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/dhildenb/git/qemu/slirp'
CHK version_gen.h
CC s390x-softmmu/target/s390x/excp_helper.o/home/dhildenb/git/qemu/target/s390x/excp_helper.c: In function 'tcg_s390_vector_exception':/home/dhildenb/git/qemu/target/s390x/excp_helper.c:78:5: error: too many arguments to function 'tcg_s390_program_interrupt'
78 | tcg_s390_program_interrupt(env, PGM_VECTOR_PROCESSING, ILEN_AUTO, ra);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dhildenb/git/qemu/target/s390x/excp_helper.c:37:20: note: declared here
37 | void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~make[1]: *** [/home/dhildenb/git/qemu/rules.mak:69: target/s390x/excp_helper.o] Error 1
make: *** [Makefile:482: s390x-softmmu/all] Error 2
Easy to fixup.
Signature · 3 lines
Thanks, David / dhildenb
PATCH v4 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 | 4 +-- 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, 103 insertions(+), 115 deletions(-)
target/s390x/cpu.h +1 -2
@@ -808,8 +808,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 +2 -2
@@ -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)
@@ -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 v4 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 v4 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 v4 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 v4 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 | 15 ++++++--------- 3 files changed, 9 insertions(+), 12 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 -9
@@ -555,15 +555,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. */ -const int ilen = (rw ==MMU_INST_FETCH ) ?2 :ILEN_AUTO ; -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 ;
@@ -572,9 +568,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, 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 v4 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
@@ -113,7 +113,7 @@ static inline int read_table_entry(hwaddr gaddr, uint64_t *entry)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 );
@@ -424,7 +424,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 v4 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/mem_helper.c | 13 +++++++--- target/s390x/mmu_helper.c | 49 +++++++++++++++----------------------- 4 files changed, 32 insertions(+), 36 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/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 +19 -30
87 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v4 09/18] target/s390x: Return exception from mmu_translate
Quoted 156 lines · Richard Henderson
Do not raise the exception directly within
mmu_translate, but pass it back so that caller may do so.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/internal.h | 2 +- target/s390x/excp_helper.c | 4 ++-- target/s390x/mem_helper.c | 13 +++++++--- target/s390x/mmu_helper.c | 49 +++++++++++++++----------------------- 4 files changed, 32 insertions(+), 36 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/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 +14
-29@@ -369,17 +369,15 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)* @return 0 if the translation was successful, -1 if a fault occurred */ 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) { -/* Code accesses have an undefined ilc, let's use 2 bytes. */ -const int ilen = (rw ==MMU_INST_FETCH ) ?2 :ILEN_AUTO ; -uint64_t tec = (vaddr &TARGET_PAGE_MASK ) | (asc >>46 ) | - (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ );uint64_t asce;int r; - + *tec = (vaddr &TARGET_PAGE_MASK ) | (asc >>46 ) | + (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ ); *flags =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +if (is_low_address (vaddr &TARGET_PAGE_MASK ) &&lowprot_enabled (env, asc)) {/* * If any part of this page is currently protected, make sure the @@ -391,12 +389,9 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,*/ *flags |=PAGE_WRITE_INV ;if (is_low_address (vaddr) && rw ==MMU_DATA_STORE ) { -if (exc) { -/* LAP sets bit 56 */ - tec |=0x80 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -EACCES ; +/* LAP sets bit 56 */ + *tec |=0x80 ; +return PGM_PROTECTION ; } }@@ -426,30 +421,21 @@ 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);if (unlikely (r)) { -if (exc) { -trigger_access_exception (env, r, ilen, tec); - } -return -1 ; +return r; }/* check for DAT protection */ if (unlikely (rw ==MMU_DATA_STORE && !(*flags &PAGE_WRITE ))) { -if (exc) { -/* DAT sets bit 61 only */ - tec |=0x4 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -1 ; +/* DAT sets bit 61 only */ + *tec |=0x4 ; +return PGM_PROTECTION ; }/* check for Instruction-Execution-Protection */ if (unlikely (rw ==MMU_INST_FETCH && !(*flags &PAGE_EXEC ))) { -if (exc) { -/* IEP sets bit 56 and 61 */ - tec |=0x84 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -1 ; +/* IEP sets bit 56 and 61 */ + *tec |=0x84 ; +return PGM_PROTECTION ; } nodat:@@ -473,9 +459,12 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,int ret, i, pflags;for (i =0 ; i < nr_pages; i++) { - ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, true);
target/s390x/mmu_helper.c static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, · line 470
Quoted 10 lines
target/s390x/mmu_helper.c +5
-1+uint64_t tec; + + ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, &tec);if (ret) { -return ret; +trigger_access_exception (env, ret,ILEN_AUTO , tec); +return -EFAULT ; } if (!address_space_access_valid(&address_space_memory, pages[i], TARGET_PAGE_SIZE, is_write,
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v4 09/18] target/s390x: Return exception from mmu_translate
In reply to Richard HendersonQuoted 156 lines · Richard Henderson
Do not raise the exception directly within
mmu_translate, but pass it back so that caller may do so.Signed-off-by Richard Henderson <[email protected]>--- target/s390x/internal.h | 2 +- target/s390x/excp_helper.c | 4 ++-- target/s390x/mem_helper.c | 13 +++++++--- target/s390x/mmu_helper.c | 49 +++++++++++++++----------------------- 4 files changed, 32 insertions(+), 36 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/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 +14
-29@@ -369,17 +369,15 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)* @return 0 if the translation was successful, -1 if a fault occurred */ 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) { -/* Code accesses have an undefined ilc, let's use 2 bytes. */ -const int ilen = (rw ==MMU_INST_FETCH ) ?2 :ILEN_AUTO ; -uint64_t tec = (vaddr &TARGET_PAGE_MASK ) | (asc >>46 ) | - (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ );uint64_t asce;int r; - + *tec = (vaddr &TARGET_PAGE_MASK ) | (asc >>46 ) | + (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ ); *flags =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +if (is_low_address (vaddr &TARGET_PAGE_MASK ) &&lowprot_enabled (env, asc)) {/* * If any part of this page is currently protected, make sure the @@ -391,12 +389,9 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,*/ *flags |=PAGE_WRITE_INV ;if (is_low_address (vaddr) && rw ==MMU_DATA_STORE ) { -if (exc) { -/* LAP sets bit 56 */ - tec |=0x80 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -EACCES ; +/* LAP sets bit 56 */ + *tec |=0x80 ; +return PGM_PROTECTION ; } }@@ -426,30 +421,21 @@ 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);if (unlikely (r)) { -if (exc) { -trigger_access_exception (env, r, ilen, tec); - } -return -1 ; +return r; }/* check for DAT protection */ if (unlikely (rw ==MMU_DATA_STORE && !(*flags &PAGE_WRITE ))) { -if (exc) { -/* DAT sets bit 61 only */ - tec |=0x4 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -1 ; +/* DAT sets bit 61 only */ + *tec |=0x4 ; +return PGM_PROTECTION ; }/* check for Instruction-Execution-Protection */ if (unlikely (rw ==MMU_INST_FETCH && !(*flags &PAGE_EXEC ))) { -if (exc) { -/* IEP sets bit 56 and 61 */ - tec |=0x84 ; -trigger_access_exception (env,PGM_PROTECTION , ilen, tec); - } -return -1 ; +/* IEP sets bit 56 and 61 */ + *tec |=0x84 ; +return PGM_PROTECTION ; } nodat:@@ -473,9 +459,12 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,int ret, i, pflags;for (i =0 ; i < nr_pages; i++) { - ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, true);
target/s390x/mmu_helper.c static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, · line 470
Quoted 10 lines
target/s390x/mmu_helper.c +5
-1+uint64_t tec; + + ret =mmu_translate (env, addr, is_write, asc, &pages[i], &pflags, &tec);if (ret) { -return ret; +trigger_access_exception (env, ret,ILEN_AUTO , tec); +return -EFAULT ; } if (!address_space_access_valid(&address_space_memory, pages[i], TARGET_PAGE_SIZE, is_write,
This patch breaks "tests/test-hmp"
[dhildenb@desktop qemu]$ LANG=C make check-qtest-s390x make[1]: Entering directory '/home/dhildenb/git/qemu/slirp' make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/dhildenb/git/qemu/slirp'
CHK version_gen.h
TEST check-qtest-s390x: tests/boot-serial-test TEST check-qtest-s390x: tests/pxe-test TEST check-qtest-s390x: tests/test-netfilter TEST check-qtest-s390x: tests/test-filter-mirror TEST check-qtest-s390x: tests/test-filter-redirector TEST check-qtest-s390x: tests/drive_del-test TEST check-qtest-s390x: tests/device-plug-test TEST check-qtest-s390x: tests/virtio-ccw-test TEST check-qtest-s390x: tests/cpu-plug-test TEST check-qtest-s390x: tests/migration-test TEST check-qtest-s390x: tests/qmp-test TEST check-qtest-s390x: tests/qmp-cmd-test TEST check-qtest-s390x: tests/device-introspect-test TEST check-qtest-s390x: tests/cdrom-test TEST check-qtest-s390x: tests/machine-none-test TEST check-qtest-s390x: tests/qom-test TEST check-qtest-s390x: tests/test-hmp
Broken pipetests/libqtest.c:149: kill_qemu() detected QEMU death from signal 11 (Segmentation fault) (core dumped)
ERROR - too few tests run (expected 4, got 0)
make: *** [/home/dhildenb/git/qemu/tests/Makefile.include:901:
check-qtest-s390x] Error 1
Haven't looked at the detail, but I could imagine some debug page access.
The current combined tree resides at:
https://github.com/davidhildenbrand/qemu/tree/mmu_plus_rewind
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v4 09/18] target/s390x: Return exception from mmu_translate
Quoted 4 lines · David Hildenbrand
TEST check-qtest-s390x: tests/test-hmp
Broken pipetests/libqtest.c:149:kill_qemu()detected QEMU death from signal 11 (Segmentation fault) (core dumped)
Missed a change to s390_cpu_get_phys_page_debug:
(gdb) bt 4
#0 0x00005555557a4923 in mmu_translate (env=0x555555f7c330, vaddr=vaddr@entry=0, rw=rw@entry=0, asc=0, raddr=raddr@entry=0x7fffffffd010, flags=flags@entry=0x7fffffffd00c, tec=0x0) at /home/rth/qemu/qemu/target/s390x/mmu_helper.c:376
#1 0x000055555575a135 in s390_cpu_get_phys_page_debug (cs=<optimized out>, vaddr=0) at /home/rth/qemu/qemu/target/s390x/helper.c:70
#2 0x0000555555752219 in cpu_get_phys_page_attrs_debug (attrs=0x7fffffffd034, addr=0, cpu=<optimized out>) at /home/rth/qemu/qemu/include/hw/core/cpu.h:605 #3 0x0000555555752219 in hmp_gva2gpa (mon=0x555555f53310, qdict=<optimized out>) at /home/rth/qemu/qemu/monitor/misc.c:850
Irritating that the "0" produced an implicit null instead of a compile-time failure. Anyway, will fix and rebase on your mmu branch.
r~
PATCH v4 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
@@ -452,25 +452,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 ; }
@@ -498,6 +495,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 ()) {
@@ -511,8 +509,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 v4 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 v4 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 v4 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 v4 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
@@ -511,7 +511,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 v4 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
@@ -805,8 +805,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 v4 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 ); } }
@@ -511,7 +511,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 v4 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 v4 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
@@ -803,8 +803,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
Re: [PATCH v4 18/18] target/s390x: Remove ILEN_UNWIND
Quoted 13 lines · Richard Henderson
This setting is no longer used.
Signed-off-by Richard Henderson <[email protected]>--- target/s390x/cpu.h | 2 -- 1 file changed, 2 deletions(-)target/s390x/cpu.h +0
-0
target/s390x/cpu.h int cpu_s390x_signal_handler(int host_signum, void *pinfo, void *puc); · line 808
Quoted 8 lines
target/s390x/cpu.h +0
-2@@ -803,8 +803,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 · 3 lines
Thanks, David / dhildenb
Quoted 9 lines · Richard Henderson
Based-on: <[email protected]> \
("s390x/mmu: DAT translation rewrite")Based-on: <[email protected]> \
("s390x/mmu: Implement more facilities") \
With the suggested follow-up for patch 2 re ilen.Which should mean that this applies on top of David's current s390x tree. ;-)
Indeed, both are located at
https://github.com/davidhildenbrand/qemu/tree/mmu
Once I have more feedback on "s390x/mmu: Implement more facilities", I am going to pick up this series and give it a good test. Then send it upstream (either via Conny, due to the CPU model change, or directly). Sounds good?
Signature · 3 lines
Thanks, David / dhildenb
Quoted 11 lines · David Hildenbrand
Quoted 9 lines · Richard Henderson
Based-on: <[email protected]> \
("s390x/mmu: DAT translation rewrite")Based-on: <[email protected]> \
("s390x/mmu: Implement more facilities") \
With the suggested follow-up for patch 2 re ilen.Which should mean that this applies on top of David's current s390x tree. ;-)
Quoted 8 lines
Indeed, both are located at
https://github.com/davidhildenbrand/qemu/tree/mmuOnce I have more feedback on "s390x/mmu: Implement more facilities", I am going to pick up this series and give it a good test. Then send it upstream (either via Conny, due to the CPU model change, or directly). Sounds good?
Yep, thanks!
r~