diff mbox series

[2/4] target/hppa: defer hppa_ptlbe until CPU starts running

Message ID 20250225184628.3590671-3-alex.bennee@linaro.org (mailing list archive)
State New
Headers show
Series cputlb: add tlb_flush_other_cpu | expand

Commit Message

Alex Bennée Feb. 25, 2025, 6:46 p.m. UTC
Since 30933c4fb4 (tcg/cputlb: remove other-cpu capability from TLB flushing)
we don't expect non-CPU callers to the tlb_flush() code. Normally I
would drop the call anyway as the common cpu_reset() code will call
tlb_flush anyway. However as the flush function does more than that,
and is called from helpers instead defer it with an async_run_on_cpu.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 target/hppa/cpu.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Richard Henderson Feb. 25, 2025, 7:33 p.m. UTC | #1
On 2/25/25 10:46, Alex Bennée wrote:
> @@ -191,7 +199,7 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
>   
>           cpu->alarm_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>                                           hppa_cpu_alarm_timer, cpu);
> -        hppa_ptlbe(&cpu->env);
> +        async_run_on_cpu(cs, hppa_clear_ptlbe, RUN_ON_CPU_HOST_PTR(&cpu->env));

Nack, this is emulation of hardware, not softmmu.


r~
Richard Henderson Feb. 25, 2025, 7:38 p.m. UTC | #2
On 2/25/25 11:33, Richard Henderson wrote:
> On 2/25/25 10:46, Alex Bennée wrote:
>> @@ -191,7 +199,7 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
>>           cpu->alarm_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>>                                           hppa_cpu_alarm_timer, cpu);
>> -        hppa_ptlbe(&cpu->env);
>> +        async_run_on_cpu(cs, hppa_clear_ptlbe, RUN_ON_CPU_HOST_PTR(&cpu->env));
> 
> Nack, this is emulation of hardware, not softmmu.

Hmm.  I see what you're thinking about though: this function, after resetting the data 
structures associated with the hardware emulation, also calls the softmmu flush.

If we absolutely need to do so, I suppose delaying the hardware emulation flush to the 
work queue isn't the worst solution.  This is where the hppa patch is more correct than 
the ppc patch which completely eliminated the hardware emulation flush.


r~
diff mbox series

Patch

diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 5655677431..b631af381c 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -168,6 +168,14 @@  void hppa_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
     cpu_loop_exit(cs);
 }
+
+static void hppa_clear_ptlbe(CPUState *cpu, run_on_cpu_data opaque)
+{
+    CPUHPPAState *env = (CPUHPPAState *) opaque.host_ptr;
+    hppa_ptlbe(env);
+}
+
+
 #endif /* CONFIG_USER_ONLY */
 
 static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
@@ -191,7 +199,7 @@  static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
 
         cpu->alarm_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
                                         hppa_cpu_alarm_timer, cpu);
-        hppa_ptlbe(&cpu->env);
+        async_run_on_cpu(cs, hppa_clear_ptlbe, RUN_ON_CPU_HOST_PTR(&cpu->env));
     }
 #endif