From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754963AbbCPWl0 (ORCPT ); Mon, 16 Mar 2015 18:41:26 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:49749 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751989AbbCPWlU (ORCPT ); Mon, 16 Mar 2015 18:41:20 -0400 Date: Mon, 16 Mar 2015 23:43:01 +0100 From: Quentin Casasnovas To: Oleg Nesterov Cc: Dave Hansen , Borislav Petkov , Ingo Molnar , Andy Lutomirski , Linus Torvalds , Pekka Riikonen , Rik van Riel , Suresh Siddha , LKML , "Yu, Fenghua" , Quentin Casasnovas , "H. Peter Anvin" Subject: Re: [PATCH RFC 2/2] x86/fpu: change xsave_user() and xrestore_user() to use __user_insn() Message-ID: <20150316224301.GB14575@chrystal.uk.oracle.com> References: <54F74F59.5070107@intel.com> <20150315164948.GA28149@redhat.com> <20150315165036.GC28149@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150315165036.GC28149@redhat.com> User-Agent: Mutt/1.5.22 (2013-10-16) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 15, 2015 at 05:50:36PM +0100, Oleg Nesterov wrote: > Change xsave_user() and xrestore_user() to avoid the (imho) horrible > and should-die xstate_fault helper, they both can use __user_insn(). > > This also removes the "memory" clobber but I think it was never needed. > xrestore_user() doesn't change the memory, it only changes the FPU regs. > xsave_user() does write to "*buf" but this memory is "__user", we must > never access it directly. > So I'm really not sure about all the callers, but it seems that this instruction can be used to restore more than just the FPU state and I've no idea how much can change underneath gcc when we do so. It "feels" safe when saving the CPU state, not sure for the restoring case. > > This patch adds '"=m" (*buf)' in both cases, but this is only because > currently __user_insn() needs the non-empty "output" arg. > See if my suggestion on your front e-mail works for you. > > Note: I think we can change all other xstate_fault users too, including > alternative_input's. > I'd agree but I think we'll need new safe versions of alternative_input_*() macros as opposed to just using check_insn(alternative_input_2(...),...).