[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFxU-4T7oMCJw3vZjL+-qFCzNwoqNLN-k2FxhPFcE0_GUA@mail.gmail.com>
Date: Sat, 7 Mar 2015 12:11:51 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Andy Lutomirski <luto@...capital.net>,
Oleg Nesterov <oleg@...hat.com>,
Dave Hansen <dave.hansen@...el.com>,
Borislav Petkov <bp@...e.de>, Pekka Riikonen <priikone@....fi>,
Rik van Riel <riel@...hat.com>,
Suresh Siddha <sbsiddha@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
"Yu, Fenghua" <fenghua.yu@...el.com>,
Quentin Casasnovas <quentin.casasnovas@...cle.com>
Subject: Re: [PATCH 1/1] x86/fpu: math_state_restore() should not blindly
disable irqs
On Sat, Mar 7, 2015 at 2:36 AM, Ingo Molnar <mingo@...nel.org> wrote:
>
> We could save the same 10 cycles from page fault overhead as well,
> AFAICS.
Are trap gates actually noticeably faster? Or is it just he
"conditional_sti()" you're worried about?
Anyway, for page faulting, we traditionally actually wanted an
interrupt gate, because of how we wanted to avoid interrupts coming in
and possibly messing up %cr2 due to vmalloc faults, but more
importantly for preemption. vmalloc faults are "harmless" because
we'll notice that it's already done, return, and then re-take the real
fault. But a preemption event before we read %cr2 can cause bad things
to happen:
- page fault pushes error code on stack, address in %cr2
- we don't have interrupts disabled, and some interrupt comes in and
causes preemption
- some other process runs, take another page fault. %cr2 now is the
wrong address
- we go back to the original thread (perhaps on another cpu), which
now reads %cr2 for the wrong address
- we send the process a SIGSEGV because we think it's accessing
memory that it has no place touching
So the page fault code actually *needs* interrupts disabled until we
read %cr2. Stupid x86 trap semantics where the error code is on the
thread-safe stack, but %cr2 is not.
Maybe there is some trick I'm missing, but on the whole I think
"interrupt gate + conditional_sti()" does have things going for it.
Yes, it still leaves NMI as being special, but NMI really *is*
special.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists