From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753811AbbDCRIe (ORCPT ); Fri, 3 Apr 2015 13:08:34 -0400 Received: from mail.skyhub.de ([78.46.96.112]:45777 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753791AbbDCRI3 (ORCPT ); Fri, 3 Apr 2015 13:08:29 -0400 Date: Fri, 3 Apr 2015 19:06:25 +0200 From: Borislav Petkov To: Quentin Casasnovas Cc: X86 ML , LKML , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Oleg Nesterov , Andy Lutomirski Subject: Re: [PATCH] x86/xsave: Robustify and merge macros Message-ID: <20150403170625.GJ3418@pd.tnic> References: <1427980282-25929-1-git-send-email-bp@alien8.de> <20150402155210.GB6703@chrystal.uk.oracle.com> <20150402161259.GE3483@pd.tnic> <20150403140630.GD14902@chrystal.uk.oracle.com> <20150403141426.GE14902@chrystal.uk.oracle.com> <20150403152324.GG3418@pd.tnic> <20150403154055.GF14902@chrystal.uk.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150403154055.GF14902@chrystal.uk.oracle.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 Fri, Apr 03, 2015 at 05:40:55PM +0200, Quentin Casasnovas wrote: > So yeah I still think we're not properly padding, if you take my earlier > example where repl2 = 5 bytes, repl1 = 4 bytes and orin_insn = 3. > > I'll let you re-read my original mail and come back to me to tell me what'd > I really miss! :) Dammit, dammit, dammit! And I thought this aspect was taken care of. I went into the old branches where I had done this and there I have: +#define OLDINSTR_2(oldinstr, num1, num2) \ + __OLDINSTR(oldinstr, num1) \ + ".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")) > 0) * " \ + "((" alt_rlen(num2) ")-(" alt_rlen(num1) ")),0x90\n" \ + alt_end_marker ":\n" + without the size of the orig_insn factored in into the padding. And that would work for your example because it would add 1+1 bytes padding. Basically, the idea was: .skip len(repl1) - len(orig), 0x90 .skip len(repl2) - len(repl1), 0x90 BUT!, for some reason I changed it to what's there now and I can't remember why anymore. IOW, this should fix your example but I need to think about it on a clear head first, to try to remember what was the problem with that original approach: --- diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h index 524bddce0b76..708838260f7c 100644 --- a/arch/x86/include/asm/alternative-asm.h +++ b/arch/x86/include/asm/alternative-asm.h @@ -50,7 +50,7 @@ \oldinstr 141: .skip -(((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)),0x90 - .skip -(((145f-144f)-(144f-143f)-(141b-140b)) > 0) * ((145f-144f)-(144f-143f)-(141b-140b)),0x90 + .skip -(((145f-144f)-(144f-143f)) > 0) * ((145f-144f)-(144f-143f)),0x90 142: .pushsection .altinstructions,"a" diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 5aef6a97d80e..2b8cc1dd7dbf 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -101,8 +101,8 @@ static inline int alternatives_text_reserved(void *start, void *end) */ #define OLDINSTR_2(oldinstr, num1, num2) \ __OLDINSTR(oldinstr, num1) \ - ".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")-(662b-661b)) > 0) * " \ - "((" alt_rlen(num2) ")-(" alt_rlen(num1) ")-(662b-661b)),0x90\n" \ + ".skip -(((" alt_rlen(num2) ")-(" alt_rlen(num1) ")) > 0) * " \ + "((" alt_rlen(num2) ")-(" alt_rlen(num1) ")),0x90\n" \ alt_end_marker ":\n" #define ALTINSTR_ENTRY(feature, num) \ --- -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --