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

Eli Zaretskii
2025-06-17T12:24:39Z

> 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>