From patchwork Thu Apr 1 16:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12178423 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 0B48FC433ED for ; Thu, 1 Apr 2021 16:53:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7A3196120D for ; Thu, 1 Apr 2021 16:52:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A3196120D 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc: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=7sHan6zFqMSv7BBlqCoM0Sdtk/aO6YGRzqX9jsAIM9w=; b=MXCFPzyNMOITO2pecjoSHfXVYx kb1Y+bxgm0e7/k4c18Sxp/O6ukdN255Qomd32CvVl3TP31mayNJ/nW3Aq6+QzI+fOygA8WshXGxkg MfA+FBpp1WOab2O++3jBDqSuiBU1LwWGiYXE0nGvcyrqRl49+mgjo37sESdE/COGLWLUWdlUDc257 zQDUTqSmVpppUDUeuR/i2sBuhdUfiGiqT1lWxsHoXhXbR5p8jxLclNDgdsaU0EvgdnsZGa4BCFcOK Mf/aJ5BFK5bE/ZSQMIy5cnwNpmYI349cx0YXRLXmItYSH63QXUmV6lc6I4e1GVHwvoEKuUq6E5aqc 21Lu4hVw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS0Xl-00AOnO-1p; Thu, 01 Apr 2021 16:51:41 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS0Xf-00AOm5-TM for linux-arm-kernel@lists.infradead.org; Thu, 01 Apr 2021 16:51:38 +0000 Received: by mail-pl1-x649.google.com with SMTP id t18so3281534plr.15 for ; Thu, 01 Apr 2021 09:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=9vTU0L/T7IngBBh2gwOaqiBEmh3tpZ/KoOkiMOuv1Qw=; b=ZP3U/hoI3nkqb4bVctDkhc9JgAzWXkyhLBm9pBjaUFdnV0XOjjJaKKF5lt0ns9hoZ0 SI7oUdqL1IdOzUY0bEs3zWF2gP0aVdJvo2bu2rHLew8j5yVfHQTgi+GZ6PBUU7OkPLut 2P/VjEVY5LLf6vMrebN3g8BwOyyhWPAwPhinTC1RrLFwPD1HiZr7bChVIG7cMRkUnAL2 I5hXaYX9P9HEmE2RYNIVufMAFFKJvP/4Cgih3h+fcFMlmMtgPtyKk4buunWJoVctPLh9 5Rp+K/ErAGzZIm/dWcW9B9YeqOj4yZuDuK3qVg/wS8yD75bGWYwA8FAD/i4Jnx40LoCf gH3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=9vTU0L/T7IngBBh2gwOaqiBEmh3tpZ/KoOkiMOuv1Qw=; b=tlbr83zhieSeSU6BGc6vNDobb/twruNgWVAOw/p4WARRr6izRHl19GWfNHW1/YwZoP C3VQIQO4t+0VQpZAFlAfOKN+F4qn3paNN5olub8fdPXT9Rk81Zpj7FmcpJRqZ0I5BVib mHICLbuAxX9tLneesn1q1DwXEnfpawkjICb8GmQjuEPQ1Ws0G+FcYb4A8XiWxGcjvZ65 yUEnPN3fvGZo+I0Vros8HEZaI18ywJlDVbytWHtZt4tyWqlLyPoLeFa52anRd2SBuP1z QaLbrIBWYRD8aegdKdo70SnviwV8ogtRXFX/BsJxuBkv/wBuwCkbMUr5Li++6OhVVGUL NoSg== X-Gm-Message-State: AOAM531gxba4XS1Gr/kSRxkbqyFBbejOSKYvGXcgTC04zgdgxxTddYWW oIl+YgM+yJuKyGumoKwdxjBOYp0= X-Google-Smtp-Source: ABdhPJz22djsWCBeTCZsjWJqO0jJh5CTzU1OcoH9V4YF+J5lglwwH1BzisGEtRPrRZyJ4a3W7FIanfY= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:0:3dc0:b59f:6f36:16d2]) (user=pcc job=sendgmr) by 2002:a17:902:e051:b029:e7:37d9:f32e with SMTP id x17-20020a170902e051b02900e737d9f32emr8698748plx.78.1617295893619; Thu, 01 Apr 2021 09:51:33 -0700 (PDT) Date: Thu, 1 Apr 2021 09:51:10 -0700 Message-Id: <20210401165110.3952103-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog Subject: [PATCH] arm64: fix inline asm in load_unaligned_zeropad() From: Peter Collingbourne To: Catalin Marinas , Will Deacon Cc: Peter Collingbourne , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_175136_037387_43722443 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The inline asm's addr operand is marked as input-only, however in the case where an exception is taken it may be modified by the BIC instruction on the exception path. Fix the problem by using a temporary register as the destination register for the BIC instruction. Signed-off-by: Peter Collingbourne Cc: stable@vger.kernel.org Link: https://linux-review.googlesource.com/id/I84538c8a2307d567b4f45bb20b715451005f9617 --- arch/arm64/include/asm/word-at-a-time.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/word-at-a-time.h b/arch/arm64/include/asm/word-at-a-time.h index 3333950b5909..ea487218db79 100644 --- a/arch/arm64/include/asm/word-at-a-time.h +++ b/arch/arm64/include/asm/word-at-a-time.h @@ -53,7 +53,7 @@ static inline unsigned long find_zero(unsigned long mask) */ static inline unsigned long load_unaligned_zeropad(const void *addr) { - unsigned long ret, offset; + unsigned long ret, tmp; /* Load word from unaligned pointer addr */ asm( @@ -61,9 +61,9 @@ static inline unsigned long load_unaligned_zeropad(const void *addr) "2:\n" " .pushsection .fixup,\"ax\"\n" " .align 2\n" - "3: and %1, %2, #0x7\n" - " bic %2, %2, #0x7\n" - " ldr %0, [%2]\n" + "3: bic %1, %2, #0x7\n" + " ldr %0, [%1]\n" + " and %1, %2, #0x7\n" " lsl %1, %1, #0x3\n" #ifndef __AARCH64EB__ " lsr %0, %0, %1\n" @@ -73,7 +73,7 @@ static inline unsigned long load_unaligned_zeropad(const void *addr) " b 2b\n" " .popsection\n" _ASM_EXTABLE(1b, 3b) - : "=&r" (ret), "=&r" (offset) + : "=&r" (ret), "=&r" (tmp) : "r" (addr), "Q" (*(unsigned long *)addr)); return ret;