public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: "Andreas Kleen" <ak@suse.de>
Cc: <linux-kernel@vger.kernel.org>, <discuss@x86-64.org>
Subject: [PATCH] x86-64: adjust double fault handling
Date: Tue, 08 Nov 2005 15:23:55 +0100	[thread overview]
Message-ID: <4370C30B.76F0.0078.0@novell.com> (raw)
In-Reply-To: 4370AFF0.76F0.0078.0@novell.com

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

Since a double fault always implies that kernel data structures are
corrupt, this fault should neither be handed to user mode handling,
nor should the handler allow resuming the faulting code stream (since
architecturally this isn't a fault, but an abort).

Note that this slightly depends on the previously submitted patch
adjusting the prototype of notify_die() (a compiler warning will
result
without that other patch).

From: Jan Beulich <jbeulich@novell.com>

(actual patch attached)


[-- Attachment #2: linux-2.6.14-x86_64-doublefault.patch --]
[-- Type: application/octet-stream, Size: 1767 bytes --]

Since a double fault always implies that kernel data structures are
corrupt, this fault should neither be handed to user mode handling,
nor should the handler allow resuming the faulting code stream (since
architecturally this isn't a fault, but an abort).

Note that this slightly depends on the previously submitted patch
adjusting the prototype of notify_die() (a compiler warning will result
without that other patch).

From: Jan Beulich <jbeulich@novell.com>

--- 2.6.14/arch/x86_64/kernel/traps.c	2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-doublefault/arch/x86_64/kernel/traps.c	2005-11-07 09:33:53.000000000 +0100
@@ -506,7 +506,35 @@ DO_ERROR(11, SIGBUS,  "segment not prese
 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
 DO_ERROR(18, SIGSEGV, "reserved", reserved)
 DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
-DO_ERROR( 8, SIGSEGV, "double fault", double_fault)
+
+asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
+{
+	static const char str[] = "double fault";
+	struct task_struct *tsk = current;
+
+	notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
+
+#ifdef CONFIG_CHECKING
+	{ 
+		unsigned long gs; 
+		struct x8664_pda *pda = cpu_pda + safe_smp_processor_id(); 
+		rdmsrl(MSR_GS_BASE, gs); 
+		if (gs != (unsigned long)pda) { 
+			wrmsrl(MSR_GS_BASE, pda); 
+			printk("%s: wrong gs %lx expected %p rip %lx\n",
+			       str, gs, pda, regs->rip);
+		}
+	}
+#endif
+
+	tsk->thread.error_code = error_code;
+	tsk->thread.trap_no = 8;
+
+	/* This is always a kernel trap and never fixable (and thus must
+	   never return). */
+	for (;;)
+		die(str, regs, error_code);
+}
 
 asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
 						long error_code)

  parent reply	other threads:[~2005-11-08 14:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-08 13:02 [PATCH] x86-64: separate unwind info generation from CONFIG_DEBUG_INFO Jan Beulich
2005-11-08 14:21 ` [PATCH] x86-64: fix bound check IDT gate Jan Beulich
2005-11-08 14:22 ` [PATCH] x86-64: remove dead die_if_kernel() Jan Beulich
2005-11-08 14:23 ` [PATCH] x86-64: make trap information available to die notification handlers Jan Beulich
2005-11-08 14:23 ` Jan Beulich [this message]
2005-11-08 14:24 ` [PATCH] x86-64: remove unprotected iret Jan Beulich
2005-11-10  3:38   ` [discuss] " Andi Kleen
2005-11-08 14:25 ` [PATCH] x86-64: adjust page fault handling Jan Beulich
2005-11-09 16:10   ` [PATCH] x86-64: adjust ia32entry.S Jan Beulich
2005-11-11 15:34     ` Andi Kleen
2005-11-11 15:50       ` Jan Beulich
2005-11-11 15:53         ` [discuss] " Andi Kleen

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=4370C30B.76F0.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.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