From: Paolo Bonzini Subject: Re: [RFC PATCH 04/10 v2 ] x86/fpu: eager switch PKRU state Date: Wed, 19 Sep 2018 19:00:34 +0200 Message-ID: <099b9f82-e162-c91a-bc51-aa1ac0cd50aa@redhat.com> References: <8e5b64e4-b3e6-f884-beb6-b7b69ab2d8c1@redhat.com> <20180914203501.qibhpmueosvkr74w@linutronix.de> <20180918142701.atfb4ul45k7tl6ew@linutronix.de> <7e9a13f3-93f5-fe4a-20d2-f4f9407bd43b@redhat.com> <83e271e1298d603c1105dd0dbea32d67da9cf1fa.camel@surriel.com> <36e8493f-f994-e885-8fe6-2f0d4a9904a1@redhat.com> <20180918160419.2zeru6xnufxixcax@linutronix.de> <11aa7d0f4ba36eff8b61a5dc1bd35ee5195fd576.camel@surriel.com> <20180919165719.iepvc7tg6aabp5mm@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Rik van Riel , linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" To: Sebastian Andrzej Siewior Return-path: In-Reply-To: <20180919165719.iepvc7tg6aabp5mm@linutronix.de> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 19/09/2018 18:57, Sebastian Andrzej Siewior wrote: > On 2018-09-19 07:55:51 [+0200], Paolo Bonzini wrote: >> A kthread can do use_mm/unuse_mm. > > indeed. The FPU struct for the kernel thread isn't valid / does not > contain the expected PKRU value. So loading the pkru value from the > struct FPU does not work as expected. We could set it to 0 for a kernel > thread so we don't end up with a random value. > If we want to get this usecase working then we would have to move pkru > value from FPU to mm_struct and consider it in use_mm(). Do we want > this? As a start, I think keeping it in the FPU struct but loading it unconditionally will work. kthreads will not obey PKU but it will be better already. I honestly don't know if PKRU should be per-mm, I don't know mm very well despite my brilliant observation above. :) Paolo