Received: by 10.223.185.116 with SMTP id b49csp3535358wrg; Mon, 26 Feb 2018 01:28:35 -0800 (PST) X-Google-Smtp-Source: AH8x2254cjMNpL5gnVoQjteYqKyquh3wHMr5JNI71uxFDpZSLLvXwtDtVESEa9NGyTbupXu4vA6K X-Received: by 10.98.155.93 with SMTP id r90mr10033804pfd.132.1519637314993; Mon, 26 Feb 2018 01:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519637314; cv=none; d=google.com; s=arc-20160816; b=U3DIhZwE3PA9YzYQjUrpGCPrkaglXqQ/m+TStWqa9dQJD5PM6b02dJVwCIGBFxbnGB 4U0bYYat8yBDWVnEXb5ctf8EFPk4nmkueJUjoZI7+ywP7UmfPbbq2+KWWGM2rNvp+7I8 /aypJOQ1jfFmGnR2GKzac6ZdvRpelnYzArJ00w9MhNCb8uFMlHZYrdVU89AA2u0N0Mm+ e+3hjMf4iskg9rkSiNefQxUq56psxq1DXL1jDF9MlgzKwsy16C5xPGroq+/8jhqCWNQX Gl2gUNQ0DeCuaSqsUdcz4tL4OTJjIJPDnUHGahKn6/t3agABLcckOoBwyBCJG/e3CRG5 bqaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xvgV1V/35uc4hgQy6MdwRokvugXCwCCQNIkjHoqS9X8=; b=U6/SzVmbcr7esnOZfWY3vx2smFqTcs+U8f96I5OkxSYMy0SY8JtdGDOw0RvSkXV0XY CSftDI3f4AHpKES12Yuxn5iVB2RLJYt9HcTKPz3zPkPLGV/yaa2wrIDd3SaaNdimGsPf wUxmOUO7U2oMMNHnIogXy/fzyna8payMzE1iV8BPy2hlY0z0uqxSsdR3hQ2l3unbmJ43 W1Tw+eTyEfPVeVedvjFntmFiqG+CpQ9NIEFpWhH+DW6pPTYE1uHKEBNZPTmlnZoEDA+L RGVE/Zkcj/WcsgGWEP5m7njRtPJJgguQDR3MupdshHMG+SqQl7Zk78TZc+o5lT0R2fcN l/Hg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=orcon.net.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si5081607pgc.493.2018.02.26.01.28.20; Mon, 26 Feb 2018 01:28:34 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=orcon.net.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752267AbeBZJ1M (ORCPT + 99 others); Mon, 26 Feb 2018 04:27:12 -0500 Received: from smtp-4.orcon.net.nz ([60.234.4.59]:51858 "EHLO smtp-4.orcon.net.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbeBZJ1J (ORCPT ); Mon, 26 Feb 2018 04:27:09 -0500 X-Greylist: delayed 1446 seconds by postgrey-1.27 at vger.kernel.org; Mon, 26 Feb 2018 04:27:08 EST Received: from [121.99.228.40] (port=14350 helo=localhost.localdomain) by smtp-4.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1eqEgL-0004L2-VW; Mon, 26 Feb 2018 22:02:55 +1300 From: Michael Cree To: linux-alpha@vger.kernel.org Cc: Matt Turner , Ivan Kokshaysky , Richard Henderson , linux-kernel@vger.kernel.org, Michael Cree Subject: [PATCH] alpha: Implement CPU vulnerabilities sysfs functions. Date: Mon, 26 Feb 2018 22:02:12 +1300 Message-Id: <20180226090212.23871-1-mcree@orcon.net.nz> X-Mailer: git-send-email 2.11.0 X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the CPU vulnerabilty show functions for meltdown, spectre_v1 and spectre_v2 on Alpha. Tests on XP1000 (EV67/667MHz) and ES45 (EV68CB/1.25GHz) show them to be vulnerable to Meltdown and Spectre V1. In the case of Meltdown I saw a 1 to 2% success rate in reading bytes on the XP1000 and 50 to 60% success rate on the ES45. (This compares to 99.97% success reported for Intel CPUs.) Report EV6 and later CPUs as vulnerable. Tests on PWS600au (EV56/600MHz) for Spectre V1 attack were unsuccessful (though I did not try particularly hard) so mark EV4 through to EV56 as not vulnerable. Signed-off-by: Michael Cree --- arch/alpha/Kconfig | 1 + arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/bugs.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 arch/alpha/kernel/bugs.c diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index e96adcbcab41..b2022885ced8 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -18,6 +18,7 @@ config ALPHA select ARCH_HAVE_NMI_SAFE_CMPXCHG select AUDIT_ARCH select GENERIC_CLOCKEVENTS + select GENERIC_CPU_VULNERABILITIES select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile index bf7b41fa7b01..5a74581bf0ee 100644 --- a/arch/alpha/kernel/Makefile +++ b/arch/alpha/kernel/Makefile @@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare obj-y := entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ - systbls.o err_common.o io.o + systbls.o err_common.o io.o bugs.o obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/alpha/kernel/bugs.c b/arch/alpha/kernel/bugs.c new file mode 100644 index 000000000000..08cc10d7fa17 --- /dev/null +++ b/arch/alpha/kernel/bugs.c @@ -0,0 +1,45 @@ + +#include +#include + + +#ifdef CONFIG_SYSFS + +static int cpu_is_ev6_or_later(void) +{ + struct percpu_struct *cpu; + unsigned long cputype; + + cpu = (struct percpu_struct *)((char *)hwrpb + hwrpb->processor_offset); + cputype = cpu->type & 0xffffffff; + /* Include all of EV6, EV67, EV68, EV7, EV79 and EV69. */ + return (cputype == EV6_CPU) || ((cputype >= EV67_CPU) && (cputype <= EV69_CPU)); +} + +ssize_t cpu_show_meltdown(struct device *dev, + struct device_attribute *attr, char *buf) +{ + if (cpu_is_ev6_or_later()) + return sprintf(buf, "Vulnerable\n"); + else + return sprintf(buf, "Not affected\n"); +} + +ssize_t cpu_show_spectre_v1(struct device *dev, + struct device_attribute *attr, char *buf) +{ + if (cpu_is_ev6_or_later()) + return sprintf(buf, "Vulnerable\n"); + else + return sprintf(buf, "Not affected\n"); +} + +ssize_t cpu_show_spectre_v2(struct device *dev, + struct device_attribute *attr, char *buf) +{ + if (cpu_is_ev6_or_later()) + return sprintf(buf, "Vulnerable\n"); + else + return sprintf(buf, "Not affected\n"); +} +#endif -- 2.11.0