Message ID | 20240904230150.2248673-1-hjl.tools@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB41D386182F for <patchwork@sourceware.org>; Wed, 4 Sep 2024 23:02:17 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 80C253858435 for <gdb-patches@sourceware.org>; Wed, 4 Sep 2024 23:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 80C253858435 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 80C253858435 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725490915; cv=none; b=Zb3zyx5QOp3T+Xlnktfcz0XeoBvHzRKI0jNblAlq+/vvkitlXJm9bq3dVANc9CQd4t6LVOS1jeaOqr5H43Yi5xGX3iUh0PlyB0MZnlOlsDfPdS2wMK0fzINh0//OyeKwqfq7xR8MNlupJTAujJ/j3hBuVaue+u+BKcr8LJsAT2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725490915; c=relaxed/simple; bh=G4RXrrv/FAb868sSerwV/R/rBD+HqjGZKQgVpblJX3w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=c8InNJvFNQ55gpxtq0Xi5NTG3/bFS4euTBQcDZTNlrJXpmzOVUANftFT2/p1JQpEDNZ/l5gwz/AVCai4tA8qkSYZ6s59nxr1tDydyynQJIm5rVSlPw+vxCCu6g4/1gdw07llxxB3k1NydqWtdTTZgZB0OxDhQT2wJXK4iGEl/Cc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-206bd1c6ccdso1708275ad.3 for <gdb-patches@sourceware.org>; Wed, 04 Sep 2024 16:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725490912; x=1726095712; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dDce4HAQQcCQ1jWJcWdUbdTojTvf470IJhYew4MArP8=; b=jyExKDiwx3C6x8kC4ToasWuo3txKa+4eysLwx7STzRitQfO06dzPu+GFXsIoZ2QPNl toW9io9RtxA6q6/qI7WSOziiBw1pvnkzDiwqjrhpyMToDwP1bSeywiQiHL71yf4Vy7Ru CeqjX5GItZxBR3kAgGWhyzUrAQyab0DbXSeOLb5xxRKwx4aqxMwSMbPIGOyGTLkayh/M 9alZ7j+2ZGF4qu7lSSYHvOprnjT2YF8H92R19BWvWiEYXAhVT3Kn57wyiK5/bPYBdqNW ZCi16EBmvr6f/iQqh35fpO+sOw6Uiazu+y3z3gXGLMGmRvQOJuakgaAMRydQ44zq2Qhw m4Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725490912; x=1726095712; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dDce4HAQQcCQ1jWJcWdUbdTojTvf470IJhYew4MArP8=; b=fB3tpCKzetFATi+qMz7gP7DlvmHl9sl/2Kb6hfXyjYi5vsP+1C+KtjCUZunjuReXm9 T3y7nfEMBFcLiCFf9thJFXfy9ZMA6k1ACQYd+PDmbVfpeRaxvz+wvWLRvnmREA4IidZA NVhZdeOOv7ZiK/N7F88bvVk3xRlhgBskDpVnkdsPT9XFejKqleu5QP27seMu3m5QA6IX lCcNTIWzp5yPsW7TGRgv4/BHWyOE6Iv6/0Er7rOcT7Ah9nqybbf+yZ+1+sNGhIIRqmfF vvUaWDDGqnffiw13DSDLaOR1kFJHCQw/1aYDvRdLH0UPLlMONlsAU+Q+l/UsrYnae/VO EF+w== X-Gm-Message-State: AOJu0Yz+gGb8fHtrm1NqghHImYusYoVTHh+dbSqX5iYFVtIaBf31JSMn J2Sk13Abh1OU3GIw7Sk4eMHy7aSlwo2BczcuTrmovf5zUjE7sVkg X-Google-Smtp-Source: AGHT+IGcQdOojFIvIv2Q+tNg7XEu7Njf1ek4Y5nRF1jVbKjmRfldBkuoKvZ6/8AK6CKK+lGXoeUrZA== X-Received: by 2002:a17:903:1d0:b0:206:b79e:5780 with SMTP id d9443c01a7336-206b79e59fcmr36251655ad.24.1725490912050; Wed, 04 Sep 2024 16:01:52 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.129.158]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea384e1sm18064845ad.145.2024.09.04.16.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 16:01:51 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 79533740153; Wed, 4 Sep 2024 16:01:50 -0700 (PDT) From: "H.J. Lu" <hjl.tools@gmail.com> To: gdb-patches@sourceware.org Cc: aburgess@redhat.com Subject: [PATCH] gdb-15-branch: Clear the X86_XSTATE_MPX bit in XCRO for x32 Date: Wed, 4 Sep 2024 16:01:50 -0700 Message-ID: <20240904230150.2248673-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3020.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
Series |
gdb-15-branch: Clear the X86_XSTATE_MPX bit in XCRO for x32
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | fail | Patch failed to apply |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | fail | Patch failed to apply |
Commit Message
H.J. Lu
Sept. 4, 2024, 11:01 p.m. UTC
commit 868883583e7520ff1bd99fcb224d2b33a990edff
Author: Andrew Burgess <aburgess@redhat.com>
Date: Sat Mar 23 16:17:36 2024 +0000
gdb/arch: assert that X86_XSTATE_MPX is not set for x32
added
if (xcr0 & X86_XSTATE_MPX)
{
/* MPX is not available on x32. */
gdb_assert (!is_x32);
regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
}
But x32 is a software convention. There is no x32 mode in hardware and
CPU always returns the 64-bit mode XCR0 value for x32 processes. This
regression was fixed on master branch by
commit bf616be99153b43c1077be9dbb7b081b4c080031 (HEAD)
Author: Andrew Burgess <aburgess@redhat.com>
Date: Thu Jan 25 14:25:57 2024 +0000
gdb/gdbserver: share some code relating to target description creation
which used the gdbserver code to clear the X86_XSTATE_MPX bit in XCR0 for
x32. Fix this regression on gdb-15-branch by clearing the X86_XSTATE_MPX
bit in XCR0 for x32 in gdb.
PR gdb/32143
* x86-linux-nat.c (x86_linux_nat_target::read_description): Clear
the X86_XSTATE_MPX bit in XCR0 for x32.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gdb/x86-linux-nat.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Wed, Sep 4, 2024 at 4:01 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > commit 868883583e7520ff1bd99fcb224d2b33a990edff > Author: Andrew Burgess <aburgess@redhat.com> > Date: Sat Mar 23 16:17:36 2024 +0000 > > gdb/arch: assert that X86_XSTATE_MPX is not set for x32 > > added > > if (xcr0 & X86_XSTATE_MPX) > { > /* MPX is not available on x32. */ > gdb_assert (!is_x32); > regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum); > } > > But x32 is a software convention. There is no x32 mode in hardware and > CPU always returns the 64-bit mode XCR0 value for x32 processes. This > regression was fixed on master branch by > > commit bf616be99153b43c1077be9dbb7b081b4c080031 (HEAD) > Author: Andrew Burgess <aburgess@redhat.com> > Date: Thu Jan 25 14:25:57 2024 +0000 > > gdb/gdbserver: share some code relating to target description creation > > which used the gdbserver code to clear the X86_XSTATE_MPX bit in XCR0 for > x32. Fix this regression on gdb-15-branch by clearing the X86_XSTATE_MPX > bit in XCR0 for x32 in gdb. > > PR gdb/32143 > * x86-linux-nat.c (x86_linux_nat_target::read_description): Clear > the X86_XSTATE_MPX bit in XCR0 for x32. > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > --- > gdb/x86-linux-nat.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c > index a3d8ffb60f1..1214aa4be96 100644 > --- a/gdb/x86-linux-nat.c > +++ b/gdb/x86-linux-nat.c > @@ -180,6 +180,12 @@ x86_linux_nat_target::read_description () > xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET > / sizeof (uint64_t))]; > > +#ifdef __x86_64__ > + /* No MPX on x32. */ > + if (is_x32) > + xcr0 &= ~X86_XSTATE_MPX; > +#endif > + > m_xsave_layout = x86_fetch_xsave_layout (xcr0, x86_xsave_length ()); > } > } > -- > 2.46.0 > Is this OK for gdb-15-branch? Another option is to revert commit 868883583e7520ff1bd99fcb224d2b33a990edff Author: Andrew Burgess <aburgess@redhat.com> Date: Sat Mar 23 16:17:36 2024 +0000 gdb/arch: assert that X86_XSTATE_MPX is not set for x32 Either will work. Thanks.
On Wed, Sep 04, 2024 at 04:01:50PM -0700, H.J. Lu wrote: > commit 868883583e7520ff1bd99fcb224d2b33a990edff > Author: Andrew Burgess <aburgess@redhat.com> > Date: Sat Mar 23 16:17:36 2024 +0000 > > gdb/arch: assert that X86_XSTATE_MPX is not set for x32 > > added > > if (xcr0 & X86_XSTATE_MPX) > { > /* MPX is not available on x32. */ > gdb_assert (!is_x32); > regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum); > } > > But x32 is a software convention. There is no x32 mode in hardware and > CPU always returns the 64-bit mode XCR0 value for x32 processes. This > regression was fixed on master branch by > > commit bf616be99153b43c1077be9dbb7b081b4c080031 (HEAD) > Author: Andrew Burgess <aburgess@redhat.com> > Date: Thu Jan 25 14:25:57 2024 +0000 > > gdb/gdbserver: share some code relating to target description creation > > which used the gdbserver code to clear the X86_XSTATE_MPX bit in XCR0 for > x32. Fix this regression on gdb-15-branch by clearing the X86_XSTATE_MPX > bit in XCR0 for x32 in gdb. > > PR gdb/32143 > * x86-linux-nat.c (x86_linux_nat_target::read_description): Clear > the X86_XSTATE_MPX bit in XCR0 for x32. > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Thank you. Approved for the gdb-15-branch. > --- > gdb/x86-linux-nat.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c > index a3d8ffb60f1..1214aa4be96 100644 > --- a/gdb/x86-linux-nat.c > +++ b/gdb/x86-linux-nat.c > @@ -180,6 +180,12 @@ x86_linux_nat_target::read_description () > xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET > / sizeof (uint64_t))]; > > +#ifdef __x86_64__ > + /* No MPX on x32. */ > + if (is_x32) > + xcr0 &= ~X86_XSTATE_MPX; > +#endif > + > m_xsave_layout = x86_fetch_xsave_layout (xcr0, x86_xsave_length ()); > } > } > -- > 2.46.0 >
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index a3d8ffb60f1..1214aa4be96 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -180,6 +180,12 @@ x86_linux_nat_target::read_description () xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET / sizeof (uint64_t))]; +#ifdef __x86_64__ + /* No MPX on x32. */ + if (is_x32) + xcr0 &= ~X86_XSTATE_MPX; +#endif + m_xsave_layout = x86_fetch_xsave_layout (xcr0, x86_xsave_length ()); } }