From patchwork Mon Jul 20 15:10:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 51283 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D942E202B9 for ; Mon, 20 Jul 2015 15:10:25 +0000 (UTC) Received: by wgal16 with SMTP id l16sf13988853wga.2 for ; Mon, 20 Jul 2015 08:10:25 -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=OHggHkB8nppAO0YE3v4XWTBhp7GHpFeSXhGDEWdLRSM=; b=bWo15pIfmo4jTrhVT6lYxKaEc9zggHop1Q81gj6+ARDVgIRre5ZBV1AQc0Ud5SCHGK Y916ILHaNJqYjr2wa+pZvmAdzUeWN0pTKMUuFd4xRYxM1R5h22qL/AY+tmAnI+1VX7Wf X0IcgB2R2X58rINHwxOdETc60T9nyOyotm63Ea1FSpYBKeE1aDDIs43pO35ErHHOmliD CBLhQL8FKH/FfwDGhkincxl3xNeyH/0vKJZJ/9Ll7S9Pw3yHUVYajm3XFhvJPHanBMKn y5hkRp5NnTIUxxayRcQ199SQFsRHJ0JbFzC8smLOnZ/IocD0YSiIaDbDEEvcVQn4wazC u0wg== X-Gm-Message-State: ALoCoQl5FloYzx6Vy6y7FOF6cUSAMtDH8JBALWMtyZF3Yobwy/KrOEs/dAs/3h+Lw/m2LM2zvf7z X-Received: by 10.112.173.230 with SMTP id bn6mr6547733lbc.15.1437405025179; Mon, 20 Jul 2015 08:10:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.168 with SMTP id ev8ls798749lac.8.gmail; Mon, 20 Jul 2015 08:10:24 -0700 (PDT) X-Received: by 10.152.179.162 with SMTP id dh2mr24879004lac.53.1437405024968; Mon, 20 Jul 2015 08:10:24 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id r2si8014020lae.66.2015.07.20.08.10.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2015 08:10:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lblf12 with SMTP id f12so97127339lbl.2 for ; Mon, 20 Jul 2015 08:10:24 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr28857967lbb.56.1437405024848; Mon, 20 Jul 2015 08:10:24 -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 l6csp853495lba; Mon, 20 Jul 2015 08:10:23 -0700 (PDT) X-Received: by 10.180.102.74 with SMTP id fm10mr22708140wib.25.1437405022282; Mon, 20 Jul 2015 08:10:22 -0700 (PDT) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com. [74.125.82.51]) by mx.google.com with ESMTPS id ex6si13782954wid.103.2015.07.20.08.10.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2015 08:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.51 as permitted sender) client-ip=74.125.82.51; Received: by wgkl9 with SMTP id l9so132954708wgk.1 for ; Mon, 20 Jul 2015 08:10:21 -0700 (PDT) X-Received: by 10.194.5.74 with SMTP id q10mr55950490wjq.27.1437405021312; Mon, 20 Jul 2015 08:10:21 -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 z9sm12254158wiv.9.2015.07.20.08.10.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2015 08:10:20 -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 v2 1/5] arm64: alternative: Provide if/else/endif assembler macros Date: Mon, 20 Jul 2015 16:10:00 +0100 Message-Id: <1437405004-1296-2-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437405004-1296-1-git-send-email-daniel.thompson@linaro.org> References: <1436536130-31438-1-git-send-email-daniel.thompson@linaro.org> <1437405004-1296-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.182 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 | 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. + */ +.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. + */ +.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 */