[v2,20/24] gdb: add missing raw register read in aarch64_sme_pseudo_register_write

Message ID 20231124212656.96801-21-simon.marchi@efficios.com
State New
Headers
Series Fix reading and writing pseudo registers in non-current frames |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Simon Marchi Nov. 24, 2023, 9:26 p.m. UTC
  It seems like the intention here is to read the contents of the ZA
register and only write part of it.  However, there's no actual read of
the ZA register, so it looks like we'll write uninitialized bytes to the
target, for the portion of the raw register where we don't write the
pseudo register.  Add a call to raw_read to fix this.

I don't know how to test this though.

Change-Id: I7548240bd4324f6a3b729a1ebf7502fae5a46e9e
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
---
 gdb/aarch64-tdep.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Luis Machado Nov. 27, 2023, 11:43 a.m. UTC | #1
On 11/24/23 21:26, Simon Marchi wrote:
> It seems like the intention here is to read the contents of the ZA
> register and only write part of it.  However, there's no actual read of
> the ZA register, so it looks like we'll write uninitialized bytes to the
> target, for the portion of the raw register where we don't write the
> pseudo register.  Add a call to raw_read to fix this.
> 
> I don't know how to test this though.
> 
> Change-Id: I7548240bd4324f6a3b729a1ebf7502fae5a46e9e
> Reviewed-By: John Baldwin <jhb@FreeBSD.org>
> ---
>  gdb/aarch64-tdep.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
> index e9f5bdd141c8..e31e4bea41fc 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -3337,6 +3337,7 @@ aarch64_sme_pseudo_register_write (struct gdbarch *gdbarch,
>    /* Fetch the contents of ZA.  */
>    size_t svl = sve_vl_from_vq (tdep->sme_svq);
>    gdb::byte_vector za (std::pow (svl, 2));
> +  regcache->raw_read (tdep->sme_za_regnum, za);
>  
>    /* Copy the requested data.  */
>    for (int chunks = 0; chunks < offsets.chunks; chunks++)

Thanks. LGTM.

Approved-by: Luis Machado <luis.machado@arm.com>
  
Simon Marchi Nov. 27, 2023, 3:57 p.m. UTC | #2
On 11/27/23 06:43, Luis Machado wrote:
> On 11/24/23 21:26, Simon Marchi wrote:
>> It seems like the intention here is to read the contents of the ZA
>> register and only write part of it.  However, there's no actual read of
>> the ZA register, so it looks like we'll write uninitialized bytes to the
>> target, for the portion of the raw register where we don't write the
>> pseudo register.  Add a call to raw_read to fix this.
>>
>> I don't know how to test this though.
>>
>> Change-Id: I7548240bd4324f6a3b729a1ebf7502fae5a46e9e
>> Reviewed-By: John Baldwin <jhb@FreeBSD.org>
>> ---
>>  gdb/aarch64-tdep.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
>> index e9f5bdd141c8..e31e4bea41fc 100644
>> --- a/gdb/aarch64-tdep.c
>> +++ b/gdb/aarch64-tdep.c
>> @@ -3337,6 +3337,7 @@ aarch64_sme_pseudo_register_write (struct gdbarch *gdbarch,
>>    /* Fetch the contents of ZA.  */
>>    size_t svl = sve_vl_from_vq (tdep->sme_svq);
>>    gdb::byte_vector za (std::pow (svl, 2));
>> +  regcache->raw_read (tdep->sme_za_regnum, za);
>>  
>>    /* Copy the requested data.  */
>>    for (int chunks = 0; chunks < offsets.chunks; chunks++)
> 
> Thanks. LGTM.
> 
> Approved-by: Luis Machado <luis.machado@arm.com>

Thanks, added the trailer.

Simon
  

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index e9f5bdd141c8..e31e4bea41fc 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -3337,6 +3337,7 @@  aarch64_sme_pseudo_register_write (struct gdbarch *gdbarch,
   /* Fetch the contents of ZA.  */
   size_t svl = sve_vl_from_vq (tdep->sme_svq);
   gdb::byte_vector za (std::pow (svl, 2));
+  regcache->raw_read (tdep->sme_za_regnum, za);
 
   /* Copy the requested data.  */
   for (int chunks = 0; chunks < offsets.chunks; chunks++)