From patchwork Mon Aug 27 14:33:06 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: 10577161 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 E6F1D1390 for ; Mon, 27 Aug 2018 14:34:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1B79295B0 for ; Mon, 27 Aug 2018 14:34:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C58FD297D7; Mon, 27 Aug 2018 14:34:09 +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,RCVD_IN_DNSWL_NONE 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 6341A295B0 for ; Mon, 27 Aug 2018 14:34: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=+DIn03qIDksmDpLuXVH8CkeSwsqcmwMpmIQV2GR9vqc=; b=RosOWTH8zKc4OGsaqzNEiNgvCp EaJiK4rKRwAU9Rc3vk2rvDoqMa7vihuYFAc7GerofiSul0RgH6lpH3l7YBcqhvP2gw1BXbKhxJaRJ 7Uqbu87XUIx1QR8KTwwpRgcf7h2GVT8uNp5P7LoY7azrE4uDpKHSpj8zc9ybiwXY62/j0AVoXu/O8 FKR7jdpFQgt+aJMMFFZ4vtm4L+SbD5ZJLedc+GDbAwo4MpFxRXxVMLc4irLlOdKIX4yl+1x4PN8N4 mlC5Uah8o8raNoXZF0BE2eDv6CgXWb3WOqOpq4g32UwdC8zX2PdTNDSu6+6rgnn//YKHy98Bs7/EI 9r8pliWQ==; 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 1fuIac-00043Z-Vx; Mon, 27 Aug 2018 14:33:58 +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 1fuIaY-0003zG-Ar for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 14:33:56 +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 32DC8AFE7; Mon, 27 Aug 2018 14:33:41 +0000 (UTC) From: Mian Yousaf Kaukab To: will.deacon@arm.com, marc.zyngier@arm.com Subject: [PATCH RESEND 2/6] arm64: add sysfs vulnerability show for meltdown Date: Mon, 27 Aug 2018 16:33:06 +0200 Message-Id: <20180827143310.641-3-ykaukab@suse.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180827143310.641-1-ykaukab@suse.de> References: <20180827143310.641-1-ykaukab@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_073354_545545_C6C06BA6 X-CRM114-Status: GOOD ( 10.36 ) 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