a few Arm HVF and TCG bug fixes
The following changes since commit 2257f52a97f28ce3be4366817ea8817ad866562b:
Merge tag 'pull-10.2-final-fixes-051225-2' of https://gitlab.com/stsquad/qemu into staging (2025-12-05 12:38:37 -0600)
are available in the Git repository at:
https://gitlab.com/stsquad/qemu.git tags/pull-10.2-more-final-fixes-091225-1
for you to fetch changes up to dd77ef99aa0280c467fe8442b4238122899ae6cf:
target/arm: handle unaligned PC during tlb probe (2025-12-09 16:21:56 +0000)
----------------------------------------------------------------
a few Arm HVF and TCG bug fixes:
- don't re-use TCG only PSCI code in HVF
- fix deadlock in HVF when shutting down (#3228)
- fix corruption of register state from PSCI (#3228)
- properly prioritise PC alignment faults (#3233)
----------------------------------------------------------------
Alex Bennée (4):
Revert "target/arm: Re-use arm_is_psci_call() in HVF" target/arm: ensure PSCI register updates are flushed target/arm: make HV_EXIT_REASON_CANCELED leave hvf_arch_vcpu_exec target/arm: handle unaligned PC during tlb probe
target/arm/hvf/hvf.c | 11 ++++++++--- target/arm/tcg/tlb_helper.c | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.47.3
[PULL 2/4] target/arm: ensure PSCI register updates are flushed
When we handle a host call we report state back to the caller via registers. Set vcpu_dirty to indicate QEMU is currently the reference and hoist the flush_cpu_state() and make the call unconditional.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3228
Message-ID: <[email protected]>
target/arm/hvf/hvf.c +5 -1
@@ -1942,6 +1942,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)/* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */ env->xregs[0 ] =-1 ; } + cpu->vcpu_dirty = true; }else {trace_hvf_unknown_hvc (env->pc, env->xregs[0 ]);hvf_raise_exception (cpu,EXCP_UDEF ,syn_uncategorized (),1 );
@@ -1958,6 +1959,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)/* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */ env->xregs[0 ] =-1 ; } + cpu->vcpu_dirty = true; }else {trace_hvf_unknown_smc (env->xregs[0 ]);hvf_raise_exception (cpu,EXCP_UDEF ,syn_uncategorized (),1 );
@@ -1980,10 +1982,12 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)error_report ("0x%llx: unhandled exception ec=0x%x" , env->pc, ec); } +/* flush any changed cpu state back to HVF */ +flush_cpu_state (cpu); +if (advance_pc) {uint64_t pc; -flush_cpu_state (cpu); r =hv_vcpu_get_reg (cpu->accel->fd,HV_REG_PC , &pc);assert_hvf_ok (r);
Signature · 1 line
2.47.3
[PULL 4/4] target/arm: handle unaligned PC during tlb probe
In reply to Alex BennéePC alignment faults have priority over instruction aborts and we have code to deal with this in the translation front-ends. However during tb_lookup we can see a potentially faulting probe which doesn't get a MemOp set. If the page isn't available this results in EC_INSNABORT (0x20) instead of EC_PCALIGNMENT (0x22).
As there is no easy way to set the appropriate MemOp in the instruction fetch probe path lets just detect it in arm_cpu_tlb_fill_align() ahead of the main alignment check. We also teach arm_deliver_fault to deliver the right syndrome for MMU_INST_FETCH alignment issues.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3233
Message-ID: <[email protected]>
target/arm/tcg/tlb_helper.c +16 -5
@@ -250,7 +250,11 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, fsr =compute_fsr_fsc (env, fi, target_el, mmu_idx, &fsc);if (access_type ==MMU_INST_FETCH ) { - syn =syn_insn_abort (same_el, fi->ea, fi->s1ptw, fsc); +if (fi->type == ARMFault_Alignment) { + syn =syn_pcalignment (); + }else { + syn =syn_insn_abort (same_el, fi->ea, fi->s1ptw, fsc); + } exc =EXCP_PREFETCH_ABORT ; }else {bool gcs =regime_is_gcs (core_to_arm_mmu_idx (env, mmu_idx));
@@ -346,11 +350,18 @@ bool arm_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr address, }/* -* Per R_XCHFJ, alignment fault not due to memory type has -* highest precedence. Otherwise, walk the page table and -* and collect the page description. +* PC alignment faults should be dealt with at translation time +* but we also need to catch them while being probed. +* +* Then per R_XCHFJ, alignment fault not due to memory type take +* precedence. Otherwise, walk the page table and and collect the +* page description. +* */ -if (address & ((1 <<memop_alignment_bits (memop)) -1 )) { +if (access_type ==MMU_INST_FETCH && !cpu->env.thumb && + (address &3 )) { + fi->type = ARMFault_Alignment; + }else if (address & ((1 <<memop_alignment_bits (memop)) -1 )) { fi->type = ARMFault_Alignment; } else if (!get_phys_addr(&cpu->env, address, access_type, memop, core_to_arm_mmu_idx(&cpu->env, mmu_idx),
Signature · 1 line
2.47.3
[PULL 1/4] Revert "target/arm: Re-use arm_is_psci_call() in HVF"
In reply to Alex BennéeThis breaks a pure HVF (--disable-tcg) build because the fallback stub will always report false.
This reverts commit 4695daacc068cd0aa9a91c0063c4f2a9ec9b7ba1.
Message-ID: <[email protected]>
target/arm/hvf/hvf.c +2 -2
@@ -1935,7 +1935,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)break ;case EC_AA64_HVC :cpu_synchronize_state (cpu); -if (arm_is_psci_call (arm_cpu,EXCP_HVC )) { +if (arm_cpu->psci_conduit ==QEMU_PSCI_CONDUIT_HVC ) {/* Do NOT advance $pc for HVC */ if (!hvf_handle_psci_call (cpu)) {trace_hvf_unknown_hvc (env->pc, env->xregs[0 ]);
@@ -1949,7 +1949,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)break ;case EC_AA64_SMC :cpu_synchronize_state (cpu); -if (arm_is_psci_call (arm_cpu,EXCP_SMC )) { +if (arm_cpu->psci_conduit ==QEMU_PSCI_CONDUIT_SMC ) {/* Secure Monitor Call exception, we need to advance $pc */ advance_pc = true;
Signature · 1 line
2.47.3
[PULL 3/4] target/arm: make HV_EXIT_REASON_CANCELED leave hvf_arch_vcpu_exec
In reply to Alex BennéeWithout this we can spin tightly in the main HVF dispatch loop and never release the lock long enough. As a result the HMP never gets to run and shutting down the system deadlocks.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3228
Message-ID: <[email protected]>
target/arm/hvf/hvf.c +1 -0
@@ -2020,6 +2020,7 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit)break ;case HV_EXIT_REASON_CANCELED :/* we got kicked, no exit to process */ + ret =-1 ;break ;default :g_assert_not_reached ();
Signature · 1 line
2.47.3
Richard Henderson
AppliedQuoted 27 lines · Alex Bennée
The following changes since commit
2257f52a97f28ce3be4366817ea8817ad866562b:Merge tag 'pull-10.2-final-fixes-051225-2' of https://gitlab.com/stsquad/qemu into staging (2025-12-05 12:38:37 -0600)are available in the Git repository at:
https://gitlab.com/stsquad/qemu.git tags/pull-10.2-more-final-fixes-091225-1for you to fetch changes up to
dd77ef99aa0280c467fe8442b4238122899ae6cf:target/arm: handle unaligned PC during tlb probe (2025-12-09 16:21:56 +0000)
----------------------------------------------------------------
a few Arm HVF and TCG bug fixes:- don't re-use TCG only PSCI code in HVF
- fix deadlock in HVF when shutting down (#3228)
- fix corruption of register state from PSCI (#3228)
- properly prioritise PC alignment faults (#3233)----------------------------------------------------------------
Alex Bennée (4):
Revert "target/arm: Re-usearm_is_psci_call()in HVF" target/arm: ensure PSCI register updates are flushed target/arm: makeHV_EXIT_REASON_CANCELEDleavehvf_arch_vcpu_exectarget/arm: handle unaligned PC during tlb probe
Quoted 4 lines
target/arm/hvf/hvf.c | 11 ++++++++--- target/arm/tcg/tlb_helper.c | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-)
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.
r~