The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: gdb@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>, Xin Li <xin3.li@intel.com>,
	Xin Li <xin@zytor.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Desired behavior from a gdb perspective for single-step (x86)
Date: Wed, 21 May 2025 15:06:47 -0700	[thread overview]
Message-ID: <fff293d0-1bf8-42de-adea-a7e7ee559777@zytor.com> (raw)

Hi,

With FRED x86 has the ability for the single step flag (TF) to trigger
immediately after a return to user space. By default, we do that that
when we return to user space after entering the kernel via a system call
instruction of some kind (syscall, sysenter, INT) so that from a user
space perspective, the system call appears as one single instruction (as
opposed to skipping over the following instruction, which is the
behavior with IRET.)

We did discover that to make it work properly in the case of the TF
being used without a debugger attached, we need to clear the
immediate-trap flag in the sigreturn handler, to avoid an infinite loop
where SIGTRAP is taken over and over again.

Our current thinking is that we will clear the trap-immediately bit in
sigreturn if TF is *not* set before sigreturn is called, and Xin
preparing a kernel patch to do that to fix the mentioned infinite loop.

What isn't entirely clear to me is how ptrace should play into all of
this, and specifically, what does gdb (or another debugger) *WANT* the
behavior to be. We have the opportunity to make it "better" than the IDT
behavior, so it would be good to hear what specific semantics you would
prefer to have.

Thanks!

	-hpa


                 reply	other threads:[~2025-05-21 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=fff293d0-1bf8-42de-adea-a7e7ee559777@zytor.com \
    --to=hpa@zytor.com \
    --cc=aburgess@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xin3.li@intel.com \
    --cc=xin@zytor.com \
    /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