Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751725AbcJCQX3 (ORCPT ); Mon, 3 Oct 2016 12:23:29 -0400 Received: from mga11.intel.com ([192.55.52.93]:47322 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbcJCQXV (ORCPT ); Mon, 3 Oct 2016 12:23:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,438,1473145200"; d="scan'208";a="1059857485" Subject: Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace To: Rik van Riel , Andy Lutomirski References: <1475353895-22175-1-git-send-email-riel@redhat.com> <1475353895-22175-3-git-send-email-riel@redhat.com> <1475368956.21644.15.camel@redhat.com> Cc: "linux-kernel@vger.kernel.org" , X86 ML , Thomas Gleixner , Paolo Bonzini , Ingo Molnar , Andrew Lutomirski , "H. Peter Anvin" , Borislav Petkov From: Dave Hansen Message-ID: <57F285F7.7050708@linux.intel.com> Date: Mon, 3 Oct 2016 09:23:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1475368956.21644.15.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1046 Lines: 22 On 10/01/2016 05:42 PM, Rik van Riel wrote: > On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote: >> > On Sat, Oct 1, 2016 at 1:31 PM, wrote: >>> > > +static inline void switch_fpu_finish(void) >>> > > { >>> > > + set_thread_flag(TIF_LOAD_FPU); >>> > > } >> > >> > I can imagine this causing problems with kernel code that accesses >> > current's FPU state, e.g. get_xsave_field_ptr(). > That makes me wonder, what test programs do people have > to verify the correctness of the FPU switching code? The MPX testing code in selftests/ goes off the rails pretty quickly when the FP/XSAVE state gets corrupt. It has found quite a few bugs in the last few years. The protection keys code in there also keeps a shadow copy of the "PKRU" register in software which also makes it notice pretty quickly if something goes awry. That said, I'd _love_ to see more formal FPU testing done. We've had lots of bugs in there, and they tend to hit the newer features and newer CPUs. Let me know if you find something. :)