From patchwork Thu Mar 21 23:05:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 160828 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp140021jan; Thu, 21 Mar 2019 16:06:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUP+fT9LfUybknLsMK+Zai6w8+MaV10U2FWp5/IvVogsnpnbmOgInXldfZI+7gh0dZFvjJ X-Received: by 2002:a17:902:681:: with SMTP id 1mr6293096plh.31.1553209582168; Thu, 21 Mar 2019 16:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553209582; cv=none; d=google.com; s=arc-20160816; b=az9C6unWtVM/fmMQ9VUSpC7W0yp7sJF+qQC1lX6WWgkVgOaPmZde4UuLFljc4JgFtJ Tj1Zwncjf/8W4KOOAvXERBGSJsjkkBmvTakMcqbTgxrJbv0tVVg9kpJcdB5Eq9/dgCWv vh78Gh9suxde7oTXL/m1vado8SsgSZvtN8cjnUfQHGgrS6uoIMaG0thPHNX6rcOexI0c Usf2ylwh2l9RaoExs+HX0/f1MQLkUrlJwMB/SzwXj5iy2KxjLwUqxTbzykWRq8pKSt/4 MzWkKkpYJW27moutyJP4kmedsGRBpTEWBwS6ObwNPw20L6qS1HTM1KlUzxd8V+myjecZ Kgcw== 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; bh=ax91oskZDxgzgy/61js674czDJzRzYkVE4BK6F5sxM4=; b=IYdmClnIDsxS2dE6zGgHEksVMcXI/HuGPYl5G3IdTLtxc5beUquhr0yhRTh4Gk4+Fw IO4MEm6wIKqGWg3/M9ROWzKC4DSszXcJS3eMCwkj30PdPE4hnRivrVWN1cYqz0tc312n BBdtgJILarSLjD148MuH6jAc/po42GvSIxmdZID2FSVQST6Ty8KvoBLaYmN/hsmbSIsy dbIlYy2zUvuGYVlrU3U/Yf+Fvmlf0ALB9O3t4rFmJcneYxQ+sCyPxdORCR4GRy+H8npv 2VD8C10FX7CCODTMhWYJr8a5sLPhqKFob+GkAWMylQ+ZX5IODc6m4loM6BPow4qaO+9r 9TuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si5491856plr.411.2019.03.21.16.06.21; Thu, 21 Mar 2019 16:06:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbfCUXGU (ORCPT + 31 others); Thu, 21 Mar 2019 19:06:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35772 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbfCUXGQ (ORCPT ); Thu, 21 Mar 2019 19:06:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8C70E1713; Thu, 21 Mar 2019 16:06:15 -0700 (PDT) Received: from beelzebub.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DC56E3F614; Thu, 21 Mar 2019 16:06:14 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, Dave.Martin@arm.com, shankerd@codeaurora.org, julien.thierry@arm.com, mlangsdo@redhat.com, stefan.wahren@i2e.com, Andre.Przywara@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton , Andre Przywara , Stefan Wahren Subject: [PATCH v6 06/10] arm64: Always enable spectrev2 vulnerability detection Date: Thu, 21 Mar 2019 18:05:53 -0500 Message-Id: <20190321230557.45107-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321230557.45107-1-jeremy.linton@arm.com> References: <20190321230557.45107-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sysfs patches need to display machine vulnerability status regardless of kernel config. Prepare for that by breaking out the vulnerability/mitigation detection code from the logic which implements the mitigation. Signed-off-by: Jeremy Linton Reviewed-by: Andre Przywara Tested-by: Stefan Wahren --- arch/arm64/kernel/cpu_errata.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index e5c4c5d84a4e..74c4a66500c4 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -109,7 +109,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 @@ -270,11 +269,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 */ #ifdef CONFIG_ARM64_SSBD DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); @@ -513,7 +512,6 @@ cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused) .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ CAP_MIDR_RANGE_LIST(midr_list) -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR /* * List of CPUs that do not need any Spectre-v2 mitigation at all. */ @@ -545,6 +543,11 @@ 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 configuration\n"); + return false; + } + /* forced off */ if (__nospectre_v2) { pr_info_once("spectrev2 mitigation disabled by command line option\n"); @@ -556,7 +559,6 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope) return (need_wa > 0); } -#endif #ifdef CONFIG_HARDEN_EL2_VECTORS @@ -731,13 +733,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",