From patchwork Tue Mar 10 15:39:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 5978631 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 3D90FBF440 for ; Tue, 10 Mar 2015 15:42:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 758942012D for ; Tue, 10 Mar 2015 15:42:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1AC32011D for ; Tue, 10 Mar 2015 15:42:55 +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 1YVMH0-0004bd-Mb; Tue, 10 Mar 2015 15:40:46 +0000 Received: from mail-we0-f171.google.com ([74.125.82.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVMGV-00035a-BN for linux-arm-kernel@lists.infradead.org; Tue, 10 Mar 2015 15:40:16 +0000 Received: by wesk11 with SMTP id k11so2649409wes.13 for ; Tue, 10 Mar 2015 08:39:52 -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=J493jfUo0ErUaILFxc4/LRzTeLKFKzUMCBT2kIVkhjs=; b=IwszDzMH04EXasi1qZhb3yGQKsjpeuvDF/fh84GetSy2c2r19uxk7xKvwHMOwKIpo6 lK3XeSbpiIKaBNjd9Eiv1E/HF7BLwZ4HOzSN64AsTNmWPsOeYkZkVv3wlUgh4sP9QPQR 9CP9bSzF2rQqJZca5pP8x9KDlSEmfFhIoMrw6dQ49qPj+naCTf0Jnl+28woCoy0M5JCe QchWIikhcPfE8HiENOOJ9QNfodWsFWNX5dJHkArA+bUHf0OHYz+o6hiwrJs4vHTAzDuy he25i/RMCZJkebqJMNJIJf6ZZYEcTc2AqkLW3K0YVP5iapcd4EezW3iD+vIxx2yyVCGs rtfg== X-Gm-Message-State: ALoCoQlvzDZCuRXF7m2U7ce7ErZ34gsbGWQL1t+3oqDo9epRfQodW6uFzdrieoRwE63TtU51MzAs X-Received: by 10.194.62.167 with SMTP id z7mr70519190wjr.106.1426001992122; Tue, 10 Mar 2015 08:39:52 -0700 (PDT) Received: from ards-macbook-pro.local ([213.143.60.209]) by mx.google.com with ESMTPSA id ei3sm7381208wib.4.2015.03.10.08.39.49 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Mar 2015 08:39:51 -0700 (PDT) From: Ard Biesheuvel To: will.deacon@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 1/5] arm64: add macros for common adrp usages Date: Tue, 10 Mar 2015 16:39:38 +0100 Message-Id: <1426001982-20047-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1426001982-20047-1-git-send-email-ard.biesheuvel@linaro.org> References: <1426001982-20047-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150310_084015_608274_7BF532A7 X-CRM114-Status: UNSURE ( 9.04 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 adrp instruction is mostly used in combination with either an add, a ldr or a str instruction with the low bits of the referenced symbol in the 12-bit immediate of the followup instruction. Introduce the macros adr_l, ldr_l and str_l that encapsulate these common patterns. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/assembler.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 750bac4e637e..f1804d4803fb 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -159,4 +159,33 @@ lr .req x30 // link register orr \rd, \lbits, \hbits, lsl #32 .endm +/* + * Pseudo-ops for PC-relative adr/ldr/str , where + * is within the range +/- 4 GB of the PC. + */ + .macro adr_l, dst, sym, tmp= + .ifb \tmp + adrp \dst, \sym + add \dst, \dst, :lo12:\sym + .else + adrp \tmp, \sym + add \dst, \tmp, :lo12:\sym + .endif + .endm + + .macro ldr_l, dst, sym, tmp= + .ifb \tmp + adrp \dst, \sym + ldr \dst, [\dst, :lo12:\sym] + .else + adrp \tmp, \sym + ldr \dst, [\tmp, :lo12:\sym] + .endif + .endm + + .macro str_l, src, sym, tmp + adrp \tmp, \sym + str \src, [\tmp, :lo12:\sym] + .endm + #endif /* __ASM_ASSEMBLER_H */