From patchwork Tue Aug 7 18:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B68B14E5 for ; Tue, 7 Aug 2018 18:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F00B2A762 for ; Tue, 7 Aug 2018 18:15:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 331232A7D0; Tue, 7 Aug 2018 18:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D22EB2A762 for ; Tue, 7 Aug 2018 18:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=IkGeBOZXdZv8Ocd1w2a4Zzz1/u6jHS+zOWJTuBRk+lk=; b=afqiXw7flmhXdvbKen3vUJ151b rmhx8lSNyrNU8koJsFEXBxF4hJ4oVs8I0HxpUI1QTooOBIPr4zIrS01LB8+EL/ggM6TsXMqw408Kn YF0pEtTMzjCgeace9yTKO72zZKGS24FWKZfeWm8y/zdHEajqvAr4eLnBcO+EWuKmHKV8NjcvF498Y uxjQLi4M4sYn6vIbg29gJNsLlaoSZ7HZYRTRrrmrZ8Qzll+DFUEIM7wCTWBiFUeYI3ebEBOggtu5m JmY6lc5ZMIf7VxQx+F7qv7FxOt72pjBAtgJVhGxmlyTYJsWU7gJ2mZXjdLW3l2Ay7ZurUVFdsEg5i a7cutxlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vw-0006aB-Nv; Tue, 07 Aug 2018 18:15:24 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vm-00057c-Fw for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:16 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A32F6ACD3; Tue, 7 Aug 2018 18:15:00 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 1/6] arm64: kpti: move check for non-vulnerable CPUs to a function Date: Tue, 7 Aug 2018 20:14:14 +0200 Message-Id: <20180807181419.15690-2-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111514_695524_D9C2A570 X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Prepare to call it in generic cpu vulnerabilities support. Signed-off-by: Mian Yousaf Kaukab --- arch/arm64/include/asm/cpufeature.h | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 9 +-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 1717ba1db35d..0b0b5b3e36ba 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -530,6 +530,22 @@ void arm64_set_ssbd_mitigation(bool state); static inline void arm64_set_ssbd_mitigation(bool state) {} #endif +static inline bool is_cpu_meltdown_safe(void) +{ + /* List of CPUs that are not vulnerable and don't need KPTI */ + static const struct midr_range kpti_safe_list[] = { + MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2), + MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), + { /* sentinel */ } + }; + + /* Don't force KPTI for CPUs that are not vulnerable */ + if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) + return true; + + return false; +} + #endif /* __ASSEMBLY__ */ #endif diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index e238b7932096..6a94f8bce35a 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -865,12 +865,6 @@ static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, int scope) { - /* List of CPUs that are not vulnerable and don't need KPTI */ - static const struct midr_range kpti_safe_list[] = { - MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2), - MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), - { /* sentinel */ } - }; char const *str = "command line option"; /* @@ -894,8 +888,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) return true; - /* Don't force KPTI for CPUs that are not vulnerable */ - if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) + if (is_cpu_meltdown_safe()) return false; /* Defer to CPU feature registers */ From patchwork Tue Aug 7 18:14:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90E1A14E2 for ; Tue, 7 Aug 2018 18:25:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82FD22A5A9 for ; Tue, 7 Aug 2018 18:25:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74D0B2A7C4; Tue, 7 Aug 2018 18:25:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2EC082A5A9 for ; Tue, 7 Aug 2018 18:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+DIn03qIDksmDpLuXVH8CkeSwsqcmwMpmIQV2GR9vqc=; b=ohQHZ31k5BO9DQOZ8hB6sA3zno COon6+f9yVhMcvAc+jwtAQeDjljb5f8wKpBZmzl/kglbx0WG0B4qdBdnSs2vuE++CqtgwWD2/ZrHW K12I8ADVpuJXT9JEdVDPE4V4IQ9soWeBJOyIpBgm82aIF+jMLDmOql5fwBgp2IcGXY9onsoZJtKRM VD+DE6rJUXl9nVPRV2yJ34RBZTpTzA+YCCZPWu+/L4/ZEXlH3AvVroyKBvRJwHe7PfhIy6xCTKWHI jMLIzvfVZDcgd6g4d8ZDLr3xdI1ZNtMNq8G2oWYEiW1nqVBS9pxwIZJKvGAKbq2p2Mi2vZvESX9Fa TC3uXmkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6fj-00038M-6Z; Tue, 07 Aug 2018 18:25:31 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vm-00057i-G1 for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:17 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F0B35ACD7; Tue, 7 Aug 2018 18:15:00 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 2/6] arm64: add sysfs vulnerability show for meltdown Date: Tue, 7 Aug 2018 20:14:15 +0200 Message-Id: <20180807181419.15690-3-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111514_705544_93540D57 X-CRM114-Status: GOOD ( 10.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Checking CSV3 support directly in case CONFIG_UNMAP_KERNEL_AT_EL0 is not enabled. Signed-off-by: Mian Yousaf Kaukab --- arch/arm64/kernel/cpu_errata.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index dec10898d688..996edb4e18ad 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -22,6 +22,7 @@ #include #include #include +#include static bool __maybe_unused is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) @@ -683,3 +684,26 @@ const struct arm64_cpu_capabilities arm64_errata[] = { { } }; + +#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES + +ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, + char *buf) +{ + u64 pfr0; + u32 csv3; + + if (arm64_kernel_unmapped_at_el0()) + return sprintf(buf, "Mitigation: KPTI\n"); + + pfr0 = read_cpuid(ID_AA64PFR0_EL1); + csv3 = cpuid_feature_extract_unsigned_field(pfr0, + ID_AA64PFR0_CSV3_SHIFT); + + if (csv3 || is_cpu_meltdown_safe()) + return sprintf(buf, "Not affected\n"); + + return sprintf(buf, "Vulnerable\n"); +} + +#endif From patchwork Tue Aug 7 18:14:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61EAE14E5 for ; Tue, 7 Aug 2018 18:15:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 516B928FDE for ; Tue, 7 Aug 2018 18:15:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410D329016; Tue, 7 Aug 2018 18:15:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83D0428FDE for ; Tue, 7 Aug 2018 18:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FevkHDbcSykut29VvfCQOjXvMBHUm/UUjQuA6o1u+Dg=; b=WMWDgBCARhukogjeRKOFzBZiuY nfj4+2n6PH8vBN+0mXXOpWKiFglkL4Z4rjYad+z+mtIsYjDvc6oiFldiQS6uA6Jn31bP8Ms+igz6N EjnYa6Bfj+71SKy5e1W9xNmO5970FFhZaI6e00B4xFo+Ic1dPwzIHIQ8Yi4wT0ZUa8LqoxsR0gJT+ uiPcFPiY0OaMra2+NwT6iP5Uk8dg9gjeHd6o7SZNSR7ebMH8jqv2YITMj8zlr2KWwjrd8jkRpsz1T o44p12IOeZ2rL2g6Xc9h4XxzCgveFqPAl5DrH0rdI8/G0H4SgUiVYyFgsb+dEHO76qmpd6abb/vo8 OhMpS91w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vp-0006RC-Aw; Tue, 07 Aug 2018 18:15:17 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vm-00057z-Fw for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:15 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 88BE1ACEA; Tue, 7 Aug 2018 18:15:01 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 3/6] arm64: add sysfs vulnerability show for spectre v1 Date: Tue, 7 Aug 2018 20:14:16 +0200 Message-Id: <20180807181419.15690-4-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111514_692934_9CC8023E X-CRM114-Status: UNSURE ( 8.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hard-coded since patches are merged and there are no configuration options. Signed-off-by: Mian Yousaf Kaukab --- arch/arm64/kernel/cpu_errata.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 996edb4e18ad..92616431ae4e 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -706,4 +706,10 @@ ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, return sprintf(buf, "Vulnerable\n"); } +ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "Mitigation: __user pointer sanitization\n"); +} + #endif From patchwork Tue Aug 7 18:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B9E813BB for ; Tue, 7 Aug 2018 18:15:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B9B928FDE for ; Tue, 7 Aug 2018 18:15:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BF5B29016; Tue, 7 Aug 2018 18:15:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1C9C28FDE for ; Tue, 7 Aug 2018 18:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=c5P77RH08IdpJ6rq7bsKqhI8k2h7x83Nx6sOJk9gxm0=; b=moCiRSIDa3SNtBp+XjZDixUhsd vJlZCd1hln8fsRPKdkafP+/4cGeKU3jx2yfFsj/n8xH9xjzcqRX6PfAybW5yuGtLcR8jBjXw0Ud7+ GgYq5UrOHJRDhZs7mk3OoKsT2PiHzAkr6EvYwIO/EJZs6qK29UTq7YKAzwm/KbJF6kI6KHBJcowr+ v/svlizdyWlj7ahQe2RyrXFvdhEg7XhWcKYGJNXrIltnNf5OuqobgQ9We1xajeKjiFug6jsXQggvH nTt0FnwNNQV3hWZ/SdJ7E4dxL8TeO+V1Cxt1ZfOUWipvs8/fLnazG2xqZsaLkwEBFX+q1DdGM6whQ a7GlEJvw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6WD-0006zh-1d; Tue, 07 Aug 2018 18:15:41 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vm-0005Br-G0 for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:17 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 12093AD04; Tue, 7 Aug 2018 18:15:02 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 4/6] arm64: add sysfs vulnerability show for spectre v2 Date: Tue, 7 Aug 2018 20:14:17 +0200 Message-Id: <20180807181419.15690-5-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111514_700705_759AA9CB X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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"); + + 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(); + if (data && data->fn) + return sprintf(buf, + "Mitigation: Branch predictor hardening"); + else + /* For example SMCCC_VERSION_1_0 */ + return sprintf(buf, "Vulnerable\n"); + } + + /* In case CONFIG_HARDEN_BRANCH_PREDICTOR is not enabled */ + if (is_midr_in_range_list(read_cpuid_id(), arm64_bp_harden_smccc_cpus)) + return sprintf(buf, "Vulnerable\n"); + + return sprintf(buf, "Not affected\n"); +} + #endif From patchwork Tue Aug 7 18:14:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F4C714E5 for ; Tue, 7 Aug 2018 18:16:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3295E28FDE for ; Tue, 7 Aug 2018 18:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26F0B2909D; Tue, 7 Aug 2018 18:16:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D0DBD28FDE for ; Tue, 7 Aug 2018 18:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4xc8Re2J3OcK4inqRaM5P7SHXoE8dFcjmLNP1m5LShk=; b=qNfc9e+SyzxDDjgi0BgnI1ROH0 orOBZzhk11oghOR+Hta5VJuld6CwMtSLMGGh1jF52gJKcsjrRdNLZGdC8LUvoU297Q/PtU9AH0ZDZ adIFjTc9e08MZQWBmIfEJN8qCMrdVDROymfVfu2+K/Me6Q938xT3soP8Cig2cY1/nio3af6XdhArh bTmbecxmWNGPMpSzFPZraHjPMLCvoKkPrqGLvfemtpEpnZdLEbpG1pc0pIpcn61Yg4DExcvSLzhyN L9E1jEHtlx72ILhm/mZTVZh/Y7JSS3ncUUuOxsTjLNBMRafP53sgblzKGjKmItjys3UXMFVYYlOa6 3OiCXS+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Wl-0007in-H9; Tue, 07 Aug 2018 18:16:15 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vz-0006R7-5h for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:31 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8F463AD82; Tue, 7 Aug 2018 18:15:02 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 5/6] arm64: add sysfs vulnerability show for speculative store bypass Date: Tue, 7 Aug 2018 20:14:18 +0200 Message-Id: <20180807181419.15690-6-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111528_252343_EDE3202C X-CRM114-Status: UNSURE ( 8.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Return status based no ssbd_state. Return string "Unknown" in case CONFIG_ARM64_SSBD is disabled or arch workaround2 is not available in the firmware. Signed-off-by: Mian Yousaf Kaukab --- arch/arm64/kernel/cpu_errata.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 8469d3be7b15..8b60aa30a3fa 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -744,4 +744,24 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, return sprintf(buf, "Not affected\n"); } +ssize_t cpu_show_spec_store_bypass(struct device *dev, + struct device_attribute *attr, char *buf) +{ + switch (arm64_get_ssbd_state()) { + case ARM64_SSBD_MITIGATED: + return sprintf(buf, "Not affected\n"); + + case ARM64_SSBD_KERNEL: + case ARM64_SSBD_FORCE_ENABLE: + return sprintf(buf, + "Mitigation: Speculative Store Bypass disabled"); + + case ARM64_SSBD_FORCE_DISABLE: + return sprintf(buf, "Vulnerable\n"); + + default: /* ARM64_SSBD_UNKNOWN*/ + return sprintf(buf, "Unknown\n"); + } +} + #endif From patchwork Tue Aug 7 18:14:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mian Yousaf Kaukab X-Patchwork-Id: 10559073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FD5013BB for ; Tue, 7 Aug 2018 18:16:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D9328FDE for ; Tue, 7 Aug 2018 18:16:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 044EA29016; Tue, 7 Aug 2018 18:16:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D43828FDE for ; Tue, 7 Aug 2018 18:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qP6dUr3QovRwQR8/Dmz/gFsVG6m9TacBtmcTlGk5KLo=; b=ndrm7vixbqNeHSDZBkwqKjcB3O Tpiz68yH59JcxlZpeXITKooX0RdVYavoow25vG7UfgckjHKgp0JveprYjWIoTX45lt/cvlYjFLHZP UqZJIgii0WRV2Q3VqfsfeZB3QWQTMfpvAj7vXK2ECspJcHxiHTIfvsmFCIl8CvUgyHvsfy4uuth3b h5ba1H0x3EkEg4Iyp/U5RuvOYmv9S9A8SRQzag1Yg/ip9OZWtbISOmZwMizfA7Awcuzk1TwAkDvTr E9ovlCrOq+iRb2djbym+fRBqrI2vfaX16fv5GfFldq0HDznxRqjlQJfygwddX/9+dCe1oy8BG5K/N ImvG0ing==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6WZ-0007Sf-1h; Tue, 07 Aug 2018 18:16:03 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn6Vz-0006R6-5f for linux-arm-kernel@lists.infradead.org; Tue, 07 Aug 2018 18:15:31 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 061A1ADB1; Tue, 7 Aug 2018 18:15:03 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH 6/6] arm64: enable generic CPU vulnerabilites support Date: Tue, 7 Aug 2018 20:14:19 +0200 Message-Id: <20180807181419.15690-7-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807181419.15690-1-ykaukab@suse.de> References: <20180807181419.15690-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180807_111528_243255_ECBB1DF4 X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.richter@cavium.com, Mian Yousaf Kaukab , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, cwu@amperecomputing.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Enable CPU vulnerabilty show functions for spectre_v1, spectre_v2, meltdown and store-bypass. Signed-off-by: Mian Yousaf Kaukab --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 0dec01a0c81c..ffd97bc0f5d5 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -84,6 +84,7 @@ config ARM64 select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_IDLE_POLL_SETUP select GENERIC_IRQ_MULTI_HANDLER