Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935528AbeAKScC (ORCPT + 1 other); Thu, 11 Jan 2018 13:32:02 -0500 Received: from mail-io0-f177.google.com ([209.85.223.177]:34131 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbeAKScB (ORCPT ); Thu, 11 Jan 2018 13:32:01 -0500 X-Google-Smtp-Source: ACJfBoti4uvvg8QKYzAKVBtuT0KivqTaQGjxGvJAr6Hu6EYTJCbljm357fT2f13SYN15CUBM/e2WXagvz9m81kdq5jY= MIME-Version: 1.0 In-Reply-To: <21a05bdd-bd9b-d522-1b23-61a1cdb56dbe@linux.intel.com> References: <20180110082207.GX29822@worktop.programming.kicks-ass.net> <20180110091102.GH14066@1wt.eu> <20180111064259.GC14920@1wt.eu> <0f08d89e-61e1-20e3-5c59-0b2f7b32bf0c@linux.intel.com> <20180111154412.GA15296@1wt.eu> <20180111174025.GB15344@1wt.eu> <20180111180502.GE15344@1wt.eu> <21a05bdd-bd9b-d522-1b23-61a1cdb56dbe@linux.intel.com> From: Linus Torvalds Date: Thu, 11 Jan 2018 10:31:58 -0800 X-Google-Sender-Auth: MkPjGyrZhWXapV61yjePz6TgViM Message-ID: Subject: Re: [RFC PATCH v2 6/6] x86/entry/pti: don't switch PGD on when pti_disable is set To: Dave Hansen Cc: Willy Tarreau , Andy Lutomirski , Peter Zijlstra , LKML , X86 ML , Borislav Petkov , Brian Gerst , Ingo Molnar , Thomas Gleixner , Josh Poimboeuf , "H. Peter Anvin" , Greg Kroah-Hartman , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 11, 2018 at 10:15 AM, Dave Hansen wrote: > > Well, on the bright side, we don't need IPIs when _removing_ NX. We can > just handle those like a spurious fault. I think I agree. > But, when re-enabling it, we need all the TLB flushing for all the CPUs > that have run with the un-NX'd page tables. Actually, I really don't think we should even allow "re-enable PTI". The only thing that re-enables PTI is a completely new page table, notably "execve()". And I think that is when the "NOW" vs "NEXT" *may* make sense. Not for enabling PTI, but if we want to have a "disable PTI", I think it should act on the next execve(). And one reason I think we want that behavior is that once you've disabled PTI, I don't think the double page tables would necessarily even exist, and I don't think we should try to re-populate them. A noPTI process might simply *have* just the single page table. That wouldn't be the first implementation, but I think the interface should be designed for that kind of thing in mind, where nopti really means "stop doing two page tables for this process". And that may make it *impossible* to re-enable PTI for this process, simply because we don't have the required double-page PGD allocation at all. Linus