From: Ingo Molnar <mingo@elte.hu>
To: Stas Sergeev <stsp@aknet.ru>
Cc: Linus Torvalds <torvalds@osdl.org>,
linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
Petr Vandrovec <VANDROVE@vc.cvut.cz>
Subject: Re: crash in entry.S restore_all, 2.6.12-rc2, x86, PAGEALLOC
Date: Thu, 7 Apr 2005 10:00:04 +0200 [thread overview]
Message-ID: <20050407080004.GA27252@elte.hu> (raw)
In-Reply-To: <425403F6.409@aknet.ru>
* Stas Sergeev <stsp@aknet.ru> wrote:
> ENTRY(sysenter_entry)
> movl TSS_sysenter_esp0(%esp),%esp
> sysenter_past_esp:
> - sti
> pushl $(__USER_DS)
> pushl %ebp
> + sti
ah, yes, sysenter. SYSENTER creates a degenerate 'small' stackframe with
an esp0 that is missing the 5 entry words relative to the normal entry
(int80 or irq) esp0 stackframe. These 5 words are: xss, esp, eflags,
xcs, eip. The sysenter code sets them up manually.
now if an interrupt hits at this point, it will set up a 'same privilege
level' stackframe, which has eip/xcs/eflags, i.e. no esp/xss. If upon
irq-return we then examine the stack due to your patch, it will be an
incorrect stackframe -> kaboom.
your patch doesnt remove the condition, it only removes the crash,
because it adds the 2 words space that is needed - but the information
relied on by your irq-return test is still bogus. At this point i'd
suggest to remove the ESP patch altogether.
the correct solution is to always let the sysenter path set up a full
and correct stackframe, before allowing preemption (see the attached
patch). This was a nasty bug in the waiting. (I have not made this
conditional on CONFIG_PREEMPT, to keep it simple and because the impact
to irq latency is small and predictable. There's no runtime overhead.)
so i think with the help of Stas the mystery has been fully explained
and solved. Linus?
Ingo
Signed-off-by: Ingo Molnar <mingo@elte.hu>
--- linux/arch/i386/kernel/entry.S.orig
+++ linux/arch/i386/kernel/entry.S
@@ -179,12 +179,17 @@ need_resched:
ENTRY(sysenter_entry)
movl TSS_sysenter_esp0(%esp),%esp
sysenter_past_esp:
- sti
+ #
+ # irqs are disabled: set up an entry stackframe without
+ # allowing irqs to potentially preempt us with an
+ # incomplete entry frame!
+ #
pushl $(__USER_DS)
pushl %ebp
pushfl
pushl $(__USER_CS)
pushl $SYSENTER_RETURN
+ sti
/*
* Load the potential sixth argument from user stack.
next prev parent reply other threads:[~2005-04-07 8:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-05 6:55 crash in entry.S restore_all, 2.6.12-rc2, x86, PAGEALLOC Ingo Molnar
2005-04-05 7:03 ` Andrew Morton
2005-04-05 7:07 ` Ingo Molnar
2005-04-05 7:16 ` Ingo Molnar
2005-04-05 7:29 ` Ingo Molnar
2005-04-05 7:40 ` Ingo Molnar
2005-04-05 9:51 ` Mikael Pettersson
2005-04-05 18:09 ` Ingo Molnar
2005-04-05 7:05 ` Ingo Molnar
2005-04-05 19:11 ` Stas Sergeev
2005-04-05 19:19 ` Linus Torvalds
2005-04-05 19:41 ` Stas Sergeev
2005-04-05 19:53 ` Linus Torvalds
2005-04-05 20:44 ` Ingo Molnar
2005-04-05 21:04 ` Linus Torvalds
2005-04-06 15:44 ` Stas Sergeev
2005-04-07 8:00 ` Ingo Molnar [this message]
2005-04-07 11:10 ` Andrew Morton
2005-04-07 14:47 ` Linus Torvalds
2005-04-07 14:51 ` Ingo Molnar
2005-04-07 16:47 ` Dave Jones
2005-04-07 17:17 ` Richard B. Johnson
2005-04-07 17:23 ` Linus Torvalds
2005-04-07 16:11 ` Stas Sergeev
2005-04-07 16:35 ` Linus Torvalds
2005-04-07 16:46 ` Stas Sergeev
2005-04-07 16:55 ` Linus Torvalds
2005-04-07 18:10 ` Stas Sergeev
2005-04-10 13:20 ` Stas Sergeev
2005-04-10 22:32 ` Andrew Morton
2005-04-11 17:15 ` Stas Sergeev
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=20050407080004.GA27252@elte.hu \
--to=mingo@elte.hu \
--cc=VANDROVE@vc.cvut.cz \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stsp@aknet.ru \
--cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.