Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755898AbbGTRMq (ORCPT ); Mon, 20 Jul 2015 13:12:46 -0400 Received: from foss.arm.com ([217.140.101.70]:56799 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752777AbbGTRMo (ORCPT ); Mon, 20 Jul 2015 13:12:44 -0400 Date: Mon, 20 Jul 2015 18:12:42 +0100 From: Will Deacon To: Daniel Thompson Cc: Catalin Marinas , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "patches@linaro.org" , "linaro-kernel@lists.linaro.org" , John Stultz , Sumit Semwal , Christoffer Dall , Marc Zyngier , Andre Przywara Subject: Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif assembler macros Message-ID: <20150720171242.GP9908@arm.com> References: <1436536130-31438-1-git-send-email-daniel.thompson@linaro.org> <1437405004-1296-1-git-send-email-daniel.thompson@linaro.org> <1437405004-1296-2-git-send-email-daniel.thompson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437405004-1296-2-git-send-email-daniel.thompson@linaro.org> 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 Content-Length: 2316 Lines: 67 Hi Daniel, Couple of really small comments. On Mon, Jul 20, 2015 at 04:10:00PM +0100, Daniel Thompson wrote: > The existing alternative_insn macro has some limitations that make it > hard to work with. In particular the fact it takes instructions from it > own macro arguments means it doesn't play very nicely with C pre-processor > macros because the macro arguments look like a string to the C > pre-processor. Workarounds are (probably) possible but things start to > look ugly. > > Introduce an alternative set of macros that allows instructions to be > presented to the assembler as normal and switch everything over to the > new macros. > > Signed-off-by: Daniel Thompson > --- > arch/arm64/include/asm/alternative.h | 40 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h > index c385a0c4057f..31b19ad18f7e 100644 > --- a/arch/arm64/include/asm/alternative.h > +++ b/arch/arm64/include/asm/alternative.h > @@ -77,6 +77,46 @@ void free_alternatives_memory(void); > .org . - (662b-661b) + (664b-663b) > .endm > > +/* > + * Begin an alternative code sequence. > + * > + * The code that follows this marco will be assembled and linked as > + * normal. There are no restrictions on this code. s/marco/macro/ > + */ > +.macro alternative_if_not cap > + .pushsection .altinstructions, "a" > + altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f > + .popsection > +661: > +.endm > + > +/* > + * Provide the alternative code sequence. > + * > + * The code that follows this macro is assembled into a special > + * section to be used for dynamic patching. Code that follows this > + * macro must: > + * > + * 1. Be exactly the same length (in bytes) as the default code > + * sequence. > + * > + * 2. Not jump to local labels defined outside of the alternative > + * sequence. Actually, we fix up the branch target during patching. What you can't do is jump into *another* alternative sequence. Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/