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: 51339 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 5079D22E16 for ; Wed, 22 Jul 2015 11:21:20 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf56180710lbv.3 for ; Wed, 22 Jul 2015 04:21:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=vF8jcS7v1PpP9NKwi5G/uTPYo2f6ckZpzr8N6JeuaUA=; b=jE7zc8dssruf84U0yOvNh6hXexVybWB2c1wLGg69Tmwo9XiHjloZ6VsNGnb5BMLHr8 N+f97szbln03L5q8ep0FN3AoPYpBgKLPVJjb8OaxxXiDJ2tsmTQ2bkBX7q0pWU1R16HQ BaXXSk9EFzVMdg6/PPoKVLbEJrN33sGCkTDbEzvSEqtPtcJ2+VSM3BZPia7ZfJEdW5b5 Kktc5dT45jzNAwdrYhNbKzzdU55YO0ghT23jvPn9iWol1c+Mu7LCCfMDYDDQzEOj0DyO arN4a+JOwv5i5tRIIunqCjBtPsEnCjMwEsIJ8U4T7Hz1gu+OgQlSr9gMG5P7vL+x+nBd ZzwQ== X-Gm-Message-State: ALoCoQnZnojL8SQ2x5duf+sXLePhiZX0dJM+eyYd4KsSVCOmS7pRgb6iKcDZttQ8upPASzaowTrH X-Received: by 10.180.79.10 with SMTP id f10mr7836693wix.3.1437564079244; Wed, 22 Jul 2015 04:21:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.228 with SMTP id h4ls70618lam.23.gmail; Wed, 22 Jul 2015 04:21:19 -0700 (PDT) X-Received: by 10.112.146.36 with SMTP id sz4mr1907723lbb.54.1437564079086; Wed, 22 Jul 2015 04:21:19 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id jx2si921924lbc.124.2015.07.22.04.21.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 04:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbzr7 with SMTP id zr7so134490618lbb.1 for ; Wed, 22 Jul 2015 04:21:18 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr1836387lbc.112.1437564078813; Wed, 22 Jul 2015 04:21:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp2046545lba; Wed, 22 Jul 2015 04:21:18 -0700 (PDT) X-Received: by 10.180.77.200 with SMTP id u8mr5755292wiw.70.1437564078106; Wed, 22 Jul 2015 04:21:18 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com. [209.85.212.169]) by mx.google.com with ESMTPS id bq1si24197277wib.68.2015.07.22.04.21.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 04:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by wicmv11 with SMTP id mv11so76958519wic.0 for ; Wed, 22 Jul 2015 04:21:17 -0700 (PDT) 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 Cc: Daniel Thompson , 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: [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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */