From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756822AbbDVNb5 (ORCPT ); Wed, 22 Apr 2015 09:31:57 -0400 Received: from mail.skyhub.de ([78.46.96.112]:37490 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754976AbbDVNbz (ORCPT ); Wed, 22 Apr 2015 09:31:55 -0400 Date: Wed, 22 Apr 2015 15:31:46 +0200 From: Borislav Petkov To: Oleg Nesterov Cc: Dave Hansen , linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com, riel@redhat.com, sbsiddha@gmail.com, luto@amacapital.net, mingo@redhat.com, hpa@zytor.com, fenghua.yu@intel.com Subject: Re: [PATCH 01/16] x86, fpu: wrap get_xsave_addr() to make it safer Message-ID: <20150422133146.GE6897@pd.tnic> References: <20150401004623.894DF37A@viggo.jf.intel.com> <20150401004624.49096AD0@viggo.jf.intel.com> <20150422104047.GA6897@pd.tnic> <20150422131618.GA16785@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150422131618.GA16785@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2015 at 03:16:18PM +0200, Oleg Nesterov wrote: > I agree, tsk_used_math(tsk) looks better, simpy because we have this > argument. > > But this "tsk" should be always current, otherwise this code is wrong This is exactly what I'm asking: is that always the case?... > anyway. Say, unlazy_fpu(tsk) can't work if tsk != current. > > So perhaps the comment should be updated... > > > Because used_math() is looking at current, maybe even in > > preemption-enabled paths - I'm eyeing task_get_bounds_dir() - and > > that current might get changed from under us and it might happen that > > current != tsk. Yes, no? > > Not sure I understand... "current" can't change from under us? ... I'm not sure all tsk_get_xsave_field() callers disable preemption. If not, then current can change from under us... > Even if this CPU switches to another thread which executes the same code, > that thread will obviously see another "current", but its "tsk" variable > will still match its "current". Well, we want to see if @tsk used math, not necessarily if current used math, especially if it is another task, right? I read tsk_get_xsave_field(@tsk, ) as give me the xsave field of @tsk but doing used_math() we're querying current and I'm not sure tsk == current in all the call sites of tsk_get_xsave_field(). Does that make more sense? -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --