From patchwork Thu Jan 3 00:49:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154683 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127370ljp; Wed, 2 Jan 2019 16:49:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uxm4pUQqf7s/w5c9wE1rYSr7aKUiqsBZHFG/Bm3Jn7FTCbE8nlKWObKT2OaHd0DNK6Rcxm X-Received: by 2002:a62:dbc2:: with SMTP id f185mr46008357pfg.235.1546476573096; Wed, 02 Jan 2019 16:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476573; cv=none; d=google.com; s=arc-20160816; b=QX6nIQpp+I59/bxfsdtS5RiTL0pb4zRrOG2AK8JEUrMxolITjoRhol1ksp0SSyoFhg DbJ1BGppI2NW+R25RkMst5gpgf1HnqARrj5VS0Cx2HCowYEjEKFZmrb9dAu6qdxiFMHG Og8fB1yMD595ClVWHcNo/mJfk1rmtmF1zAaXCned2raE1GjwKtaAjTOV6kHTATh3fRae CUUHkbFWiC3zIY1VmJE8XVB9oBlFdydOZ26u1eO0R7ynaHeaUosCqln+iKCGksyqvKx2 x9dSOWUrjTBN+AETd5AAxUgdva+nhSVTRm78KVOy3lmx4BFtAeojJnsg9aFbJSFjhILo 7dnQ== 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; bh=nujYigEZEYQvOo/px7JA187/vxmeSCVob1dF9n02g8k=; b=R5YV44uNXAemwy+2vjdMU321LbQeK8IeFLt2IBsG9/yxeKVtj+3h0x26Rbrss1CnYn Nt8vj+/sbqI6qODbI3epxLJ5shm7Vy1lZDPsPGj4VuKtkfGxXMb9tlMg8UfEPA3aGt4I 6X/OEDdakKMsAhVU5e2NUYKgZlgcURoa04vJuII0v9Zg5nFW/JCBWylVW3VshTTOW7iB tYgbaP0LK7R9AEgxgUh8y2cbRoQS9q3mChjQ2rIBvaXVNHt6o0Ctfg9T0EnSkEF2bNik AeGOfUTUUoz8IG9cO1Ly9OJuUBEkXdInWmD8fOxE6b70/kOSJOqXmnJ7jDlOUdTDCKs4 J54A== 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 f12si30416238pgd.68.2019.01.02.16.49.32; Wed, 02 Jan 2019 16:49:33 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730204AbfACAtc (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:32 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39766 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfACAtb (ORCPT ); Wed, 2 Jan 2019 19:49:31 -0500 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 3E2C580D; Wed, 2 Jan 2019 16:49:31 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 090573F5AF; Wed, 2 Jan 2019 16:49:29 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton , Thomas Gleixner , Greg Kroah-Hartman , "Rafael J . Wysocki" , Konrad Rzeszutek Wilk , Peter Zijlstra , Dave Hansen , Borislav Petkov , David Woodhouse Subject: [PATCH v2 1/7] sysfs/cpu: Add "Unknown" vulnerability state Date: Wed, 2 Jan 2019 18:49:15 -0600 Message-Id: <20190103004921.1928921-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a lot of variation in the Arm ecosystem. Because of this, there exist possible cases where the kernel cannot authoritatively determine if a machine is vulnerable. Rather than guess the vulnerability status in cases where the mitigation is disabled or the firmware isn't responding correctly, we need to display an "Unknown" state. Signed-off-by: Jeremy Linton Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Konrad Rzeszutek Wilk Cc: Peter Zijlstra Cc: Dave Hansen Cc: Borislav Petkov Cc: David Woodhouse --- Documentation/ABI/testing/sysfs-devices-system-cpu | 1 + 1 file changed, 1 insertion(+) -- 2.17.2 diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 9605dbd4b5b5..876103fddfa4 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -495,6 +495,7 @@ Description: Information about CPU vulnerabilities "Not affected" CPU is not affected by the vulnerability "Vulnerable" CPU is affected and no mitigation in effect "Mitigation: $M" CPU is affected and mitigation $M is in effect + "Unknown" The kernel is unable to make a determination Details about the l1tf file can be found in Documentation/admin-guide/l1tf.rst From patchwork Thu Jan 3 00:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154684 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127413ljp; Wed, 2 Jan 2019 16:49:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN7IV+4D67vpmuTJ5yS0k9VGdncV+3TyT3deqAUofREyxA+BFU646a4pd3pA/XKgPBocI1q3 X-Received: by 2002:a17:902:14e:: with SMTP id 72mr45574804plb.287.1546476577134; Wed, 02 Jan 2019 16:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476577; cv=none; d=google.com; s=arc-20160816; b=LGi4mfBtV8yFECRaQHDZQmv5deVSxkrEWwivL/YGtc2PsU73m6wcBnf9u8wFVS0fC8 Y7O5KynFfcxGpFpW70ViPTz2D3/U1JKw+c33KLRRnSoify+l1T4dxAOMt7hj07Docchp oe1I9Y/RMFiVAGZ9f4mp/utX8OFpzr9aROOq9ub8hFyuxJBdZTq4bvnaAH11LCV2WKSL 43RYlw0Cye5jZdWbvL6XtCGZPHhwgK+7uIZu3gDV8/vYooX4iOXS8GKdNVv7tCzOGVBQ JTjAfyLEthiu2yXt5XqM/e5lnO+/OrhSspjq/SLHBrLu5sEMMp9r4KWMsGN+cKFdUicU l3gg== 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; bh=WXdEmfHn2+iMM7oygZUFDZkDFuQPUNuxEMCjNq8SnZw=; b=xvciX86kVNZMUT2P5fzBrBNwC7gYe+eAWw9WcszjVHAUfYxKkC7bwdFrsdDZ1b5M7l /cvbeXxE3Xh3VvopTIW3bvav7sZr2C7KnmgqbuJeFocb93avBAq7La7soTiR8l+1HEWR fbTOnCtSXUyD24//+jYuJdJqTAddTgX0BtW4anuvNGRPxCfT/OYIlJoe9C4U3rzaA1Va 4ttN+9yUEcefUDorGW2ffr/dMUuihuWenvAcOvDivFAaqN+BnpM753rdN2vxhiig0dNH ZYb0ihF4xHtPEahDULuqBB3DA+cNZXVOAdJ2lUTjKrXclgkxUO0+pwiaBpHMy4nQ5erW CYww== 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 f12si30416238pgd.68.2019.01.02.16.49.36; Wed, 02 Jan 2019 16:49:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730229AbfACAtg (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:36 -0500 Received: from foss.arm.com ([217.140.101.70]:39792 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfACAtd (ORCPT ); Wed, 2 Jan 2019 19:49:33 -0500 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 3158E1596; Wed, 2 Jan 2019 16:49:33 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 590D33F5AF; Wed, 2 Jan 2019 16:49:32 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 2/7] arm64: kpti: move check for non-vulnerable CPUs to a function Date: Wed, 2 Jan 2019 18:49:16 -0600 Message-Id: <20190103004921.1928921-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mian Yousaf Kaukab Add is_meltdown_safe() which is a whitelist of known safe cores. Signed-off-by: Mian Yousaf Kaukab [Moved location of function] Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpufeature.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 2.17.2 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 4f272399de89..ab784d7a0083 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -947,8 +947,7 @@ has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope) #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 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) +static 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[] = { @@ -962,6 +961,15 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), { /* sentinel */ } }; + if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) + return true; + + return false; +} + +static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, + int scope) +{ char const *str = "command line option"; /* @@ -985,8 +993,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 Thu Jan 3 00:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154689 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127710ljp; Wed, 2 Jan 2019 16:50:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6djS8WAqnND+3p4233jPaqqLrRJGJaiiRR1QEAJfSVNbZp9e7Wulsy1xJeJA9gpzxywPRg X-Received: by 2002:a62:178f:: with SMTP id 137mr45911077pfx.226.1546476602328; Wed, 02 Jan 2019 16:50:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476602; cv=none; d=google.com; s=arc-20160816; b=E3qYsEShitl8Yq3vJNKb+ShO2G1ibCzE71dA2J8p7KdCK/GxfJ1jgQVS42G/AyXxzA Bm18I3TH/g2aQXOzPgJwACOHMfgqlc77Y2L8qD6Ol6C7qxSvPj7JQpdurjqWRMwi225H KEAk9/ufXC5w8ZsQoj3LJmJ5aQCOwtWijPIlCAWDlrmTaYpzTjCs0f0s2O2JlJj0bQdZ Z8AxBitH9JzZevAX0h8ss/BmcuzZl/e9WTYJ2myrrOH4CeBmdGnOeE30aTF2uo6tEMQ9 yaVYLR+3MqLEqakzTgJvkpU5alhZuPiFpeNNIS2vjL5leSNKZ2d/z4ngYpNWI3MXzQyF glYg== 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; bh=Thijdf4j7uhhDudInMr2T0q+S8pMj7VjZf+amntbpso=; b=RwH7mGIb275zCji45e6SUYTMBtIMydlrrbjrkrd1RXxoMydfP6h/5BDVyvOkLmNj4D LQ3SzOfTs6hscCK/qOxDy+VmtZrmybrHmOqEnxPJhne6wJZbZSLkMcUfn5aP9iOGDJSV 2zklztQQwnfjPz9EL6k4BgABftpjp15NL9o3hoEi1rhGRtKYWoTgc7JfbrN8NodD18hk derfdEYoZFHYDD9h8pY/T5vKBas9Q4emQq+d8e/Psr7tFsQx3lRS/7FHDZSpr4+uYI3V o+iC64eMAAG0iUwmzdITYaWbZW0x3+5o+454TIIv9Np/fKLChe74IYZBq557XytsolLQ Ubsg== 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 g1si33378834pld.197.2019.01.02.16.50.02; Wed, 02 Jan 2019 16:50:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730314AbfACAuB (ORCPT + 31 others); Wed, 2 Jan 2019 19:50:01 -0500 Received: from foss.arm.com ([217.140.101.70]:39806 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730205AbfACAtf (ORCPT ); Wed, 2 Jan 2019 19:49:35 -0500 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 9EC4E15AB; Wed, 2 Jan 2019 16:49:34 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C869B3F5AF; Wed, 2 Jan 2019 16:49:33 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 3/7] arm64: add sysfs vulnerability show for meltdown Date: Wed, 2 Jan 2019 18:49:17 -0600 Message-Id: <20190103004921.1928921-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a simple state machine which will track whether all the online cores in a machine are vulnerable. Once that is done we have a fairly authoritative view of the machine vulnerability, which allows us to make a judgment about machine safety if it hasn't been mitigated. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpufeature.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index ab784d7a0083..1f64cbff8456 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -944,6 +944,9 @@ has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope) return has_cpuid_feature(entry, scope); } +/* default value is invalid until unmap_kernel_at_el0() runs */ +static bool __meltdown_safe = true; + #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */ @@ -972,6 +975,12 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, { char const *str = "command line option"; + bool meltdown_safe = is_cpu_meltdown_safe() || + has_cpuid_feature(entry, scope); + + if (!meltdown_safe) + __meltdown_safe = false; + /* * For reasons that aren't entirely clear, enabling KPTI on Cavium * ThunderX leads to apparent I-cache corruption of kernel text, which @@ -993,11 +1002,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) return true; - if (is_cpu_meltdown_safe()) - return false; - - /* Defer to CPU feature registers */ - return !has_cpuid_feature(entry, scope); + return !meltdown_safe; } static void @@ -2065,3 +2070,17 @@ static int __init enable_mrs_emulation(void) } core_initcall(enable_mrs_emulation); + +#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES +ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, + char *buf) +{ + if (arm64_kernel_unmapped_at_el0()) + return sprintf(buf, "Mitigation: KPTI\n"); + + if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0) && __meltdown_safe) + return sprintf(buf, "Not affected\n"); + + return sprintf(buf, "Unknown\n"); +} +#endif From patchwork Thu Jan 3 00:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154685 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127449ljp; Wed, 2 Jan 2019 16:49:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN5WhjLL02T6SwkXk4lewfW3K2Hg48kkd6iCxOY9hY4xPQfsUyhwqPiqN6dYhaI116u+eVH9 X-Received: by 2002:a63:3d1:: with SMTP id 200mr43729015pgd.68.1546476580214; Wed, 02 Jan 2019 16:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476580; cv=none; d=google.com; s=arc-20160816; b=lVLRCXXcuX+E8ro6VEZ7I+8h0WapcyJnJ/tlpXmuXkvi8awKA1lYLBOzjHcuvASt49 XM5b/qo2YXdXcF3TcZCnx5OCWVeXzgK3bhZ9HGcn2Wd/VEpNMRjpEnDQB1+0mPNxiod1 Zcu8xAs563WeZZtB7DVIgXT+ym+nAcSC9O/O+cOovoLFdKAGTj7eC2huO0li4dxkdB41 vF6EoGfh5bOi37VSYFrqP+8L9DNvqe38PePZZa1f+VJsh0r/P4tgV9JDCL7dZoj+/BoO 13gu7xfjWkiwkUTqfyr2jd5V7yMTfssctcmg2Cn35qvhLeSKI1R7f09tolM5ACMT64DT 8hRQ== 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; bh=3IzUsHtorXdNzzBfqlr3gxkzaNCa4/7c5I3SnNG2LQg=; b=U96o0UYBbbva6iVDeiDPU8UxViEiQW2W2+w1n3TFAuVZsQQ7+h4EHjhK/kgZeWm1ZB baM1zUY4RbLD3K7tRkpSqySME/F+28XBQH5f1iw22jumpRO0d2pY6JakzqRatxjP0jvz JpMQnvUL3v3F0Dr6G9HiR46gWrEypNdRGzu3Vm1dz2qK3m5iDL53ijysciJcKk/tf9J8 dcVZQ8CRLzVOWF2FveZVRXea3bITKPSPqB6uIdQqsW3ryxUK3efiEmvKPUU4FxUgfMVS A63hu/EfW3JphDgAaCaCP2tO6ZBUTA01HwqPpzfTnPcaLHDS1OU8jVqC54gng7Ot5QLe ZNyA== 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 f12si30416238pgd.68.2019.01.02.16.49.39; Wed, 02 Jan 2019 16:49:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730252AbfACAtj (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:39 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39820 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfACAtg (ORCPT ); Wed, 2 Jan 2019 19:49:36 -0500 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 1943515BF; Wed, 2 Jan 2019 16:49:36 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A2D43F5AF; Wed, 2 Jan 2019 16:49:35 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 4/7] arm64: add sysfs vulnerability show for spectre v1 Date: Wed, 2 Jan 2019 18:49:18 -0600 Message-Id: <20190103004921.1928921-5-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mian Yousaf Kaukab spectre v1, has been mitigated, and the mitigation is always active. Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpu_errata.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.2 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 09ac548c9d44..2352955b1259 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -742,3 +742,13 @@ const struct arm64_cpu_capabilities arm64_errata[] = { { } }; + +#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES + +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 Thu Jan 3 00:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154688 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127594ljp; Wed, 2 Jan 2019 16:49:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/U6qPBqGs0jMkzRueOXGhYAQCiybRUV2Orgpwjq4P5tM0yz6uSZ6jZv9MoMhAsHGJaPPZFI X-Received: by 2002:a62:c21c:: with SMTP id l28mr45922007pfg.74.1546476593110; Wed, 02 Jan 2019 16:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476593; cv=none; d=google.com; s=arc-20160816; b=WFTrxgRzi7yrQ6YfvsmO1ZzbskqHf3xbjoJPKZHFQxzyQEQmqj0BhJ3e3pOj5oedJD uzdgYxWvi/I4o6nazIHlv7HK+Qsqj0TNG9zJzjhWYgKimLWoSPAEj2DSb6BT4bD66Bxf xzHbOZyqB7EwsjBvumIV/5wMQ3Fg5XOuxsgNmwXDQOO8br27XvdHkfNgMvj6JfSjwt3W 1mul5RXePCGDS0H2bj0CQg1fbZmaIu/fB5ALTGbcKOu7VvMg+xy8TqtGmoaa4m0/JsTs HaQjvjCa6tEzZc5/YlSjYjo7fpiT5Z7QYKrShsTLlyoAJ8rRztGHjdVUw0PKEbs5/cBg gTIQ== 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; bh=rBFmbu9/zO9jsp1ogtY0AmFI8M8YT90U6CyMlV8YQ7E=; b=EhSHBtw+8APWCpirOiAk11DBCZWSv+iN5Ykec+2tf3Nn/oQVPAvERCMIUX2VNDNlQv 9g8nmLsU++TD8fCifArBsxiT/w5FCCLJVAOv2fuxpHDIJQ5Ch7VWAto4NiP72O0kpeQx AeTPW0trc7eVQThtFtY3zGoujTuv9jhY4zKbmnvj/xs/QaA8qlM9CNMQvEb8PSfduqWv 98hShIUSvacu+vIv05Fsa0GYWp2xlxZnRwaTjDiWQU/rlDJKha1ayA0IMVuGa6Z9T0eG xRcWm87lyod6bHQmZmTuyEpSTIq9okl/RJ3Cie0QR+rXZ6Skl+JWafDAYMGaRk++bTVn jmDg== 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 g1si33378834pld.197.2019.01.02.16.49.52; Wed, 02 Jan 2019 16:49:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730298AbfACAtw (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:52 -0500 Received: from foss.arm.com ([217.140.101.70]:39836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730244AbfACAti (ORCPT ); Wed, 2 Jan 2019 19:49:38 -0500 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 AABAF1650; Wed, 2 Jan 2019 16:49:37 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D434B3F5AF; Wed, 2 Jan 2019 16:49:36 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 5/7] arm64: add sysfs vulnerability show for spectre v2 Date: Wed, 2 Jan 2019 18:49:19 -0600 Message-Id: <20190103004921.1928921-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add code to track whether all the cores in the machine are vulnerable, and whether all the vulnerable cores have been mitigated. Once we have that information we can add the sysfs stub and provide an accurate view of what is known about the machine. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpu_errata.c | 69 +++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 5 deletions(-) -- 2.17.2 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 2352955b1259..96a55accefa9 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -109,6 +109,11 @@ cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused) atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1); +#if defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || defined(CONFIG_GENERIC_CPU_VULNERABILITIES) +/* Track overall mitigation state. We are only mitigated if all cores are ok */ +static bool __hardenbp_enab = true; +#endif + #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR #include #include @@ -231,15 +236,19 @@ enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry) if (!entry->matches(entry, SCOPE_LOCAL_CPU)) return; - if (psci_ops.smccc_version == SMCCC_VERSION_1_0) + if (psci_ops.smccc_version == SMCCC_VERSION_1_0) { + __hardenbp_enab = false; return; + } switch (psci_ops.conduit) { case PSCI_CONDUIT_HVC: arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 < 0) + if ((int)res.a0 < 0) { + __hardenbp_enab = false; return; + } cb = call_hvc_arch_workaround_1; /* This is a guest, no need to patch KVM vectors */ smccc_start = NULL; @@ -249,14 +258,17 @@ enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry) case PSCI_CONDUIT_SMC: arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 < 0) + if ((int)res.a0 < 0) { + __hardenbp_enab = false; return; + } cb = call_smc_arch_workaround_1; smccc_start = __smccc_workaround_1_smc_start; smccc_end = __smccc_workaround_1_smc_end; break; default: + __hardenbp_enab = false; return; } @@ -507,7 +519,36 @@ cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused) .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ CAP_MIDR_RANGE_LIST(midr_list) -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR +#if defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \ + defined(CONFIG_GENERIC_CPU_VULNERABILITIES) + +static enum { A64_SV2_UNSET, A64_SV2_SAFE, A64_SV2_UNSAFE } __spectrev2_safe = A64_SV2_UNSET; + +/* + * Track overall bp hardening for all heterogeneous cores in the machine. + * We are only considered "safe" if all booted cores are known safe. + */ +static bool __maybe_unused +check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope) +{ + bool is_vul; + bool has_csv2; + u64 pfr0; + + WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); + + is_vul = is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list); + + pfr0 = read_cpuid(ID_AA64PFR0_EL1); + has_csv2 = cpuid_feature_extract_unsigned_field(pfr0, ID_AA64PFR0_CSV2_SHIFT); + + if (is_vul) + __spectrev2_safe = A64_SV2_UNSAFE; + else if (__spectrev2_safe == A64_SV2_UNSET && has_csv2) + __spectrev2_safe = A64_SV2_SAFE; + + return is_vul; +} /* * List of CPUs where we need to issue a psci call to @@ -705,7 +746,9 @@ const struct arm64_cpu_capabilities arm64_errata[] = { { .capability = ARM64_HARDEN_BRANCH_PREDICTOR, .cpu_enable = enable_smccc_arch_workaround_1, - ERRATA_MIDR_RANGE_LIST(arm64_bp_harden_smccc_cpus), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + .matches = check_branch_predictor, + .midr_range_list = arm64_bp_harden_smccc_cpus, }, #endif #ifdef CONFIG_HARDEN_EL2_VECTORS @@ -751,4 +794,20 @@ 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) +{ + switch (__spectrev2_safe) { + case A64_SV2_SAFE: + return sprintf(buf, "Not affected\n"); + case A64_SV2_UNSAFE: + if (__hardenbp_enab) + return sprintf(buf, + "Mitigation: Branch predictor hardening\n"); + return sprintf(buf, "Vulnerable\n"); + default: + return sprintf(buf, "Unknown\n"); + } +} + #endif From patchwork Thu Jan 3 00:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154686 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127488ljp; Wed, 2 Jan 2019 16:49:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Utoybb6PDvH9l53vAB1kanT2O92e4ZgtG/dqQW/v9To8xPRcDbkTq6gcZcLMWZNiFKmJ2m X-Received: by 2002:a62:2606:: with SMTP id m6mr45429552pfm.133.1546476583943; Wed, 02 Jan 2019 16:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476583; cv=none; d=google.com; s=arc-20160816; b=YsHqzRKMKOl7WnwsZCv931XAviZomVJuzRWrM6i/jWjBsU/tzmmZT5dPSEDYJlG6R7 NYnta7iTOddcI0FNZHdistLZg2VPgtuCmIT5SyodctXo5pIopta3ic1W6AuDpD2WUt4l xrZHxMZbS4Ac9MtDOJXugi7Mo7eNJH3PxsC56ml3TghZ3uSwbJvReVtJ3GpwTBlbU6Vw VMqe47fLWKhDARx+oJnaTnGw4XeGiXuGv9peaAVRP8+rOSFwa93aWgsXKR51ltRWsS3N JSg03Qq22VpyabfgtBmzNVJtgHg0SV2NlZw+oKnavkerAYMrXqvME144t9foYa2KosKh OfBA== 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; bh=KTZIRT5a6Q6mgHHtSd8/o41F24BhW1+BLwFBvX6hfBM=; b=tXe424fo207VehUCRXoV2P5JA8S6nrCWI9sh0spI0hhf9YRxjoGLyPm4IK4M4dFheP MQ7ptNM+OX8gWM0MmZ31SMoiDcZTCc8Q1HqD8INKiLVttxXrXJMIqyA9moHk6Bns5ZnX q/MoDVVkMTezKYfae5VD6yL2Ipxe98WBO6RIl+8snM2u6k/9jHrk+9khOJ2Ik3SAMRU0 6XiyjYdpii2MkeqQAS16tCc2S4hAiF+T31E0ZxRY0at92mmjvCG+BKuR01lyG9Mj15KB SJSMWazTb3PmGa36h6tMt5jmXgntGwp5visddL/dBU3NuL0t6qs5QYpXx7HQoBmhcBk4 icQQ== 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 f12si30416238pgd.68.2019.01.02.16.49.43; Wed, 02 Jan 2019 16:49:43 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730270AbfACAtn (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:43 -0500 Received: from foss.arm.com ([217.140.101.70]:39854 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730253AbfACAtj (ORCPT ); Wed, 2 Jan 2019 19:49:39 -0500 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 17BFA1596; Wed, 2 Jan 2019 16:49:39 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 415EF3F5AF; Wed, 2 Jan 2019 16:49:38 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 6/7] arm64: add sysfs vulnerability show for speculative store bypass Date: Wed, 2 Jan 2019 18:49:20 -0600 Message-Id: <20190103004921.1928921-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mian Yousaf Kaukab Return status based on ssbd_state and the arm64 SSBS feature. 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 [Added SSBS logic] Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpu_errata.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- 2.17.2 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 96a55accefa9..c962b5856c87 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -420,6 +420,7 @@ static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry, ssbd_state = ARM64_SSBD_UNKNOWN; return false; + /* machines with mixed mitigation requirements must not return this */ case SMCCC_RET_NOT_REQUIRED: pr_info_once("%s mitigation not required\n", entry->desc); ssbd_state = ARM64_SSBD_MITIGATED; @@ -810,4 +811,31 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, } } +ssize_t cpu_show_spec_store_bypass(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* + * Two assumptions: First, get_ssbd_state() reflects the worse case + * for hetrogenous machines, and that if SSBS is supported its + * supported by all cores. + */ + switch (arm64_get_ssbd_state()) { + case ARM64_SSBD_MITIGATED: + return sprintf(buf, "Not affected\n"); + + case ARM64_SSBD_KERNEL: + case ARM64_SSBD_FORCE_ENABLE: + if (cpus_have_cap(ARM64_SSBS)) + return sprintf(buf, "Not affected\n"); + return sprintf(buf, + "Mitigation: Speculative Store Bypass disabled\n"); + + case ARM64_SSBD_FORCE_DISABLE: + return sprintf(buf, "Vulnerable\n"); + + default: /* ARM64_SSBD_UNKNOWN*/ + return sprintf(buf, "Unknown\n"); + } +} + #endif From patchwork Thu Jan 3 00:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 154687 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp127512ljp; Wed, 2 Jan 2019 16:49:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN6MFp7TXWxFdpnLL9LlqIkQS4zdcvFH6ceCF1Lbg6fzPnNhw/wo7wWkgDXGccFaC7KNx/cV X-Received: by 2002:a63:bd1a:: with SMTP id a26mr42958928pgf.121.1546476586338; Wed, 02 Jan 2019 16:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546476586; cv=none; d=google.com; s=arc-20160816; b=eGtkxm280hwDUcSVxhtUU0ZvrQQJekBEuHlH8gHR98awDRv1iQxZMaS1W4KjsCPsof Rxs5BHK40st4C0RFj2SVHx5ru+++Zh5u7GFitaDeXX3sIQcmolO3cqgRCK44ERKQlIFJ F3OVOFqJC9E4u+AzXLeLwh7Zb+9TH283SwMbHgxU9nIxPzsSfClGI6MbC+L6rBbizNcR tgLScvCu/s7T19ZBjQK0TWSB+MTKcTcUO7mi5USl2QcEevpJs+ETBvDFlGMgN1XKXlKD 6l2YyWzV8bb/r089HkNNRo/7nhF2rkpVtBSX4dHz3KO51H9llUC/zzY5GIHapZaCATRB L4YA== 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; bh=2W/YWXLfSLBgeiJ+hz08gWxtcRMh5zmRBIqb2zczsJ0=; b=q63vqA7uHt5Ven6u7VJrVvHxTzVzDFUcZXj3roBWdYLdkV8ki6oyvpErut4QBGlwFA JIaIhJAQP9aUVZ1Do2/xsUqz9y+P0lBrvf4Nt1HJhvzS8jXY5jjNV1mnxdY+6M0pdoJp 0awnbFpVYiCUm0qIrSt0+BG1z4R3HnjyeI9Yuafhqk/DQ0xL2ez/4pXlYs4f836xfAa1 85VWMXP4jlAXqCO5wDHtYrGuM5txsxy1jzMLya70BUjeJAWoXOjyEH7r+uE2wjfgFJtD GupXcwQDQ5gvGROLR4c2H1Rgb/w8XDe+0P4EOh4i0MkO21kpowqBcWd6ugoDehRq5O65 pE5Q== 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 g1si33378834pld.197.2019.01.02.16.49.46; Wed, 02 Jan 2019 16:49:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730281AbfACAto (ORCPT + 31 others); Wed, 2 Jan 2019 19:49:44 -0500 Received: from foss.arm.com ([217.140.101.70]:39868 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730261AbfACAtk (ORCPT ); Wed, 2 Jan 2019 19:49:40 -0500 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 7FEC21682; Wed, 2 Jan 2019 16:49:40 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9FC3D3F5AF; Wed, 2 Jan 2019 16:49:39 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, dave.martin@arm.com, shankerd@codeaurora.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, Jeremy Linton Subject: [PATCH v2 7/7] arm64: enable generic CPU vulnerabilites support Date: Wed, 2 Jan 2019 18:49:21 -0600 Message-Id: <20190103004921.1928921-8-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190103004921.1928921-1-jeremy.linton@arm.com> References: <20190103004921.1928921-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mian Yousaf Kaukab Enable CPU vulnerabilty show functions for spectre_v1, spectre_v2, meltdown and store-bypass. Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Jeremy Linton --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) -- 2.17.2 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a4168d366127..be9872ee1d61 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -88,6 +88,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