Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1314034imu; Wed, 9 Jan 2019 15:58:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN60PBGdBmfJGs5ryl7vB5dwyXb3jBzcOblb5pznzH37cOfiMGTPDr8AmbQoZ4kjBbORlowB X-Received: by 2002:a63:ba4d:: with SMTP id l13mr5057151pgu.194.1547078327260; Wed, 09 Jan 2019 15:58:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547078327; cv=none; d=google.com; s=arc-20160816; b=QeGz5wcq7GdQWxDJKJ+oFrB5Zq/AFUiJMnZI3ParF9Be01ZY+TCpvfpfEJprjBoJ5Y XBofskiPqmBsL0xkOYkHSwLf0uh4Ey1ma3W/zYvOVHng/F0FPdHs7Mkp1Y6D/8YRobn5 a0RTlkPlqfQE6l6T1RWFUhL17lcn/0aDim2ntVXN1dYkmMJHjIv074C+D1VilHtRNw1b atl5kKilUu2Czxr481D/xM+oa4v7vvQ3uzOMnjOjbNRgDuefABESIaFgcWEYvtxXS8sI 5R8NKV42mLAx5sT/hd5UjD6uLpXIPHNMqLtEsv+zmes9Jm29ZqmBqr8EzSrFTdGBquFW 5EAw== 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=YL4Q5QMT6HQEQ6qbsywjaGsKyTzBeYAgCROVi2KbnZqCSHF7RKi0ofsUGjj4XCphsn zT+f160lGUmJjJyBCfcQpKHi5RNueWasiuvPX3+04XY9cmRHTQkWHk+LPlR25SLwb1kx Ofkq0ArlNFuKXupYmCBTIER5cFh/i7VvqliozmjGwXVA5dpAJFFVsPBGzqsTVdIbpPvI pAmU9PWcJfe4U500YwdPLY0UGVqbxFJ4wZ885xWcF95S0mq6VkmzPI1eahcLae54WB8+ BkMyypeQza2KUXR55e+pKK8vf9OKw56ULwB/vRL6T4o16j272MmRhA3YdYn/IHfR4IpS xVbA== 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 b11si21422093pfo.240.2019.01.09.15.58.32; Wed, 09 Jan 2019 15:58:47 -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 S1726946AbfAIX42 (ORCPT + 99 others); Wed, 9 Jan 2019 18:56:28 -0500 Received: from foss.arm.com ([217.140.101.70]:53342 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbfAIXzy (ORCPT ); Wed, 9 Jan 2019 18:55:54 -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 953BA15BE; Wed, 9 Jan 2019 15:55:53 -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 ED75C3F5AF; Wed, 9 Jan 2019 15:55:52 -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, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, stefan.wahren@i2se.com, Jeremy Linton Subject: [PATCH v3 3/7] arm64: kpti: move check for non-vulnerable CPUs to a function Date: Wed, 9 Jan 2019 17:55:40 -0600 Message-Id: <20190109235544.2992426-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190109235544.2992426-1-jeremy.linton@arm.com> References: <20190109235544.2992426-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