Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp296166imu; Wed, 2 Jan 2019 20:22:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN5gFSz0Blkith6rGXURWnJZvy4W7mLLkd6+QAvhCTcih/bdnKb15q9auYpJPxOPTJd66vud X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr46429671plk.291.1546489352114; Wed, 02 Jan 2019 20:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546489352; cv=none; d=google.com; s=arc-20160816; b=EB30Sh5HdVCWzmpgg7Il9IlWiIC6+Yu5dP3Z8wdofhB5fdn8WeIfht5VsRfdQ4tnv7 rjw2F7QmILzz8jJP/XOEUH8H1vvDVSnIHNCg6gVCRUHu3VGk9eex3kPZw6ht/Biw25gC HmUW+ru/hSY6+BhaFLWvZMnftT4qYAwDLyiWXNOdMVnjTFmtk8qVbAlae3ZY9OOc0dMJ nI1RQHUAJqVBzmVoYvf6J2L0veiD0k4lwPtvFVa+e6bHSa9zRXMVCrCa210RH98soopJ A+38cuUVSEovABT5t+HhrfsGJ712b+QpQkS7LcwikzVW09BSPd6wRvrkIbLk9Y9zizHO gJ3g== 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 q7si53100287pfa.99.2019.01.02.20.22.16; Wed, 02 Jan 2019 20:22:32 -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 S1730222AbfACAtg (ORCPT + 99 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(-) 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 */ -- 2.17.2