From patchwork Tue Mar 6 17:15:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10262287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50AA360211 for ; Tue, 6 Mar 2018 17:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4092F29006 for ; Tue, 6 Mar 2018 17:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 339B52910A; Tue, 6 Mar 2018 17:19:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7747629006 for ; Tue, 6 Mar 2018 17:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WDpXGbIQRR5j7JQlMhZmpzM93j6Y6zTanSUKx0F/g6M=; b=saiE2cdg4Z2JftKrxVazMnL6wY AkfIS5dtREHTJBD9lBHwpQOrb2yR/VQ08lq57mw7RXzlE05lUMS+o8j1Lz5y299e4nyiqwx/NPMYb HkrS1vD4La6VqkT4cbGN7c9iTYqtyxQR7r+MUq9/gHTnm80QSQyD9ifC3aH1xfvbro+gF1ATEj3j2 +HmYgHvepLFbfMrqYu5dSzGRptYqjrS1WXc/SzGvCBL4eYSFOQxRxZGJBPLjZEQ7nijRLGvcsXAB0 sdm7ZNwC/EEluDMaVbE9zEaKloZSTNwm0c0NZNKoYzEeVUT/ahKApQGnJ/bqy/l9X35+URstJwHaB /nOSkFig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etGF5-0005Hc-PB; Tue, 06 Mar 2018 17:19:11 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1etGCJ-0003fD-E4 for linux-arm-kernel@lists.infradead.org; Tue, 06 Mar 2018 17:16:29 +0000 Received: by mail-wm0-x244.google.com with SMTP id t6so23746456wmt.5 for ; Tue, 06 Mar 2018 09:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kQwzt2kIi0zTsQqpqieqvEJxui8TcfZW/p54WjbqVqo=; b=gD7eLvByp8OVpRZZC98Widbe1tZPp6sgVI9gdbcrWhMg0w1nEwFIt0adD4osojI3uR MGw+YQUymdBX9Q1uK+wvo2I7/H7/P98JlmXdp7iIqapS18zaYr+QvqYAWocqEMMhVq6Y HXH9/hJEkHpTjEVyXympxjKmJtMRVqKl0g6+4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kQwzt2kIi0zTsQqpqieqvEJxui8TcfZW/p54WjbqVqo=; b=a6yFQIWq8gaivOsrmYTaLWS1nyCGly7G/YkYt0N5coB68Onk5YEIy1lsQJDd6k8NTr zz2MhQbZRQpDVMlIrPSfDaT6qqEwzia7bd1x0+zsTEjaRN8ZFV0cw6W0n6EIU2nKV9QJ hjcQwOCZSbi1og66qQ+7o0BEnwJQcwi9z37aNAx4Z0HkqdLQ3J7Ge1xD9NlmNjyYEy5x GOaKskTfqRvbhTlfv90MMN8+cR2wcqHEyX/kA4Gm2MAU+hbMiOPbkr/nGTNvy7BIm4bK DJKpiNvewYBMrx6P9WWQemaAO3nfoAt7PLoSkM877rr2W3oNf06Y/qM2O7JoVRYYTMGl Mh2g== X-Gm-Message-State: AElRT7H2ConwXAH9mhKp+7iTQe0Kxv6/q2SCWjzyPJYMNQKYm0SsKUqp Io/fBIxVxClZ/VfPlHMJfEYa+2yjmPg= X-Google-Smtp-Source: AG47ELveiSXPK+7I2wHxY4ZEEtY87sp3OJ3b1rp8YWbmbtSmNVogChr5ip0a4/Q3W6jBdr6MFpUq6w== X-Received: by 10.28.142.142 with SMTP id q136mr3271062wmd.131.1520356567514; Tue, 06 Mar 2018 09:16:07 -0800 (PST) Received: from localhost.localdomain ([160.168.113.39]) by smtp.gmail.com with ESMTPSA id j89sm10570026wrj.92.2018.03.06.09.16.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 09:16:06 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 5/5] arm64/kernel: enable A53 erratum #8434319 handling at runtime Date: Tue, 6 Mar 2018 17:15:35 +0000 Message-Id: <20180306171535.25681-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180306171535.25681-1-ard.biesheuvel@linaro.org> References: <20180306171535.25681-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180306_091620_091655_64F9792C X-CRM114-Status: GOOD ( 15.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, suzuki.poulose@arm.com, marc.zyngier@arm.com, catalin.marinas@arm.com, Ard Biesheuvel , will.deacon@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Omit patching of ADRP instruction at module load time if the current CPUs are not susceptible to the erratum. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 10 ++++++++++ arch/arm64/kernel/module-plts.c | 3 ++- arch/arm64/kernel/module.c | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index bb263820de13..39134c46bb13 100644 --- a/arch/arm64/include/asm/cpucaps.h +++ b/arch/arm64/include/asm/cpucaps.h @@ -45,7 +45,8 @@ #define ARM64_HARDEN_BRANCH_PREDICTOR 24 #define ARM64_HARDEN_BP_POST_GUEST_EXIT 25 #define ARM64_HAS_RAS_EXTN 26 +#define ARM64_WORKAROUND_843419 27 -#define ARM64_NCAPS 27 +#define ARM64_NCAPS 28 #endif /* __ASM_CPUCAPS_H */ diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index b161abdd6e27..e18023e5deb9 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -298,6 +298,16 @@ const struct arm64_cpu_capabilities arm64_errata[] = { MIDR_CPU_VAR_REV(1, 2)), }, #endif +#ifdef CONFIG_ARM64_ERRATUM_843419 + { + /* Cortex-A53 r0p[01234] */ + .desc = "ARM erratum 843419", + .capability = ARM64_WORKAROUND_843419, + .def_scope = SCOPE_LOCAL_CPU, + MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x04), + MIDR_FIXED(0x4, BIT(8)), + }, +#endif #ifdef CONFIG_ARM64_ERRATUM_845719 { /* Cortex-A53 r0p[01234] */ diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c index 534bf1d47119..1a583ccace00 100644 --- a/arch/arm64/kernel/module-plts.c +++ b/arch/arm64/kernel/module-plts.c @@ -158,7 +158,8 @@ static unsigned int count_plts(Elf64_Sym *syms, Elf64_Rela *rela, int num, break; case R_AARCH64_ADR_PREL_PG_HI21_NC: case R_AARCH64_ADR_PREL_PG_HI21: - if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_843419)) + if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_843419) || + !cpus_have_const_cap(ARM64_WORKAROUND_843419)) break; /* diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index 89217704944e..47b40aaa1a5d 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -201,6 +201,7 @@ static int reloc_insn_imm(enum aarch64_reloc_op op, __le32 *place, u64 val, static int reloc_insn_adrp(struct module *mod, __le32 *place, u64 val) { if (!IS_ENABLED(CONFIG_ARM64_ERRATUM_843419) || + !cpus_have_const_cap(ARM64_WORKAROUND_843419) || ((u64)place & 0xfff) < 0xff8) return reloc_insn_imm(RELOC_OP_PAGE, place, val, 12, 21, AARCH64_INSN_IMM_ADR);