Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934058AbbGVLIG (ORCPT ); Wed, 22 Jul 2015 07:08:06 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:36319 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933446AbbGVLIE (ORCPT ); Wed, 22 Jul 2015 07:08:04 -0400 Subject: Re: [PATCH v2 1/5] arm64: alternative: Provide if/else/endif assembler macros To: Will Deacon 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> <20150720171242.GP9908@arm.com> 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 From: Daniel Thompson Message-ID: <55AF7990.6070105@linaro.org> Date: Wed, 22 Jul 2015 12:08:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150720171242.GP9908@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1895 Lines: 60 On 20/07/15 18:12, Will Deacon wrote: >> 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/ Will fix this. > >> + */ >> +.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. Ok. I will update this. I saw that there must be branch target patching (due to branches to __save_vgic_v3_state) but got it into my head that branches to local labels confused the assembler. I guess I must made an unrelated syntax error because I just done a few tests and can't reproduce anything like that. Daniel. -- 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/