From patchwork Mon Apr 15 21:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 162273 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3418195jan; Mon, 15 Apr 2019 14:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc8Cu2/Fa0MeIilKxwaRdqShHe4GCzHxOJq+mEBNeJpV9Cyo4NTZHgknUAbUfbH0zj3E5U X-Received: by 2002:a62:59cb:: with SMTP id k72mr79031996pfj.111.1555363307770; Mon, 15 Apr 2019 14:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555363307; cv=none; d=google.com; s=arc-20160816; b=YByOEJ92uNvqvlfavvfiu6d+A35Qbw/w4BeJrWqFkzCwxRfxlmhe6r0pkNS9n9AOwF tAjobHbC1a5yjXMNtLWSwg8UzRa63ENUDWyzBbRqNPdxBDRr8G57wsHEr//2kNV2SR3e Zwp68apV/kPISdo300Gjqu32ESlHQ3Hvpt3/P4hdjwMdBCPt75jvYY9x+mSR46+YOKOw 8oAGqrdZM70f3kAHkWW7mAU691k2UZh/mZ/0ELs1oVWX9/2MRL/4wOSncxX9WF0Kvlr/ dGDnG+gbWMJ6emySJGlULsOnwB+O8VZkmnETkyHjeEV1iIpm0TbO5F4a060Ib6jHCT9a OPRw== 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=rQCESJdc6KbVv9lW5790OcnC6ct5HRBCHKVdR3iQHi0=; b=lniDHRoxkSXgRf2jG+Ne/Bm3hgSflbhodyxlDoawuvQZj56bgkATJ5tI8UZpgxVF45 guupPm/HXFdkNVfqJF/SwOl3gWeEjjflt6sKvPwBOouDLRG9pcGgqwgpdcjQiSc1OMuu qy9KiDwfCqFB+AoEkHw6UiShcVmq2GYO7N7PcfXRYQRwVEk1R1xVz3pU39oXxY/EKR36 QgvfiCl1xm2cbPNhzWXmhWTBRlY1mqOVV9sC2J0Qy2QJ7XOPzh26Zf8/+7cUkFMXXLDZ LKH1crsI1W8oqQl7vpBQ9/+5u+es5XBC/9GaXALSAXGbHDOBvABX1a4OCP/mGv6hINA+ IR6w== 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 x9si39124931pgx.212.2019.04.15.14.21.47; Mon, 15 Apr 2019 14:21:47 -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 S1728088AbfDOVVq (ORCPT + 30 others); Mon, 15 Apr 2019 17:21:46 -0400 Received: from foss.arm.com ([217.140.101.70]:42942 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbfDOVVn (ORCPT ); Mon, 15 Apr 2019 17:21:43 -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 E18D0168F; Mon, 15 Apr 2019 14:21:42 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 45F0F3F68F; Mon, 15 Apr 2019 14:21:42 -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@i2se.com, Andre.Przywara@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton , Andre Przywara Subject: [v8 06/10] arm64: Always enable spectrev2 vulnerability detection Date: Mon, 15 Apr 2019 16:21:25 -0500 Message-Id: <20190415212129.1112-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190415212129.1112-1-jeremy.linton@arm.com> References: <20190415212129.1112-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 Reviewed-by: Catalin Marinas 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 60cf87c4deb7..bd2cdd22da99 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",