tcg patch queue
The following changes since commit 75d30fde55485b965a1168a21d016dd07b50ed32:
Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2022-10-30 15:07:25 -0400)
are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20221031
for you to fetch changes up to cb375590983fc3d23600d02ba05a05d34fe44150:
target/i386: Expand eflags updates inline (2022-10-31 11:39:10 +1100)
----------------------------------------------------------------
Remove sparc32plus support from tcg/sparc. target/i386: Use cpu_unwind_state_data for tpr access. target/i386: Expand eflags updates inline
----------------------------------------------------------------
Icenowy Zheng (1):
tcg/tci: fix logic error when registering helpers via FFI
Richard Henderson (10):
tcg/sparc: Remove support for sparc32plus
tcg/sparc64: Rename from tcg/sparc
tcg/sparc64: Remove sparc32plus constraints
accel/tcg: Introduce cpu_unwind_state_data
target/i386: Use cpu_unwind_state_data for tpr access target/openrisc: Always exit after mtspr npc target/openrisc: Use cpu_unwind_state_data for mfspr accel/tcg: Remove will_exit argument from cpu_restore_state accel/tcg: Remove reset_icount argument from cpu_restore_state_from_tb target/i386: Expand eflags updates inline
meson.build | 4 +-
accel/tcg/internal.h | 4 +-
include/exec/exec-all.h | 24 ++-
target/i386/helper.h | 5 -
tcg/{sparc => sparc64}/tcg-target-con-set.h | 16 +-
tcg/{sparc => sparc64}/tcg-target-con-str.h | 3 -
tcg/{sparc => sparc64}/tcg-target.h | 11 --
accel/tcg/cpu-exec-common.c | 2 +-
accel/tcg/tb-maint.c | 4 +-
accel/tcg/translate-all.c | 91 +++++----
target/alpha/helper.c | 2 +-
target/alpha/mem_helper.c | 2 +-
target/arm/op_helper.c | 2 +-
target/arm/tlb_helper.c | 8 +-
target/cris/helper.c | 2 +-
target/i386/helper.c | 21 ++-
target/i386/tcg/cc_helper.c | 41 -----
target/i386/tcg/sysemu/svm_helper.c | 2 +-
target/i386/tcg/translate.c | 30 ++-
target/m68k/op_helper.c | 4 +-
target/microblaze/helper.c | 2 +-
target/nios2/op_helper.c | 2 +-
target/openrisc/sys_helper.c | 17 +-
target/ppc/excp_helper.c | 2 +-
target/s390x/tcg/excp_helper.c | 2 +-
target/tricore/op_helper.c | 2 +-
target/xtensa/helper.c | 6 +-
tcg/tcg.c | 81 +-------
tcg/{sparc => sparc64}/tcg-target.c.inc | 275 ++++++++--------------------
MAINTAINERS | 2 +-
30 files changed, 232 insertions(+), 437 deletions(-)
rename tcg/{sparc => sparc64}/tcg-target-con-set.h (69%)
rename tcg/{sparc => sparc64}/tcg-target-con-str.h (77%)
rename tcg/{sparc => sparc64}/tcg-target.h (95%)
rename tcg/{sparc => sparc64}/tcg-target.c.inc (91%)[PULL 02/11] tcg/sparc64: Rename from tcg/sparc
Emphasize that we only support full 64-bit code generation.
---
meson.build | 4 +---
tcg/{sparc => sparc64}/tcg-target-con-set.h | 0
tcg/{sparc => sparc64}/tcg-target-con-str.h | 0
tcg/{sparc => sparc64}/tcg-target.h | 0
tcg/{sparc => sparc64}/tcg-target.c.inc | 0
MAINTAINERS | 2 +-
6 files changed, 2 insertions(+), 4 deletions(-)
rename tcg/{sparc => sparc64}/tcg-target-con-set.h (100%)
rename tcg/{sparc => sparc64}/tcg-target-con-str.h (100%)
rename tcg/{sparc => sparc64}/tcg-target.h (100%)
rename tcg/{sparc => sparc64}/tcg-target.c.inc (100%)meson.build +1 -3
@@ -49,7 +49,7 @@ qapi_trace_events = [] bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin'] supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux'] supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64', - 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64'] + 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64'] cpu = host_machine.cpu_family()
@@ -469,8 +469,6 @@ if get_option('tcg').allowed() endif if get_option('tcg_interpreter') tcg_arch = 'tci' - elif host_arch == 'sparc64' - tcg_arch = 'sparc' elif host_arch == 'x86_64' tcg_arch = 'i386' elif host_arch == 'ppc64'
tcg/sparc64/tcg-target-con-set.h renamed from tcg/sparc/tcg-target-con-set.h +0 -0
tcg/sparc64/tcg-target-con-str.h renamed from tcg/sparc/tcg-target-con-str.h +0 -0
tcg/sparc64/tcg-target.h renamed from tcg/sparc/tcg-target.h +0 -0
tcg/sparc64/tcg-target.c.inc renamed from tcg/sparc/tcg-target.c.inc +0 -0
MAINTAINERS +1 -1
@@ -3379,7 +3379,7 @@ L: [email protected] SPARC TCG target S: Odd Fixes -F: tcg/sparc/ +F: tcg/sparc64/ F: disas/sparc.c TCI TCG target
Signature · 1 line
2.34.1
[PULL 06/11] target/i386: Use cpu_unwind_state_data for tpr access
In reply to Richard HendersonAvoid cpu_restore_state, and modifying env->eip out from underneath the translator with TARGET_TB_PCREL. There is some slight duplication from x86_restore_state_to_opc, but it's just a few lines.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269
--- target/i386/helper.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
target/i386/helper.c +19 -2
@@ -509,6 +509,23 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, } } +static target_ulong get_memio_eip (CPUX86State *env) +{ +uint64_t data[TARGET_INSN_START_WORDS ]; +CPUState *cs =env_cpu (env); + +if (!cpu_unwind_state_data (cs, cs->mem_io_pc, data)) { +return env->eip; + } + +/* Per x86_restore_state_to_opc. */ +if (TARGET_TB_PCREL ) { +return (env->eip &TARGET_PAGE_MASK ) | data[0 ]; + }else { +return data[0 ] - env->segs[R_CS ].base; + } +} +void cpu_report_tpr_access (CPUX86State *env,TPRAccess access) {X86CPU *cpu =env_archcpu (env);
@@ -519,9 +536,9 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access) cpu_interrupt(cs, CPU_INTERRUPT_TPR); }else if (tcg_enabled ()) { -cpu_restore_state (cs, cs->mem_io_pc, false); +target_ulong eip =get_memio_eip (env); -apic_handle_tpr_access_report (cpu->apic_state, env->eip, access); +apic_handle_tpr_access_report (cpu->apic_state, eip, access); } }#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.34.1
[PULL 04/11] tcg/tci: fix logic error when registering helpers via FFI
In reply to Richard HendersonFrom: Icenowy Zheng <[email protected]>
When registering helpers via FFI for TCI, the inner loop that iterates parameters of the helper reuses (and thus pollutes) the same variable used by the outer loop that iterates all helpers, thus made some helpers unregistered.
Fix this logic error by using a dedicated temporary variable for the inner loop.
Message-Id: <[email protected]>
--- tcg/tcg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tcg/tcg.c +3 -3
@@ -634,9 +634,9 @@ static void tcg_context_init(unsigned max_cpus)if (nargs !=0 ) { ca->cif.arg_types = ca->args; -for (i =0 ; i < nargs; ++i) { -int typecode =extract32 (typemask, (i +1 ) *3 ,3 ); - ca->args[i] = typecode_to_ffi[typecode]; +for (int j =0 ; j < nargs; ++j) { +int typecode =extract32 (typemask, (j +1 ) *3 ,3 ); + ca->args[j] = typecode_to_ffi[typecode]; } }
Signature · 1 line
2.34.1
[PULL 09/11] accel/tcg: Remove will_exit argument from cpu_restore_state
In reply to Richard HendersonThe value passed is always true, and if the target's synchronize_from_tb hook is non-trivial, not exiting may be erroneous.
--- include/exec/exec-all.h | 5 +---- accel/tcg/cpu-exec-common.c | 2 +- accel/tcg/translate-all.c | 12 ++---------- target/alpha/helper.c | 2 +- target/alpha/mem_helper.c | 2 +- target/arm/op_helper.c | 2 +- target/arm/tlb_helper.c | 8 ++++---- target/cris/helper.c | 2 +- target/i386/tcg/sysemu/svm_helper.c | 2 +- target/m68k/op_helper.c | 4 ++-- target/microblaze/helper.c | 2 +- target/nios2/op_helper.c | 2 +- target/openrisc/sys_helper.c | 4 ++-- target/ppc/excp_helper.c | 2 +- target/s390x/tcg/excp_helper.c | 2 +- target/tricore/op_helper.c | 2 +- target/xtensa/helper.c | 6 +++--- 17 files changed, 25 insertions(+), 36 deletions(-)
include/exec/exec-all.h +1 -4
@@ -56,16 +56,13 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);* cpu_restore_state: * @cpu: the cpu context * @host_pc: the host pc within the translation -* @will_exit: true if the TB executed will be interrupted after some -cpu adjustments. Required for maintaining the correct -icount valus * @return: true if state was restored, false otherwise * * Attempt to restore the state for a fault occurring in translated * code. If @host_pc is not in translated code no state is * restored and the function returns false. */ -bool cpu_restore_state (CPUState *cpu,uintptr_t host_pc,bool will_exit); +bool cpu_restore_state (CPUState *cpu,uintptr_t host_pc); G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit(CPUState *cpu);
accel/tcg/cpu-exec-common.c +1 -1
@@ -71,7 +71,7 @@ void cpu_loop_exit(CPUState *cpu)void cpu_loop_exit_restore (CPUState *cpu,uintptr_t pc) {if (pc) { -cpu_restore_state (cpu, pc, true); +cpu_restore_state (cpu, pc); }cpu_loop_exit (cpu); }
accel/tcg/translate-all.c +2 -10
@@ -318,16 +318,8 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,#endif } -bool cpu_restore_state (CPUState *cpu,uintptr_t host_pc,bool will_exit) +bool cpu_restore_state (CPUState *cpu,uintptr_t host_pc) { -/* -* The pc update associated with restore without exit will -* break the relative pc adjustments performed by TARGET_TB_PCREL. -*/ -if (TARGET_TB_PCREL ) { -assert (will_exit); - } -/* * The host_pc has to be in the rx region of the code buffer. * If it is not we will not be able to resolve it here.
@@ -341,7 +333,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit)if (in_code_gen_buffer ((const void *)(host_pc - tcg_splitwx_diff))) {TranslationBlock *tb =tcg_tb_lookup (host_pc);if (tb) { -cpu_restore_state_from_tb (cpu, tb, host_pc, will_exit); +cpu_restore_state_from_tb (cpu, tb, host_pc, true);return true; } }
target/alpha/helper.c +1 -1
@@ -532,7 +532,7 @@ G_NORETURN void dynamic_excp(CPUAlphaState *env, uintptr_t retaddr, cs->exception_index = excp; env->error_code = error;if (retaddr) { -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr);/* Floating-point exceptions (our only users) point to the next PC. */ env->pc +=4 ; }
target/alpha/mem_helper.c +1 -1
@@ -28,7 +28,7 @@ static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retadduint64_t pc;uint32_t insn; -cpu_restore_state (env_cpu (env), retaddr, true); +cpu_restore_state (env_cpu (env), retaddr); pc = env->pc; insn =cpu_ldl_code (env, pc);
target/arm/op_helper.c +1 -1
@@ -78,7 +78,7 @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome,* we must restore CPU state here before setting the syndrome * the caller passed us, and cannot use cpu_loop_exit_restore(). */ -cpu_restore_state (cs, ra, true); +cpu_restore_state (cs, ra);raise_exception (env, excp, syndrome, target_el); }
target/arm/tlb_helper.c +4 -4
@@ -156,7 +156,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,ARMMMUFaultInfo fi = {};/* now we have a real cpu fault */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); fi.type = ARMFault_Alignment;arm_deliver_fault (cpu, vaddr, access_type, mmu_idx, &fi);
@@ -196,7 +196,7 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,ARMMMUFaultInfo fi = {};/* now we have a real cpu fault */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); fi.ea =arm_extabort_type (response); fi.type = ARMFault_SyncExternal;
@@ -252,7 +252,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,return false; }else {/* now we have a real cpu fault */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr);arm_deliver_fault (cpu, address, access_type, mmu_idx, fi); } }
@@ -271,7 +271,7 @@ void arm_cpu_record_sigsegv(CPUState *cs, vaddr addr,* We report both ESR and FAR to signal handlers. * For now, it's easiest to deliver the fault normally. */ -cpu_restore_state (cs, ra, true); +cpu_restore_state (cs, ra);arm_deliver_fault (cpu, addr, access_type,MMU_USER_IDX , &fi); }
target/cris/helper.c +1 -1
@@ -87,7 +87,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, cs->exception_index =EXCP_BUSFAULT ; env->fault_vector = res.bf_vec;if (retaddr) { -if (cpu_restore_state (cs, retaddr, true)) { +if (cpu_restore_state (cs, retaddr)) {/* Evaluate flags after retranslation. */ helper_top_evaluate_flags (env); }
target/i386/tcg/sysemu/svm_helper.c +1 -1
@@ -704,7 +704,7 @@ void cpu_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1, {CPUState *cs =env_cpu (env); -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n",
target/m68k/op_helper.c +2 -2
@@ -460,7 +460,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,M68kCPU *cpu =M68K_CPU (cs);CPUM68KState *env = &cpu->env; -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr);if (m68k_feature (env,M68K_FEATURE_M68040 )) { env->mmu.mmusr =0 ;
@@ -558,7 +558,7 @@ raise_exception_format2(CPUM68KState *env, int tt, int ilen, uintptr_t raddr) cs->exception_index = tt;/* Recover PC and CC_OP for the beginning of the insn. */ -cpu_restore_state (cs, raddr, true); +cpu_restore_state (cs, raddr);/* Flags are current in env->cc_*, or are undefined. */ env->cc_op =CC_OP_FLAGS ;
target/microblaze/helper.c +1 -1
@@ -277,7 +277,7 @@ void mb_cpu_do_unaligned_access(CPUState *cs, vaddr addr,uint32_t esr, iflags;/* Recover the pc and iflags from the corresponding insn_start. */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); iflags = cpu->env.iflags; qemu_log_mask(CPU_LOG_INT,
target/nios2/op_helper.c +1 -1
@@ -40,7 +40,7 @@ void nios2_cpu_loop_exit_advance(CPUNios2State *env, uintptr_t retaddr)* Do this here, rather than in restore_state_to_opc(), * lest we affect QEMU internal exceptions, like EXCP_DEBUG. */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); env->pc +=4 ;cpu_loop_exit (cs); }
target/openrisc/sys_helper.c +2 -2
@@ -45,7 +45,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)break ;case TO_SPR (0 ,16 ):/* NPC */ -cpu_restore_state (cs,GETPC (), true); +cpu_restore_state (cs,GETPC ());/* ??? Mirror or1ksim in not trashing delayed branch state when "jumping" to the current instruction. */ if (env->pc != rb) {
@@ -131,7 +131,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)case TO_SPR (8 ,0 ):/* PMR */ env->pmr = rb;if (env->pmr &PMR_DME || env->pmr &PMR_SME ) { -cpu_restore_state (cs,GETPC (), true); +cpu_restore_state (cs,GETPC ()); env->pc +=4 ; cs->halted =1 ;raise_exception (cpu,EXCP_HALTED );
target/ppc/excp_helper.c +1 -1
@@ -2414,7 +2414,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,uint32_t insn;/* Restore state and reload the insn we executed, for filling in DSISR. */ -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); insn =cpu_ldl_code (env, env->nip);switch (env->mmu_model) {
target/s390x/tcg/excp_helper.c +1 -1
@@ -39,7 +39,7 @@ G_NORETURN void tcg_s390_program_interrupt(CPUS390XState *env, {CPUState *cs =env_cpu (env); -cpu_restore_state (cs, ra, true); +cpu_restore_state (cs, ra);qemu_log_mask (CPU_LOG_INT ,"program interrupt at %#" PRIx64"\n" , env->psw.addr);trigger_pgm_exception (env, code);
target/tricore/op_helper.c +1 -1
@@ -31,7 +31,7 @@ void raise_exception_sync_internal(CPUTriCoreState *env, uint32_t class, int tin {CPUState *cs =env_cpu (env);/* in case we come from a helper-call we need to restore the PC */ -cpu_restore_state (cs, pc, true); +cpu_restore_state (cs, pc);/* Tin is loaded into d[15] */ env->gpr_d[15 ] = tin;
target/xtensa/helper.c +3 -3
@@ -253,7 +253,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cs,assert (xtensa_option_enabled (env->config,XTENSA_OPTION_UNALIGNED_EXCEPTION )); -cpu_restore_state (CPU (cpu), retaddr, true); +cpu_restore_state (CPU (cpu), retaddr);HELPER (exception_cause_vaddr)(env, env->pc,LOAD_STORE_ALIGNMENT_CAUSE , addr);
@@ -284,7 +284,7 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, }else if (probe) {return false; }else { -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr);HELPER (exception_cause_vaddr)(env, env->pc, ret, address); } }
@@ -297,7 +297,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,XtensaCPU *cpu =XTENSA_CPU (cs);CPUXtensaState *env = &cpu->env; -cpu_restore_state (cs, retaddr, true); +cpu_restore_state (cs, retaddr); HELPER(exception_cause_vaddr)(env, env->pc, access_type == MMU_INST_FETCH ? INSTR_PIF_ADDR_ERROR_CAUSE :
Signature · 1 line
2.34.1
[PULL 11/11] target/i386: Expand eflags updates inline
In reply to Richard HendersonThe helpers for reset_rf, cli, sti, clac, stac are completely trivial; implement them inline.
Drop some nearby #if 0 code.
--- target/i386/helper.h | 5 ----- target/i386/tcg/cc_helper.c | 41 ------------------------------------- target/i386/tcg/translate.c | 30 ++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 51 deletions(-)
target/i386/helper.h +0 -5
@@ -56,13 +56,8 @@ DEF_HELPER_2(syscall, void, env, int) DEF_HELPER_2(sysret, void, env, int)#endif DEF_HELPER_FLAGS_2(pause, TCG_CALL_NO_WG, noreturn, env, int) -DEF_HELPER_1(reset_rf, void, env) DEF_HELPER_FLAGS_3(raise_interrupt, TCG_CALL_NO_WG, noreturn, env, int, int) DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, int) -DEF_HELPER_1(cli, void, env) -DEF_HELPER_1(sti, void, env) -DEF_HELPER_1(clac, void, env) -DEF_HELPER_1(stac, void, env) DEF_HELPER_3(boundw, void, env, tl, int)DEF_HELPER_3 (boundl, void, env, tl, int)
target/i386/tcg/cc_helper.c +0 -41
44 lines not on this page · raw message
target/i386/tcg/translate.c +25 -5
@@ -2746,6 +2746,26 @@ static void gen_reset_hflag(DisasContext *s, uint32_t mask) } } +static void gen_set_eflags (DisasContext *s,target_ulong mask) +{ +TCGv t =tcg_temp_new (); + +tcg_gen_ld_tl (t, cpu_env, offsetof(CPUX86State , eflags)); +tcg_gen_ori_tl (t, t, mask); +tcg_gen_st_tl (t, cpu_env, offsetof(CPUX86State , eflags)); +tcg_temp_free (t); +} + +static void gen_reset_eflags (DisasContext *s,target_ulong mask) +{ +TCGv t =tcg_temp_new (); + +tcg_gen_ld_tl (t, cpu_env, offsetof(CPUX86State , eflags)); +tcg_gen_andi_tl (t, t, ~mask); +tcg_gen_st_tl (t, cpu_env, offsetof(CPUX86State , eflags)); +tcg_temp_free (t); +} +/* Clear BND registers during legacy branches. */ static void gen_bnd_jmp (DisasContext *s) {
@@ -2776,7 +2796,7 @@ do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, bool jr) }if (s->base.tb->flags &HF_RF_MASK ) { -gen_helper_reset_rf (cpu_env); +gen_reset_eflags (s,RF_MASK ); }if (recheck_tf) {gen_helper_rechecking_single_step (cpu_env);
@@ -5502,12 +5522,12 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)#endif case 0xfa :/* cli */ if (check_iopl (s)) { -gen_helper_cli (cpu_env); +gen_reset_eflags (s,IF_MASK ); }break ;case 0xfb :/* sti */ if (check_iopl (s)) { -gen_helper_sti (cpu_env); +gen_set_eflags (s,IF_MASK );/* interruptions are enabled only the first insn after sti */ gen_update_eip_next (s);gen_eob_inhibit_irq (s, true);
@@ -5789,7 +5809,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) || CPL(s) != 0) { goto illegal_op; } -gen_helper_clac (cpu_env); +gen_reset_eflags (s,AC_MASK ); s->base.is_jmp =DISAS_EOB_NEXT ;break ;
@@ -5798,7 +5818,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) || CPL(s) != 0) { goto illegal_op; } -gen_helper_stac (cpu_env); +gen_set_eflags (s,AC_MASK ); s->base.is_jmp =DISAS_EOB_NEXT ;break ;
Signature · 1 line
2.34.1
[PULL 10/11] accel/tcg: Remove reset_icount argument from cpu_restore_state_from_tb
In reply to Richard HendersonThe value passed is always true.
--- accel/tcg/internal.h | 2 +- accel/tcg/tb-maint.c | 4 ++-- accel/tcg/translate-all.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-)
accel/tcg/internal.h +1 -1
@@ -107,7 +107,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, tb_page_addr_t phys_page2);bool tb_invalidate_phys_page_unwind (tb_page_addr_t addr,uintptr_t pc);void cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb, -uintptr_t host_pc,bool reset_icount); +uintptr_t host_pc);/* Return the current PC from CPU, which may be cached in TB. */ static inline target_ulong log_pc (CPUState *cpu,const TranslationBlock *tb)
accel/tcg/tb-maint.c +2 -2
@@ -536,7 +536,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,* restore the CPU state. */ current_tb_modified = true; - cpu_restore_state_from_tb(cpu, current_tb, retaddr, true); + cpu_restore_state_from_tb(cpu, current_tb, retaddr); }#endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate__locked (tb);
@@ -685,7 +685,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)* function to partially restore the CPU state. */ current_tb_modified = true; - cpu_restore_state_from_tb(cpu, current_tb, pc, true); + cpu_restore_state_from_tb(cpu, current_tb, pc); }#endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate (tb, addr);
accel/tcg/translate-all.c +7 -8
@@ -282,12 +282,11 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc, }/* -* The cpu state corresponding to 'host_pc' is restored. -* When reset_icount is true, current TB will be interrupted and -* icount should be recalculated. +* The cpu state corresponding to 'host_pc' is restored in +* preparation for exiting the TB. */ void cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb, -uintptr_t host_pc,bool reset_icount) +uintptr_t host_pc) {uint64_t data[TARGET_INSN_START_WORDS ];#ifdef CONFIG_PROFILER
@@ -300,7 +299,7 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,return ; } -if (reset_icount && (tb_cflags (tb) &CF_USE_ICOUNT )) { +if (tb_cflags (tb) &CF_USE_ICOUNT ) {assert (icount_enabled ());/* * Reset the cycle counter to the start of the block and
@@ -333,7 +332,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc)if (in_code_gen_buffer ((const void *)(host_pc - tcg_splitwx_diff))) {TranslationBlock *tb =tcg_tb_lookup (host_pc);if (tb) { -cpu_restore_state_from_tb (cpu, tb, host_pc, true); +cpu_restore_state_from_tb (cpu, tb, host_pc);return true; } }
@@ -1032,7 +1031,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) tb =tcg_tb_lookup (retaddr);if (tb) {/* We can use retranslation to find the PC. */ -cpu_restore_state_from_tb (cpu, tb, retaddr, true); +cpu_restore_state_from_tb (cpu, tb, retaddr);tb_phys_invalidate (tb,-1 ); }else {/* The exception probably happened in a helper. The CPU state should
@@ -1068,7 +1067,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)cpu_abort (cpu,"cpu_io_recompile: could not find TB for pc=%p" , (void *)retaddr); } -cpu_restore_state_from_tb (cpu, tb, retaddr, true); +cpu_restore_state_from_tb (cpu, tb, retaddr);/* * Some guests must re-execute the branch when re-executing a delay
Signature · 1 line
2.34.1
[PULL 03/11] tcg/sparc64: Remove sparc32plus constraints
In reply to Richard HendersonWith sparc64 we need not distinguish between registers that can hold 32-bit values and those that can hold 64-bit values.
--- tcg/sparc64/tcg-target-con-set.h | 16 +---- tcg/sparc64/tcg-target-con-str.h | 3 - tcg/sparc64/tcg-target.c.inc | 109 ++++++++++++------------------- 3 files changed, 44 insertions(+), 84 deletions(-)
tcg/sparc64/tcg-target-con-set.h +3 -13
@@ -11,22 +11,12 @@*/ C_O0_I1(r) C_O0_I2(rZ, r) -C_O0_I2(RZ, r) C_O0_I2(rZ, rJ) -C_O0_I2(RZ, RJ) -C_O0_I2(sZ, A) -C_O0_I2(SZ, A) -C_O1_I1(r, A) -C_O1_I1(R, A) +C_O0_I2(sZ, s) +C_O1_I1(r, s) C_O1_I1(r, r) -C_O1_I1(r, R) -C_O1_I1(R, r) -C_O1_I1(R, R) -C_O1_I2(R, R, R) +C_O1_I2(r, r, r) C_O1_I2(r, rZ, rJ) -C_O1_I2(R, RZ, RJ) C_O1_I4(r, rZ, rJ, rI, 0) -C_O1_I4(R, RZ, RJ, RI, 0) C_O2_I2(r, r, rZ, rJ) -C_O2_I4(R, R, RZ, RZ, RJ, RI) C_O2_I4(r, r, rZ, rZ, rJ, rJ)
tcg/sparc64/tcg-target-con-str.h +0 -3
@@ -9,10 +9,7 @@* REGS(letter, register_mask) */ REGS('r', ALL_GENERAL_REGS) -REGS('R', ALL_GENERAL_REGS64)REGS ('s' ,ALL_QLDST_REGS ) -REGS('S', ALL_QLDST_REGS64) -REGS ('A' ,TARGET_LONG_BITS ==64 ?ALL_QLDST_REGS64 :ALL_QLDST_REGS )/* * Define constraint letters for constants:
tcg/sparc64/tcg-target.c.inc +41 -68
174 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 08/11] target/openrisc: Use cpu_unwind_state_data for mfspr
In reply to Richard HendersonSince we do not plan to exit, use cpu_unwind_state_data and extract exactly the data requested.
This is a bug fix, in that we no longer clobber dflag.
Consider:
l.j L2 // branch
l.mfspr r1, ppc // delayL1: boom L2: l.lwa r3, (r4)
Here, dflag would be set by cpu_restore_state (because that is the current state of the cpu), but but not cleared by tb_stop on exiting the TB (because DisasContext has recorded the current value as zero).
The next TB begins at L2 with dflag incorrectly set. If the load has a tlb miss, then the exception will be delivered as per a delay slot:
with DSX set in the status register and PC decremented (delay slots restart by re-executing the branch). This will cause the return from interrupt to go to L1, and boom!
--- target/openrisc/sys_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
target/openrisc/sys_helper.c +9 -2
@@ -199,6 +199,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, target_ulong spr) {#ifndef CONFIG_USER_ONLY +uint64_t data[TARGET_INSN_START_WORDS ];MachineState *ms =MACHINE (qdev_get_machine ());OpenRISCCPU *cpu =env_archcpu (env);CPUState *cs =env_cpu (env);
@@ -232,14 +233,20 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd,return env->evbar;case TO_SPR (0 ,16 ):/* NPC (equals PC) */ -cpu_restore_state (cs,GETPC (), false); +if (cpu_unwind_state_data (cs,GETPC (), data)) { +return data[0 ]; + }return env->pc;case TO_SPR (0 ,17 ):/* SR */ return cpu_get_sr (env);case TO_SPR (0 ,18 ):/* PPC */ -cpu_restore_state (cs,GETPC (), false); +if (cpu_unwind_state_data (cs,GETPC (), data)) { +if (data[1 ] &2 ) { +return data[0 ] -4 ; + } + }return env->ppc;case TO_SPR (0 ,32 ):/* EPCR */
Signature · 1 line
2.34.1
[PULL 05/11] accel/tcg: Introduce cpu_unwind_state_data
In reply to Richard HendersonAdd a way to examine the unwind data without actually restoring the data back into env.
--- accel/tcg/internal.h | 4 +-- include/exec/exec-all.h | 21 ++++++++--- accel/tcg/translate-all.c | 74 ++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 31 deletions(-)
accel/tcg/internal.h +2 -2
@@ -106,8 +106,8 @@ void tb_reset_jump(TranslationBlock *tb, int n);TranslationBlock *tb_link_page (TranslationBlock *tb,tb_page_addr_t phys_pc,tb_page_addr_t phys_page2);bool tb_invalidate_phys_page_unwind (tb_page_addr_t addr,uintptr_t pc); -int cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb, -uintptr_t searched_pc,bool reset_icount); +void cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb, +uintptr_t host_pc,bool reset_icount);/* Return the current PC from CPU, which may be cached in TB. */ static inline target_ulong log_pc (CPUState *cpu,const TranslationBlock *tb)
include/exec/exec-all.h +17 -4
@@ -39,20 +39,33 @@ typedef ram_addr_t tb_page_addr_t;#define TB_PAGE_ADDR_FMT RAM_ADDR_FMT#endif +/** +* cpu_unwind_state_data: +* @cpu: the cpu context +* @host_pc: the host pc within the translation +* @data: output data +* +* Attempt to load the the unwind state for a host pc occurring in +* translated code. If @host_pc is not in translated code, the +* function returns false; otherwise @data is loaded. +* This is the same unwind info as given to restore_state_to_opc. +*/ +bool cpu_unwind_state_data (CPUState *cpu,uintptr_t host_pc,uint64_t *data); +/** * cpu_restore_state: -* @cpu: the vCPU state is to be restore to -* @searched_pc: the host PC the fault occurred at +* @cpu: the cpu context +* @host_pc: the host pc within the translation * @will_exit: true if the TB executed will be interrupted after some cpu adjustments. Required for maintaining the correct icount valus * @return: true if state was restored, false otherwise * * Attempt to restore the state for a fault occurring in translated -* code. If the searched_pc is not in translated code no state is +* code. If @host_pc is not in translated code no state is * restored and the function returns false. */ -bool cpu_restore_state (CPUState *cpu,uintptr_t searched_pc,bool will_exit); +bool cpu_restore_state (CPUState *cpu,uintptr_t host_pc,bool will_exit); G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit(CPUState *cpu);
accel/tcg/translate-all.c +49 -25
114 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 07/11] target/openrisc: Always exit after mtspr npc
In reply to Richard HendersonWe have called cpu_restore_state asserting will_exit. Do not go back on that promise. This affects icount.
--- target/openrisc/sys_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/sys_helper.c +1 -1
@@ -51,8 +51,8 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)if (env->pc != rb) { env->pc = rb; env->dflag =0 ; -cpu_loop_exit (cs); } +cpu_loop_exit (cs);break ;case TO_SPR (0 ,17 ):/* SR */
Signature · 1 line
2.34.1
[PULL 01/11] tcg/sparc: Remove support for sparc32plus
In reply to Richard HendersonSince 9b9c37c36439, we have only supported sparc64 cpus. Debian and Gentoo now only support 64-bit sparc64 userland, so it is time to drop the 32-bit sparc64 userland: sparc32plus.
--- tcg/sparc/tcg-target.h | 11 --- tcg/tcg.c | 75 +---------------- tcg/sparc/tcg-target.c.inc | 166 +++++++------------------------------ 3 files changed, 33 insertions(+), 219 deletions(-)
tcg/sparc/tcg-target.h +0 -11
@@ -25,8 +25,6 @@#ifndef SPARC_TCG_TARGET_H #define SPARC_TCG_TARGET_H -#define TCG_TARGET_REG_BITS 64 -#define TCG_TARGET_INSN_UNIT_SIZE 4#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32#define TCG_TARGET_NB_REGS 32
@@ -70,19 +68,10 @@ typedef enum {/* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_O6 -#ifdef __arch64__#define TCG_TARGET_STACK_BIAS 2047#define TCG_TARGET_STACK_ALIGN 16#define TCG_TARGET_CALL_STACK_OFFSET (128 + 6*8 + TCG_TARGET_STACK_BIAS) -#else -#define TCG_TARGET_STACK_BIAS 0 -#define TCG_TARGET_STACK_ALIGN 8 -#define TCG_TARGET_CALL_STACK_OFFSET (64 + 4 + 6*4) -#endif - -#ifdef __arch64__#define TCG_TARGET_EXTEND_ARGS 1 -#endif #if defined(__VIS__) && __VIS__ >=0x300 #define use_vis3_instructions 1
tcg/tcg.c +2 -73
99 lines not on this page · raw message
tcg/sparc/tcg-target.c.inc +31 -135
324 lines not on this page · raw message
Signature · 1 line
2.34.1
This pull request causes the following CI failure:
cc -m64 -mcx16 -Ilibqemu-i386-softmmu.fa.p -I. -I.. -Itarget/i386 -I../target/i386 -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/capstone -I/usr/include/spice-server -I/usr/include/spice-1 -I/usr/include/cacard -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/nss3 -I/usr/include/nspr4 -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem /builds/qemu-project/qemu/linux-headers -isystem linux-headers -iquote . -iquote /builds/qemu-project/qemu -iquote /builds/qemu-project/qemu/include -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="i386-softmmu-config-target.h"' '-DCONFIG_DEVICES="i386-softmmu-config-devices.h"' -MD -MQ libqemu-i386-softmmu.fa.p/target_i386_helper.c.o -MF libqemu-i386-softmmu.fa.p/target_i386_helper.c.o.d -o libqemu-i386-softmmu.fa.p/target_i386_helper.c.o -c ../target/i386/helper.c../target/i386/helper.c: In function ‘get_memio_eip’:../target/i386/helper.c:514:19: error: ‘TARGET_INSN_START_WORDS’ undeclared (first use in this function); did you mean ‘TARGET_INSN_START_EXTRA_WORDS’?uint64_t data[TARGET_INSN_START_WORDS]; ^~~~~~~~~~~~~~~~~~~~~~~TARGET_INSN_START_EXTRA_WORDS ../target/i386/helper.c:514:19: note: each undeclared identifier is reported only once for each function it appears in ../target/i386/helper.c:514:14: error: unused variable ‘data’ [-Werror=unused-variable]uint64_t data[TARGET_INSN_START_WORDS];
^~~~
https://gitlab.com/qemu-project/qemu/-/jobs/3252134230
Stefan