target/s390x: Fix broken build with --disable-tcg
v3 cover target/s390x: Fix broken build with --disable-tcg
Our configure script was recently equipped with a new --disable-tcg parameter, but this does unfortunately not work on s390x hosts yet. Fix the build by moving some code around and by adding some few #ifdefs in the right places.
v3:
- Fixed the problem when building the s390x-linux-user target
- Added a g_assert_not_reached() to tcg_s390_program_interrupt() according to Richard's suggestion
v2:
- Reworked the changes to program_interrupt() according to the suggestions by Richard
Thomas Huth (5):
target/s390x: Move s390_cpu_dump_state() to helper.c target/s390x: Move diag helpers to a separate file target/s390x: Rework program_interrupt() and related functions target/s390x: Move exception-related functions to a new excp_helper.c
file
target/s390x: Add remaining switches to compile with --disable-tcg
target/s390x/Makefile.objs | 8 +- target/s390x/cpu.c | 4 + target/s390x/cpu.h | 17 +- target/s390x/diag.c | 179 +++++++++++++++ target/s390x/excp_helper.c | 515 +++++++++++++++++++++++++++++++++++++++++++ target/s390x/helper.c | 528 +++++---------------------------------------- target/s390x/interrupt.c | 39 ++++ target/s390x/kvm.c | 16 +- target/s390x/misc_helper.c | 193 ----------------- target/s390x/translate.c | 60 ------ 10 files changed, 819 insertions(+), 740 deletions(-) create mode 100644 target/s390x/diag.c create mode 100644 target/s390x/excp_helper.c
Signature · 1 line
1.8.3.1
PATCH v3 1/5 target/s390x: Move s390_cpu_dump_state() to helper.c
translate.c can not be compiled with --disable-tcg, but we need the s390_cpu_dump_state() in KVM-only builds, too. So let's move that function to helper.c instead, which will also be compiled when --disable-tcg has been specified.
--- target/s390x/helper.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ target/s390x/translate.c | 60 ------------------------------------------------ 2 files changed, 60 insertions(+), 60 deletions(-)
target/s390x/helper.c +60 -0
@@ -766,3 +766,63 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,program_interrupt (env,PGM_SPECIFICATION ,ILEN_AUTO ); }#endif /* CONFIG_USER_ONLY */ + +void s390_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf, +int flags) +{ +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; +int i; + +if (env->cc_op >3 ) { +cpu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %15s\n" , + env->psw.mask, env->psw.addr,cc_name (env->cc_op)); + }else { +cpu_fprintf (f,"PSW=mask %016" PRIx64" addr %016" PRIx64" cc %02x\n" , + env->psw.mask, env->psw.addr, env->cc_op); + } + +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"R%02d=%016" PRIx64, i, env->regs[i]); +if ((i %4 ) ==3 ) { +cpu_fprintf (f,"\n" ); + }else { +cpu_fprintf (f," " ); + } + } + +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"F%02d=%016" PRIx64, i,get_freg (env, i)->ll); +if ((i %4 ) ==3 ) { +cpu_fprintf (f,"\n" ); + }else { +cpu_fprintf (f," " ); + } + } + +for (i =0 ; i <32 ; i++) { +cpu_fprintf (f,"V%02d=%016" PRIx64"%016" PRIx64, i, + env->vregs[i][0 ].ll, env->vregs[i][1 ].ll); +cpu_fprintf (f, (i %2 ) ?"\n" :" " ); + } + +#ifndef CONFIG_USER_ONLY +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"C%02d=%016" PRIx64, i, env->cregs[i]); +if ((i %4 ) ==3 ) { +cpu_fprintf (f,"\n" ); + }else { +cpu_fprintf (f," " ); + } + } +#endif + +#ifdef DEBUG_INLINE_BRANCHES +for (i =0 ; i <CC_OP_MAX ; i++) { +cpu_fprintf (f," %15s = %10ld\t%10ld\n" ,cc_name (i), + inline_branch_miss[i], inline_branch_hit[i]); + } +#endif + +cpu_fprintf (f,"\n" ); +}
target/s390x/translate.c +0 -60
66 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 2/5 target/s390x: Move diag helpers to a separate file
In reply to Thomas Huthmisc_helper.c won't be compiled with --disable-tcg anymore, but we still need the diag helpers in KVM builds, too, so move the helper functions to a separate file.
--- target/s390x/Makefile.objs | 2 +- target/s390x/diag.c | 179 +++++++++++++++++++++++++++++++++++++++++++++ target/s390x/misc_helper.c | 167 ------------------------------------------ 3 files changed, 180 insertions(+), 168 deletions(-) create mode 100644 target/s390x/diag.c
target/s390x/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o obj-y += gdbstub.o cpu_models.o cpu_features.o -obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o +obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o diag.o obj-$(CONFIG_KVM) += kvm.o # build and run feature list generator
target/s390x/diag.c new file +179 -0
179 lines not on this page · raw message
target/s390x/misc_helper.c +0 -167
188 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 3/5 target/s390x: Rework program_interrupt() and related functions
In reply to Thomas Huthmisc_helper.c won't be compiled with --disable-tcg anymore, but we still need the program_interrupt() function in that case. Move it to interrupt.c instead, and refactor it to re-use the code from trigger_pgm_exception() (for TCG) and enter_pgmcheck() (for KVM, which now got renamed to kvm_s390_program_interrupt() for clarity).
--- target/s390x/cpu.h | 9 +++++---- target/s390x/helper.c | 10 ---------- target/s390x/interrupt.c | 39 +++++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 16 ++++++++-------- target/s390x/misc_helper.c | 26 -------------------------- 5 files changed, 52 insertions(+), 48 deletions(-)
target/s390x/cpu.h +5 -4
@@ -474,10 +474,6 @@ static inline bool get_per_in_range(CPUS390XState *env, uint64_t addr) } } -#ifndef CONFIG_USER_ONLY -void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen); -#endif -S390CPU *cpu_s390x_init (const char *cpu_model);S390CPU *s390x_new_cpu (const char *cpu_model,int64_t id,Error **errp);S390CPU *cpu_s390x_create (const char *cpu_model,Error **errp);
@@ -1146,10 +1142,12 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3);/* automatically detect the instruction length */ #define ILEN_AUTO 0xffvoid program_interrupt (CPUS390XState *env,uint32_t code,int ilen); +void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen); void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,uintptr_t retaddr);#ifdef CONFIG_KVM +void kvm_s390_program_interrupt (S390CPU *cpu,uint16_t code);void kvm_s390_io_interrupt (uint16_t subchannel_id,uint16_t subchannel_nr,uint32_t io_int_parm,uint32_t io_int_word);
@@ -1170,6 +1168,9 @@ int kvm_s390_get_ri(void);int kvm_s390_get_gs (void );void kvm_s390_crypto_reset (void );#else +static inline void kvm_s390_program_interrupt (S390CPU *cpu,uint16_t code) +{ +} static inline void kvm_s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm,
target/s390x/helper.c +0 -10
@@ -165,16 +165,6 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address,#else /* !CONFIG_USER_ONLY */ -/* Ensure to exit the TB after this call! */ -void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen) -{ -CPUState *cs =CPU (s390_env_get_cpu (env)); - - cs->exception_index =EXCP_PGM ; - env->int_pgm_code = code; - env->int_pgm_ilen = ilen; -} -int s390_cpu_handle_mmu_fault (CPUState *cs,vaddr orig_vaddr,int rw,int mmu_idx) {
target/s390x/interrupt.c +39 -0
@@ -8,10 +8,49 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" #include "cpu.h" +#include "exec/exec-all.h" #include "sysemu/kvm.h" #include "hw/s390x/ioinst.h" +/* Ensure to exit the TB after this call! */ +void trigger_pgm_exception (CPUS390XState *env,uint32_t code,uint32_t ilen) +{ +CPUState *cs =CPU (s390_env_get_cpu (env)); + + cs->exception_index =EXCP_PGM ; + env->int_pgm_code = code; + env->int_pgm_ilen = ilen; +} + +static void tcg_s390_program_interrupt (CPUS390XState *env,uint32_t code, +int ilen) +{ +#ifdef CONFIG_TCG +trigger_pgm_exception (env, code, ilen); +cpu_loop_exit (CPU (s390_env_get_cpu (env))); +#else +g_assert_not_reached (); +#endif +} + +void program_interrupt (CPUS390XState *env,uint32_t code,int ilen) +{ +S390CPU *cpu =s390_env_get_cpu (env); + +qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , + env->psw.addr); + +if (kvm_enabled ()) { +kvm_s390_program_interrupt (cpu, code); + }else if (tcg_enabled ()) { +tcg_s390_program_interrupt (env, code, ilen); + }else { +g_assert_not_reached (); + } +} +#if !defined(CONFIG_USER_ONLY )void cpu_inject_ext (S390CPU *cpu,uint32_t code,uint32_t param,uint64_t param64)
target/s390x/kvm.c +8 -8
@@ -1032,7 +1032,7 @@ void kvm_s390_service_interrupt(uint32_t parm)kvm_s390_floating_interrupt (&irq); } -static void enter_pgmcheck (S390CPU *cpu,uint16_t code) +void kvm_s390_program_interrupt (S390CPU *cpu,uint16_t code) {struct kvm_s390_irq irq = { .type =KVM_S390_PROGRAM_INT ,
@@ -1068,7 +1068,7 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, r =sclp_service_call (env, sccb, code);if (r <0 ) { -enter_pgmcheck (cpu, -r); +kvm_s390_program_interrupt (cpu, -r); }else {setcc (cpu, r); }
@@ -1236,7 +1236,7 @@ static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run) isc = (env->regs[r3] >>27 ) &0x7 ; r =css_do_sic (env, isc, mode);if (r) { -enter_pgmcheck (cpu, -r); +kvm_s390_program_interrupt (cpu, -r); }return 0 ;
@@ -1357,7 +1357,7 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_run *run)cpu_synchronize_state (CPU (cpu)); ret =s390_virtio_hypercall (env);if (ret == -EINVAL ) { -enter_pgmcheck (cpu,PGM_SPECIFICATION ); +kvm_s390_program_interrupt (cpu,PGM_SPECIFICATION );return 0 ; }
@@ -1374,7 +1374,7 @@ static void kvm_handle_diag_288(S390CPU *cpu, struct kvm_run *run) r3 = run->s390_sieic.ipa &0x000f ; rc =handle_diag_288 (&cpu->env, r1, r3);if (rc) { -enter_pgmcheck (cpu,PGM_SPECIFICATION ); +kvm_s390_program_interrupt (cpu,PGM_SPECIFICATION ); } }
@@ -1431,7 +1431,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)break ;default :DPRINTF ("KVM: unknown DIAG: 0x%x\n" , func_code); -enter_pgmcheck (cpu,PGM_SPECIFICATION ); +kvm_s390_program_interrupt (cpu,PGM_SPECIFICATION );break ; }
@@ -1899,7 +1899,7 @@ static int handle_instruction(S390CPU *cpu, struct kvm_run *run)if (r <0 ) { r =0 ; -enter_pgmcheck (cpu,0x0001 ); +kvm_s390_program_interrupt (cpu,PGM_OPERATION ); }return r;
@@ -2009,7 +2009,7 @@ static int handle_intercept(S390CPU *cpu)/* Then check for potential pgm check loops */ r =handle_oper_loop (cpu, run);if (r ==0 ) { -enter_pgmcheck (cpu,PGM_OPERATION ); +kvm_s390_program_interrupt (cpu,PGM_OPERATION ); } }break ;
target/s390x/misc_helper.c +0 -26
@@ -68,32 +68,6 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp)cpu_loop_exit (cs); } -void program_interrupt (CPUS390XState *env,uint32_t code,int ilen) -{ -S390CPU *cpu =s390_env_get_cpu (env); - -qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , - env->psw.addr); - -if (kvm_enabled ()) { -#ifdef CONFIG_KVM -struct kvm_s390_irq irq = { - .type =KVM_S390_PROGRAM_INT , - .u.pgm.code = code, - }; - -kvm_s390_vcpu_interrupt (cpu, &irq); -#endif - }else { -CPUState *cs =CPU (cpu); - - env->int_pgm_code = code; - env->int_pgm_ilen = ilen; - cs->exception_index =EXCP_PGM ; -cpu_loop_exit (cs); - } -} -#ifndef CONFIG_USER_ONLY /* SCLP service call */
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v3 3/5] target/s390x: Rework program_interrupt() and related functions
Quoted 7 lines · Thomas Huth
misc_helper.cwon't be compiled with --disable-tcg anymore, but we still need theprogram_interrupt()function in that case. Move it tointerrupt.cinstead, and refactor it to re-use the code fromtrigger_pgm_exception()(for TCG) andenter_pgmcheck()(for KVM, which now got renamed tokvm_s390_program_interrupt()for clarity).
Quoted 8 lines
Signed-off-by Thomas Huth<[email protected]>--- target/s390x/cpu.h | 9 +++++---- target/s390x/helper.c | 10 ---------- target/s390x/interrupt.c | 39 +++++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 16 ++++++++-------- target/s390x/misc_helper.c | 26 -------------------------- 5 files changed, 52 insertions(+), 48 deletions(-)
r~
Re: [Qemu-devel] [PATCH v3 3/5] target/s390x: Rework program_interrupt() and related functions
In reply to Thomas HuthQuoted 8 lines · Thomas Huth
misc_helper.cwon't be compiled with --disable-tcg anymore, but we still need theprogram_interrupt()function in that case. Move it tointerrupt.cinstead, and refactor it to re-use the code fromtrigger_pgm_exception()(for TCG) andenter_pgmcheck()(for KVM, which now got renamed tokvm_s390_program_interrupt()for clarity).Signed-off-by Thomas Huth <[email protected]>
I like that! Looks good to me!
Signature · 3 lines
Thanks, David
PATCH v3 4/5 target/s390x: Move exception-related functions to a new excp_helper.c file
In reply to Thomas HuthThese functions can not be compiled with --disable-tcg. But since we need the other functions from helper.c in the non-tcg build, we can also not simply remove helper.c from the non-tcg builds. Thus the problematic functions have to be moved into a separate new file instead that we can later omit in the non-tcg builds.
--- target/s390x/Makefile.objs | 2 +- target/s390x/cpu.h | 8 + target/s390x/excp_helper.c | 515 +++++++++++++++++++++++++++++++++++++++++++++ target/s390x/helper.c | 472 +---------------------------------------- 4 files changed, 528 insertions(+), 469 deletions(-) create mode 100644 target/s390x/excp_helper.c
target/s390x/Makefile.objs +1 -1
@@ -1,6 +1,6 @@ obj-y += translate.o helper.o cpu.o interrupt.o obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-y += gdbstub.o cpu_models.o cpu_features.o +obj-y += gdbstub.o cpu_models.o cpu_features.o excp_helper.o obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o diag.o obj-$(CONFIG_KVM) += kvm.o
target/s390x/cpu.h +8 -0
@@ -801,6 +801,8 @@ static inline void setcc(S390CPU *cpu, uint64_t cc) env->cc_op = cc; } +#ifndef CONFIG_USER_ONLY + typedef struct LowCore { /* prefix area: defined by architecture */
@@ -918,6 +920,11 @@ typedef struct LowCore uint8_t pad18[0x2000-0x1400]; /* 0x1400 */ }QEMU_PACKED LowCore; +LowCore *cpu_map_lowcore (CPUS390XState *env); +void cpu_unmap_lowcore (LowCore *lowcore); + +#endif +/* STSI */ #define STSI_LEVEL_MASK 0x00000000f0000000ULL#define STSI_LEVEL_CURRENT 0x0000000000000000ULL
@@ -1094,6 +1101,7 @@ struct sysib_322 {#define SIGP_ORDER_MASK 0x000000ffvoid load_psw (CPUS390XState *env,uint64_t mask,uint64_t addr); +uint64_t get_psw_mask (CPUS390XState *env);target_ulong mmu_real2abs (CPUS390XState *env,target_ulong raddr);int mmu_translate (CPUS390XState *env,target_ulong vaddr,int rw,uint64_t asc,target_ulong *raddr,int *flags,bool exc);
target/s390x/excp_helper.c new file +515 -0
515 lines not on this page · raw message
target/s390x/helper.c +4 -468
514 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 5/5 target/s390x: Add remaining switches to compile with --disable-tcg
In reply to Thomas HuthAdding some CONFIG_TCG tests to be finally able to compile QEMU on s390x also without TCG.
--- target/s390x/Makefile.objs | 6 +++--- target/s390x/cpu.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-)
target/s390x/Makefile.objs +3 -3
@@ -1,6 +1,6 @@ -obj-y += translate.o helper.o cpu.o interrupt.o -obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-y += gdbstub.o cpu_models.o cpu_features.o excp_helper.o +obj-y += cpu.o cpu_models.o cpu_features.o gdbstub.o interrupt.o helper.o +obj-$(CONFIG_TCG) += translate.o cc_helper.o excp_helper.o fpu_helper.o +obj-$(CONFIG_TCG) += int_helper.o mem_helper.o misc_helper.o obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o diag.o obj-$(CONFIG_KVM) += kvm.o
target/s390x/cpu.c +4 -0
@@ -417,7 +417,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->reset = s390_cpu_full_reset; cc->class_by_name = s390_cpu_class_by_name, cc->has_work = s390_cpu_has_work; +#ifdef CONFIG_TCG cc->do_interrupt = s390_cpu_do_interrupt; +#endif cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register;
@@ -428,10 +430,12 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->vmsd = &vmstate_s390_cpu; cc->write_elf64_note = s390_cpu_write_elf64_note; +#ifdef CONFIG_TCG cc->cpu_exec_interrupt = s390_cpu_exec_interrupt; cc->debug_excp_handler = s390x_cpu_debug_excp_handler; cc->do_unaligned_access = s390x_cpu_do_unaligned_access;#endif +#endif cc->disas_set_info = s390_cpu_disas_set_info; cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;
Signature · 1 line
1.8.3.1
Quoted 9 lines · On Mon, 24 Jul 2017 10:52:45 +0200 Thomas Huth <[email protected]> wrote:
Our configure script was recently equipped with a new --disable-tcg parameter, but this does unfortunately not work on s390x hosts yet. Fix the build by moving some code around and by adding some few #ifdefs in the right places.
v3:
- Fixed the problem when building the s390x-linux-user target
- Added ag_assert_not_reached()totcg_s390_program_interrupt()according to Richard's suggestion
If I get one more R-b by Richard for patch 3 before tomorrow, I'll merge that in.
Quoted 13 lines
v2:
- Reworked the changes toprogram_interrupt()according to the suggestions by RichardThomas Huth (5):
target/s390x: Moves390_cpu_dump_state()tohelper.ctarget/s390x: Move diag helpers to a separate file target/s390x: Reworkprogram_interrupt()and related functions target/s390x: Move exception-related functions to a newexcp_helper.c
file
target/s390x: Add remaining switches to compile with --disable-tcg
Quoted 14 lines
target/s390x/Makefile.objs | 8 +- target/s390x/cpu.c | 4 + target/s390x/cpu.h | 17 +- target/s390x/diag.c | 179 +++++++++++++++ target/s390x/excp_helper.c | 515 +++++++++++++++++++++++++++++++++++++++++++ target/s390x/helper.c | 528 +++++---------------------------------------- target/s390x/interrupt.c | 39 ++++ target/s390x/kvm.c | 16 +- target/s390x/misc_helper.c | 193 ----------------- target/s390x/translate.c | 60 ------ 10 files changed, 819 insertions(+), 740 deletions(-) create mode 100644 target/s390x/diag.c create mode 100644 target/s390x/excp_helper.c
Thanks, queued to s390-next.
Quoted 8 lines · Cornelia Huck
Quoted 5 lines · On Mon, 24 Jul 2017 10:52:45 +0200 Thomas Huth <[email protected]> wrote:
Our configure script was recently equipped with a new --disable-tcg parameter, but this does unfortunately not work on s390x hosts yet. Fix the build by moving some code around and by adding some few #ifdefs in the right places.
Quoted 7 lines
Quoted 4 lines
v3:
- Fixed the problem when building the s390x-linux-user target
- Added ag_assert_not_reached()totcg_s390_program_interrupt()according to Richard's suggestionIf I get one more R-b by Richard for patch 3 before tomorrow, I'll merge that in.
Thanks, please do.
r~