From: Luis Machado <luis.machado@arm.com>
To: "Schimpe, Christina" <christina.schimpe@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "thiago.bauermann@linaro.org" <thiago.bauermann@linaro.org>,
"eliz@gnu.org" <eliz@gnu.org>
Subject: Re: [PATCH v4 04/11] gdb, gdbserver: Use xstate_bv for target description creation on x86.
Date: Mon, 23 Jun 2025 13:56:16 +0100 [thread overview]
Message-ID: <4c57870a-7233-49b6-990c-9e6f3b7ce452@arm.com> (raw)
In-Reply-To: <SN7PR11MB763849225CC9403BF7884B76F979A@SN7PR11MB7638.namprd11.prod.outlook.com>
On 6/23/25 13:46, Schimpe, Christina wrote:
> Hi Luis,
>
> Thanks a lot for the feedback. Please find my comments below.
>
>> -----Original Message-----
>> From: Luis Machado <luis.machado@arm.com>
>> Sent: Thursday, June 19, 2025 11:24 AM
>> To: Schimpe, Christina <christina.schimpe@intel.com>; gdb-
>> patches@sourceware.org
>> Cc: thiago.bauermann@linaro.org; eliz@gnu.org
>> Subject: Re: [PATCH v4 04/11] gdb, gdbserver: Use xstate_bv for target
>> description creation on x86.
>>
>> On 6/17/25 13:11, Christina Schimpe wrote:
>>> diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c index
>>> 252650b6390..9cac0645cdc 100644
>>> --- a/gdb/arch/amd64.c
>>> +++ b/gdb/arch/amd64.c
>>> @@ -30,14 +30,11 @@
>>>
>>> #include "../features/i386/x32-core.c"
>>>
>>> -/* Create amd64 target descriptions according to XCR0. If IS_X32 is
>>> - true, create the x32 ones. If IS_LINUX is true, create target
>>> - descriptions for Linux. If SEGMENTS is true, then include
>>> - the "org.gnu.gdb.i386.segments" feature registers. */
>>> +/* See amd64.h. */
>>
>> More appropriate to reference arch/amd64.h.
>
> True, will fix.
>
>>
>>>
>>> target_desc *
>>> -amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
>>> - bool segments)
>>> +amd64_create_target_description (uint64_t xstate_bv_mask, bool is_x32,
>>> + bool is_linux, bool segments)
>>> {
>>> target_desc_up tdesc = allocate_target_description ();
>>>
>>> @@ -62,13 +59,13 @@ amd64_create_target_description (uint64_t xcr0,
>> bool is_x32, bool is_linux,
>>> if (segments)
>>> regnum = create_feature_i386_64bit_segments (tdesc.get (),
>>> regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_AVX)
>>> + if (xstate_bv_mask & X86_XSTATE_AVX)
>>> regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_AVX512)
>>> + if (xstate_bv_mask & X86_XSTATE_AVX512)
>>> regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_PKRU)
>>> + if (xstate_bv_mask & X86_XSTATE_PKRU)
>>> regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
>>>
>>> return tdesc.release ();
>>
>> <...>
>>
>>> diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c index
>>> 835df53c75d..84f31439e7a 100644
>>> --- a/gdb/arch/i386.c
>>> +++ b/gdb/arch/i386.c
>>> @@ -29,10 +29,11 @@
>>> #include "../features/i386/32bit-segments.c"
>>> #include "../features/i386/pkeys.c"
>>>
>>> -/* Create i386 target descriptions according to XCR0. */
>>> +/* See i386.h. */
>>
>> arch/i386.h
>
> Will fix.
>
>>
>>>
>>> target_desc *
>>> -i386_create_target_description (uint64_t xcr0, bool is_linux, bool
>>> segments)
>>> +i386_create_target_description (uint64_t xstate_bv_mask, bool is_linux,
>>> + bool segments)
>>> {
>>> target_desc_up tdesc = allocate_target_description ();
>>>
>>> @@ -44,10 +45,10 @@ i386_create_target_description (uint64_t xcr0,
>>> bool is_linux, bool segments)
>>>
>>> long regnum = 0;
>>>
>>> - if (xcr0 & X86_XSTATE_X87)
>>> + if (xstate_bv_mask & X86_XSTATE_X87)
>>> regnum = create_feature_i386_32bit_core (tdesc.get (), regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_SSE)
>>> + if (xstate_bv_mask & X86_XSTATE_SSE)
>>> regnum = create_feature_i386_32bit_sse (tdesc.get (), regnum);
>>>
>>> if (is_linux)
>>> @@ -56,13 +57,13 @@ i386_create_target_description (uint64_t xcr0, bool
>> is_linux, bool segments)
>>> if (segments)
>>> regnum = create_feature_i386_32bit_segments (tdesc.get (),
>>> regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_AVX)
>>> + if (xstate_bv_mask & X86_XSTATE_AVX)
>>> regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_AVX512)
>>> + if (xstate_bv_mask & X86_XSTATE_AVX512)
>>> regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
>>>
>>> - if (xcr0 & X86_XSTATE_PKRU)
>>> + if (xstate_bv_mask & X86_XSTATE_PKRU)
>>> regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
>>>
>>> return tdesc.release ();
>>
>> <...>
>>
>>> diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index
>>> fc7c5f642ed..a82ad21da27 100644
>>> --- a/gdb/x86-linux-nat.c
>>> +++ b/gdb/x86-linux-nat.c
>>> @@ -97,15 +97,20 @@ const struct target_desc *
>>> x86_linux_nat_target::read_description () {
>>> /* The x86_linux_tdesc_for_tid call only reads xcr0 the first time it is
>>> - called, the xcr0 value is stored here and reused on subsequent calls. */
>>> - static uint64_t xcr0_storage;
>>> + called. The mask is stored in XSTATE_BV_STORAGE and reused on
>>> + subsequent calls. Note that GDB currently supports features for user
>>> + state components only. However, once supervisor state components are
>>> + supported in GDB XSTATE_BV_STORAGE will not be configured based on
>>> + xcr0 only. */
>>
>> Something about the comment above reads off in the last phrase. Is there a
>> missing connection word?
>
> I agree, would this be a bit better?
>
> "However, once supervisor state components are supported in GDB, the value
> XSTATE_BV_STORAGE will not be configured based on xcr0 only."
>
Yes, that reads better, thanks.
I don't think you need a new iteration for these fixes though. They could be local.
>>
>>> + static uint64_t xstate_bv_storage;
>>>
>>> if (inferior_ptid == null_ptid)
>>> return this->beneath ()->read_description ();
>>>
>>> int tid = inferior_ptid.pid ();
>>>
>>> - return x86_linux_tdesc_for_tid (tid, &xcr0_storage,
>>> &this->m_xsave_layout);
>>> + return x86_linux_tdesc_for_tid (tid, &xstate_bv_storage,
>>> + &this->m_xsave_layout);
>>> }
>>>
>
>> Otherwise this looks OK to me. I suppose this was regression tested? I'd be a bit
>> more comfortable if someone more knowledgeable could chime in before this
>> gets approved.
>>
>> But if nobody shows up, we can get it in if others have no concerns.
>>
>> Reviewed-By: Luis Machado <luis.machado@arm.com>
>
> Yes, this has been regression tested (recent testing for v4 on ubuntu 24.04).
> I am currently working on the setup for testing x32 again. This configuration has been tested for v1 initially only.
Alright. Thanks for confirming.
next prev parent reply other threads:[~2025-06-23 12:57 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 12:11 [PATCH v4 00/11] Add CET shadow stack support Christina Schimpe
2025-06-17 12:11 ` [PATCH v4 01/11] gdbserver: Add optional runtime register set type Christina Schimpe
2025-06-19 9:27 ` Luis Machado
2025-06-17 12:11 ` [PATCH v4 02/11] gdbserver: Add assert in x86_linux_read_description Christina Schimpe
2025-06-19 9:27 ` Luis Machado
2025-06-17 12:11 ` [PATCH v4 03/11] gdb: Sync up x86-gcc-cpuid.h with cpuid.h from gcc 14 branch Christina Schimpe
2025-06-17 18:12 ` Tom Tromey
2025-06-20 12:39 ` Schimpe, Christina
2025-06-17 12:11 ` [PATCH v4 04/11] gdb, gdbserver: Use xstate_bv for target description creation on x86 Christina Schimpe
2025-06-19 9:23 ` Luis Machado
2025-06-23 12:46 ` Schimpe, Christina
2025-06-23 12:56 ` Luis Machado [this message]
2025-06-24 13:46 ` Schimpe, Christina
2025-06-26 16:03 ` Luis Machado
2025-06-17 12:11 ` [PATCH v4 05/11] gdb, gdbserver: Add support of Intel shadow stack pointer register Christina Schimpe
2025-06-17 12:20 ` Eli Zaretskii
2025-06-19 9:24 ` Luis Machado
2025-06-23 13:05 ` Schimpe, Christina
2025-06-17 12:11 ` [PATCH v4 06/11] gdb: amd64 linux coredump support with shadow stack Christina Schimpe
2025-06-19 9:24 ` Luis Machado
2025-06-23 13:16 ` Schimpe, Christina
2025-06-17 12:11 ` [PATCH v4 07/11] gdb: Handle shadow stack pointer register unwinding for amd64 linux Christina Schimpe
2025-06-19 9:25 ` Luis Machado
2025-06-20 1:42 ` Thiago Jung Bauermann
2025-06-23 14:55 ` Schimpe, Christina
2025-06-23 23:26 ` Thiago Jung Bauermann
2025-06-23 15:00 ` Schimpe, Christina
2025-06-23 15:06 ` Luis Machado
2025-06-23 23:36 ` Thiago Jung Bauermann
2025-06-20 1:52 ` Thiago Jung Bauermann
2025-06-17 12:11 ` [PATCH v4 08/11] gdb, gdbarch: Enable inferior calls for shadow stack support Christina Schimpe
2025-06-19 9:25 ` Luis Machado
2025-06-23 17:49 ` Schimpe, Christina
2025-06-17 12:11 ` [PATCH v4 09/11] gdb: Implement amd64 linux shadow stack support for inferior calls Christina Schimpe
2025-06-17 12:21 ` Eli Zaretskii
2025-06-19 9:25 ` Luis Machado
2025-06-27 19:52 ` Schimpe, Christina
2025-06-28 10:38 ` Luis Machado
2025-06-28 20:03 ` Thiago Jung Bauermann
2025-06-28 21:05 ` Thiago Jung Bauermann
2025-06-17 12:11 ` [PATCH v4 10/11] gdb, gdbarch: Introduce gdbarch method to get the shadow stack pointer Christina Schimpe
2025-06-17 18:16 ` Tom Tromey
2025-06-20 12:59 ` Schimpe, Christina
2025-06-19 9:26 ` Luis Machado
2025-06-23 18:00 ` Schimpe, Christina
2025-06-17 12:11 ` [PATCH v4 11/11] gdb: Enable displaced stepping with shadow stack on amd64 linux Christina Schimpe
2025-06-17 12:22 ` Eli Zaretskii
2025-06-17 15:16 ` Schimpe, Christina
2025-06-19 9:26 ` Luis Machado
2025-06-23 18:24 ` Schimpe, Christina
2025-06-24 8:05 ` Luis Machado
2025-06-27 19:26 ` Schimpe, Christina
2025-06-28 10:35 ` Luis Machado
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=4c57870a-7233-49b6-990c-9e6f3b7ce452@arm.com \
--to=luis.machado@arm.com \
--cc=christina.schimpe@intel.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=thiago.bauermann@linaro.org \
/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