Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3987012imm; Mon, 17 Sep 2018 06:31:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaM79w2LotlpqOxsSnhyZKIpEyeibBE5lIZgXXbEvAitlnXBRX0UJup/T7OUHVqx9hlGKzS X-Received: by 2002:a17:902:7009:: with SMTP id y9-v6mr24634042plk.249.1537191071719; Mon, 17 Sep 2018 06:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537191071; cv=none; d=google.com; s=arc-20160816; b=NCxUXadT+KOKkudc4wloc9wlixU0keZ7ucXHsZI4DYzxqiq1etJ531exZg1ne9alDE XCtpvWXXuY8iyLZPpjCRvWCeRZlzFR8OgkP28ZOCQNYA4pL1MYa5E3VzT4puidlDorLP sNG7Nn40byx6yuU5Tmwp6ev8YbbxNzpdExKWfKxqjNulwZrma7W1p51AFslVlP2YSWAy Pdtjtt2o/BSOR2q84UylflbPuOw/iWDK2xWdgVorPGTdqDw2voHR6lCby0rNaoYr+qbK 3SD9EBqpVMPYuyJPOGt0kNmwpPjgbAMn/Z3BvXSI25TSVdHKJozpJ7l6G544wsP7ieBa iceA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qc3levBref9mEap6+9vINJWbJzMS04PnRn3WvTVreYQ=; b=om/s3YDfGZqvpwELBuqSHsMEtNZALrvH72KoNYTZT2c5tIXaVzrLdyr/KISsjPr+iX ca/qYojXxborMPDQn4/F6KxajIqgSPwZHFWza1Y80kFmc+IU+ivlgvjChd5VwdBQ8u+A Vabl3+TRPRWDJzLru1wLLNmu2HLhcGUccQv5DJDhqu5jwbReswiiAYcNyKYoChZPc+DY g8xWJ+XE6IqoBaDVfSI75nThvDz4haiSLvuypLM2SI4phGzN//AGBlBT8viPkN0dh1ET 8IIHWog18ectXzGypgTYXzBIOK5HhI+oFVE1cWB1iH/0t0hp9TR0kSPrYyfTEmLMgv+k uHmg== 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 o137-v6si17194335pfg.362.2018.09.17.06.30.49; Mon, 17 Sep 2018 06:31:11 -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 S1728598AbeIQS5o (ORCPT + 99 others); Mon, 17 Sep 2018 14:57:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59070 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728273AbeIQS5n (ORCPT ); Mon, 17 Sep 2018 14:57: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 335A41596; Mon, 17 Sep 2018 06:30:23 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 055763F557; Mon, 17 Sep 2018 06:30:23 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 9189C1AE3063; Mon, 17 Sep 2018 14:30:41 +0100 (BST) Date: Mon, 17 Sep 2018 14:30:41 +0100 From: Will Deacon To: Mian Yousaf Kaukab Cc: marc.zyngier@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robert.richter@cavium.com, cwu@amperecomputing.com Subject: Re: [PATCH RESEND 4/6] arm64: add sysfs vulnerability show for spectre v2 Message-ID: <20180917133041.GC23040@arm.com> References: <20180827143310.641-1-ykaukab@suse.de> <20180827143310.641-5-ykaukab@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180827143310.641-5-ykaukab@suse.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 27, 2018 at 04:33:08PM +0200, Mian Yousaf Kaukab wrote: > Only report mitigation present if hardening callback has been > successfully installed. > > Signed-off-by: Mian Yousaf Kaukab > --- > arch/arm64/kernel/cpu_errata.c | 34 +++++++++++++++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c > index 92616431ae4e..8469d3be7b15 100644 > --- a/arch/arm64/kernel/cpu_errata.c > +++ b/arch/arm64/kernel/cpu_errata.c > @@ -481,7 +481,8 @@ multi_entry_cap_cpu_enable(const struct arm64_cpu_capabilities *entry) > caps->cpu_enable(caps); > } > > -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR > +#if defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \ > + defined(CONFIG_GENERIC_CPU_VULNERABILITIES) > > /* > * List of CPUs where we need to issue a psci call to > @@ -712,4 +713,35 @@ ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, > return sprintf(buf, "Mitigation: __user pointer sanitization\n"); > } > > +ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + u64 pfr0; > + struct bp_hardening_data *data; > + > + pfr0 = read_cpuid(ID_AA64PFR0_EL1); > + if (cpuid_feature_extract_unsigned_field(pfr0, ID_AA64PFR0_CSV2_SHIFT)) > + return sprintf(buf, "Not affected\n"); This strikes me as a pretty terrible interface, as it means that the file can return different contents depending on which CPU it was read from on a big/little machine. I think we need to either expose this per-cpu, or expose the value of the system (e.g. if one CPU is vulnerable, we always say vulnerable). > + > + if (cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR)) { > + /* > + * Hardware is vulnerable. Lets check if bp hardening callback > + * has been successfully installed > + */ > + data = arm64_get_bp_hardening_data(); Related to the above, but this is accessing per-cpu stuff. Will