From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934053AbbCPO7m (ORCPT ); Mon, 16 Mar 2015 10:59:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54445 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933264AbbCPO7f (ORCPT ); Mon, 16 Mar 2015 10:59:35 -0400 Date: Mon, 16 Mar 2015 15:57:42 +0100 From: Oleg Nesterov To: Borislav Petkov Cc: Dave Hansen , 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 0/2] x86/fpu: avoid "xstate_fault" in xsave_user/xrestore_user Message-ID: <20150316145742.GA4059@redhat.com> References: <54F74F59.5070107@intel.com> <20150315164948.GA28149@redhat.com> <20150316143605.GL22995@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150316143605.GL22995@pd.tnic> 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 03/16, Borislav Petkov wrote: > > On Sun, Mar 15, 2015 at 05:49:48PM +0100, Oleg Nesterov wrote: > > > > And I agree with Quentin, user_insn/check_insn can be improved to allow > > clobbers, more flexible "output", etc. But imo they already can make this > > code look a bit better, and "xstate_fault" must die eventually. > > FWIW, I did poke at that but there's still something wrong with my macros, will > take a look when I get a chance: Sure, I won't argue if we use the new macros instead. But we already have check_insn/user_insn, why not use them? For example, > +#define XSTATE_XSAVE(st, lmask, hmask, err) \ > + asm volatile(ALTERNATIVE_2(XSAVE, \ > + XSAVEOPT, X86_FEATURE_XSAVEOPT, \ > + XSAVES, X86_FEATURE_XSAVES) \ > + "\n" \ > + ".pushsection .fixup,\"ax\"\n" \ > + "3: movl $-1, %[err]\n" \ > + "jmp " alt_end_marker "b\n" \ > + ".popsection\n" \ > + _ASM_EXTABLE(661b, 3b) \ > + : [err] "=r" (err) \ > + : "D" (st), "a" (lmask), "d" (hmask) \ > + : "memory") > + to me check_insn(ALTERNATIVE_2(...)) looks better. Except we need the clobber. It is not easy to read the code like this, imo it would be better to avoid copy-and-paste and use the helpers we already have. Just we need to improve them. But let me repeat, I leave this to you and others, I do not understand asm enough. Oleg.