Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933457AbaDVRUs (ORCPT ); Tue, 22 Apr 2014 13:20:48 -0400 Received: from mail-vc0-f170.google.com ([209.85.220.170]:49569 "EHLO mail-vc0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932941AbaDVRUo (ORCPT ); Tue, 22 Apr 2014 13:20:44 -0400 MIME-Version: 1.0 In-Reply-To: <5356A248.5060605@zytor.com> References: <5355A9E9.9070102@zytor.com> <1dbe8155-58da-45c2-9dc0-d9f4b5a6e643@email.android.com> <20140422112312.GB15882@pd.tnic> <20140422144659.GF15882@pd.tnic> <53569467.1030809@zytor.com> <5356A248.5060605@zytor.com> From: Andrew Lutomirski Date: Tue, 22 Apr 2014 10:20:23 -0700 Message-ID: Subject: Re: [PATCH] x86-64: espfix for 64-bit mode *PROTOTYPE* To: "H. Peter Anvin" Cc: Linus Torvalds , Borislav Petkov , "H. Peter Anvin" , Linux Kernel Mailing List , Ingo Molnar , Alexander van Heukelum , Konrad Rzeszutek Wilk , Boris Ostrovsky , Arjan van de Ven , Brian Gerst , Alexandre Julliard , Andi Kleen , Thomas Gleixner 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 Tue, Apr 22, 2014 at 10:09 AM, H. Peter Anvin wrote: > > As for Andy's questions: > >> What happens on the IST entries? If I've read your patch right, >> you're still switching back to the normal stack, which looks >> questionable. > > No, in that case %rsp won't point into the espfix region, and the switch > will be bypassed. We will resume back into the espfix region on IRET, > which is actually required e.g. if we take an NMI in the middle of the > espfix setup. Aha. I misread that. Would it be worth adding a comment along the lines of /* Check whether we are running on the espfix stack. This is different from checking whether we faulted from the espfix stack, since an ist exception will have switched us off of the espfix stack. */ > >> Also, if you want to same some register abuse on each exception entry, >> could you check the saved RIP instead of the current RSP? I.e. use >> the test instruction with offset(%rsp)? Maybe there are multiple >> possible values, though, and just testing some bits doesn't help. > > I don't see how that would work. It won't, given the above. I misunderstood what you were checking. It still seems to me that only #GP needs this special handling. The IST entries should never run on the espfix stack, and #MC, #DB, #NM, and #SS (I missed that one earlier) use IST. Would it ever make sense to make #GP use IST as well? That might allow espfix_adjust_stack to be removed entirely. I don't know how much other fiddling would be needed to make that work. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/