From patchwork Tue Oct 8 15:39:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 175506 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5864512ill; Tue, 8 Oct 2019 08:40:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMt8K7G9OKPA8IJpkMid4v1RpBrZ2WhSq8ByBPHpsPHTX1AF86hvyZMadk4eQJUW4sL+em X-Received: by 2002:a17:906:6c8:: with SMTP id v8mr29964986ejb.252.1570549228113; Tue, 08 Oct 2019 08:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570549228; cv=none; d=google.com; s=arc-20160816; b=hsyqbZG6qpnn9kB1g4a6kVDej1ypFaDuXviivEIs+BXcKbPqZd0pA5gpXNFrsNoxd2 aUIQbHvMrhblZjk5149CdzQBd57y3hrR5Iz8Y2NRIS8cuOiWwk1iD9rrQ0Y6H4IKQDh/ mSbZ33nE6kaP+qfa8J8X91kDGi9koxDrc4pFs4LjF+iU8XQSK3FJLa7vjOwNhmDxmKZu /mggodSTj88+BGdnK4QyXfSeYxaAr/8CGzGQxMoXKYdJh/Qx8M0dkY+uPZ1gjw2AQ+lj keIbb+cOL7klC3hAos4Z8hwsRulkmbtE8iuWmcSRDpFJS/JsNa70iphU3uSA7z1QMEAY kYLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b980Hl78DxMdOTDWa2ywxLFA73lq8TP+ptHAnX2cLHA=; b=mR6qCkJcUN8G0CqgfEibtKOE28tsV3pW3ZMC2mULgivBzfR6RdQR0ItntM/Fmmagh7 8lAS+JyAUUeWh32Wmf3LwPX+KkghqA8izCAr0mY7B9lXIZkaNJJ2bA4ae/d8G74MF3a9 QlYN2dx5WkyS0RyqdzsXMMUcl4dC60HhnxC7zpJppaT2LJ0/3wfBak0eCy+c7Lbv/+Fo a83918cnExGTxvk+QpWTmnFeBUJYi4vosTBSaGj1vdk8uCNO6QO2PjHiNLvKGEOQgmuX sLXHhiZp+lS0Z2afWuJD8yBUmcMqv2cnw9d7RDeZtMjSID4op8+/+cs8OMMQ2fhHruLP +cpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j1Q8gOGZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si10919464edc.67.2019.10.08.08.40.27; Tue, 08 Oct 2019 08:40:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j1Q8gOGZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727228AbfJHPk0 (ORCPT + 13 others); Tue, 8 Oct 2019 11:40:26 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40807 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbfJHPk0 (ORCPT ); Tue, 8 Oct 2019 11:40:26 -0400 Received: by mail-wm1-f67.google.com with SMTP id b24so3610500wmj.5 for ; Tue, 08 Oct 2019 08:40:25 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=b980Hl78DxMdOTDWa2ywxLFA73lq8TP+ptHAnX2cLHA=; b=j1Q8gOGZWX7QaB9s7ddocqr1BtoUdBxNIAjtKQw7ZXf4UKEtQFazekJzePh7ajN8u5 G91896HYqOqb/LdD0v4yUDRE1sxH0J0Cv6IDfwpb0uhnwVl7VYCx4O9VcPcz7GEBQWbN SFNyCqFejMTpqiA9Ld8nNGA8UA1TrqO1bCgsNx3TXp1YPmPbHt3YtooVZXodfytOXigx t0JeSzM5gLAzmYkH0Nu5vugApxhEHu7WN84OKH8mIMtPg5r2epaODTg5nRXznaZFlrkn gSwBwNA/LNGNWC4nghQyeH1DHUCBUdzJuhmI3wV5XzUlrMeRkqlGhbhtaC0iGnn+zTC5 6DDw== 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:mime-version:content-transfer-encoding; bh=b980Hl78DxMdOTDWa2ywxLFA73lq8TP+ptHAnX2cLHA=; b=YfJrEprHsH03VooohwU2a4t3mnOJRyC3m3rx5FDW9mA07kEpcyXhb6HPnCBDFoIFcD LE9et0614rNVUMv2TxRdCvDJ737AjlrNeBwDMbEwI4X4BK4ZfIFXTHn2Ytlwdobs5vw+ /rEkQ0xU9hNccmiTtmVXDSflwDacd8kzKlmbRFpv8JZmFG/HwcO/y5DQYGjt0MEjZ1N9 0Ia71KTfSF1r5tuNzjhnB6A3TpUHXcAb2r3YsnHFUPt0OuTZ+6rUPkixqOfunELaduw0 0lfz6ffJoetrPg+0PYhSc+MLAuunos+Zbwy3MvSKmePU1OpE5HBWL9vLfI66dB7XhQ6L oLug== X-Gm-Message-State: APjAAAUrRdH4Swyj2eeWHiPlggP6/8rhbdxfXBHJrSEbAlhAhU3wLdLT pzhpv2dEZcbg93GyJtEwluC9Ug== X-Received: by 2002:a1c:a616:: with SMTP id p22mr4234707wme.3.1570549224904; Tue, 08 Oct 2019 08:40:24 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id x16sm16784723wrl.32.2019.10.08.08.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 08:40:23 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: stable@vger.kernel.org, Jeremy Linton , Andre Przywara , Catalin Marinas , Stefan Wahren , Will Deacon , Ard Biesheuvel Subject: [PATCH for-stable-v4.19 12/16] arm64: Always enable spectre-v2 vulnerability detection Date: Tue, 8 Oct 2019 17:39:26 +0200 Message-Id: <20191008153930.15386-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008153930.15386-1-ard.biesheuvel@linaro.org> References: <20191008153930.15386-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeremy Linton [ Upstream commit 8c1e3d2bb44cbb998cb28ff9a18f105fee7f1eb3 ] Ensure we are always able to detect whether or not the CPU is affected by Spectre-v2, so that we can later advertise this to userspace. Signed-off-by: Jeremy Linton Reviewed-by: Andre Przywara Reviewed-by: Catalin Marinas Tested-by: Stefan Wahren Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/cpu_errata.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index ffb1b8ff7d82..96b0319dd0d6 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -87,7 +87,6 @@ cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused) atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1); -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR #include #include @@ -225,11 +224,11 @@ static int detect_harden_bp_fw(void) ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1)) cb = qcom_link_stack_sanitization; - install_bp_hardening_cb(cb, smccc_start, smccc_end); + if (IS_ENABLED(CONFIG_HARDEN_BRANCH_PREDICTOR)) + install_bp_hardening_cb(cb, smccc_start, smccc_end); return 1; } -#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR */ DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); @@ -513,7 +512,6 @@ multi_entry_cap_cpu_enable(const struct arm64_cpu_capabilities *entry) caps->cpu_enable(caps); } -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR /* * List of CPUs that do not need any Spectre-v2 mitigation at all. */ @@ -545,6 +543,12 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope) if (!need_wa) return false; + if (!IS_ENABLED(CONFIG_HARDEN_BRANCH_PREDICTOR)) { + pr_warn_once("spectrev2 mitigation disabled by kernel configuration\n"); + __hardenbp_enab = false; + return false; + } + /* forced off */ if (__nospectre_v2) { pr_info_once("spectrev2 mitigation disabled by command line option\n"); @@ -556,7 +560,6 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope) return (need_wa > 0); } -#endif #ifdef CONFIG_HARDEN_EL2_VECTORS @@ -715,13 +718,11 @@ const struct arm64_cpu_capabilities arm64_errata[] = { ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), }, #endif -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR { .capability = ARM64_HARDEN_BRANCH_PREDICTOR, .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, .matches = check_branch_predictor, }, -#endif #ifdef CONFIG_HARDEN_EL2_VECTORS { .desc = "EL2 vector hardening",