Final (for real this time) patches for arm - pre-PR
cover Final (for real this time) patches for arm - pre-PR
These are all bug fixes for Arm including a recent regression to the Arm HVF code. Last chance to object as I will roll the PR later today once Richard is online.
Alex.
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
PATCH 1/4 Revert "target/arm: Re-use arm_is_psci_call() in HVF"
This breaks a pure HVF (--disable-tcg) build because the fallback stub will always report false.
This reverts commit 4695daacc068cd0aa9a91c0063c4f2a9ec9b7ba1.
--- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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
PATCH 2/4 target/arm: ensure PSCI register updates are flushed
In reply to Alex BennéeWhen 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
---
v2
- Fixes->Resolves
--- target/arm/hvf/hvf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
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
Re: [PATCH 2/4] target/arm: ensure PSCI register updates are flushed
Quoted 8 lines · Alex Bennée
When we handle a host call we report state back to the caller via registers. Set
vcpu_dirtyto indicate QEMU is currently the reference and hoist theflush_cpu_state()and make the call unconditional.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3228
Signed-off-by Alex Bennée <[email protected]>Tested-by Christian Stussak <[email protected]>
Quoted 6 lines
---
v2
-Fixes->Resolves--- target/arm/hvf/hvf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Again:
PATCH 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
---
v2
- expanded commit summary and contents
- added Resolves link
--- target/arm/hvf/hvf.c | 1 + 1 file changed, 1 insertion(+)
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
PATCH 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]>
---
v2
- Fixes -> Resolves
--- target/arm/tcg/tlb_helper.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
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