From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753388AbbCFNqK (ORCPT ); Fri, 6 Mar 2015 08:46:10 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:41929 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067AbbCFNqG (ORCPT ); Fri, 6 Mar 2015 08:46:06 -0500 Date: Fri, 6 Mar 2015 14:46:01 +0100 From: Ingo Molnar To: Oleg Nesterov Cc: Dave Hansen , Borislav Petkov , Andy Lutomirski , Linus Torvalds , Pekka Riikonen , Rik van Riel , Suresh Siddha , LKML , "Yu, Fenghua" , Quentin Casasnovas Subject: Re: [PATCH 1/1] x86/fpu: math_state_restore() should not blindly disable irqs Message-ID: <20150306134601.GA11718@gmail.com> References: <54F74F59.5070107@intel.com> <20150305195127.GA12657@redhat.com> <20150305195149.GB12657@redhat.com> <20150305201101.GA21571@gmail.com> <20150305212532.GA16890@redhat.com> <20150306075833.GA623@gmail.com> <20150306132634.GA20693@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150306132634.GA20693@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 * Oleg Nesterov wrote: > On 03/06, Ingo Molnar wrote: > > > > * Oleg Nesterov wrote: > > > > > [...] The patch above looks "obviously safe", but perhaps I am > > > paranoid too much... > > > > IMHO your hack above isn't really acceptable, even for a backport. > > So lets test the patch below (assuming it's the right thing to do) > > and move forward? > > OK, but please note that this patch is not beckportable. If you think > that -stable doesn't need this fix, then I agree. > > If the caller is do_device_not_available(), then we can not enable > irqs before __thread_fpu_begin() + restore_fpu_checking(). > > 1. Preemption in between can destroy ->fpu.state initialized by > fpu_finit(), __switch_to() will save the live (wrong) FPU state > again. > > 2. kernel_fpu_begin() from irq right after __thread_fpu_begin() is > not nice too. It will do __save_init_fpu() and this overwrites > ->fpu.state too. > > Starting from v4.0 it does kernel_fpu_disable(), but the older kernels > do not. > > Ingo, this code is really horrible and fragile. We need to cleanup it > step-by-step, imho. How about the patch from David Vrabel? That seems to solve the irq-disable problem too, right? Thanks, Ingo