From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752108AbdKZILP (ORCPT ); Sun, 26 Nov 2017 03:11:15 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:51192 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752053AbdKZILO (ORCPT ); Sun, 26 Nov 2017 03:11:14 -0500 Date: Sun, 26 Nov 2017 09:11:10 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski cc: Ingo Molnar , "linux-kernel@vger.kernel.org" , Dave Hansen , "H . Peter Anvin" , Peter Zijlstra , Borislav Petkov , Linus Torvalds Subject: Re: [PATCH 42/43] x86/mm/kaiser: Allow KAISER to be enabled/disabled at runtime In-Reply-To: Message-ID: References: <20171124172411.19476-1-mingo@kernel.org> <20171124172411.19476-43-mingo@kernel.org> <47186975-1DCB-4767-8C4C-0816931E3595@amacapital.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 25 Nov 2017, Andy Lutomirski wrote: > On Sat, Nov 25, 2017 at 2:48 PM, Thomas Gleixner wrote: > > On Sat, 25 Nov 2017, Andy Lutomirski wrote: > >> > On Nov 25, 2017, at 1:05 PM, Thomas Gleixner wrote: > >> > On Sat, 25 Nov 2017, Andy Lutomirski wrote: > >> >> Keep in mind that, for a static_branch, actually setting the thing needs > >> >> to be deferred, but that's straightforward. > >> > > >> > That's not an issue during boot. That would be an issue for a run time > >> > switch. > >> > >> What I mean is: if you modify a static_branch too early, it blows up terribly. > > > > I'm aware of that. We can't switch it in the early boot stage. But that > > does not matter as we can switch way before we reach user space. > > > > The early kaiser mappings are fine whether we use them later or not. At the > > point in boot where we actually make the decision, there is nothing more > > than the extra 4k shadow which got initialized. > > > > If we ever want to do runtime switching, then the full shadow mapping needs > > to be maintained even while kaiser is disabled, just the NX poisoning of > > the user space mappings is what makes the difference. > > One unfortunate thing is that, if we boot with kaiser off and don't > intend to ever switch it on at runtime, we could avoid the 8k pgd > allocations. But if we want to be able to enable kaiser, we need the > 8k mappings. My inclination is to not try for runtime control until > some distro asks for it. I completely agree. boot time is good enough. We should start with the 8k allocations for simplicity reasons and when that works have a patch on top which switches is back to 4k. > In general, I think that trying to runtime switch without stop_machine > is a bit nuts, and getting it to be reliable even with stop_machine is > gross. Not to mention that stop_machine is currently incompatible > with writing to static branches, although that's fixable. Yes, it's doable, but surely not trivial and I'd like to avoid the mess it creates. Thanks, tglx