Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Tedeschi, Walfred" <walfred.tedeschi@intel.com>
To: Pedro Alves <palves@redhat.com>
Cc: "mark.kettenis@xs4all.nl" <mark.kettenis@xs4all.nl>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2 1/1] Fix PR16193 - gdbserver aborts.
Date: Mon, 25 Nov 2013 17:08:00 -0000	[thread overview]
Message-ID: <AC542571535E904D8E8ADAE745D60B191B1DC176@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <52937A8C.9080301@redhat.com>

Hi Pedro,

In fact I didn't like this macro from the beginning on. And liked less when I saw it with AVX512. 
Therefore I took the time to rewrite it. It was too awful to read in the way it was. :)
:)

I will fix the rationale.

Thanks and regards,
-Fred

-----Original Message-----
From: Pedro Alves [mailto:palves@redhat.com] 
Sent: Monday, November 25, 2013 5:28 PM
To: Tedeschi, Walfred
Cc: mark.kettenis@xs4all.nl; gdb-patches@sourceware.org
Subject: Re: [PATCH v2 1/1] Fix PR16193 - gdbserver aborts.

On 11/25/2013 03:55 PM, Walfred Tedeschi wrote:
> The MPX patch has broken the I386_XSTATE_SIZE macro. For any xcr0 
> value entered return is 576. This patch fixes that and improves 
> readability of the macros.

Since you still didn't explain it, I took another closer look.
I can't believe how long it took me to spot it.  I kept staring at the BNDREGS and BNDCFG bits, but the issue is really in the AVX check.

>  /* Get I386 XSAVE extended state size.  */  #define 
> I386_XSTATE_SIZE(XCR0) \
> -    (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
> -       : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
> -       : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \

The issue is here:

     : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \

That should have been:

     : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \


Please fix the rationale in the commit log.  It's not true that I386_XSTATE_SIZE _always_ returns 576.  For MPX machines, the existing code returns the right value.  It's only non-MPX AVX machines that get the wrong value.  IOW, this one lines would be the equivalent smallest fix:

/* Get I386 XSAVE extended state size.  */ #define I386_XSTATE_SIZE(XCR0) \
    (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
       : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
-       : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \
+       : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \
       : I386_XSTATE_SSE_SIZE)))


Something like this:

"
The MPX patch has broken the I386_XSTATE_SIZE macro.  For AVX machines, it ends up returning I386_XSTATE_SSE_SIZE.  Where it first reads I386_XSTATE_AVX_SIZE, it should have read I386_XSTATE_AVX:

 #define I386_XSTATE_SIZE(XCR0) \
     (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \
        : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \
 -       : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \
 +       : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \
        : I386_XSTATE_SSE_SIZE)))

The patch goes a step further and improves readability of the macro, by adding a couple other auxiliary macros.

2013-11-25  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-xstate.h (I386_XSTATE_MPX): New Macro.
	(I386_XSTATE_MPX_MASK): Makes use of I386_XSTATE_MPX.
	(HAS_MPX): New macro.
	(HAS_AVX): New macro.
	(I386_XSTATE_SIZE): Uses HAS_MPX and HAS_AVX.
"

> 2013-12-25  Walfred Tedeschi  <walfred.tedeschi@intel.com>

Longing for Christmas? ;-)


-> Oh! Yah! :)
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


      reply	other threads:[~2013-11-25 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 16:28 Walfred Tedeschi
2013-11-25 17:00 ` Pedro Alves
2013-11-25 17:08   ` Tedeschi, Walfred [this message]

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=AC542571535E904D8E8ADAE745D60B191B1DC176@IRSMSX104.ger.corp.intel.com \
    --to=walfred.tedeschi@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=palves@redhat.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