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 */