From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: [PATCH 04/11] x86/fpu: eager switch PKRU state Date: Thu, 18 Oct 2018 10:50:38 -0700 Message-ID: <642da544-908f-74e5-6168-10acff39f3f3@linux.intel.com> References: <20181004140547.13014-1-bigeasy@linutronix.de> <20181004140547.13014-5-bigeasy@linutronix.de> <76caafd5-c85d-61bb-62ec-8056cd6d95ac@linux.intel.com> <20181018161305.f4t7bdxhmpy5htrs@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel To: Sebastian Andrzej Siewior Return-path: In-Reply-To: <20181018161305.f4t7bdxhmpy5htrs@linutronix.de> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org >>> diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h >>> index 19b137f1b3beb..b184f916319e5 100644 >>> --- a/arch/x86/include/asm/pkeys.h >>> +++ b/arch/x86/include/asm/pkeys.h >>> @@ -119,7 +119,7 @@ extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, >>> unsigned long init_val); >>> extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, >>> unsigned long init_val); >>> -extern void copy_init_pkru_to_fpregs(void); >>> +extern void pkru_set_init_value(void); >> >> Could you elaborate on why the name is being changed? > > The function name read like init_pkru value is copied to fpregs save > area which is not the case. I could revert it if you prefer. I would just prefer that we find some way of saying *where* pkru is being set. Is it fpstate, fpregs, or both? >>> + * switch between those two operation would load the new value from the >>> + * updated xstate and then we would write (the same value) to the CPU. >>> + */ >>> + pk->pkru = pkru; >>> + __write_pkru(pkru); >>> + >>> +} >> >> There's an unnecessary line there. >> >> This also needs a lot more high-level context about why it is necessary. >> I think you had that in the changelog, but we also need the function >> commented. > > What is necessary? The manual update of "pk->pkru? Why we need to update fpstate *and* the actual register.