[PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()

Jim Shu posted 3 patches 1 week, 5 days ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Peter Xu <peterx@redhat.com>
[PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Jim Shu 1 week, 5 days ago
To let io_prepare() function use the multiple members in
CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
member as the argument.

It is the preliminary patch of next commit.

Signed-off-by: Jim Shu <jim.shu@sifive.com>
---
 accel/tcg/cputlb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 6900a126827..82c9b6389dc 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1270,14 +1270,14 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
 }
 
 static MemoryRegionSection *
-io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
+io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
            MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
 {
     MemoryRegionSection *section;
     hwaddr mr_offset;
 
-    section = iotlb_to_section(cpu, xlat, attrs);
-    mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
+    section = iotlb_to_section(cpu, full->xlat_section, attrs);
+    mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr;
     cpu->mem_io_pc = retaddr;
     if (!cpu->neg.can_do_io) {
         cpu_io_recompile(cpu, retaddr);
@@ -1981,7 +1981,7 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
     tcg_debug_assert(size > 0 && size <= 8);
 
     attrs = full->attrs;
-    section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
+    section = io_prepare(&mr_offset, cpu, full, attrs, addr, ra);
     mr = section->mr;
 
     BQL_LOCK_GUARD();
@@ -2002,7 +2002,7 @@ static Int128 do_ld16_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full,
     tcg_debug_assert(size > 8 && size <= 16);
 
     attrs = full->attrs;
-    section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
+    section = io_prepare(&mr_offset, cpu, full, attrs, addr, ra);
     mr = section->mr;
 
     BQL_LOCK_GUARD();
@@ -2499,7 +2499,7 @@ static uint64_t do_st_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full,
     tcg_debug_assert(size > 0 && size <= 8);
 
     attrs = full->attrs;
-    section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
+    section = io_prepare(&mr_offset, cpu, full, attrs, addr, ra);
     mr = section->mr;
 
     BQL_LOCK_GUARD();
@@ -2519,7 +2519,7 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full,
     tcg_debug_assert(size > 8 && size <= 16);
 
     attrs = full->attrs;
-    section = io_prepare(&mr_offset, cpu, full->xlat_section, attrs, addr, ra);
+    section = io_prepare(&mr_offset, cpu, full, attrs, addr, ra);
     mr = section->mr;
 
     BQL_LOCK_GUARD();
-- 
2.43.0
Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Richard Henderson 1 week ago
On 1/29/26 01:23, Jim Shu wrote:
> To let io_prepare() function use the multiple members in
> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
> member as the argument.
> 
> It is the preliminary patch of next commit.
> 
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> ---
>   accel/tcg/cputlb.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index 6900a126827..82c9b6389dc 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -1270,14 +1270,14 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
>   }
>   
>   static MemoryRegionSection *
> -io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
> +io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
>              MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
>   {
>       MemoryRegionSection *section;
>       hwaddr mr_offset;
>   
> -    section = iotlb_to_section(cpu, xlat, attrs);
> -    mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
> +    section = iotlb_to_section(cpu, full->xlat_section, attrs);
> +    mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr;

attrs is also present in CPUTLBEntryFull; you can also drop that parameter.


r~
Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Philippe Mathieu-Daudé 6 days, 15 hours ago
On 3/2/26 02:15, Richard Henderson wrote:
> On 1/29/26 01:23, Jim Shu wrote:
>> To let io_prepare() function use the multiple members in
>> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
>> member as the argument.
>>
>> It is the preliminary patch of next commit.
>>
>> Signed-off-by: Jim Shu <jim.shu@sifive.com>
>> ---
>>   accel/tcg/cputlb.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)


>>   static MemoryRegionSection *
>> -io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
>> +io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
>>              MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
>>   {
>>       MemoryRegionSection *section;
>>       hwaddr mr_offset;
>> -    section = iotlb_to_section(cpu, xlat, attrs);
>> -    mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
>> +    section = iotlb_to_section(cpu, full->xlat_section, attrs);
>> +    mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr;
> 
> attrs is also present in CPUTLBEntryFull; you can also drop that parameter.

Jim, now that this patch got merged (commit 94c6e9cf044), do you mind
sending a cleanup patch?

Thanks,

Phil.

Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Jim Shu 6 days, 12 hours ago
Sorry for the late reply.
Yes, I can send a cleanup patch soon to fix the issue Richard mentioned, thanks!

Thanks,
Jim


On Tue, Feb 3, 2026 at 6:47 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 3/2/26 02:15, Richard Henderson wrote:
> > On 1/29/26 01:23, Jim Shu wrote:
> >> To let io_prepare() function use the multiple members in
> >> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
> >> member as the argument.
> >>
> >> It is the preliminary patch of next commit.
> >>
> >> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> >> ---
> >>   accel/tcg/cputlb.c | 14 +++++++-------
> >>   1 file changed, 7 insertions(+), 7 deletions(-)
>
>
> >>   static MemoryRegionSection *
> >> -io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
> >> +io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
> >>              MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
> >>   {
> >>       MemoryRegionSection *section;
> >>       hwaddr mr_offset;
> >> -    section = iotlb_to_section(cpu, xlat, attrs);
> >> -    mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
> >> +    section = iotlb_to_section(cpu, full->xlat_section, attrs);
> >> +    mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr;
> >
> > attrs is also present in CPUTLBEntryFull; you can also drop that parameter.
>
> Jim, now that this patch got merged (commit 94c6e9cf044), do you mind
> sending a cleanup patch?
>
> Thanks,
>
> Phil.
Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Jim Shu 6 days, 11 hours ago
I have sent a cleanup patch:
https://mail.gnu.org/archive/html/qemu-devel/2026-02/msg00800.html
(20260203142737.2164763-1-jim.shu@sifive.com)

Thanks,
Jim


On Tue, Feb 3, 2026 at 9:44 PM Jim Shu <jim.shu@sifive.com> wrote:
>
> Sorry for the late reply.
> Yes, I can send a cleanup patch soon to fix the issue Richard mentioned, thanks!
>
> Thanks,
> Jim
>
>
> On Tue, Feb 3, 2026 at 6:47 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> >
> > On 3/2/26 02:15, Richard Henderson wrote:
> > > On 1/29/26 01:23, Jim Shu wrote:
> > >> To let io_prepare() function use the multiple members in
> > >> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
> > >> member as the argument.
> > >>
> > >> It is the preliminary patch of next commit.
> > >>
> > >> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> > >> ---
> > >>   accel/tcg/cputlb.c | 14 +++++++-------
> > >>   1 file changed, 7 insertions(+), 7 deletions(-)
> >
> >
> > >>   static MemoryRegionSection *
> > >> -io_prepare(hwaddr *out_offset, CPUState *cpu, hwaddr xlat,
> > >> +io_prepare(hwaddr *out_offset, CPUState *cpu, CPUTLBEntryFull *full,
> > >>              MemTxAttrs attrs, vaddr addr, uintptr_t retaddr)
> > >>   {
> > >>       MemoryRegionSection *section;
> > >>       hwaddr mr_offset;
> > >> -    section = iotlb_to_section(cpu, xlat, attrs);
> > >> -    mr_offset = (xlat & TARGET_PAGE_MASK) + addr;
> > >> +    section = iotlb_to_section(cpu, full->xlat_section, attrs);
> > >> +    mr_offset = (full->xlat_section & TARGET_PAGE_MASK) + addr;
> > >
> > > attrs is also present in CPUTLBEntryFull; you can also drop that parameter.
> >
> > Jim, now that this patch got merged (commit 94c6e9cf044), do you mind
> > sending a cleanup patch?
> >
> > Thanks,
> >
> > Phil.
Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Pierrick Bouvier 1 week, 5 days ago
On 1/28/26 7:23 AM, Jim Shu wrote:
> To let io_prepare() function use the multiple members in
> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
> member as the argument.
> 
> It is the preliminary patch of next commit.
> 
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> ---
>   accel/tcg/cputlb.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Re: [PATCH v2 1/3] accel/tcg: Send the CPUTLBEntryFull struct into io_prepare()
Posted by Philippe Mathieu-Daudé 1 week, 5 days ago
On 28/1/26 16:23, Jim Shu wrote:
> To let io_prepare() function use the multiple members in
> CPUTLBEntryFull struct, send the full struct instead of 'xlat_section'
> member as the argument.
> 
> It is the preliminary patch of next commit.
> 
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> ---
>   accel/tcg/cputlb.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Mark Burton <mburton@qti.qualcomm.com>