public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: PATCH: 0/6 [2nd try]: Add AVX support
Date: Sun, 07 Mar 2010 21:04:00 -0000	[thread overview]
Message-ID: <6dc9ffc81003071304m1b858d6fp3ca2b80364d4a473@mail.gmail.com> (raw)
In-Reply-To: <201003072028.o27KSrsI016094@glazunov.sibelius.xs4all.nl>

On Sun, Mar 7, 2010 at 12:28 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Sun, 7 Mar 2010 08:40:10 -0800
>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>
>> On Sun, Mar 7, 2010 at 8:31 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> > On Sun, Mar 7, 2010 at 6:37 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >> On Sun, Mar 7, 2010 at 6:16 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> >>>> Date: Sat, 6 Mar 2010 14:16:34 -0800
>> >>>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>> >>>>
>> >>>> AVX registers are saved and restored via the XSAVE extended state. The
>> >>>> extended control register 0 (the XFEATURE_ENABLED_MASK register), XCR0,
>> >>>> is used to determine which states, x87, SSE, AVX, ... are supported
>> >>>> in the XSAVE extended state.  XCR0 can be read with the new "xgetbv"
>> >>>> instruction.  The xstate_bv field at byte offset 512 in the XSAVE
>> >>>> extended state indicates what states the current process is in. If
>> >>>> the feature bit is cleared, the corresponding registers should be read as
>> >>>> 0. If we update a register, we should set the corresponding feature
>> >>>> bit in the xstate_bv field.
>> >>>>
>> >>>> We added PTRACE_GETREGSET and PTRACE_SETREGSET to Linux kernel to
>> >>>> fetch and store AVX registers with ptrace. Linux kernel also stores
>> >>>> XCR0 at the first 8 bytes of the software usable bytes, starting at
>> >>>> byte offset 464.
>> >>>>
>> >>>> There are total 6 patches to add AVX support for Linux.  They support:
>> >>>>
>> >>>> 1. The upper 128bit YMM registers are added for AVX support. The upper
>> >>>> 128bit YMM registers are hidden from users. Gdb combines XMM register,
>> >>>> %xmmX, with 128bit YMM register, %ymmXh, and present the whole 256bit
>> >>>> YMM register, %ymmX, as pseudo register to users.
>> >>>> 2. Backward compatible. If AVX isn't supported, SSE will be used.
>> >>>> 3. Forward compatible. If new state beyond AVX is supported in
>> >>>> the XSAVE extended state, only AVX state will be used.
>> >>>> 4. Remote gdb protocol extension. GDB will send "x86=xml" in qSupported
>> >>>> request packet to indicate that GDB supports x86 XML target desciption.
>> >>>> The gdb stub will send x86 XML target desciption if it sees "x86=xml"
>> >>>> in qSupported request packet.
>> >>>>
>> >>>> One advantage of this approach is YMM registers are actually stored as
>> >>>> XMM registers and upper YMM registers in the XSAVE extended state.  It
>> >>>> is easy and natural to access them as %xmmX and %ymmXh internally.  We
>> >>>> just need to hide %ymmXh from users.
>> >>>>
>> >>>> To support AVX on other OSes, the following changes are needed:
>> >>>>
>> >>>> 1. Kernel support to get/set the XSAVE extended state.
>> >>>> 2. Handle 8/16 upper YMM registers.
>> >>>> 3. Provide target to_read_description to return SSE or AVX target
>> >>>> description.
>> >>>> 4. Update gdbarch_core_read_description to return SSE or AVX target
>> >>>> description based on contents of core dump.
>> >>>
>> >>> Wait; there is something important missing here.  How are the new %ymm
>> >>> registers referred to in debug info?  The AMD64 SysV psABI defines the
>> >>> DWARF register Number Mapping, but the 0.99.4 draft copy I have
>> >>> doesn't define any mappings for the %ymm registers.  What mapping does
>> >>> GCC use?
>> >>>
>> >>
>> >> In gcc, XMM and YMM registers have the same register number. They map
>> >> to be the same DWARF register with different sizes.  Since XMM and YMM
>> >> registers are caller-saved, they don't appear in unwind info. So, the same
>> >> DWARF register with different sizes for XMM/YMM registers isn't a problem.
>> >>
>> >>
>> >
>> > Yes, there is a problem. amd64_dwarf_reg_to_regnum needs to map 256bit
>> > register to YMM. How do other arches solve this?
>
> A possible solution here is to simply always map %xmmN onto %ymmN if
> the target supports AVX.  This'll make "info address" say that a
> 128-bit vector variable lives in %ymmN instead of %xmmN, but that
> wouldn't really be a lie, would it?  The only problem with this
> approach is that it will break cases where the debug info refers to a
> variable living in consecutive %xmm (128-bit) registers using (only)
> the register number of the first %xmm register.  This shouldn't happen
> with DWARF2, but might happen with older debug formats like stabs.
> Not necessarily a serious probem; at least nothing I care about still
> uses stabs.
>
> Should be a simple matter of returning the %ymm pseudo register number
> if tdep->num_ymm_regs > 0.

Yes, it works.

Thanks.

-- 
H.J.

  reply	other threads:[~2010-03-07 21:04 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 18:02 PATCH: 1/6: " H.J. Lu
2010-03-04 18:05 ` PATCH: 2/6: Add AVX support (Update document) H.J. Lu
2010-03-04 18:06   ` PATCH: 3/6: Add AVX support (i386 changes) H.J. Lu
2010-03-06 22:21     ` PATCH: 3/6 [2nd try]: " H.J. Lu
2010-03-07 21:32       ` H.J. Lu
2010-03-11 22:37         ` Mark Kettenis
2010-03-12  0:00           ` H.J. Lu
2010-03-27 14:55             ` Mark Kettenis
2010-03-27 15:30               ` Daniel Jacobowitz
2010-03-27 16:05                 ` Mark Kettenis
2010-03-27 15:33               ` H.J. Lu
2010-03-27 16:09                 ` Mark Kettenis
2010-03-28  1:39                   ` H.J. Lu
2010-03-12 16:49       ` H.J. Lu
2010-03-13  1:38         ` H.J. Lu
2010-03-29  1:11         ` PATCH: 3/6 [3rd " H.J. Lu
2010-04-02 14:31           ` H.J. Lu
2010-04-02 14:42             ` Mark Kettenis
2010-04-02 15:28               ` H.J. Lu
2010-04-07 10:13                 ` Mark Kettenis
2010-04-07 14:56                   ` H.J. Lu
2010-04-07 15:04                     ` H.J. Lu
2010-04-07 15:19                       ` Mark Kettenis
2010-04-07 16:55             ` H.J. Lu
2010-04-07 18:34               ` Mark Kettenis
2010-04-07 18:50                 ` H.J. Lu
2010-03-27 15:48       ` PATCH: 3/6 [2nd " Mark Kettenis
2010-03-28  1:37         ` H.J. Lu
2010-03-28 11:55           ` Mark Kettenis
2010-03-28 14:25             ` H.J. Lu
2010-03-29 20:32               ` Mark Kettenis
2010-03-29 21:41                 ` H.J. Lu
2010-03-04 18:08   ` PATCH: 4/6: Add AVX support (amd64 changes) H.J. Lu
2010-03-04 18:09     ` PATCH: 5/6: Add AVX support (i387 changes) H.J. Lu
2010-03-04 18:10       ` PATCH: 6/6: Add AVX support (gdbserver changes) H.J. Lu
2010-03-06 22:23         ` PATCH: 6/6 [2nd try]: " H.J. Lu
2010-03-12 17:25           ` H.J. Lu
2010-03-27 16:07             ` Daniel Jacobowitz
2010-03-28  1:11               ` H.J. Lu
2010-03-28  7:55                 ` Pedro Alves
2010-03-28 14:56                   ` H.J. Lu
2010-03-28 16:17                     ` Pedro Alves
2010-03-28 16:37                       ` H.J. Lu
2010-03-28 16:40                   ` Daniel Jacobowitz
2010-03-28 16:47                     ` Pedro Alves
2010-03-28 20:53                       ` H.J. Lu
2010-03-28 21:27                         ` Pedro Alves
2010-03-28 16:39                 ` Daniel Jacobowitz
2010-03-28 19:31                   ` H.J. Lu
2010-03-29  1:09             ` PATCH: 6/6 [3rd " H.J. Lu
2010-03-29 14:08               ` Eli Zaretskii
2010-03-29 14:42                 ` H.J. Lu
2010-03-29 15:11                   ` Eli Zaretskii
2010-03-29 15:42                     ` H.J. Lu
2010-03-29 15:51                       ` Eli Zaretskii
2010-03-30 16:48               ` H.J. Lu
2010-04-02 17:39                 ` Daniel Jacobowitz
2010-04-07  4:37                   ` H.J. Lu
2010-04-03 21:57                 ` Jan Kratochvil
2010-04-07  4:12                   ` H.J. Lu
2010-04-07 16:59                 ` H.J. Lu
2010-03-05  3:20       ` PATCH: 5/6: Add AVX support (i387 changes) Hui Zhu
2010-03-05  3:54         ` H.J. Lu
2010-03-06 22:22       ` PATCH: 5/6 [2nd try]: " H.J. Lu
2010-03-12 17:24         ` H.J. Lu
2010-04-07 16:57           ` PATCH: 5/6 [3rd " H.J. Lu
2010-03-27 15:08         ` PATCH: 5/6 [2nd " Mark Kettenis
2010-03-27 15:15           ` H.J. Lu
2010-03-06 22:21     ` PATCH: 4/6 [2nd try]: Add AVX support (amd64 changes) H.J. Lu
2010-03-07 21:33       ` H.J. Lu
2010-03-12 17:01         ` H.J. Lu
2010-03-13  1:38           ` H.J. Lu
2010-03-29  1:07           ` PATCH: 4/6 [3rd " H.J. Lu
2010-04-02 14:32             ` H.J. Lu
2010-04-07 16:54               ` H.J. Lu
2010-03-05 10:33   ` PATCH: 2/6: Add AVX support (Update document) Eli Zaretskii
2010-03-05 14:08     ` H.J. Lu
2010-03-06 22:19   ` PATCH: 2/6 [2nd try]: " H.J. Lu
2010-03-12 11:11     ` Eli Zaretskii
2010-03-12 14:17       ` H.J. Lu
2010-03-12 15:28         ` Eli Zaretskii
2010-03-12 15:27     ` Eli Zaretskii
2010-03-12 16:46     ` H.J. Lu
2010-03-12 18:15       ` Eli Zaretskii
2010-03-29  0:18     ` PATCH: 2/6 [3rd " H.J. Lu
2010-03-30 16:41       ` H.J. Lu
2010-03-30 18:27         ` Eli Zaretskii
2010-03-30 18:37           ` H.J. Lu
2010-03-04 19:09 ` PATCH: 1/6: Add AVX support Daniel Jacobowitz
2010-03-04 19:29   ` H.J. Lu
2010-03-04 19:47     ` Daniel Jacobowitz
2010-03-04 21:27       ` H.J. Lu
2010-03-04 21:34         ` Nathan Froyd
2010-03-04 21:41           ` H.J. Lu
2010-03-04 21:59             ` Nathan Froyd
2010-03-04 21:47         ` Daniel Jacobowitz
2010-03-05  2:06           ` H.J. Lu
2010-03-05  7:29             ` Mark Kettenis
2010-03-06 22:16 ` PATCH: 0/6 [2nd try]: " H.J. Lu
2010-03-06 22:18   ` PATCH: 1/6 [2nd try]: Add AVX support (AVX XML files) H.J. Lu
2010-03-07 14:16   ` PATCH: 0/6 [2nd try]: Add AVX support Mark Kettenis
2010-03-07 14:37     ` H.J. Lu
2010-03-07 16:31       ` H.J. Lu
2010-03-07 16:40         ` H.J. Lu
2010-03-07 17:04           ` H.J. Lu
2010-03-07 17:39             ` H.J. Lu
2010-03-07 20:00               ` Mark Kettenis
2010-03-07 19:10           ` Nathan Froyd
2010-03-07 19:49             ` Mark Kettenis
2010-03-07 21:07               ` Nathan Froyd
2010-03-07 21:17                 ` H.J. Lu
2010-03-07 20:29           ` Mark Kettenis
2010-03-07 21:04             ` H.J. Lu [this message]
2010-03-27 16:16   ` Daniel Jacobowitz
2010-03-29  0:16   ` PATCH: 0/6 [3nd " H.J. Lu

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=6dc9ffc81003071304m1b858d6fp3ca2b80364d4a473@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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).