* [PULL 1/4] Revert "target/arm: Re-use arm_is_psci_call() in HVF"
2025-12-09 16:28 [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Alex Bennée
@ 2025-12-09 16:28 ` Alex Bennée
2025-12-09 16:28 ` [PULL 2/4] target/arm: ensure PSCI register updates are flushed Alex Bennée
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2025-12-09 16:28 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Philippe Mathieu-Daudé, Christian Stussak,
Alexander Graf, Mads Ynddal, Peter Maydell,
open list:ARM TCG CPUs
This breaks a pure HVF (--disable-tcg) build because the fallback stub
will always report false.
This reverts commit 4695daacc068cd0aa9a91c0063c4f2a9ec9b7ba1.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Christian Stussak <christian.stussak@imaginary.org>
Message-ID: <20251209092459.1058313-2-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index de1e8fb8a05..70d34063df8 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -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;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PULL 2/4] target/arm: ensure PSCI register updates are flushed
2025-12-09 16:28 [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Alex Bennée
2025-12-09 16:28 ` [PULL 1/4] Revert "target/arm: Re-use arm_is_psci_call() in HVF" Alex Bennée
@ 2025-12-09 16:28 ` Alex Bennée
2025-12-09 16:28 ` [PULL 3/4] target/arm: make HV_EXIT_REASON_CANCELED leave hvf_arch_vcpu_exec Alex Bennée
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2025-12-09 16:28 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Christian Stussak, Philippe Mathieu-Daudé,
Alexander Graf, Mads Ynddal, Peter Maydell,
open list:ARM TCG CPUs
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
Tested-by: Christian Stussak <christian.stussak@imaginary.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251209092459.1058313-3-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 70d34063df8..8e2940217a6 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -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);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PULL 3/4] target/arm: make HV_EXIT_REASON_CANCELED leave hvf_arch_vcpu_exec
2025-12-09 16:28 [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Alex Bennée
2025-12-09 16:28 ` [PULL 1/4] Revert "target/arm: Re-use arm_is_psci_call() in HVF" Alex Bennée
2025-12-09 16:28 ` [PULL 2/4] target/arm: ensure PSCI register updates are flushed Alex Bennée
@ 2025-12-09 16:28 ` Alex Bennée
2025-12-09 16:28 ` [PULL 4/4] target/arm: handle unaligned PC during tlb probe Alex Bennée
2025-12-09 19:31 ` [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Richard Henderson
4 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2025-12-09 16:28 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Philippe Mathieu-Daudé, Alexander Graf,
Mads Ynddal, Peter Maydell, open list:ARM TCG CPUs
Without 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
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251209092459.1058313-4-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 8e2940217a6..8288b605299 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -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();
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PULL 4/4] target/arm: handle unaligned PC during tlb probe
2025-12-09 16:28 [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Alex Bennée
` (2 preceding siblings ...)
2025-12-09 16:28 ` [PULL 3/4] target/arm: make HV_EXIT_REASON_CANCELED leave hvf_arch_vcpu_exec Alex Bennée
@ 2025-12-09 16:28 ` Alex Bennée
2025-12-09 19:31 ` [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Richard Henderson
4 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2025-12-09 16:28 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Jessica Clarke, Richard Henderson,
Peter Maydell, open list:ARM TCG CPUs
PC 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
Tested-by: Jessica Clarke <jrtc27@jrtc27.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251209092459.1058313-5-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
index f1983a5732e..5c689d3b69f 100644
--- a/target/arm/tcg/tlb_helper.c
+++ b/target/arm/tcg/tlb_helper.c
@@ -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),
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes
2025-12-09 16:28 [PULL for 10.2 0/4] a few Arm HVF and TCG bug fixes Alex Bennée
` (3 preceding siblings ...)
2025-12-09 16:28 ` [PULL 4/4] target/arm: handle unaligned PC during tlb probe Alex Bennée
@ 2025-12-09 19:31 ` Richard Henderson
4 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2025-12-09 19:31 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
On 12/9/25 10:28, Alex Bennée wrote:
> 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(-)
>
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/10.2 as appropriate.
r~
^ permalink raw reply [flat|nested] 6+ messages in thread