From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16340 invoked by alias); 25 Nov 2013 16:28:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16326 invoked by uid 89); 25 Nov 2013 16:28:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Nov 2013 16:28:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAPGRw38010473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Nov 2013 11:27:58 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAPGRuMh009076; Mon, 25 Nov 2013 11:27:57 -0500 Message-ID: <52937A8C.9080301@redhat.com> Date: Mon, 25 Nov 2013 17:00:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Walfred Tedeschi CC: mark.kettenis@xs4all.nl, gdb-patches@sourceware.org Subject: Re: [PATCH v2 1/1] Fix PR16193 - gdbserver aborts. References: <1385394941-26593-1-git-send-email-walfred.tedeschi@intel.com> In-Reply-To: <1385394941-26593-1-git-send-email-walfred.tedeschi@intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-11/txt/msg00788.txt.bz2 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 * 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 Longing for Christmas? ;-)