Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
To: David Spickett <david.spickett@linaro.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 07/24] Documentation for memory tagging remote packets
Date: Tue, 17 Nov 2020 11:44:16 -0300	[thread overview]
Message-ID: <ccd88198-274a-7ec2-b156-ccf63f04b333@linaro.org> (raw)
In-Reply-To: <CACBW-2J1m9CUw=SrRigw=ahLrRgh1he-n1NQpbxgNxNizQHyzg@mail.gmail.com>

On 11/17/20 9:29 AM, David Spickett wrote:
>> Right. The type is really telling you what specific kind of tag you are
>> requesting, not the technology. So it may be perfectly valid to request
>> a MTE logical tag from the remote target, but the remote target doesn't
>> know how to reply to that at the moment (nor does it make much sense, IMO).
>>
>> The tag types don't overlap at the moment, given they are an ENUM in
>> generic code. So the server will tell them apart by their values.
> 
> Ok but my concern here is that there are two aspects to type. (which I
> probably confused earlier tbf)
> 
> 1. logical vs allocation
> 2. MTE vs <future tagging technology>
> 
> So we have three scenarios:
> 1. Server uses type to decide between logical and allocation

Right now 0 maps to logical and 1 maps to allocation for all 
architectures. For AArch64 0 maps to MTE logical and 1 maps to MTE 
allocation.

But, if more tag types are supported in the future, we will need to map 
types to logical, allocation or something else.

> 2. Server uses type to decide between MTE and <future tagging technology>

Right now 0 and 1 map to MTE for AArch64 and ADI for SPARC (not yet 
supported). In the future, if there are more tagging technologies, we 
will need to provide a mapping from tag types to tag technology.

> 3. The combination of the two, should a system have both technologies

In this case, we will use two mappings: type to tag type and type to tag 
technology.

> 
> What I want to avoid is a two step process:
> 1. Somehow select tagging technology you want to interact with
> 2. You send memtag packets with the logical vs allocation "type"
> 
> Which would be needed if the protocol "type" is just allocation vs
> logical. If the "type" includes the technology
> then we can do it in one step.

Right now you can infer the technology and logical/allocation from the 
type. There is no need for a two step process. I don't anticipate a need 
for that in the future either, as long as we prevent the tag type ENUM 
from having overlapping values.

> 
> So I prefer:
> 0 = mte logical, 1 = mte allocation, 1 = future logical, 2 = future
> allocation, 3 = future tag form (not logical/allocation) etc...

So this is wrong, as the remote/native side won't be able to tell both 
definitions of type "1" apart.

> Over:
> 0 = logical, 1 = allocation, 2 = future term for other tag form etc...

This is correct in my view. Everything is unique.

The complicating factor here is that generic code/UI needs to use a 
generic tag type so all architectures supporting memory tagging can use 
the commands out of the box.

For AArch64, tag_logical/tag_allocation means MTE logical/MTE 
allocation. For SPARC ADI, this means whatever their tagging mechanism is.

If we turn tag_logical into mte_logical, SPARC ADI won't be able to use 
that. We will, again, need a mapping.

If we want to address this and make it a bit more flexible, then we will 
need to let architectures define their own tag type values. Then generic 
code will have to go through an arch-specific hook to fetch the tag type.

Would that address your concerns?

> 
> I see the need for the second form in gdb internally, but my concern
> is only with the protocol side.

As long as GDB sends a unique tag type identifier (non-overlapping 
values), we will be able to tell them apart from the remote side.

> 
>> I just want to keep that option open
>> if someone wants to do it, or if some other type of tag shows up that
>> would require such support.
> 
> I hadn't thought of that. I agree that type should include that too.
> 
> On Tue, 17 Nov 2020 at 12:01, Luis Machado <luis.machado@linaro.org> wrote:
>>
>> Hi,
>>
>> On 11/17/20 7:05 AM, David Spickett wrote:
>>>> Right now the design makes these types architecture-specific.
>>>
>>> This works too, in fact it matches the breakpoint types example better that way.
>>>
>>>> But there's one catch right now. The user-visible commands know about
>>>> two types of tags (logical and allocation). The native/remote side of
>>>> GDB only sees one type, the allocation one, as it doesn't make sense to
>>>> ask the native/remote target about logical tags.
>>>>
>>>> This is slightly messy and, in my opinion, should be an implementation
>>>> detail.
>>>
>>> Tell me if I have this right.
>>>
>>> In gdb in overall you have these two types but the server only uses
>>> one of them, the allocation tag type.
>>> So only the allocation tag type will ever go over the protocol. (for
>>> MTE at least)
>>
>> That's correct. Only GDB knows about logical tags. Those don't make
>> their way to the remote via the remote protocol.
>>
>>>
>>> Given that, if we assume that "mte allocation" type is 1. A future
>>> AArch64 kind of memory tagging could allocate 2 and on for its tag
>>> types.
>>> Something like:
>>> AArch64 Memory Tag types -
>>>     0 : MTE logical (which is internal only, reserved but documented as
>>> unused, or left out completely?)
>>>     1 : MTE allocation (the one we use at present)
>>>     2: <future tagging> logical tag (because maybe there is some server
>>> component for this kind of tagging extension?)
>>>     3: <future tagging> allocation tag
>>>
>>> The reason I want to clarify is that I understood the type to
>>> differentiate tagging technologies, not the kind of tag within them.
>>> (the type tells you MTE vs <future tag type> instead of allocation vs logical)
>>> The use case being what if you have MTE and <future tag type> active
>>> in the same target and I want to set an MTE allocation tag,
>>> how can the server tell them apart?
>>
>> Right. The type is really telling you what specific kind of tag you are
>> requesting, not the technology. So it may be perfectly valid to request
>> a MTE logical tag from the remote target, but the remote target doesn't
>> know how to reply to that at the moment (nor does it make much sense, IMO).
>>
>> The tag types don't overlap at the moment, given they are an ENUM in
>> generic code. So the server will tell them apart by their values.
>>
>>>
>>> If the type numbers overlap between tagging technologies, we can't
>>> tell them apart.
>>> However if they encode what extension they are for and the
>>> logical/allocation type (as in the example above) then we can.
>>>
>>> A lot of that is probably academic given there's one relevant type but
>>> we can at least document the intent of the field.
>>> E.g. "these types are global to AArch64 so new types should not
>>> overlap existing ones"
>>
>> I suppose. I chose to have generic ENUM's without specific references to
>> MTE for that reason. Architectures can use logical/allocation tags as
>> they see fit, but the ENUM values will not overlap.
>>
>> We need to support the UI as well, so there needs to be some generic
>> definitions so commands can query different tag types.
>>
>>>
>>>> Otherwise we'd need to standardize on particular tag type names across
>>>> different architectures, like "hw memory tag", "sw memory tag",
>>>> "capability tag" etc.
>>>
>>> Well I was thinking of type more as a single value like "mte". Anyway
>>> I'm fine with the integer route.
>>
>> Though we don't have a use for requesting logical tags from the remote
>> targets, it is possible to support that. Passing "mte" or any other
>> technology name would close that option.
>>
>> If, for example, we decide to have a dumb GDB client and a smart
>> GDBserver (unlikely at this point), then it would make sense to pass
>> down logical tag requests I think. I just want to keep that option open
>> if someone wants to do it, or if some other type of tag shows up that
>> would require such support.
>>
>>>
>>> On Mon, 16 Nov 2020 at 17:23, Luis Machado <luis.machado@linaro.org> wrote:
>>>>
>>>>
>>>>
>>>> On 11/16/20 1:04 PM, David Spickett wrote:
>>>>> Also with regard to the "type" field.
>>>>>
>>>>>> +@var{type} is the type of tag the request wants to fetch.  The typeis a signed
>>>>>> +integer.
>>>>>
>>>>> (typo aside) Is this field architecture specific and will there be a
>>>>> list of these type numbers documented anywhere? (or already is)
>>>>> For example would 1 on AArch64 be MTE, and on <other arch> be <other
>>>>> tag type>. Or would that <other tag type> be 2.
>>>>>
>>>>> My assumption has been that it is the latter and that a value means a
>>>>> kind of tagging extension. So for example 1=MTE rather than
>>>>> 1= mte logical and 2 = mte allocation. Correct me if I am wrong there.
>>>>
>>>> Right now the design makes these types architecture-specific. It would
>>>> be nice to have more documentation about them, for sure.
>>>>
>>>> But there's one catch right now. The user-visible commands know about
>>>> two types of tags (logical and allocation). The native/remote side of
>>>> GDB only sees one type, the allocation one, as it doesn't make sense to
>>>> ask the native/remote target about logical tags.
>>>>
>>>> This is slightly messy and, in my opinion, should be an implementation
>>>> detail.
>>>>
>>>> So, in summary... We have a couple generic tag types GDB knows about:
>>>> logical and allocation.
>>>>
>>>> Those types get translated to an arch/a target-specific type when they
>>>> cross the native/remote target boundary.
>>>>
>>>> In theory we could have generic tag types 1 and 2 in generic code, but
>>>> tag type 2 gets translated to type 1 in a remote packet.
>>>>
>>>> Maybe we could improve this a little.
>>>>
>>>>>
>>>>> A page like:
>>>>> https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Breakpoint-Kinds.html#ARM-Breakpoint-Kinds
>>>>>
>>>>> Or just a short note, given that there's only one type right now.
>>>>
>>>> Yes, that would be nice to expand for the tag types.
>>>>
>>>>>
>>>>> Also, I may have suggested the type be a string at some point. However
>>>>> based on examples like the link above
>>>>> I don't see much advantage to it apart from making packet dumps easier
>>>>> to read. Just wanted to close the loop on that
>>>>> if I didn't before.
>>>>
>>>> I don't have a strong preference here. I'm just forwarding the tag type
>>>> from generic code.
>>>>
>>>> If we want to pass strings, we will need a gdbarch hook that maps a type
>>>> to a string in the remote target layer.
>>>>
>>>> Otherwise we'd need to standardize on particular tag type names across
>>>> different architectures, like "hw memory tag", "sw memory tag",
>>>> "capability tag" etc.
>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, 16 Nov 2020 at 15:44, David Spickett <david.spickett@linaro.org> wrote:
>>>>>>
>>>>>> Minor thing, there is a missing space here in "typeis".
>>>>>>
>>>>>>> +@var{type} is the type of tag the request wants to fetch.  The typeis a signed
>>>>>>> +integer.
>>>>>>
>>>>>> On Mon, 9 Nov 2020 at 17:08, Eli Zaretskii <eliz@gnu.org> wrote:
>>>>>>>
>>>>>>>> Date: Mon,  9 Nov 2020 14:04:18 -0300
>>>>>>>> From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
>>>>>>>> Cc: david.spickett@linaro.org
>>>>>>>>
>>>>>>>> gdb/doc/ChangeLog:
>>>>>>>>
>>>>>>>> YYYY-MM-DD  Luis Machado  <luis.machado@linaro.org>
>>>>>>>>
>>>>>>>>          * gdb.texinfo (General Query Packets): Document qMemTags and
>>>>>>>>          QMemTags.  Document the "memory-tagging" feature.
>>>>>>>> ---
>>>>>>>>     gdb/doc/gdb.texinfo | 96 +++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>     1 file changed, 96 insertions(+)
>>>>>>>
>>>>>>> OK for this part, thanks.

  reply	other threads:[~2020-11-17 14:44 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 17:04 [PATCH v3 00/24] Memory Tagging Support + AArch64 Linux implementation Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 01/24] New target methods for memory tagging support Luis Machado via Gdb-patches
2020-12-25  4:26   ` Simon Marchi via Gdb-patches
2020-12-28 15:05     ` Luis Machado via Gdb-patches
2020-12-25  5:08   ` Simon Marchi via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 02/24] New gdbarch memory tagging hooks Luis Machado via Gdb-patches
2020-12-25  4:40   ` Simon Marchi via Gdb-patches
2020-12-28 15:44     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 03/24] Add GDB-side remote target support for memory tagging Luis Machado via Gdb-patches
2020-12-25  5:08   ` Simon Marchi via Gdb-patches
2020-12-28 16:28     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 04/24] Unit testing for GDB-side remote memory tagging handling Luis Machado via Gdb-patches
2020-12-25  5:34   ` Simon Marchi via Gdb-patches
2020-12-28 17:17     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 05/24] GDBserver remote packet support for memory tagging Luis Machado via Gdb-patches
2020-12-25  5:50   ` Simon Marchi via Gdb-patches
2020-12-28 17:46     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 06/24] Unit tests for gdbserver memory tagging remote packets Luis Machado via Gdb-patches
2020-12-25 20:13   ` Simon Marchi via Gdb-patches
2020-12-28 18:12     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 07/24] Documentation for " Luis Machado via Gdb-patches
2020-11-09 17:08   ` Eli Zaretskii via Gdb-patches
2020-11-16 15:44     ` David Spickett via Gdb-patches
2020-11-16 16:04       ` David Spickett via Gdb-patches
2020-11-16 17:22         ` Luis Machado via Gdb-patches
2020-11-17 10:05           ` David Spickett via Gdb-patches
2020-11-17 12:01             ` Luis Machado via Gdb-patches
2020-11-17 12:29               ` David Spickett via Gdb-patches
2020-11-17 14:44                 ` Luis Machado via Gdb-patches [this message]
2020-11-17 15:16                   ` David Spickett via Gdb-patches
2020-11-17 17:29                     ` Luis Machado via Gdb-patches
2020-11-18 10:39                       ` David Spickett via Gdb-patches
2020-11-18 10:56                         ` Luis Machado via Gdb-patches
2020-11-18 11:22                           ` David Spickett via Gdb-patches
2020-11-16 16:49       ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 08/24] AArch64: Add MTE CPU feature check support Luis Machado via Gdb-patches
2020-12-26  0:04   ` Simon Marchi via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 09/24] AArch64: Add target description/feature for MTE registers Luis Machado via Gdb-patches
2020-12-26  0:10   ` Simon Marchi via Gdb-patches
2020-12-28 18:28     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 10/24] AArch64: Add MTE register set support for GDB and gdbserver Luis Machado via Gdb-patches
2020-12-26  0:17   ` Simon Marchi via Gdb-patches
2020-12-28 18:41     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 11/24] AArch64: Add MTE ptrace requests Luis Machado via Gdb-patches
2020-12-26  0:19   ` Simon Marchi via Gdb-patches
2020-12-28 19:12     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 12/24] AArch64: Implement memory tagging target methods for AArch64 Luis Machado via Gdb-patches
2020-12-26  0:33   ` Simon Marchi via Gdb-patches
2020-12-28 19:50     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 13/24] Refactor parsing of /proc/<pid>/smaps Luis Machado via Gdb-patches
2020-12-26  6:36   ` Simon Marchi via Gdb-patches
2020-12-29 10:57     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 14/24] AArch64: Implement the memory tagging gdbarch hooks Luis Machado via Gdb-patches
2020-12-26  6:52   ` Simon Marchi via Gdb-patches
2020-12-29 12:16     ` Luis Machado via Gdb-patches
2021-01-18 16:29       ` Simon Marchi via Gdb-patches
2021-01-20 20:01         ` Tom Tromey
2020-11-09 17:04 ` [PATCH v3 15/24] AArch64: Add unit testing for logical tag set/get operations Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 16/24] AArch64: Report tag violation error information Luis Machado via Gdb-patches
2020-11-16 15:43   ` David Spickett via Gdb-patches
2020-11-16 16:45     ` Luis Machado via Gdb-patches
2020-11-17  9:36       ` David Spickett via Gdb-patches
2020-12-26 22:23   ` Simon Marchi via Gdb-patches
2020-12-30  0:50     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 17/24] AArch64: Add gdbserver MTE support Luis Machado via Gdb-patches
2020-12-26 22:30   ` Simon Marchi via Gdb-patches
2020-12-29 14:32     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 18/24] AArch64: Add MTE register set support for core files Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 19/24] New mtag commands Luis Machado via Gdb-patches
2020-12-27  3:32   ` Simon Marchi via Gdb-patches
2020-12-29 17:21     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 20/24] Documentation for the new " Luis Machado via Gdb-patches
2020-11-09 17:11   ` Eli Zaretskii via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 21/24] Extend "x" and "print" commands to support memory tagging Luis Machado via Gdb-patches
2020-11-09 17:14   ` Eli Zaretskii via Gdb-patches
2020-11-09 17:20     ` Luis Machado via Gdb-patches
2020-12-27  4:18   ` Simon Marchi via Gdb-patches
2020-12-29 18:50     ` Luis Machado via Gdb-patches
2021-01-18 17:56       ` Simon Marchi via Gdb-patches
2021-01-18 20:20         ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 22/24] Document new "x" and "print" memory tagging extensions Luis Machado via Gdb-patches
2020-11-09 17:16   ` Eli Zaretskii via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 23/24] Add NEWS entry Luis Machado via Gdb-patches
2020-11-09 17:19   ` Eli Zaretskii via Gdb-patches
2020-11-09 17:22     ` Luis Machado via Gdb-patches
2020-11-09 17:04 ` [PATCH v3 24/24] Add memory tagging testcases Luis Machado via Gdb-patches
2020-11-16 15:47   ` David Spickett via Gdb-patches
2020-11-16 16:51     ` Luis Machado via Gdb-patches
2020-12-27  4:36   ` Simon Marchi via Gdb-patches
2020-12-29 19:32     ` Luis Machado via Gdb-patches
2020-11-16 13:48 ` [PATCH v3 00/24] Memory Tagging Support + AArch64 Linux implementation Luis Machado via Gdb-patches
2020-11-16 14:37   ` Alan Hayward via Gdb-patches
2020-11-23 16:08   ` Luis Machado via Gdb-patches
2020-11-30 13:38     ` Luis Machado via Gdb-patches
2020-12-07 13:17       ` Luis Machado via Gdb-patches
2020-12-07 14:17         ` Alan Hayward via Gdb-patches

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=ccd88198-274a-7ec2-b156-ccf63f04b333@linaro.org \
    --to=gdb-patches@sourceware.org \
    --cc=david.spickett@linaro.org \
    --cc=luis.machado@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