Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5975348imm; Mon, 27 Aug 2018 07:36:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0IEQFcYMsCOq67vFnFoOcUzPbGPfg4+XIs8fC70e4qySGL877ExN0vjHG7DWP6NPcytP5 X-Received: by 2002:a62:fc5:: with SMTP id 66-v6mr14599122pfp.237.1535380560756; Mon, 27 Aug 2018 07:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535380560; cv=none; d=google.com; s=arc-20160816; b=HSZHHDcLMMae07CQfO2wS4QUDgRI2uB/TyVOqLSsOdrvJwFWZ5FWz+MPpaR8kkxn0S u+uf6Elb/B9hsTKlR7lNI32dFI81kP4xKLaUco4kIWtTeJ1K+xugEDs7ZJ1zgqPNxWYW BqpXbdR8+opQ4Du1+XKRUzf1FCS9vwEeIh667/nqd5indeLVfwTiu+4mSbM0q4//G3Wr odSGV41F0Hsw+RGakwikdZ5Sy+xmjE6f9u0q4qOCAxBu/ZjaBzVutJ4T3uJtQdCVd33l 6cKFEBe9Ai2e8LBmR0iEE9mFaoU0L9Dfmafn99MF1w4dTgrToSxG/bOtyjia3gs9Qvtz T8Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=n88BSqj2DiO+hiBpjI74qP2kR2gAfgkGQNlwJO0a7hI=; b=L83XwIyErLtl9BKtLWDCkpER/342pSWKNi4anPiJN2zTbeelUR6wf7v7jQTWg2LA3D UGYNnaJT8G5EOVaotPBQwxRMBuYQ0ttwTr+ovgORuexQ6Q/2xCxx2BiRg7/CuBhuST9N 3j76x8Gdn4O6TD62koW/z1RRBTqYE1ZFq+WV1TX9Wg40MfaQlQsiqv9VITSpYM9GmgeF FaPxR6Wsvx87/+S19cbh3PJdKoWWU4O1v3PUFLE5TGJxYWLgpw4zK7UY5W+D4zUdvZsG vF5LKrnJZ4EHLtAQb4V16e/dMHGCl8MqYxAYcnq4MfQ8NSRH+aQRkzUl/G5/G0W+1dS9 WeMw== 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 m12-v6si8503442pgi.550.2018.08.27.07.35.45; Mon, 27 Aug 2018 07:36:00 -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 S1727629AbeH0SUf (ORCPT + 99 others); Mon, 27 Aug 2018 14:20:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:50018 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727099AbeH0SUe (ORCPT ); Mon, 27 Aug 2018 14:20:34 -0400 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 Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robert.richter@cavium.com, cwu@amperecomputing.com, Mian Yousaf Kaukab 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.11.0