mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	fastboot <fastboot@lists.osdl.org>
Subject: [RFC/PATCH 6/17][Kdump] NMI handler segment selector, stack pointer fix
Date: Mon, 28 Mar 2005 18:56:34 +0530	[thread overview]
Message-ID: <1112016394.4001.77.camel@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: x86-nmi-handler-ss-esp-fix.patch --]
[-- Type: message/rfc822, Size: 1578 bytes --]

From: 
Subject: No Subject
Date: Mon, 28 Mar 2005 17:35:11 +0530
Message-ID: <1112011511.4001.22.camel@localhost.localdomain>

From: "Vivek Goyal" <vgoyal@in.ibm.com>

o CPU does not save ss and esp on stack if execution was already in kernel 
  mode at the time of NMI occurrence. This leads to saving of erractic values
  for ss and esp. This patch fixes the issue.  

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
---

 linux-2.6.12-rc1-mm3-1M-root/arch/i386/kernel/crash.c |   13 +++++++++++++
 1 files changed, 13 insertions(+)

diff -puN arch/i386/kernel/crash.c~x86-nmi-handler-ss-esp-fix arch/i386/kernel/crash.c
--- linux-2.6.12-rc1-mm3-1M/arch/i386/kernel/crash.c~x86-nmi-handler-ss-esp-fix	2005-03-27 18:50:50.000000000 +0530
+++ linux-2.6.12-rc1-mm3-1M-root/arch/i386/kernel/crash.c	2005-03-27 18:56:16.000000000 +0530
@@ -112,7 +112,20 @@ static atomic_t waiting_for_crash_ipi;
 
 static int crash_nmi_callback(struct pt_regs *regs, int cpu)
 {
+	struct pt_regs fixed_regs;
 	local_irq_disable();
+
+	/* CPU does not save ss and esp on stack if execution is already
+	 * running in kernel mode at the time of NMI occurrence. This code
+	 * fixes it.
+	 */
+	if (!user_mode(regs)) {
+		memcpy(&fixed_regs, regs, sizeof(*regs));
+		fixed_regs.esp = (unsigned long)&(regs->esp);
+		__asm__ __volatile__("xorl %eax, %eax;");
+		__asm__ __volatile__ ("movw %%ss, %%ax;" :"=a"(fixed_regs.xss));
+		regs = &fixed_regs;
+	}
 	crash_save_this_cpu(regs, cpu);
 	disable_local_APIC();
 	atomic_dec(&waiting_for_crash_ipi);
_

                 reply	other threads:[~2005-03-28 13:47 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=1112016394.4001.77.camel@localhost.localdomain \
    --to=vgoyal@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=fastboot@lists.osdl.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®