Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gustavo Romero <gustavo.romero@linaro.org>
To: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Cc: gdb-patches@sourceware.org, luis.machado@arm.com
Subject: Re: [PATCH v2 2/4] gdb: aarch64: Move MTE address check out of set_memtag
Date: Thu, 4 Apr 2024 02:25:02 -0300	[thread overview]
Message-ID: <322b8080-d9f4-7741-4358-ca6f0de4b7f5@linaro.org> (raw)
In-Reply-To: <87msqg8s1b.fsf@linaro.org>


On 3/29/24 9:47 PM, Thiago Jung Bauermann wrote:
> Gustavo Romero <gustavo.romero@linaro.org> writes:
> 
>> Move MTE address check out of set_memtag and add this check to the
>> upper layer, before set_memtag is called. This is a preparation for
>> using a target hook instead of a gdbarch hook MTE address checks.
> 
> gdbarch_set_memtags is also called from
> memory_tag_with_logical_tag_command. Shouldn't the same check be added
> there?

In aarch64_linux_set_memtags, the memory check is inside the else {}, which
is only executed when tag_type == memtag_type::allocation, but not in the if {},
which is executed when memtag_type::logical. Because
memory_tag_with_logical_tag_command always calls set_memtags with the argument
for tag_type param == memtag_type::logical there is no need to check the address.

In other words, memory_tag_with_logical_tag_command is about logical tags only,
so it's a local operation that does not touch any memory in the target, it just
changes a local pointer, so it's ok to change the pointer, being it tagged or not,
hence not memory checks are needed.

These comments try to clarify a bit it:

In memory_tag_with_logical_tag_command:

   /* Setting the logical tag is just a local operation that does not touch
      any memory from the target.  Given an input value, we modify the value
      to include the appropriate tag.  <--


In memory_tag_print_tag_command:

   /* If the address is not in a region memory mapped with a memory tagging
      flag, it is no use trying to access/manipulate its allocation tag.

      It is OK to manipulate the logical tag though.  */ <--


>>
>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>> ---
>>   gdb/aarch64-linux-tdep.c | 4 ----
>>   gdb/printcmd.c           | 6 ++++++
>>   2 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>> index 50055ac3f48..8e6e63d4dcb 100644
>> --- a/gdb/aarch64-linux-tdep.c
>> +++ b/gdb/aarch64-linux-tdep.c
>> @@ -2525,10 +2525,6 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address,
>>         /* Remove the top byte.  */
>>         addr = gdbarch_remove_non_address_bits (gdbarch, addr);
>>
>> -      /* Make sure we are dealing with a tagged address to begin with.  */
>> -      if (!aarch64_linux_tagged_address_p (gdbarch, address))
>> -	return false;
>> -
>>         /* With G being the number of tag granules and N the number of tags
>>   	 passed in, we can have the following cases:
>>
>> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
>> index cb0d32aa4bc..ae4d640ccf2 100644
>> --- a/gdb/printcmd.c
>> +++ b/gdb/printcmd.c
>> @@ -3127,6 +3127,12 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
>>     /* Parse the input.  */
>>     parse_set_allocation_tag_input (args, &val, &length, tags);
>>
>> +  /* If the address is not in a region memory mapped with a memory tagging
>> +     flag, it is no use trying to manipulate its allocation tag.  */
>> +  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) {
>> +    show_addr_not_tagged (value_as_address(val));
>> +  }
> 
> GNU style doesn't use curly braces in if blocks with only one statement.

Fixed in v3.


Cheers,
Gustavo

  reply	other threads:[~2024-04-04  5:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 22:48 [PATCH v2 0/4] Add another way to check for MTE-tagged addresses on remote targets Gustavo Romero
2024-03-28 22:48 ` [PATCH v2 1/4] gdb: aarch64: Remove MTE address checking from get_memtag Gustavo Romero
2024-03-30  0:37   ` Thiago Jung Bauermann
2024-03-30  0:55     ` Thiago Jung Bauermann
2024-04-04  5:15       ` Gustavo Romero
2024-03-28 22:48 ` [PATCH v2 2/4] gdb: aarch64: Move MTE address check out of set_memtag Gustavo Romero
2024-03-30  0:47   ` Thiago Jung Bauermann
2024-04-04  5:25     ` Gustavo Romero [this message]
2024-04-06  1:55       ` Thiago Jung Bauermann
2024-03-28 22:48 ` [PATCH v2 3/4] gdb: aarch64: Remove MTE address checking from memtag_matches_p Gustavo Romero
2024-03-30  2:53   ` Thiago Jung Bauermann
2024-03-28 22:48 ` [PATCH v2 4/4] gdb: Add new remote packet to check if address is tagged Gustavo Romero
2024-03-29 23:35   ` Thiago Jung Bauermann
2024-04-04  5:32     ` Gustavo Romero
2024-03-30  3:08   ` Thiago Jung Bauermann
2024-04-03 14:04     ` Luis Machado
2024-04-03 16:39       ` Gustavo Romero
2024-04-03 11:51 ` [PATCH v2 0/4] Add another way to check for MTE-tagged addresses on remote targets Luis Machado
2024-04-03 14:29   ` Gustavo Romero
2024-04-03 14:39     ` Luis Machado
2024-04-04  5:35       ` Gustavo Romero

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=322b8080-d9f4-7741-4358-ca6f0de4b7f5@linaro.org \
    --to=gustavo.romero@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@arm.com \
    --cc=thiago.bauermann@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox