All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, foss@percivaleng.com,
	Michael Rolnik <mrolnik@gmail.com>,
	Laurent Vivier <laurent@vivier.eu>,
	Stafford Horne <shorne@gmail.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: Re: [PATCH 03/12] target: Use cpu_pointer_wrap_uint32 for 32-bit targets
Date: Mon, 5 May 2025 13:34:57 +0200	[thread overview]
Message-ID: <aBiiYUzBe33JIa6d@zapote> (raw)
In-Reply-To: <20250504205714.3432096-4-richard.henderson@linaro.org>

On Sun, May 04, 2025 at 01:57:04PM -0700, Richard Henderson wrote:
> M68K, MicroBlaze, OpenRISC, RX, TriCore and Xtensa are
> all 32-bit targets.  AVR is more complicated, but using
> a 32-bit wrap preserves current behaviour.
> 
> Cc: Michael Rolnik <mrolnik@gmail.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>



> ---
>  include/accel/tcg/cpu-ops.h | 1 +
>  accel/tcg/cputlb.c          | 6 ++++++
>  target/avr/cpu.c            | 6 ++++++
>  target/m68k/cpu.c           | 1 +
>  target/microblaze/cpu.c     | 1 +
>  target/openrisc/cpu.c       | 1 +
>  target/rx/cpu.c             | 1 +
>  target/tricore/cpu.c        | 1 +
>  target/xtensa/cpu.c         | 1 +
>  9 files changed, 19 insertions(+)
> 
> diff --git a/include/accel/tcg/cpu-ops.h b/include/accel/tcg/cpu-ops.h
> index 4f3b4fd3bc..dd8ea30016 100644
> --- a/include/accel/tcg/cpu-ops.h
> +++ b/include/accel/tcg/cpu-ops.h
> @@ -326,6 +326,7 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len);
>   * Common pointer_wrap implementations.
>   */
>  vaddr cpu_pointer_wrap_notreached(CPUState *, int, vaddr, vaddr);
> +vaddr cpu_pointer_wrap_uint32(CPUState *, int, vaddr, vaddr);
>  
>  #endif
>  
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index 75cd875948..022d555f48 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -2945,3 +2945,9 @@ vaddr cpu_pointer_wrap_notreached(CPUState *cs, int idx, vaddr res, vaddr base)
>  {
>      g_assert_not_reached();
>  }
> +
> +/* To be used for strict 32-bit targets. */
> +vaddr cpu_pointer_wrap_uint32(CPUState *cs, int idx, vaddr res, vaddr base)
> +{
> +    return (uint32_t)res;
> +}
> diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> index 250241541b..6995de6a12 100644
> --- a/target/avr/cpu.c
> +++ b/target/avr/cpu.c
> @@ -250,6 +250,12 @@ static const TCGCPUOps avr_tcg_ops = {
>      .cpu_exec_reset = cpu_reset,
>      .tlb_fill = avr_cpu_tlb_fill,
>      .do_interrupt = avr_cpu_do_interrupt,
> +    /*
> +     * TODO: code and data wrapping are different, but for the most part
> +     * AVR only references bytes or aligned code fetches.  But we use
> +     * non-aligned MO_16 accesses for stack push/pop.
> +     */
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>  };
>  
>  static void avr_cpu_class_init(ObjectClass *oc, const void *data)
> diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
> index c5196a612e..6a09db3a6f 100644
> --- a/target/m68k/cpu.c
> +++ b/target/m68k/cpu.c
> @@ -619,6 +619,7 @@ static const TCGCPUOps m68k_tcg_ops = {
>  
>  #ifndef CONFIG_USER_ONLY
>      .tlb_fill = m68k_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>      .cpu_exec_interrupt = m68k_cpu_exec_interrupt,
>      .cpu_exec_halt = m68k_cpu_has_work,
>      .cpu_exec_reset = cpu_reset,
> diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> index d069e40e70..5eff1610c2 100644
> --- a/target/microblaze/cpu.c
> +++ b/target/microblaze/cpu.c
> @@ -449,6 +449,7 @@ static const TCGCPUOps mb_tcg_ops = {
>  
>  #ifndef CONFIG_USER_ONLY
>      .tlb_fill = mb_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>      .cpu_exec_interrupt = mb_cpu_exec_interrupt,
>      .cpu_exec_halt = mb_cpu_has_work,
>      .cpu_exec_reset = cpu_reset,
> diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
> index 054ad33360..dfbb2df643 100644
> --- a/target/openrisc/cpu.c
> +++ b/target/openrisc/cpu.c
> @@ -265,6 +265,7 @@ static const TCGCPUOps openrisc_tcg_ops = {
>  
>  #ifndef CONFIG_USER_ONLY
>      .tlb_fill = openrisc_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>      .cpu_exec_interrupt = openrisc_cpu_exec_interrupt,
>      .cpu_exec_halt = openrisc_cpu_has_work,
>      .cpu_exec_reset = cpu_reset,
> diff --git a/target/rx/cpu.c b/target/rx/cpu.c
> index 36eba75545..c6dd5d6f83 100644
> --- a/target/rx/cpu.c
> +++ b/target/rx/cpu.c
> @@ -225,6 +225,7 @@ static const TCGCPUOps rx_tcg_ops = {
>      .restore_state_to_opc = rx_restore_state_to_opc,
>      .mmu_index = rx_cpu_mmu_index,
>      .tlb_fill = rx_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>  
>      .cpu_exec_interrupt = rx_cpu_exec_interrupt,
>      .cpu_exec_halt = rx_cpu_has_work,
> diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
> index e56f90fde9..4f035b6f76 100644
> --- a/target/tricore/cpu.c
> +++ b/target/tricore/cpu.c
> @@ -190,6 +190,7 @@ static const TCGCPUOps tricore_tcg_ops = {
>      .restore_state_to_opc = tricore_restore_state_to_opc,
>      .mmu_index = tricore_cpu_mmu_index,
>      .tlb_fill = tricore_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>      .cpu_exec_interrupt = tricore_cpu_exec_interrupt,
>      .cpu_exec_halt = tricore_cpu_has_work,
>      .cpu_exec_reset = cpu_reset,
> diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
> index 91b71b6caa..ea9b6df3aa 100644
> --- a/target/xtensa/cpu.c
> +++ b/target/xtensa/cpu.c
> @@ -318,6 +318,7 @@ static const TCGCPUOps xtensa_tcg_ops = {
>  
>  #ifndef CONFIG_USER_ONLY
>      .tlb_fill = xtensa_cpu_tlb_fill,
> +    .pointer_wrap = cpu_pointer_wrap_uint32,
>      .cpu_exec_interrupt = xtensa_cpu_exec_interrupt,
>      .cpu_exec_halt = xtensa_cpu_has_work,
>      .cpu_exec_reset = cpu_reset,
> -- 
> 2.43.0
> 


  parent reply	other threads:[~2025-05-05 12:44 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-04 20:57 [PATCH 00/12] accel/tcg: Fix cross-page pointer wrapping issue Richard Henderson
2025-05-04 20:57 ` [PATCH 01/12] accel/tcg: Add TCGCPUOps.pointer_wrap Richard Henderson
2025-05-05  9:26   ` Philippe Mathieu-Daudé
2025-05-04 20:57 ` [PATCH 02/12] target: Use cpu_pointer_wrap_notreached for strict align targets Richard Henderson
2025-05-05  9:26   ` Philippe Mathieu-Daudé
2025-05-04 20:57 ` [PATCH 03/12] target: Use cpu_pointer_wrap_uint32 for 32-bit targets Richard Henderson
2025-05-05  9:26   ` Philippe Mathieu-Daudé
2025-05-05 11:34   ` Edgar E. Iglesias [this message]
2025-05-08  6:40   ` Bastian Koppelmann
2025-05-04 20:57 ` [PATCH 04/12] target/arm: Fill in TCGCPUOps.pointer_wrap Richard Henderson
2025-05-05 14:29   ` Philippe Mathieu-Daudé
2025-05-26 18:21   ` Philippe Mathieu-Daudé
2025-05-27  7:33     ` Richard Henderson
2025-05-04 20:57 ` [PATCH 05/12] target/i386: " Richard Henderson
2025-05-05 16:52   ` Philippe Mathieu-Daudé
2025-05-04 20:57 ` [PATCH 06/12] target/loongarch: " Richard Henderson
2025-05-26 18:17   ` Philippe Mathieu-Daudé
2025-05-27  0:57   ` Bibo Mao
2025-05-27  4:04   ` gaosong
2025-05-04 20:57 ` [PATCH 07/12] target/mips: " Richard Henderson
2025-05-05 14:30   ` Philippe Mathieu-Daudé
2025-05-05 14:59   ` Philippe Mathieu-Daudé
2025-05-04 20:57 ` [PATCH 08/12] target/ppc: " Richard Henderson
2025-05-05 14:32   ` Philippe Mathieu-Daudé
2025-05-05 16:50   ` Philippe Mathieu-Daudé
2025-05-05 19:00     ` Richard Henderson
2025-05-04 20:57 ` [PATCH 09/12] target/riscv: " Richard Henderson
2025-05-05 16:47   ` Philippe Mathieu-Daudé
2025-05-05 18:59     ` Richard Henderson
2025-05-26 18:15       ` Philippe Mathieu-Daudé
2025-05-19  0:17   ` Alistair Francis
2025-05-04 20:57 ` [PATCH 10/12] target/s390x: " Richard Henderson
2025-05-05 14:41   ` Philippe Mathieu-Daudé
2025-05-05 16:16     ` Richard Henderson
2025-05-26 18:16       ` Philippe Mathieu-Daudé
2025-05-04 20:57 ` [PATCH 11/12] target/sparc: " Richard Henderson
2025-05-05 14:54   ` Philippe Mathieu-Daudé
2025-05-05 16:16     ` Richard Henderson
2025-05-04 20:57 ` [PATCH 12/12] accel/tcg: Assert TCGCPUOps.pointer_wrap is set Richard Henderson
2025-05-05  9:27   ` Philippe Mathieu-Daudé
2025-05-07 16:38 ` [PATCH 00/12] accel/tcg: Fix cross-page pointer wrapping issue FOSS
2025-05-07 17:32   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aBiiYUzBe33JIa6d@zapote \
    --to=edgar.iglesias@gmail.com \
    --cc=foss@percivaleng.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=laurent@vivier.eu \
    --cc=mrolnik@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shorne@gmail.com \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.