Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2557594yba; Mon, 15 Apr 2019 14:22:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz31K6hRoUB5JVYdEF5waekzh6utiP8pIiHA8WF0zDXcJWOYjCv1OETratMblEL5EsYnTAh X-Received: by 2002:aa7:9151:: with SMTP id 17mr78367652pfi.192.1555363370350; Mon, 15 Apr 2019 14:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555363370; cv=none; d=google.com; s=arc-20160816; b=nD8tMNgayumOxSU/RP08ASBDIYbMOLSVlcpMLEiKHszja529fgX+DEFxnhKowWfdB4 NhAvsxAv2e7DlpIAI8ZdyqgBekPB1bztRls2NY+7V9bZVWyBpucfo+URv/aa2Jeffenx 74irNXtsD5Zly+kaBQVK40TC8StXwMy1Vb+qDRUilW+qWec8+kUXFC66SEK/loJ/KJQj 2UrJzsNn9g0zPumtauDM82z0QMFECzn6fEz/CSfQXyFCUAi5JWBvTNs+1VElHMSOZkzF UGJcj1eKplBLUqiyEy515VJbXFF8EQ/KlwNbeIz3lzTUP3TvY/dfla/INfFHxc9L8MH7 4pAA== 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 i3si24684135pgq.350.2019.04.15.14.22.33; Mon, 15 Apr 2019 14:22:50 -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 S1728080AbfDOVVp (ORCPT + 99 others); Mon, 15 Apr 2019 17:21:45 -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 Content-Transfer-Encoding: 8bit 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(-) 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", -- 2.20.1