From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757227AbbA3NcP (ORCPT ); Fri, 30 Jan 2015 08:32:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752239AbbA3NcO (ORCPT ); Fri, 30 Jan 2015 08:32:14 -0500 Date: Fri, 30 Jan 2015 14:30:56 +0100 From: Oleg Nesterov To: Dave Hansen Cc: Rik van Riel , Suresh Siddha , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Fenghua Yu , the arch/x86 maintainers , linux-kernel Subject: Re: [PATCH 0/3]: x86, fpu: unlazy_fpu fixes/cleanups Message-ID: <20150130133056.GA7308@redhat.com> References: <54C2A245.4010307@redhat.com> <20150129210723.GA31584@redhat.com> <54CAA357.1070108@linux.intel.com> <20150129213346.GA32511@redhat.com> <54CAA973.4050401@linux.intel.com> <20150129215638.GB1045@redhat.com> <54CAC190.30905@linux.intel.com> <20150130124550.GA4551@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150130124550.GA4551@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/30, Oleg Nesterov wrote: > > On 01/29, Dave Hansen wrote: > > > > On 01/29/2015 01:56 PM, Oleg Nesterov wrote: > > > --- x/arch/x86/kernel/traps.c > > > +++ x/arch/x86/kernel/traps.c > > > @@ -313,7 +313,7 @@ dotraplinkage void do_bounds(struct pt_r > > > * It is not directly accessible, though, so we need to > > > * do an xsave and then pull it out of the xsave buffer. > > > */ > > > - fpu_save_init(&tsk->thread.fpu); > > > + unlazy_fpu(tsk); > > > xsave_buf = &(tsk->thread.fpu.state->xsave); > > ... > > > bndcsr = get_xsave_addr(xsave_buf, XSTATE_BNDCSR); > > > > Hmm, if the the thread was not using the FPU, and this fails to save > > anything in to the xsave_buf, what will bndcsr point to? It _looks_ to > > me like it will just point to uninitialized data since the xsave never > > happened. > > > > Fenghua, shouldn't get_xsave_addr() be checking the xstate bit against > > the xsave->xstate_bv? > > Can't really comment, but let me clarify what I meant just in case... > > If it was not using FPU then I guess do_bounds() can't happen. However, > it can be preempted after conditional_sti(). fpu_save_init() is obviously > wrong unless __thread_has_fpu() == T, and this can be false if !eagerfpu > or if we add TIF_LOAD_FPU (defer FPU restore until return to userspace). Forgot to mention... and if we use unlazy_fpu() we should not worry about preemption/__thread_has_fpu, we can rely on __save_init_fpu() in __switch_to() and/or __thread_has_fpu() check in unlazy_fpu(). But I am afraid I misunderstood your concerns, sorry for noise in this case. Oleg.