From: Jason Wessel <jason.wessel@windriver.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net
Subject: Re: [PATCH 2/3] kgdb,i386: use address that SP register points to in the exception frame
Date: Fri, 15 May 2009 14:20:53 -0500 [thread overview]
Message-ID: <4A0DC095.7050706@windriver.com> (raw)
In-Reply-To: <alpine.LFD.2.01.0905150814180.3343@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]
Linus Torvalds wrote:
> Is this only ever used for kernel register state?
>
> Because in the _general_ case, the code should likely be something like
>
> if (user_mode_vm(regs)) {
> gdb_regs[GDB_SS] = regs->ss;
> gdb_regs[GDB_SP] = regs->sp;
> } else {
> gdb_regs[GDB_SS] = __KERNEL_DS;
> gdb_regs[GDB_SP] = (unsigned long)®s->sp
> }
>
You have discovered a long standing corner case. The only way you can
end up with user_mode_vm() being true is the death by NMI watch dog or
from the IPI to bring the non master kgdb cpus into debugger. By default
the kgdb exception handler is not going to end up with that condition,
because there is a check against regs in the kgdb notify handler for the
non NMI/IPI events.
Thank you for the suggestion. I went ahead and tested it out to
confirm the behavior, as well as to run the standard set of kgdb
regression tests.
The corner case is fixed in the attached patch, and I updated for_linus
branch with just this patch, if you would prefer to pull it.
git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb.git
for_linus
Thanks,
Jason.
[-- Attachment #2: 0001-kgdb-i386-Fix-corner-case-access-to-sp-with-NMI-watc.patch --]
[-- Type: text/x-diff, Size: 1268 bytes --]
>From 0fff698b7a60d8f534dcc0d1ef26efb579938d09 Mon Sep 17 00:00:00 2001
From: Jason Wessel <jason.wessel@windriver.com>
Date: Fri, 15 May 2009 11:39:08 -0500
Subject: [PATCH 1/1] kgdb,i386: Fix corner case access to sp with NMI watch dog exception
It is possible for the user_mode_vm(regs) check to return true for a
non master kgdb cpu or when the master kgdb cpu handles the NMI watch
dog exception.
The solution is simply to select the correct stack pointer location
based on the check to user_mode_vm(regs).
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
arch/x86/kernel/kgdb.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -85,10 +85,15 @@ void pt_regs_to_gdb_regs(unsigned long *
gdb_regs[GDB_DS] = regs->ds;
gdb_regs[GDB_ES] = regs->es;
gdb_regs[GDB_CS] = regs->cs;
- gdb_regs[GDB_SS] = __KERNEL_DS;
gdb_regs[GDB_FS] = 0xFFFF;
gdb_regs[GDB_GS] = 0xFFFF;
- gdb_regs[GDB_SP] = (int)®s->sp;
+ if (user_mode_vm(regs)) {
+ gdb_regs[GDB_SS] = regs->ss;
+ gdb_regs[GDB_SP] = regs->sp;
+ } else {
+ gdb_regs[GDB_SS] = __KERNEL_DS;
+ gdb_regs[GDB_SP] = (unsigned long)®s->sp;
+ }
#else
gdb_regs[GDB_R8] = regs->r8;
gdb_regs[GDB_R9] = regs->r9;
prev parent reply other threads:[~2009-05-15 19:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-15 13:17 [git pull] kgdb 2.6.30-rc5 regression fixes Jason Wessel
2009-05-15 13:17 ` [PATCH 1/3] sysrq, intel_fb: fix sysrq g collision Jason Wessel
2009-05-15 13:17 ` [PATCH 2/3] kgdb,i386: use address that SP register points to in the exception frame Jason Wessel
2009-05-15 13:17 ` [PATCH 3/3] kgdb: gdb documentation fix Jason Wessel
2009-05-15 15:16 ` [PATCH 2/3] kgdb,i386: use address that SP register points to in the exception frame Linus Torvalds
2009-05-15 19:20 ` Jason Wessel [this message]
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=4A0DC095.7050706@windriver.com \
--to=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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