[PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets

Richard Henderson posted 28 patches 5 months, 3 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Peter Maydell <peter.maydell@linaro.org>, Michael Rolnik <mrolnik@gmail.com>, Helge Deller <deller@gmx.de>, Eduardo Habkost <eduardo@habkost.net>, Song Gao <gaosong@loongson.cn>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Stafford Horne <shorne@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Max Filippov <jcmvbkbc@gmail.com>, WANG Xuerui <git@xen0n.name>, Huacai Chen <chenhuacai@kernel.org>
There is a newer version of this series
[PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets
Posted by Richard Henderson 5 months, 3 weeks ago
Alpha, HPPA, and SH4 always use aligned addresses,
and therefore never produce accesses that cross pages.

Cc: Helge Deller <deller@gmx.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/accel/tcg/cpu-ops.h |  5 +++++
 accel/tcg/cputlb.c          | 13 +++++++++++++
 target/alpha/cpu.c          |  1 +
 target/hppa/cpu.c           |  1 +
 target/sh4/cpu.c            |  1 +
 5 files changed, 21 insertions(+)

diff --git a/include/accel/tcg/cpu-ops.h b/include/accel/tcg/cpu-ops.h
index 83b2c2c864..4f3b4fd3bc 100644
--- a/include/accel/tcg/cpu-ops.h
+++ b/include/accel/tcg/cpu-ops.h
@@ -322,6 +322,11 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
  */
 int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len);
 
+/*
+ * Common pointer_wrap implementations.
+ */
+vaddr cpu_pointer_wrap_notreached(CPUState *, int, vaddr, vaddr);
+
 #endif
 
 #endif /* TCG_CPU_OPS_H */
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 81ff725cbc..49ec3ee5dc 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -2933,3 +2933,16 @@ uint64_t cpu_ldq_code_mmu(CPUArchState *env, vaddr addr,
 {
     return do_ld8_mmu(env_cpu(env), addr, oi, retaddr, MMU_INST_FETCH);
 }
+
+/*
+ * Common pointer_wrap implementations.
+ */
+
+/*
+ * To be used for strict alignment targets.
+ * Because no accesses are unaligned, no accesses wrap either.
+ */
+vaddr cpu_pointer_wrap_notreached(CPUState *cs, int idx, vaddr res, vaddr base)
+{
+    g_assert_not_reached();
+}
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index 890b84c032..2082db45ea 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -261,6 +261,7 @@ static const TCGCPUOps alpha_tcg_ops = {
     .record_sigbus = alpha_cpu_record_sigbus,
 #else
     .tlb_fill = alpha_cpu_tlb_fill,
+    .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = alpha_cpu_exec_interrupt,
     .cpu_exec_halt = alpha_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index 6465181543..24777727e6 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -269,6 +269,7 @@ static const TCGCPUOps hppa_tcg_ops = {
 
 #ifndef CONFIG_USER_ONLY
     .tlb_fill_align = hppa_cpu_tlb_fill_align,
+    .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = hppa_cpu_exec_interrupt,
     .cpu_exec_halt = hppa_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index b35f18e250..4f561e8c91 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -296,6 +296,7 @@ static const TCGCPUOps superh_tcg_ops = {
 
 #ifndef CONFIG_USER_ONLY
     .tlb_fill = superh_cpu_tlb_fill,
+    .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = superh_cpu_exec_interrupt,
     .cpu_exec_halt = superh_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
-- 
2.43.0


Re: [PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets
Posted by Michael Tokarev 2 months, 2 weeks ago
On 28.05.2025 11:14, Richard Henderson wrote:
> Alpha, HPPA, and SH4 always use aligned addresses,
> and therefore never produce accesses that cross pages.
> 
> Cc: Helge Deller <deller@gmx.de>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

This seems to broke booting debian on alpha, -- see
https://bugs.debian.org/1112285 .  I weren't able to repro it
though, - asked the OP to get a backtrace.

Thanks,

/mjt

Re: [PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets
Posted by Richard Henderson 2 months, 2 weeks ago
On 8/29/25 16:55, Michael Tokarev wrote:
> On 28.05.2025 11:14, Richard Henderson wrote:
>> Alpha, HPPA, and SH4 always use aligned addresses,
>> and therefore never produce accesses that cross pages.
>>
>> Cc: Helge Deller <deller@gmx.de>
>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> 
> This seems to broke booting debian on alpha, -- see
> https://bugs.debian.org/1112285 .  I weren't able to repro it
> though, - asked the OP to get a backtrace.

Ok.  I haven't reproduced this either.
Let me know if you get more information.


r~

Re: [PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets
Posted by Michael Tokarev 1 month, 1 week ago
On 8/30/25 06:11, Richard Henderson wrote:
> On 8/29/25 16:55, Michael Tokarev wrote:
>> On 28.05.2025 11:14, Richard Henderson wrote:
>>> Alpha, HPPA, and SH4 always use aligned addresses,
>>> and therefore never produce accesses that cross pages.
>>>
>>> Cc: Helge Deller <deller@gmx.de>
>>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>
>> This seems to broke booting debian on alpha, -- see
>> https://bugs.debian.org/1112285 .  I weren't able to repro it
>> though, - asked the OP to get a backtrace.
> 
> Ok.  I haven't reproduced this either.
> Let me know if you get more information.

There's some more info available at
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112285#56 -
some other debian user reproduced the issue, published instructions
about how to do that, and published a backtrace too.

Maybe this is sufficient for tracking it down?

thanks,

/mjt

Re: [PULL 18/28] target: Use cpu_pointer_wrap_notreached for strict align targets
Posted by Richard Henderson 1 month, 1 week ago
On 10/3/25 23:52, Michael Tokarev wrote:
> On 8/30/25 06:11, Richard Henderson wrote:
>> On 8/29/25 16:55, Michael Tokarev wrote:
>>> On 28.05.2025 11:14, Richard Henderson wrote:
>>>> Alpha, HPPA, and SH4 always use aligned addresses,
>>>> and therefore never produce accesses that cross pages.
>>>>
>>>> Cc: Helge Deller <deller@gmx.de>
>>>> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>>
>>> This seems to broke booting debian on alpha, -- see
>>> https://bugs.debian.org/1112285 .  I weren't able to repro it
>>> though, - asked the OP to get a backtrace.
>>
>> Ok.  I haven't reproduced this either.
>> Let me know if you get more information.
> 
> There's some more info available at
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112285#56 -
> some other debian user reproduced the issue, published instructions
> about how to do that, and published a backtrace too.
> 
> Maybe this is sufficient for tracking it down?

Thanks.  I've got it now.


r~