From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) by sourceware.org (Postfix) with ESMTPS id 47CA73955C88 for ; Tue, 10 May 2022 10:48:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 47CA73955C88 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cS55Qdh3qSq0L3Ji29Jj0No+MvzyBBqsZFvtboDMuNGPy3gVNxBtmiMSzxlfTQLIbx4B5UyDnKDCMR5fdL5cdpFG7sqM01pxYZlEijYbfi1AVIZ6pM3lL6BbrKl/QPAVGMSZjZMSP73Rreh138BsLzoxsrXKCAp45IWnAOU23UZdu4W21b35avl1JscfW+Se0XA09mK6pgXJ6vmuNl7aks+z4rcSLDAZhCYYMGXfvwKbgqSh8gXlZhTdjYv+p4m7VeYoCpQJEG+zJn61tZ4T2sBDm3qfOqxCVc7dHpQjtL7wEc2jINb8cr87aBVkTs3VHitKnFSVOhHvnYVCHm0YCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D1IYVzqzdA/WGVi5mVn91p1qrgQi0Pih9zTUJpHDKfE=; b=QdDs2uRsN4uZ0qdpiXH+We/1NM9sztVfvoLtOhWZhqzCcMgr98343nubbt8FJBBhmjdqUz2A3UvpumSm11KszGXqJS6DM0xESuP6B67roBKNY/owgB51xahySVjlBoVVUYGJKjepmN/rrfOsIx3WswKAFAOVWRG7y1sGDwcEMp8lkNn0CwcPJ86n/+fL1gzxjN+IlYH1tVsIPKekx7GdwOQEK8qCdwIXKa8y0M+gRtlZ5Z8M7SU94uRyzSyGxIZLE8N3YbtgPyCV8MSskcWvlTjsfHJjK5sqr5iowbo1iQB4PhZ7ECRkrfJ14MjTViJIvWPtxDjqvOFVJAM6qnENnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from BY5PR12MB4965.namprd12.prod.outlook.com (2603:10b6:a03:1c4::16) by DM4PR12MB5230.namprd12.prod.outlook.com (2603:10b6:5:399::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Tue, 10 May 2022 10:48:25 +0000 Received: from BY5PR12MB4965.namprd12.prod.outlook.com ([fe80::8126:6133:60e9:cc7c]) by BY5PR12MB4965.namprd12.prod.outlook.com ([fe80::8126:6133:60e9:cc7c%4]) with mapi id 15.20.5227.023; Tue, 10 May 2022 10:48:24 +0000 From: "George, Jini Susan" To: John Baldwin , "gdb-patches@sourceware.org" Subject: RE: [PATCH v3 00/13] Handle variable XSAVE layouts Thread-Topic: [PATCH v3 00/13] Handle variable XSAVE layouts Thread-Index: AQHYXzGdN2i3PEyRo026+uGfP23BHK0X7jbw Date: Tue, 10 May 2022 10:48:24 +0000 Message-ID: References: <20220503210515.30739-1-jhb@FreeBSD.org> In-Reply-To: <20220503210515.30739-1-jhb@FreeBSD.org> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ActionId=7cab6fcd-b76f-4d84-9c32-b0bcf342eaad; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ContentBits=0; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Enabled=true; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Method=Privileged; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Name=Public-AIP 2.0; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SetDate=2022-05-10T10:11:36Z; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e141d4af-b417-4e44-6262-08da32729bc1 x-ms-traffictypediagnostic: DM4PR12MB5230:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OfhXFBrQhyWgwegAhWNiXMkV4OiW9n9S7FUIIJDzPvhcFOINGyvjaLmnFhWIJRqYuqvqGuEFumkhtMZfdJEhvBeKZiiPvtqoJAbCUGO3WavYUKvX/Q0+b//OdN9DbrMBFRd3Ok6uBoYFwjkkDLg2NTONa+0V8HqN0ZZUUALRkr4eTPT/8N6CUh19iGuFzMd1gpbOOMgS9iV4z7gsekzjEGUrbPSfkIbXtzFNteYXWvFlD+hIIjKasmwE4F8UwZgXD4W8BgaJHihYQtuNj9Zv136TdbE0MaHpES9cFqh2hlBhvlQyFP7mpjshtjHWPwzNvF8lQev3sxGuGQanCD9HTSl3xd+JriNBfrRvDSON44RG+lTLkiQU/+BJkdQdrWDg3tv82GKOTTGZ9kI6yljDn4O3AdRWMdTs0C55zXEWmFES3kWU+d2QKxSrX+eo3ym7wBuvizHLillrQ2trwMYTpQspcR7ZXneyZt/6XII1DFpVJYC/2DkhyRNhwcD41Upw9joZvwc1qklRKOo0xDkh9oViFDbu8We957NcYas9PDx/QAsh3Z3dHChMfumjs5TfO2J8gBAVMzS87nmvHvS0OP4VHslGVFwbVAh2ndzdW0vEdO7aG9ckFYjZLTjP3fis2+607R2qvzYoyKyhFO9SzCBXn/E7fQBrjpUNewo9em8tBT7zidesNt0nE4yp2uVnF9xwM2oXz6ac0iZ14NpzrA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR12MB4965.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(8936002)(52536014)(76116006)(66476007)(64756008)(110136005)(66446008)(66946007)(66556008)(4326008)(8676002)(316002)(122000001)(9686003)(6506007)(26005)(7696005)(71200400001)(508600001)(38100700002)(33656002)(38070700005)(2906002)(55016003)(83380400001)(5660300002)(186003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?h6w5Nn0yPKewUUtOXqHX91gmqbyAO8sZQj+rcEaSLMaX74AahjREcHXerfHH?= =?us-ascii?Q?50jV8sHVGp1iQd7ZWpWPndvb3U43NM707DsGSjnHB7+OwIFjpUfgkFCLORY8?= =?us-ascii?Q?p6ixb6sibODwrHwptP2eOSZ2HRZcc+xzYf2IRADVl7SgIEmBCt8uARYLuQvB?= =?us-ascii?Q?P5rrkZ7m8M5ypIFag+9ozfl+eQnkd8jUSK66Kh5Llke0kjVeLv71QZtmlvXh?= =?us-ascii?Q?+dGN7R3/SyoZCeYFlaHuBL9BQwhF+5JjLEwP+UorzvBe5OkCrJ08RFhWFJfW?= =?us-ascii?Q?JVWLklTrBZC01a0mg3suXrZAB7klwmNkVl4ve+I/DGfaLrSO9kuO7IihuDPX?= =?us-ascii?Q?z+m1tKoeYkhzu73sbVzQ9UbG1qZ5s4iKVZYcm7JbD0GiLCAn6CvgWobFdTNs?= =?us-ascii?Q?ctXhhAVqNieSc7ENbBUMzsliRrQ2RLtEAIoPPO1S6KFWz+PbU9Ve70SeDi53?= =?us-ascii?Q?s72tUxUX/Ljp/z743uhWxgsaf7XLuKs4o7RJjy1FCVu+r+BfzO+VHZ1AUJ4p?= =?us-ascii?Q?muB28CrECG47omZHKgH5Ba7U33Fx4oFIoiUkRNMyAfPq7viB0iWberOUjJNX?= =?us-ascii?Q?8Pkzoruafg+FQ8DNvn6LOcQd3TGtI/3d/pbVrtFIrQwEcwEdE3qn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xul20BepqgdE73SnhA/x4y2g9ZTiw?= =?us-ascii?Q?pEZODMeb0oRGGZ+uqoHOpZ9kraevnEfLUgWVEh6y6B51PRXPHH26lTBwgiWY?= =?us-ascii?Q?c6O01h4gjr/U5uzw57WVRwbBX+8H5bNPmHi7xn2cWco9VGMCa0AaKq3adcbb?= =?us-ascii?Q?a/uctTtwvasE7xBJnvRXvS9WVwh89YBgd7w/LXpIuiad/xo+9EO6LMw03b/9?= =?us-ascii?Q?pp4T5GrjfQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4965.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e141d4af-b417-4e44-6262-08da32729bc1 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2022 10:48:24.6836 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: eD9Pg+wFB0NAga8Qe9jpDNo6qFc6ScZiXqzp/C7SjVy+bcH3E71s5Cb2JpU2Xh2chRzdiF5/n9iE8wpzYcTGow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5230 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 10:48:30 -0000 [Public] Thanks again for doing this, John, Felix and Aleksandar. I went through the= changes and tested on a few AMD CPUs of differing xsave layouts. As of now= these changes seem to cover the current AMD CPU implementations. Going for= ward, if additional AMD specific layouts have to be added, we would do it. The changes look good to me (I am no approver, though) for the most part. A= few minor comments: Nit: in gdb/i386-tdep.h, it might be good to add a comment for the followin= g line (line # 148) for consistency with the rest of the fields. x86_xsave_layout xsave_layout; Nit: You might want to modify the comments preceding the modified xsave_*_= offset[] definitions in gdb/i387-tdep.c to reflect that the offset to the l= ocations are at (tdep)->xsave_layout.*_offset + xsave_*_offset[REGNUM]. Nit: Line 771 in gdb/i387-tdep.c. Might make sense to remove the "HI16_ZMM_= area +" part. I also agree with your proposed layout of the corefile note for the xsave l= ayout. Thanks, Jini. >>-----Original Message----- >>From: John Baldwin >>Sent: Wednesday, May 4, 2022 2:35 AM >>To: gdb-patches@sourceware.org >>Cc: Willgerodt, Felix ; George, Jini Susan >> >>Subject: [PATCH v3 00/13] Handle variable XSAVE layouts >> >>[CAUTION: External Email] >> >>Changes since V2: >> >>- Pulled in some of the changes from Intel's branch Felix pointed me >> at, in particular gdbserver support. However, relative to that >> branch these patches make the following changes: >> >> - The i387_* structs and class remain in gdbserver/i387-fp.cc >> rather than moving to gdbsupport/. >> >> - Rather than invoking cpuid each time an XSAVE area is parsed, >> the x86_xsave_layout structure is used to hold offsets and >> CPUID is only invoked the first time NT_X86_XSTATE is probed >> with the offsets cached for later use. >> >> - I did not update the ChangeLog bits of these log messages, but >> probably they can be dropped for the Intel commits as GDB >> commits generally do not include these now? >> >>- Added Linux support both for gdbarches and the x86 native targets. >> I wasn't sure if PT_GETREGSET on Linux provides a way to query the >> size of the XSAVE register set (on FreeBSD PT_GETREGSET returns >> the register set's size in iov_len of the passed-in iovec if the >> original iovec has a NULL pointer and zero length), so I used >> cpuid leaf 0xd subleaf 0x0 to query the size of the register set >> for the native targets as well as for the Linux gdbserver support. >> >>Note that this still depends on the size and xcr0 mask heuristic for Linu= x and >>FreeBSD core dumps to determine the layout (and I have not added any >>additional layouts as I wasn't sure if Jini was intending to add addition= al AMD- >>specific layouts). I'd kind of like to land this series before doing a f= ollowup to >>flesh out a new core dump note. >> >>I think for the new core dump note what I would propose is a simple array= of >>CPUID results for sub-leaves of the 0xd leaf (as a NT_X86_XSTATE_CPUID or= the >>like) where each entry in the array contained the subleaf as well as eax,= ebx, ecx, >>and edx results. This note might even eventually permit handling "compac= t" >>XSTATE in future core dumps rather than only "standard". >> >>I have tested this on both an AMD Ryzen 9 5900X and Intel Core i7-8650U o= n >>FreeBSD/amd64 as well as on a Linux/x86-64 VM on the Intel system. I als= o >>tested FreeBSD/i386 in a VM on the AMD system. >> >>Aleksandar Paunovic (2): >> gdbserver: Refactor the legacy region within the xsave struct >> gdbserver: Read offsets of the XSAVE extended region via CPUID >> >>John Baldwin (11): >> x86: Add an x86_xsave_layout structure to handle variable XSAVE >> layouts. >> core: Support fetching TARGET_OBJECT_X86_XSAVE_LAYOUT from >> architectures. >> nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count. >> x86 nat: Add helper functions to save the XSAVE layout for the host. >> gdb: Update x86 FreeBSD architectures to support XSAVE layouts. >> gdb: Support XSAVE layouts for the current host in the FreeBSD x86 >> targets. >> gdb: Update x86 Linux architectures to support XSAVE layouts. >> gdb: Support XSAVE layouts for the current host in the Linux x86 >> targets. >> gdb: Use x86_xstate_layout to parse the XSAVE extended state area. >> gdbserver: Add a function to set the XSAVE mask and size. >> x86: Remove X86_XSTATE_SIZE and related constants. >> >> gdb/amd64-fbsd-nat.c | 40 +-- >> gdb/amd64-fbsd-tdep.c | 8 +- >> gdb/amd64-linux-nat.c | 6 +- >> gdb/amd64-linux-tdep.c | 8 +- >> gdb/configure.nat | 8 +- >> gdb/corelow.c | 22 ++ >> gdb/gdbarch-components.py | 13 + >> gdb/gdbarch-gen.h | 10 + >> gdb/gdbarch.c | 32 +++ >> gdb/i386-fbsd-nat.c | 39 +-- >> gdb/i386-fbsd-tdep.c | 37 ++- >> gdb/i386-fbsd-tdep.h | 6 + >> gdb/i386-linux-nat.c | 8 +- >> gdb/i386-linux-tdep.c | 34 ++- >> gdb/i386-linux-tdep.h | 6 + >> gdb/i386-tdep.c | 36 ++- >> gdb/i386-tdep.h | 3 + >> gdb/i387-tdep.c | 493 ++++++++++++++++++++++++------------- >> gdb/i387-tdep.h | 8 + >> gdb/nat/x86-cpuid.h | 27 ++ >> gdb/nat/x86-xstate.c | 65 +++++ >> gdb/nat/x86-xstate.h | 35 +++ >> gdb/target.h | 2 + >> gdb/x86-fbsd-nat.c | 51 ++++ >> gdb/x86-fbsd-nat.h | 29 ++- >> gdb/x86-linux-nat.c | 33 +++ >> gdb/x86-linux-nat.h | 11 + >> gdbserver/configure.srv | 12 +- >> gdbserver/i387-fp.cc | 312 ++++++++++++++--------- >> gdbserver/i387-fp.h | 2 +- >> gdbserver/linux-x86-low.cc | 10 +- >> gdbsupport/x86-xstate.h | 69 ++++-- >> 32 files changed, 1067 insertions(+), 408 deletions(-) create mode 1006= 44 >>gdb/nat/x86-xstate.c create mode 100644 gdb/nat/x86-xstate.h >> >>-- >>2.34.1