From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964853AbbGYR4D (ORCPT ); Sat, 25 Jul 2015 13:56:03 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:35987 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964785AbbGYR4B (ORCPT ); Sat, 25 Jul 2015 13:56:01 -0400 MIME-Version: 1.0 In-Reply-To: References: <040374ca9800988a0ed35ea9ddeb4a762c1371fa.1437690860.git.luto@kernel.org> <20150724102503.GA19090@nazgul.tnic> <20150725041656.GB32606@nazgul.tnic> <20150725043218.GD32606@nazgul.tnic> Date: Sat, 25 Jul 2015 10:56:00 -0700 X-Google-Sender-Auth: PjiV6yVAwK0Vg_gOtRD9DBKtUzg Message-ID: Subject: Re: [PATCH 1/3] x86/entry/64: Refactor IRQ stacks and make then NMI-safe From: Linus Torvalds To: Andy Lutomirski Cc: Borislav Petkov , Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , Brian Gerst , Steven Rostedt , Willy Tarreau , Thomas Gleixner , Peter Zijlstra Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 24, 2015 at 9:59 PM, Andy Lutomirski wrote: > > And people will give me five new heads if I ignore Linus and do RET > even with IF=1, saving 300 cycles? So I'm still nervous about that "sti; ret" when we're back on the original kernel stack that took the original fault or interrupt. But it's probably ok. Yes, it's irq-safe. But it's not NMI-safe, so if an NMI happens there, when the NMI returns, an interrupt might occur there too. But since we're back on the original stack where the original fault happened, and since interrupts were enabled, I don't see why that would be horrible. In theory, we might have a growing stack if this keeps happening, but since the only way to get that is to get the NMI in that one-instruction window (and apparently on at least _some_ microarchitectures the sti shadow stops even NMI's), I don't see how any kind of unbounded growth would happen. So. I think it would work, and it might even be good for "coverage" (ie the whole "iret-to-ret-conversion" will not have a lot of testing if it only happens for faults with interrupts disabled). But it still worries me a bit. Linus