From: Brian Gerst <bgerst@didntduck.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
nigel@nrg.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86 page fault handler not interrupt safe
Date: Wed, 09 May 2001 18:12:44 -0400 [thread overview]
Message-ID: <3AF9C0DC.A7EE2C5C@didntduck.org> (raw)
In-Reply-To: <Pine.LNX.4.21.0105080944380.1831-100000@penguin.transmeta.com>
[-- Attachment #1: Type: text/plain, Size: 650 bytes --]
Linus Torvalds wrote:
>
> On Tue, 8 May 2001, Alan Cox wrote:
> >
> > I dont see where the alternative patch ensures the user didnt flip the
> > direction flag for one
>
> Yeah.
>
> We might as well just make it "eflags & IF", none of the other flags
> should matter (or we explicitly want them cleared).
>
> Linus
Here is an updated patch. After reading over the Intel docs, and some
testing on my Athlon, I found that %cr2 is not set on alignment check
faults. I replaced it with the address of the faulting instruction. It
may work on an Intel but is undocumented. The eip makes more sense
anyways.
--
Brian Gerst
[-- Attachment #2: diff-pagefault2 --]
[-- Type: text/plain, Size: 2109 bytes --]
diff -urN linux-2.4.5-pre1/arch/i386/kernel/traps.c linux/arch/i386/kernel/traps.c
--- linux-2.4.5-pre1/arch/i386/kernel/traps.c Mon Mar 19 21:23:40 2001
+++ linux/arch/i386/kernel/traps.c Wed May 9 17:51:58 2001
@@ -225,15 +225,6 @@
die(str, regs, err);
}
-static inline unsigned long get_cr2(void)
-{
- unsigned long address;
-
- /* get the address */
- __asm__("movl %%cr2,%0":"=r" (address));
- return address;
-}
-
static void inline do_trap(int trapnr, int signr, char *str, int vm86,
struct pt_regs * regs, long error_code, siginfo_t *info)
{
@@ -314,7 +305,7 @@
DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
-DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, get_cr2())
+DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, regs->eip)
asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
{
@@ -973,7 +964,7 @@
set_trap_gate(11,&segment_not_present);
set_trap_gate(12,&stack_segment);
set_trap_gate(13,&general_protection);
- set_trap_gate(14,&page_fault);
+ set_intr_gate(14,&page_fault);
set_trap_gate(15,&spurious_interrupt_bug);
set_trap_gate(16,&coprocessor_error);
set_trap_gate(17,&alignment_check);
diff -urN linux-2.4.5-pre1/arch/i386/mm/fault.c linux/arch/i386/mm/fault.c
--- linux-2.4.5-pre1/arch/i386/mm/fault.c Wed May 2 09:24:09 2001
+++ linux/arch/i386/mm/fault.c Wed May 9 17:18:17 2001
@@ -98,6 +98,9 @@
* and the problem, and then passes it off to one of the appropriate
* routines.
*
+ * This is called with interrupts off, to protect %cr2 from being
+ * overwritten by an interrupt handler that faults.
+ *
* error_code:
* bit 0 == 0 means no page found, 1 means protection fault
* bit 1 == 0 means read, 1 means write
@@ -116,6 +119,10 @@
/* get the address */
__asm__("movl %%cr2,%0":"=r" (address));
+
+ /* Reenable interrupts, but don't trust any other flags */
+ if (regs->eflags & X86_EFLAGS_IF)
+ sti();
tsk = current;
next prev parent reply other threads:[~2001-05-09 22:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3AF712D5.5D712E0F@didntduck.org>
2001-05-07 21:44 ` [PATCH] x86 page fault handler not interrupt safe Linus Torvalds
2001-05-07 22:10 ` Brian Gerst
2001-05-08 10:45 ` Alan Cox
2001-05-08 16:45 ` Linus Torvalds
2001-05-09 22:12 ` Brian Gerst [this message]
2001-05-07 21:53 ` Nigel Gamble
2001-05-07 21:58 Anton Altaparmakov
[not found] <D5E932F578EBD111AC3F00A0C96B1E6F07DBE26F@orsmsx31.jf.intel .com>
2001-05-07 17:52 ` Anton Altaparmakov
-- strict thread matches above, loose matches on Subject: below --
2001-05-07 17:32 Dunlap, Randy
2001-05-07 17:51 ` David Woodhouse
2001-05-06 1:26 Brian Gerst
2001-05-07 0:53 ` Linus Torvalds
2001-05-07 3:54 ` Brian Gerst
2001-05-07 10:45 ` Alan Cox
2001-05-07 14:57 ` Brian Gerst
2001-05-07 15:07 ` Alan Cox
2001-05-07 17:12 ` Linus Torvalds
2001-05-07 17:27 ` David Woodhouse
2001-05-07 19:54 ` Brian Gerst
2001-05-07 20:16 ` Linus Torvalds
2001-05-07 21:37 ` Alan Cox
2001-05-07 22:52 ` Jesper Juhl
2001-05-07 18:35 ` Anton Altaparmakov
2001-05-07 16:51 ` Linus Torvalds
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=3AF9C0DC.A7EE2C5C@didntduck.org \
--to=bgerst@didntduck.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=nigel@nrg.org \
--cc=torvalds@transmeta.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