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: 3/6 [2nd try]: Add AVX support (i386 changes)
Date: Fri, 12 Mar 2010 00:00:00 -0000	[thread overview]
Message-ID: <6dc9ffc81003111600k66be499cqf6639a07d20f5cce@mail.gmail.com> (raw)
In-Reply-To: <201003112237.o2BMb4XR024283@glazunov.sibelius.xs4all.nl>

On Thu, Mar 11, 2010 at 2:37 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Sun, 7 Mar 2010 13:31:53 -0800
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>>
>> On Sat, Mar 06, 2010 at 02:20:37PM -0800, H.J. Lu wrote:
>> > Hi,
>> >
>> > Here are i386 changes to support AVX. OK to install?
>> >
>>
>> Here is the updated patch to change i386_dbx_reg_to_regnum to return
>> %ymmN register number for %xmmN if AVX is available.  Any comments?
>
> Can't find the time to review the complete diff.  So here's a partial
> review.
>
> The generic -tdep.c bits look reasonable, although I have a few nits.  I'm
> less happy with the Linux -tdep.c and -nat.c bits though.
>
...

>> +
>> +/* The extended state feature bits.  */
>> +#define bit_I386_XSTATE_X87          (1ULL << 0)
>> +#define bit_I386_XSTATE_SSE          (1ULL << 1)
>> +#define bit_I386_XSTATE_AVX          (1ULL << 2)
>
> #define's should be uppercase; please drop the bit_-prefix

I will make the change.

>> +
>> +/* Supported mask and size of the extended state.  */
>> +#define I386_XSTATE_SSE_MASK \
>> +  (bit_I386_XSTATE_X87 | bit_I386_XSTATE_SSE)
>> +#define I386_XSTATE_AVX_MASK \
>> +  (I386_XSTATE_SSE_MASK | bit_I386_XSTATE_AVX)
>> +#define I386_XSTATE_MAX_MASK \
>> +  I386_XSTATE_AVX_MASK
>> +
>> +#define I386_XSTATE_SSE_SIZE         576
>> +#define I386_XSTATE_AVX_SIZE         832
>> +#define I386_XSTATE_MAX_SIZE         832
>> +
>> +/* Get I386 XSAVE extended state size.  */
>> +#define I386_XSTATE_SIZE(XCR0)       \
>> +  (((XCR0) & bit_I386_XSTATE_AVX) != 0 \
>> +   ? I386_XSTATE_AVX_SIZE : I386_XSTATE_SSE_SIZE)
>> +
>> +#endif /* I386_XSTATE_H */
>
>
> Please don't introduce new nm-xxx.h files.  We've been trying to get
> rid of them for years and they shouldn't be necessary.

I will remove it.


>> +
>> +#include "i386-xstate.h"
>> +
>> +#ifndef PTRACE_GETREGSET
>> +#define PTRACE_GETREGSET     0x4204
>> +#endif
>> +
>> +#ifndef PTRACE_SETREGSET
>> +#define PTRACE_SETREGSET     0x4205
>> +#endif
>> +
>> +#endif       /* NM_LINUX_XSTATE_H */
>
> Do we really have to hardcode constants like this in GDB?  They should
> be available in through kernel/libc headers.  Are Drepper and Torvalds
> still fighting over that issue?

They are in Linux kernel 2.6.34-rc1. Do we enable gdb support only
with the new kernel/glibc headers? I compiled gdb on RHEL4 and it
works fine.  There are:

#ifndef PTRACE_GET_THREAD_AREA
#define PTRACE_GET_THREAD_AREA 25
 ...
#ifndef PTRACE_ARCH_PRCTL
#define PTRACE_ARCH_PRCTL      30

in amd64-linux-nat.c.


>> +
>> +/* The extended state size in unit of int64.  We use array of int64 for
>> +   better alignment.  */
>> +static unsigned int xstate_size_n_of_int64;
>
> Does alignment really matter?  I'd rather do without this additional
> complication.

"xcr0" is a 64bit value.  It is nice to use array of uint64 to access it.

>> +static int
>> +fetch_xstateregs (struct regcache *regcache, int tid)
>> +{
>> +  unsigned long long xstateregs[xstate_size_n_of_int64];
>> +  struct iovec iov;
>> +
>> +  if (!have_ptrace_getregset)
>> +    return 0;
>> +
>> +  iov.iov_base = xstateregs;
>> +  iov.iov_len = xstate_size;
>> +  if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
>> +           (int) &iov) < 0)
>
> This can't be right!

Why? That is the kernel interface in 2.6.34-rc1.

>> +    perror_with_name (_("Couldn't read extended state status"));
>> +
>> +  i387_supply_xsave (regcache, -1, xstateregs);
>> +  return 1;
>> +}
>> +
>> +/* Store all valid registers in GDB's register array covered by the
>> +   PTRACE_SETREGSET request into the process/thread specified by TID.
>> +   Return non-zero if successful, zero otherwise.  */
>> +
>> +static int
>> +store_xstateregs (const struct regcache *regcache, int tid, int regno)
>> +{
>> +  unsigned long long xstateregs[xstate_size_n_of_int64];
>
> I think it is better to use I386_XSTATE_MAX_SIZE here.

That is how the kernel interface works.  Whatever value I386_XSTATE_MAX_SIZE is
today won't be the same tomorrow. We will increase it in the coming
years. But the same
gdb binary will work fine since kernel will only copy number of bytes
specified in
iov.iov_len, which is all gdb cares/needs.

>> +  struct iovec iov;
>> +
>> +  if (!have_ptrace_getregset)
>> +    return 0;
>> +
>> +  iov.iov_base = xstateregs;
>> +  iov.iov_len = xstate_size;
>> +  if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
>> +           (int) &iov) < 0)
>> +    perror_with_name (_("Couldn't read extended state status"));
>
> This can't be right either!
>

>>        if (store_fpxregs (regcache, tid, regno))
>> @@ -858,7 +943,49 @@ i386_linux_child_post_startup_inferior (ptid_t ptid)
>>  static const struct target_desc *
>>  i386_linux_read_description (struct target_ops *ops)
>>  {
>> -  return tdesc_i386_linux;
>> +  static unsigned long long xcr0;
>
> Is it really ok, to cache this?  Will the Linux kernel always return
> the same value for every process?

xcr0 is a processor value and will be the same for all processes.

>
> Time for me to zzz now; hopefully I'll be able to review the remainder
> on Saturday.
>

Thanks.

-- 
H.J.

  reply	other threads:[~2010-03-12  0:00 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 18:02 PATCH: 1/6: Add AVX support 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 [this message]
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
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=6dc9ffc81003111600k66be499cqf6639a07d20f5cce@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).