RE: [PATCH v4 11/11] gdb: Enable displaced stepping with shadow stack on amd64 linux.

Schimpe, Christina
2025-06-17T15:17:31Z

Thanks for the quick feedback!

Christina

> -----Original Message-----
> From: Eli Zaretskii <eliz@gnu.org>
> Sent: Tuesday, June 17, 2025 2:22 PM
> To: Schimpe, Christina <christina.schimpe@intel.com>
> Cc: gdb-patches@sourceware.org; thiago.bauermann@linaro.org
> Subject: Re: [PATCH v4 11/11] gdb: Enable displaced stepping with shadow
> stack on amd64 linux.
>
> > From: Christina Schimpe <christina.schimpe@intel.com>
> > Cc: thiago.bauermann@linaro.org,
> > eliz@gnu.org
> > Date: Tue, 17 Jun 2025 12:11:47 +0000
> >
> > This patch enables displaced stepping to support Intel's Control-Flow
> > Enforcement Technology (CET), which provides the shadow stack feature
> > for the x86 architecture.
> > Following the restriction of the linux kernel, enable displaced
> > stepping for amd64 only.
> >
> > If displaced stepping is active and the single stepped instruction is
> > a call instruction, the return address atop the stack is the address
> > following the copied instruction. However, to allow normal program
> > execution it has to be the address following the original instruction.
> > Due to that reason, the return address is corrected in
> > amd64_displaced_step_fixup and i386_displaced_step_fixup.
> >
> > To avoid a control-protection exception if shadow stack is active, the
> > shadow stack top address must be corrected as well.
> >
> > Reviewed-By: Eli Zaretskii <eliz@gnu.org>
> > ---
> > gdb/NEWS | 3 +
> > gdb/amd64-linux-tdep.c | 16 +++-
> > gdb/amd64-tdep.c | 15 ++++
> > gdb/doc/gdb.texinfo | 11 ++-
> > gdb/i386-tdep.c | 15 ++++
> > .../gdb.arch/amd64-shadow-stack-disp-step.exp | 90
> > +++++++++++++++++++
> > 6 files changed, 147 insertions(+), 3 deletions(-) create mode
> > 100644 gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp
>
> The NEWS part is okay, thanks.
>
> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928