public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@linaro.org>
To: John Baldwin <jhb@FreeBSD.org>, Alan Hayward <Alan.Hayward@arm.com>
Cc: "gdb-patches\\@sourceware.org" <gdb-patches@sourceware.org>,
	"david.spickett@linaro.org" <david.spickett@linaro.org>,
	Catalin Marinas <Catalin.Marinas@arm.com>, nd <nd@arm.com>
Subject: Re: [PATCH] [AArch64] MTE corefile support
Date: Mon, 24 May 2021 10:41:46 -0300	[thread overview]
Message-ID: <e0017368-c67e-2a94-3241-c6fd7f4224a8@linaro.org> (raw)
In-Reply-To: <c4016f5d-67d0-bad3-3cb4-3e5e8d7b34c7@FreeBSD.org>

Hi John,

On 5/21/21 2:20 PM, John Baldwin wrote:
> On 5/21/21 8:30 AM, Luis Machado wrote:
>> Hi Alan,
>>
>> On 5/21/21 12:12 PM, Alan Hayward wrote:
>>>
>>>
>>>> On 18 May 2021, at 21:20, Luis Machado <luis.machado@linaro.org> wrote:
>>>>
>>>> Teach GDB how to dump memory tags when using the gcore command and how
>>>> to read them back from a core file generated via gcore or the kernel.
>>>>
>>>> Each tagged memory range (listed in /proc/<pid>/smaps) gets dumped 
>>>> to its
>>>> own NT_MEMTAG note. A section named ".memtag" is created for each of 
>>>> those
>>>> when reading the core file back.
>>>>
>>>> Dumping memory tags
>>>> -
>>>>
>>>> When using the gcore command to dump a core file, GDB will go 
>>>> through the maps
>>>> in /proc/<pid>/smaps looking for tagged ranges. Each of those 
>>>> entries gets
>>>> passed to an arch-specific gdbarch hook that generates a vector of 
>>>> blobs of
>>>> memory tag data that are blindly put into a NT_MEMTAG note.
>>>>
>>>> The vector is used because we may have, in the future,  multiple tag 
>>>> types for
>>>> a particular memory range.
>>>>
>>>> Each of the NT_MEMTAG notes have a generic header and a 
>>>> arch-specific header,
>>>> like so:
>>>>
>>>> struct tag_dump_header
>>>> {
>>>>    uint16_t format; // Only NT_MEMTAG_TYPE_AARCH_MTE at present
>>>>    uint64_t start_vma;
>>>>    uint64_t end_vma;
>>>> };
>>>>
>>>> struct tag_dump_mte
>>>> {
>>>>    uint16_t granule_byte_size;
>>>>    uint16_t tag_bit_size;
>>>>    uint16_t __unused;
>>>> };
>>>>
>>>> The only bits meant to be generic are the tag_dump_format, start_vma 
>>>> and
>>>> end_vma fields.
>>>>
>>>> The format-specific data is supposed to be opaque and only useful 
>>>> for the
>>>> arch-specific code.
>>>>
>>>> We can extend the format in the future to make room for other memory 
>>>> tag
>>>> layouts.
>>>>
>>>
>>> This is a wider question than this patch - but is there someplace 
>>> this format will
>>> be documented? Ideally either Linux or GDB needs something written 
>>> down in
>>> text format.
>>>
>>> A few nits below too, but mostly looks fine.
>>
>> Yes. I'm still thinking whether this should go into the Linux Kernel's
>> documentation or somewhere in the GDB manual.
>>
>> Given GDB reads core files generated by the Linux Kernel and also
>> creates cores files itself, I'm thinking it may be best to put it in the
>> GDB manual.
>>
>> I want to wait for possible feedbacks about the format before we
>> document how it will look like in the manual.
> 
> Also, NT_MEMTAG is not inherently OS specific and I plan to reuse whatever
> format is used here for CHERI tags on RISC-V and Morello in CheriBSD (a
> CHERI-aware version of FreeBSD).  If someone adds MTE support in FreeBSD
> that would use the same format as well.  To that end, I think we should
> aim to have the tag "type" values be OS independent (so just depending
> on the arch).  Having an actual value of NT_MEMTAG that is portable is
> harder as various OS's already have conflicting NT_* namespaces.  If we

Just recently Andrew added the NT_GDB_TDESC note type, which is supposed 
to be OS-independent. The value for that (0xff000000) was picked out of 
a range that doesn't overlap with existing OS-specific definitions.

I'm doing the same for NT_MEMTAG. You can use it for any OS (or 
bare-metal), as it doesn't have anything Linux-specific.

> wanted something truly independent we could perhaps choose a neutral
> note name (e.g. "memtag" instead of "Linux", "CORE", or "FreeBSD") and

I'm using CORE right now. But we could change it to something else if 
needed. Isn't CORE something any OS can work with?

> then the note type could instead take the place of the type of tag,
> but that may be overly complicated compared to just having OS-specific
> NT_MEMTAG values.
> 

  reply	other threads:[~2021-05-24 13:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 20:20 Luis Machado
2021-05-19 10:01 ` David Spickett
2021-05-19 11:11   ` Luis Machado
2021-05-19 12:13 ` Eli Zaretskii
2021-05-21 15:12 ` Alan Hayward
2021-05-21 15:30   ` Luis Machado
2021-05-21 17:20     ` John Baldwin
2021-05-24 13:41       ` Luis Machado [this message]
2021-05-24  8:07     ` Alan Hayward
2021-05-24 12:45       ` Luis Machado
2021-05-26 14:08 ` [PATCH,v2] " Luis Machado
2021-05-29  3:14   ` Simon Marchi
2021-05-31 14:12     ` Luis Machado
2021-05-31 14:49       ` Simon Marchi
2021-05-31 14:56         ` Luis Machado
2021-05-31 14:15   ` [PATCH,v3][AArch64] " Luis Machado
2021-05-31 16:44 ` [PATCH,v4][AArch64] " Luis Machado
2021-06-01 17:45 ` [PATCH,v5][AArch64] " Luis Machado
2021-06-15 14:10   ` [Ping][PATCH,v5][AArch64] " Luis Machado
2021-06-24 14:00   ` [PATCH,v5][AArch64] " Alan Hayward
2021-06-24 14:37     ` Luis Machado
2021-06-24 15:18       ` Alan Hayward
2021-07-01 13:50   ` [PING][PATCH,v5][AArch64] " Luis Machado
2021-07-11 14:22     ` Joel Brobecker
2021-07-14 13:07       ` Catalin Marinas
2021-07-29  2:26         ` Simon Marchi
2021-07-29 16:03           ` John Baldwin
2021-07-29 18:10           ` Catalin Marinas
2021-07-29 18:20             ` Simon Marchi
2021-08-01 15:44               ` Joel Brobecker
2021-08-02 12:06                 ` Luis Machado
2021-07-19 19:05   ` Luis Machado
2021-07-27 16:10   ` Luis Machado

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=e0017368-c67e-2a94-3241-c6fd7f4224a8@linaro.org \
    --to=luis.machado@linaro.org \
    --cc=Alan.Hayward@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=david.spickett@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    --cc=nd@arm.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).