From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Sandra Loosemore <sandra@codesourcery.com>
Subject: Re: [patch, nios2] fix stepping past unwritable kernel helper
Date: Thu, 28 Mar 2019 06:08:00 -0000 [thread overview]
Message-ID: <20190327230800.0a358dc0@f29-4.lan> (raw)
In-Reply-To: <80464f56-fccb-0bb4-dcdd-6a547e5418b0@codesourcery.com>
On Wed, 27 Mar 2019 22:47:44 -0600
Sandra Loosemore <sandra@codesourcery.com> wrote:
> Fix stepping past unwritable kernel helper on nios2-linux-gnu.
>
> This patch fixes a problem on nios2-linux-gnu with stepping past the
> kernel helper __kuser_cmpxchg, which was exposed by the testcase
> gdb.threads/watchpoint-fork.exp. The kernel maps this function into
> user space on an unwritable page. In this testcase, the cmpxchg
> helper is invoked indirectly from the setbuf call in the test program.
> Since this target lacks hardware breakpoint/watchpoint support, GDB
> tries to single-step through the program by setting software
> breakpoints, and was just giving an error when it reached the function
> on the unwritable page.
>
> The solution here is to always step over the call instead of stepping
> into it; cmpxchg is supposed to be an atomic operation so this
> behavior seems reasonable. The hook in nios2_get_next_pc is somewhat
> generic, but at present cmpxchg is the only helper provided by the
> Linux kernel that is invoked by an ordinary function call. (Signal
> return trampolines also go through the unwritable page but not by a
> function call.)
>
> Fixing this issue also revealed that the testcase needs a much larger
> timeout factor when software single-stepping is used. That has also
> been fixed in this patch.
>
> gdb/ChangeLog
>
> 2019-03-27 Sandra Loosemore <sandra@codesourcery.com>
>
> * nios2-tdep.h (struct gdbarch_tdep): Add is_kernel_helper.
> * nios2-tdep.c (nios2_get_next_pc): Skip over kernel helpers.
> * nios2-linux-tdep.c (nios2_linux_is_kernel_helper): New.
> (nios2_linux_init_abi): Install it.
>
> gdb/testsuite/ChangeLog
>
> 2019-03-27 Sandra Loosemore <sandra@codesourcery.com>
>
> * gdb.threads/watchpoint-fork.exp (test): Use large timeout
> factor when no hardware watchpoint support.
Thanks for the explanation, above.
The one thing that concerned me when I first saw it was the use of the
constant 0x1004 as the address for __kuser_cmpxchg. But after checking
the glibc sources at the path indicated in the comment, I saw that it's
hardcoded using the same constant there as well.
So... this patch is okay.
Kevin
next prev parent reply other threads:[~2019-03-28 6:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-28 4:47 Sandra Loosemore
2019-03-28 6:08 ` Kevin Buettner [this message]
[not found] ` <25d33f77-a884-c214-5dbb-0d45863e5a75@redhat.com>
2019-03-28 16:34 ` Sandra Loosemore
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=20190327230800.0a358dc0@f29-4.lan \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=sandra@codesourcery.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