From patchwork Mon Nov 9 20:51:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11892481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48AFFC55ABD for ; Mon, 9 Nov 2020 20:52:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB58C2068D for ; Mon, 9 Nov 2020 20:52:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VBsUjp0q"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="OpbZWml0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB58C2068D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=N2VRomltpWB/q/QXqCo0Ijcl4be06R/h2AS/T3vJX6s=; b=VBsUjp0q8loeEP9uGN0tPVrll+ bLdnZ/Xs7ccfdpktM/CvK4KhGgWz5I6R+6y93s3BVkoW0v7VAlQfD9a1Brwnh4j4I68yp+WMuc4r6 Zr/I9rQOfurPPB8ICnBl2kyXo86BZa4Fuazd7Or7QusfsMf+m874/s6bH1qtGdzxVeIIgdjUD/Wc1 7bq6d8ipYnBQPCptH4HxXJ0XyLagToDoL7Ki61w1lPyE8zxEp64cpBTJCMLGODEv7nnyyKY0Mb6op 9usv2rrPpFnlI87Z9g+pcPpSM+jQdQu24o48aE+5qM0za/34cqEOnqmUqhlZ68FlGdGBaE3fbUgtw GKuJA5xQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcE98-0005Pm-1l; Mon, 09 Nov 2020 20:52:14 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcE95-0005Ov-3T for linux-arm-kernel@lists.infradead.org; Mon, 09 Nov 2020 20:52:12 +0000 Received: by mail-yb1-xb49.google.com with SMTP id t71so3479916ybi.3 for ; Mon, 09 Nov 2020 12:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=ItIyVy5KO5WuT6gZSHv+tWX1C0qVtRdRVgajUctR89w=; b=OpbZWml0IoEtfaXE5dwayDjaDOyELvWYVSInQFtIn1S1FT9sFBhOITetVwnQszxMsn 024yRrMs+UjL9ds3ZMEiyAduvj7NeYjhThcc2XnZY8D0FwYgVMfaTeryKxJlACA9xgYi LGpaLXvqYy1Y1HLWgxGGoCvI/8CZan/03OxLwj4yLvnnVUYThEw62yPqf2haft5qAKko d17+PhXCjszC728nLT3M5kwxkhaRUfKzu6N3VDxI1DB5K3+qE6Tahif3FySRoblDRaSd 4/bPxqUPGrbsw4Y4WfUiR9m/pGW8E+1RrzTYelQdChuNk5JUJUSyyopcukvhqNb0oQyf guGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=ItIyVy5KO5WuT6gZSHv+tWX1C0qVtRdRVgajUctR89w=; b=IlhmLh5Jisv7rbbrLHe1VdcteTPpY1ktLVmvSA6CdJ4lX1gfFfDKlEj+enn5DrPawr ughAZbu93xUEY+bhvD9cbibCn20MII2vCjfFir7VZHcp7kjIIPw+Cud22xpl32Hxv1ot D4WuSoafxqkGb85XPe1aNE89llQOuunChWYsACUKCcsy8Jd1oQG9e8aJShvTrDAjCNIy icZn0O2e4Tpluewu/wlvcbDBObc6c0wvaP2NeuTFlcvEQ12Ir00UdjRv2SmFeuzoTR6+ tVti1CawRQxMeP7JrIFVp1ah24sLvaW3MdYiHdC2mT1SlMlyBlWj0gbSHtrEcf7NEvQn pwlg== X-Gm-Message-State: AOAM531BnxJDlfDaR/Qm0uVu5TtLtu5XKPrWaQFhUV9hK6Pj8z9g1Mnb MwYRfmS1qImjCyu3VFGck4MC3S43pc7/3R8WDFQ= X-Google-Smtp-Source: ABdhPJwknzqYYBgKOcdvOJ/pt9vXu7LTweCfxuf2OAuzIktrFA2MFb7PvHTPce+fPn/9JvlJ/uFKTUQmu9FDcO8UCXk= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a25:d981:: with SMTP id q123mr14118805ybg.50.1604955127041; Mon, 09 Nov 2020 12:52:07 -0800 (PST) Date: Mon, 9 Nov 2020 12:51:54 -0800 Message-Id: <20201109205155.1207545-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH] ARM: decompressor: avoid ADRL pseudo-instruction From: Nick Desaulniers To: Ard Biesheuvel X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_155211_155102_03E8A61E X-CRM114-Status: GOOD ( 16.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , Nicolas Pitre , linux-kernel@vger.kernel.org, Linus Walleij , Nick Desaulniers , Russell King , Jian Cai , clang-built-linux@googlegroups.com, Nathan Chancellor , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As Ard notes in commit 54781938ec34 ("crypto: arm/sha256-neon - avoid ADRL pseudo instruction") commit 0f5e8323777b ("crypto: arm/sha512-neon - avoid ADRL pseudo instruction") The ADRL pseudo instruction is not an architectural construct, but a convenience macro that was supported by the ARM proprietary assembler and adopted by binutils GAS as well, but only when assembling in 32-bit ARM mode. Therefore, it can only be used in assembler code that is known to assemble in ARM mode only, but as it turns out, the Clang assembler does not implement ADRL at all, and so it is better to get rid of it entirely. So replace the ADRL instruction with a ADR instruction that refers to a nearer symbol, and apply the delta explicitly using an additional instruction. We can use the same technique to generate the same offset. It looks like the ADRL pseudo instruction assembles to two SUB instructions in this case. Because the largest immediate operand that can be specified for this instruction is 0x400, and the distance between the reference and the symbol are larger than that, we need to use an intermediary symbol (cache_off in this case) to calculate the full range. Suggested-by: Ard Biesheuvel Suggested-by: Jian Cai Signed-off-by: Nick Desaulniers --- arch/arm/boot/compressed/head.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 2e04ec5b5446..b3eac6f9a709 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -1440,7 +1440,9 @@ ENTRY(efi_enter_kernel) mov r4, r0 @ preserve image base mov r8, r1 @ preserve DT pointer - ARM( adrl r0, call_cache_fn ) + ARM( sub r0, pc, #.L__efi_enter_kernel-cache_off ) + ARM( sub r0, r0, #cache_off-call_cache_fn ) +.L__efi_enter_kernel: THUMB( adr r0, call_cache_fn ) adr r1, 0f @ clean the region of code we bl cache_clean_flush @ may run with the MMU off