From patchwork Thu Dec 6 23:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 153074 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp357ljp; Thu, 6 Dec 2018 15:44:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/UAXmsxQydu4AMPxIubzISpHMIILc1eFoeDyVW7v+dgx/6tHZg3c1XVqK2c9bTM9VpApbCQ X-Received: by 2002:a62:d74d:: with SMTP id v13mr30005745pfl.34.1544139873642; Thu, 06 Dec 2018 15:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544139873; cv=none; d=google.com; s=arc-20160816; b=RCWxvDH1jH71AKYlGIin+KxSN05rfFKDDoukoohoctw29C8+sHDCV6svx3AsRWTVL9 hQNlbOjZiQx6kLSg5RqHQEkZxN0n8DaHwK76BbM/BNjuh//fjdV2C71PPY4JMcnrN7pY GnPowdhM18g3fZfQGGQzmqiboi2ijOL65L3c43pO025YWsfxKRQM7uePjend+71fmQvi dunjkXF7uwId91r0QBvU+PTbeJ/88Io+Am6W/ZdMl1buOmEhjaAh2Tsoc0lXE6qPq8ee tG9Hp91Kjxdf1sYJ+KBkx1XCGZoSGjnK8lmFJBOhP7oE+s32e/SaEcNr6e6KBL9kxBPl HcKg== 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=0IsUAzw/pqIn4AKvfyTPqPE5HZ1KR3cRnI5HX5M+Yig=; b=APSBeByBdhS/stT44fYgrcbPkkL8LwpjM9QtjaxUN5rMJ8hOUhaFFVNje11Fcpf8ku FTFtRhI5dC0TFQgSYd/FihZF/DhkCIk1yMQ01XOfFCSW5bUjKV0ueI5i2OXYar9rUydT pXzD85HMFfabV7W4Is2kIGbDgzxb+2RL7oR7jhXeizBXjT4BE531MFnNy6oT5NEU8ygS Zqzyo4fJ5D8RMBeNC63mMaLSac/y7RwgA7O8MLJ7diwxJZ90+A9PJgGIilNCEHETBM0Y xiCJf3FeFcVwszRf28cWDATa5d4xbo9veDMfaN/KltvBExBrSr78Acx5PZ6qttAEYu+i DECw== 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 g19si1351588pgj.358.2018.12.06.15.44.33; Thu, 06 Dec 2018 15:44: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 S1726396AbeLFXob (ORCPT + 31 others); Thu, 6 Dec 2018 18:44:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35896 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbeLFXoa (ORCPT ); Thu, 6 Dec 2018 18:44:30 -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 B5B8615AB; Thu, 6 Dec 2018 15:44:29 -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 34B3B3F5AF; Thu, 6 Dec 2018 15:44: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, Jeremy Linton Subject: [PATCH 1/6] arm64: kpti: move check for non-vulnerable CPUs to a function Date: Thu, 6 Dec 2018 17:44:03 -0600 Message-Id: <20181206234408.1287689-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181206234408.1287689-1-jeremy.linton@arm.com> References: <20181206234408.1287689-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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) -- 2.17.2 Reviewed-by: Julien Thierry diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index aec5ecb85737..242898395f68 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -908,8 +908,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[] = { @@ -917,6 +916,16 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), { /* sentinel */ } }; + /* Don't force KPTI for CPUs that are not vulnerable */ + 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"; /* @@ -940,8 +949,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 */