From patchwork Wed Jul 22 11:21:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 6842221 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 579E1C05AC for ; Wed, 22 Jul 2015 11:24:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8591820648 for ; Wed, 22 Jul 2015 11:24:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD3E02060D for ; Wed, 22 Jul 2015 11:24:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHs5u-0005ZZ-Ig; Wed, 22 Jul 2015 11:21:50 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHs5j-0005WL-Ut for linux-arm-kernel@lists.infradead.org; Wed, 22 Jul 2015 11:21:40 +0000 Received: by wicgb10 with SMTP id gb10so93445229wic.1 for ; Wed, 22 Jul 2015 04:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vF8jcS7v1PpP9NKwi5G/uTPYo2f6ckZpzr8N6JeuaUA=; b=EHxSK+Vw/KCllZREKZ3+AnC9wEWZv/j+vCICdarOue3njz9iM/SkGmA1dzD/+FDRq5 Usg98rR+IpAYxEvSpfWQjhN9Z1cj3+t8ZrqDSgj8ECUzGtFkxMbySWJ7Q5zdZUE1AqAd D2l29W2hHNTfNa+PyorSQ5EiiyCzuU3j1snH/DMoshgggAUbbjS+l4peRGinvIT9M8Mi ENuuGHfRYj3iMiG1S6c1N+mewL/P0/uWJfFxqqA8igjqfMB/e+6ORco+Q0nl4ay4Vytd /WiyQNBfny2LEhQb5Wu/OruE9S9T6V3ykEmKdWWhNitz5k2+zq3cCa1/xL23VhgH+Jlr +8Pg== X-Gm-Message-State: ALoCoQn4L38fGSF1Co1XGAzWcb+Q3wm0tUp2g+llV8PSXNSNLpPjHEi8uaNfXKjauFktx3WG2CXd X-Received: by 10.194.220.100 with SMTP id pv4mr4345024wjc.71.1437564077802; Wed, 22 Jul 2015 04:21:17 -0700 (PDT) Received: from wychelm.lan (cpc4-aztw19-0-0-cust71.18-1.cable.virginm.net. [82.33.25.72]) by smtp.gmail.com with ESMTPSA id j7sm1901235wjz.11.2015.07.22.04.21.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 04:21:17 -0700 (PDT) From: Daniel Thompson To: Catalin Marinas , Will Deacon Subject: [PATCH v3 1/5] arm64: alternative: Provide if/else/endif assembler macros Date: Wed, 22 Jul 2015 12:21:01 +0100 Message-Id: <1437564065-4356-2-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437564065-4356-1-git-send-email-daniel.thompson@linaro.org> References: <1436536130-31438-1-git-send-email-daniel.thompson@linaro.org> <1437564065-4356-1-git-send-email-daniel.thompson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150722_042140_161177_3CD5E47A X-CRM114-Status: GOOD ( 13.14 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Thompson , linaro-kernel@lists.linaro.org, patches@linaro.org, Marc Zyngier , Andre Przywara , linux-kernel@vger.kernel.org, John Stultz , Christoffer Dall , Sumit Semwal , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h index c385a0c4057f..e86681ad0931 100644 --- a/arch/arm64/include/asm/alternative.h +++ b/arch/arm64/include/asm/alternative.h @@ -77,6 +77,47 @@ void free_alternatives_memory(void); .org . - (662b-661b) + (664b-663b) .endm +/* + * Begin an alternative code sequence. + * + * The code that follows this macro will be assembled and linked as + * normal. There are no restrictions on this code. + */ +.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 contain a branch target that is used outside of the + * alternative sequence it is defined in (branches into an + * alternative sequence are not fixed up). + */ +.macro alternative_else +662: .pushsection .altinstr_replacement, "ax" +663: +.endm + +/* + * Complete an alternative code sequence. + */ +.macro alternative_endif +664: .popsection + .org . - (664b-663b) + (662b-661b) + .org . - (662b-661b) + (664b-663b) +.endm + #endif /* __ASSEMBLY__ */ #endif /* __ASM_ALTERNATIVE_H */