From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2064.outbound.protection.outlook.com [40.107.243.64]) by sourceware.org (Postfix) with ESMTPS id 0BEBA3858D28 for ; Tue, 10 Oct 2023 16:30:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BEBA3858D28 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFVz8XX893SHwTEWJci3tWrPqFLAVtepeyxN2+OlIi3kC+bd+XujjS3ZzY6t/z0bha6LfiQFoFL/AUhCN4hf9AxpMKRdBDf2siMOEyRf12praOk7vPeQ5Yl4uIbS7SIoFHS+/vIWHolBo8GGAkMQ6R3KufhhwTs7Dydmwwsy1beOIky4hAq7eTjlRmGEixeTNF2zJl49XvWZl1xCoZxjSKrLpXOSEykHALtf2fn3vsWwGlr8q7052qpZ7evGUuo0HmN+osNusuuMlOEQWJxWVo2cmMIJ1QPz3c76Ei78SuDIF7NY39wu+BFRNW0ljttjZwlVZjasP4AbGVmlyrw/Kw== 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=XtLtQdSyG2RrboGlBDBzogkGvJtVfybtaSE4BlSvpGk=; b=AD/R3gCpVDoQhGSFwKCMX219/w9BlN6f/Sy8hlo+emG7bJJYxBBerYe71FVbqk5yN1tQ/ZLPuLgeGRieM9Xlc5qDYZf1D07KFP00CzrmMN5WLv3/mllKfT5HtBjTUJCSklhyK0Ag2ptmo/K1mv4pAZhI2EcSb9SpuFr4d4qbKeDFsN5XYkECoh3kK+3z1PMuO4+0/fB7RgqSY5DZ2EZgmK65Z8wrdLX3VCAKD2EAven2zPVJec56Md3wlE4LDk35/EidV6ybQg+7rnol50jO8KhygZjQh7LFbcR/A7BagR0g/XOMut05e8sxr5F5L9huk6d4Qu1hx0F5D+/CTPHvXA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XtLtQdSyG2RrboGlBDBzogkGvJtVfybtaSE4BlSvpGk=; b=hBmNAJGOP9GNFq0VyABwLd8R7gb7W27uAXZGwRCwSIWGavw8/OGp/zsTkB52S2qqwf8ogHNK1GznIyuaq+mjiEoyvNIesGWVhGfx9/zoSEjFGwR2zViya36qeQReV8deeZT9yuQAodTPtfyb/X+MnZoZGpuzBrCtQ4gmllSTVxI= Received: from BY5PR12MB4965.namprd12.prod.outlook.com (2603:10b6:a03:1c4::16) by BY5PR12MB4289.namprd12.prod.outlook.com (2603:10b6:a03:204::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 16:30:50 +0000 Received: from BY5PR12MB4965.namprd12.prod.outlook.com ([fe80::bea6:412f:e04a:f2a7]) by BY5PR12MB4965.namprd12.prod.outlook.com ([fe80::bea6:412f:e04a:f2a7%4]) with mapi id 15.20.6863.032; Tue, 10 Oct 2023 16:30:49 +0000 From: "George, Jini Susan" To: John Baldwin , "gdb-patches@sourceware.org" CC: Felix Willgerodt , Felix , Simon Marchi , "Balasubrmanian, Vignesh" Subject: RE: [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note Thread-Topic: [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note Thread-Index: AQHZ+t+QbbcDlnPzDEabtoSnpzYJWbBDK7yg Date: Tue, 10 Oct 2023 16:30:49 +0000 Message-ID: References: <20231009183617.24862-1-jhb@FreeBSD.org> In-Reply-To: <20231009183617.24862-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=3f2e2a19-3603-4f05-951b-be74dd746555;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=2023-10-10T15:46:16Z;MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BY5PR12MB4965:EE_|BY5PR12MB4289:EE_ x-ms-office365-filtering-correlation-id: bc7629ee-e8bd-4df3-05c5-08dbc9ae439d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y9VGZxkvOD4xVirYNTSxzx8pnskG3EMtBNEuqb8G4oCh5yw9E1il7PNocD2CHUgvThEXWPYjJA+su9qulvIrJ4ydFW2psdnQ0VxeiR+yqRt2oEbt0by1O/QyyK50BbG8XN5ZO0ihLIn7mde3rZYXNBigowHA1QJhp3axFZcT3jW3VHfyIUOedw8OAoLrzX6W4XLPJtIJOe8ORB7lieZFlU79lE3s1158IfQtEuuspXWIl1ySOd4A/4g8q3ShR9lFwq1XgkEaPArNaZH/zKqonbatSw00vFql7haE7W0uNpDbaNpajHIsnV8PX7Hv9edhLgtCivFpdD44/Sn2bVvNKBUslQSEo+ZswU/cVb54vlJpNkGBpvAkYEb9bRZvrB2x3fMqxzj1HNjsJ1HiksaVzV2IIci70LEk1meBAWX7mH4dT1amDXF7qGRJbR8XWv27w7yaJ/M+FcNvyLE6Zlf9jzgx3uu6OoTrmeVAdiWtPhO7XHbzbbW6s07hcOyCSU3FbsogqdIYmZd6s1+BlcWGp6EfLVJK5/+y1kINqvoqtpwpLNf2aecZS5R0BPS0t32As0Q4BlbQJr9pQPIkgTHiBfSJnzsdO15LyHJcCy5oqE9bb7wpcJA9sEQCZdcQkK4hIhFRFpC4hzNJ85N+BRsCKg== 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:(13230031)(366004)(376002)(346002)(136003)(39860400002)(396003)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(6506007)(2906002)(7696005)(9686003)(26005)(3613699003)(38100700002)(122000001)(38070700005)(33656002)(86362001)(55016003)(83380400001)(52536014)(5660300002)(8676002)(4326008)(8936002)(478600001)(316002)(41300700001)(66946007)(66476007)(66446008)(66556008)(64756008)(54906003)(76116006)(110136005)(71200400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?StdeCArXt65qfPoS+7t/kEoxV4wfDXq88QuRiCexQIa4lNsxPAxH2TJpqWLE?= =?us-ascii?Q?Tls2DqdB9J63hS14m3ps5A7EGDKm2VLQF8/AnvuOnyg3KlXB6byCmqYL0ZT4?= =?us-ascii?Q?u4xINBzYyHfHKo01WubDVSQHHVt3/DpbbUK+QRu79E0tsOMZzRAA4qoanKk7?= =?us-ascii?Q?KT9k7bXPiZmG7WE2Gzie1zlfyu4G33gG9bQTV6o/nLUSnGok9rUc9TZQ602N?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4vXTpV3S7sO6rQK/KePpxQw4j?= =?us-ascii?Q?09XjmvHyEbqW4/uadp2qJZYdo2e51YI5NRa9sVBGX8t0C2m+DTyvkixmLd41?= =?us-ascii?Q?Ea83x71GHru134amEfpvroS2E0GBLGHxDRquYQcFeepOo/KQkHjwy9T2OTUd?= =?us-ascii?Q?ETKU1BKVZuaICe5pyzRN+M4NaSlVpmyXC8RUJtUwLdyRM6V26iWqWIzkqVoV?= =?us-ascii?Q?AZ9aMdvnmZ6s6ZReEYBfBn66XIxzaeqs+RG0kaGGop5GnWQ0OptQgimLTdVt?= =?us-ascii?Q?NfRowUuQQx6VfrbjUcku1pnSTNvK03N415fC/WLirtOc4ZnOMn9bSjGbnO5I?= =?us-ascii?Q?7zDUUZvtTLkFBKJWiZXjvInko8hAL+8krKU6CUTxpdbpUFljxZ8qtZSvCwyM?= =?us-ascii?Q?szLASu0fU4ictEL1pReCpCXcnBuBJm/5ATM1KROTtbUEj1pEY3J5p5x3MQpM?= =?us-ascii?Q?R/NyVo8+UFv6OuIY34M=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: bc7629ee-e8bd-4df3-05c5-08dbc9ae439d X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2023 16:30:49.8842 (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: 4RUmPleUzEiJpvs7BM38ykOY8ZhbO4fAhrYwTp0zq1Oj1KcI63pRB9lgR9zdLKHlEXXiDyyIjv+kDZN0K0zT+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4289 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: [Public] Thanks for doing this, John. I am yet to go through these patches, but I wa= nted to let you know that for the Linux kernel, we have a patch for creatin= g the core dump .note section which is being reviewed internally at this po= int. The patch follows the same structure layout proposed by you here. We w= ould cross check to confirm that the proposed Linux patch modifications are= in line with your FreeBSD changes. Regards, Jini. >>-----Original Message----- >>From: John Baldwin >>Sent: Tuesday, October 10, 2023 12:06 AM >>To: gdb-patches@sourceware.org >>Cc: Willgerodt; Felix ; George; George, Jini = Susan >>; Simon Marchi >>Subject: [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note >> >>Caution: This message originated from an External Source. Use proper caut= ion >>when opening attachments, clicking links, or responding. >> >> >>One of the shortcomings of the previous XSAVE patch series is that it dep= ends on >>heuristics based on the total XSAVE register set size and >>XCR0 mask to infer layouts of the various register blocks for core dumps.= This >>series introduces a new x86-specific core dump note intended to supplant = these >>heuristics by storing the raw CPUID leaves describing the XSAVE layout in= core >>dumps. >> >>This series proposes a new core dump note, NT_X86_CPUID (0x205), which >>contains an array of structures. Each structure describes an invidual CP= UID sub- >>leaf containing both the inputs to CPUID (%eax and %ecx) and the outputs >>(%eax, %ebx, %ecx, and %edx) in a format roughly matching the follow C >>structure: >> >>struct cpuid_leaf >>{ >> uint32_t leaf; >> uint32_t subleaf; >> uint32_t eax; >> uint32_t ebx; >> uint32_t ecx; >> uint32_t edx; >>}; >> >>This format is not XSAVE-specific and implementations could choose to add >>additional CPUID leaves to this structure if needed in the future. >>Consumers of this note should lookup the value of required leaves and ign= ore >>any unneeded leaves. >> >>An alternate approach might be to write out a more XSAVE-specific note th= at is >>an array containing the offset and size of each XSAVE region. >> >>Note that either approach would enable storing XSAVE notes in the "compac= t" >>format at some point in the future. >> >>This series adds support for reading/writing the note to binutils as well= as suport >>for parsing and generating the note in GDB. It also hooks this into both= the >>FreeBSD and Linux x86 architectures in GDB to read the XSAVE layout from = this >>note when present, and to write out a note when generating a core via `gc= ore'. >>I've done some limited testing on FreeBSD/amd64 and Linux/x86-64, but it = could >>probably use some more testing on Linux in particular. (I know Simon has= an >>AMD machine with a layout not handled by the current heuristics for >>example.) >> >>For the gcore side, a new TARGET_OBJECT_X86_CPUID is used to fetch the >>current note contents from a native target. There is still one gap even = with this >>patch series which is that if you are connected to a remote target (e.g. >>gdbserver), we currently do not have a known XSAVE layout to use when wri= ting >>out a core via `gcore'. One option that would close this gap would be to= extend >>the remote protocol to permit reading this new object from a debug server= . The >>remote target could then implement fetching this object and also make use= of >>this object to implement the target::fetch_x86_xsave_layout method which >>would close that gap. Another possibility would be to just pick a "known= " >>XSAVE format that matches one of the heuristics. >> >>The series is available from git@github.com:bsdjhb/gdb.git on the >>`nt_x86_cpuid' branch. >> >>I also have an implementation of this core dump note available for FreeBS= D's >>kernel, though I won't merge it until we've collectively settled on the f= ormat: >>https://reviews.freebsd.org/D42136 >> >>Things I have not done and could use help with: >> >>- Implementation for the Linux kernel >> >>- Coordination with folks from LLDB >> >>John Baldwin (13): >> binutils: Support for the NT_X86_CPUID core dump note >> i387-tdep: Add function to read XSAVE layout from NT_X86_CPUID >> gdb: Use NT_X86_CPUID in x86 FreeBSD architectures to read XSAVE >> layouts >> gdb: Use NT_X86_CPUID in x86 FreeBSD architectures to read XSAVE >> layouts >> nat/x86-cpuid.h: Remove non-x86 fallbacks >> nat/x86-cpuid: Add a function to build the contents of a NT_X86_CPUID >> note >> x86_elf_make_cpuid_note: Helper routine to build NT_X86_CPUID ELF note >> x86-fbsd-nat: Support fetching TARGET_OBJECT_X86_CPUID objects >> fbsd-tdep: Export fbsd_make_corefile_notes >> {amd64,i386}-fbsd-tdep: Include NT_X86_CPUID notes in core dumps from >> gcore >> x86-linux-nat: Support fetching TARGET_OBJECT_X86_CPUID objects >> linux-tdep: Export linux_make_corefile_notes >> {amd64,i386}-linux-tdep: Include NT_X86_CPUID notes in core dumps from >> gcore >> >> bfd/elf-bfd.h | 2 + >> bfd/elf.c | 35 +++++++++++ >> binutils/readelf.c | 2 + >> gdb/amd64-fbsd-tdep.c | 1 + >> gdb/amd64-linux-tdep.c | 1 + >> gdb/configure.nat | 13 ++-- >> gdb/fbsd-tdep.c | 5 +- >> gdb/fbsd-tdep.h | 7 +++ >> gdb/i386-fbsd-tdep.c | 18 +++++- >> gdb/i386-fbsd-tdep.h | 7 +++ >> gdb/i386-linux-tdep.c | 18 +++++- >> gdb/i386-linux-tdep.h | 7 +++ >> gdb/i387-tdep.c | 132 +++++++++++++++++++++++++++++++++++++++++ >> gdb/i387-tdep.h | 8 +++ >> gdb/linux-tdep.c | 5 +- >> gdb/linux-tdep.h | 7 +++ >> gdb/nat/x86-cpuid.c | 91 ++++++++++++++++++++++++++++ >> gdb/nat/x86-cpuid.h | 29 +++------ >> gdb/target.h | 2 + >> gdb/x86-fbsd-nat.c | 37 ++++++++++++ >> gdb/x86-fbsd-nat.h | 9 +++ >> gdb/x86-linux-nat.c | 37 ++++++++++++ >> gdb/x86-linux-nat.h | 9 +++ >> gdb/x86-tdep.c | 22 +++++++ >> gdb/x86-tdep.h | 9 +++ >> include/elf/common.h | 2 + >> 26 files changed, 480 insertions(+), 35 deletions(-) create mode 100644 >>gdb/nat/x86-cpuid.c >> >>-- >>2.41.0