Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3404663imm; Tue, 17 Jul 2018 04:25:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHRZsin8S3zD6iNAfKGyaBjKv5idWAHnFyg49bXXk4k48Bg5+jAVQl3HtG8bcnoSL4fJB7 X-Received: by 2002:a62:3d86:: with SMTP id x6-v6mr286837pfj.192.1531826702877; Tue, 17 Jul 2018 04:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826702; cv=none; d=google.com; s=arc-20160816; b=nUkobgyLrvLtVT1Wk9/kMC1KSrpXuSjeIoYSXQh3EpnhcBhrqTCuw1TSxFa12TtXbf 20PZd/qK0/rkx2eNkh5toEZbaYT2QySST1iCBBbL4FSfHLiKb/+RZuQVNFBQE170L2Lq nByLyEK1MyJ1KNOhGMWaVeiFc3KCwLzIxO4WxdW1zb1Gkdpq7dFijWtaj26LKDdJjuQB auyr4y9DbjarC99E+VQ+LMp/77xLFfQwZfJIMeXB5RmVhsCz91h4vHnvNS1fH0g5kl90 +h2ZDKzFee3fMNWQ3b8ucKK8T7PGhyae2LDBcacG31yHeh5VafEEtxxNKzOxzwAT1rSj /xKw== 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:arc-authentication-results; bh=D5oFOxR38ZDKm7jtbZVJJ8jELOPzD31wSekKyr61DdY=; b=l/7UY/cx3EQ1FPMYNxJpThYclpaxi08TTsVxOiz8CBT81bfSzxyVchGbFXtTlD+Xwz IjO6DvsPQM++z1fH/z7Im9mI/lzCtrQz4hi8/O4Cudp4bBHdijfb6pBjJsqnScOG2XXA AKOWAUyVNvoMsSjTVg4D+LEuJSpp4xwAOrwfedNes1sFAeK3nswwMcPA9yqGEUeBKTqI +ZH0TQvh7KkAKdgbHklpuQZPdd2lyMITPBy0II8BfxkeneEONaELx7Z2CtJGE7C7QwT0 4Epk+MV/I0Hnu8qwCMFIQ6OSwqS9d/lTmIH+XlRFVOjq5GhJkSJRBeLOENtBjV+8Lpds NC5g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 136-v6si641205pgb.587.2018.07.17.04.24.47; Tue, 17 Jul 2018 04:25:02 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731404AbeGQLx6 (ORCPT + 99 others); Tue, 17 Jul 2018 07:53:58 -0400 Received: from mga07.intel.com ([134.134.136.100]:40792 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731368AbeGQLx5 (ORCPT ); Tue, 17 Jul 2018 07:53:57 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 04:21:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="75441626" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 17 Jul 2018 04:21:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4773F7BC; Tue, 17 Jul 2018 14:21:49 +0300 (EEST) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCHv5 14/19] x86/mm: Allow to disable MKTME after enumeration Date: Tue, 17 Jul 2018 14:20:24 +0300 Message-Id: <20180717112029.42378-15-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180717112029.42378-1-kirill.shutemov@linux.intel.com> References: <20180717112029.42378-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new helper mktme_disable() allows to disable MKTME even if it's enumerated successfully. MKTME initialization may fail and this functionality allows system to boot regardless of the failure. MKTME needs per-KeyID direct mapping. It requires a lot more virtual address space which may be a problem in 4-level paging mode. If the system has more physical memory than we can handle with MKTME the feature allows to fail MKTME, but boot the system successfully. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/mktme.h | 2 ++ arch/x86/kernel/cpu/intel.c | 5 +---- arch/x86/mm/mktme.c | 9 +++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/mktme.h b/arch/x86/include/asm/mktme.h index 44409b8bbaca..ebbee6a0c495 100644 --- a/arch/x86/include/asm/mktme.h +++ b/arch/x86/include/asm/mktme.h @@ -6,6 +6,8 @@ struct vm_area_struct; +void mktme_disable(void); + #ifdef CONFIG_X86_INTEL_MKTME extern phys_addr_t mktme_keyid_mask; extern int mktme_nr_keyids; diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index efc9e9fc47d4..75e3b2602b4a 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -591,10 +591,7 @@ static void detect_tme(struct cpuinfo_x86 *c) * Maybe needed if there's inconsistent configuation * between CPUs. */ - physical_mask = (1ULL << __PHYSICAL_MASK_SHIFT) - 1; - mktme_keyid_mask = 0; - mktme_keyid_shift = 0; - mktme_nr_keyids = 0; + mktme_disable(); } #endif diff --git a/arch/x86/mm/mktme.c b/arch/x86/mm/mktme.c index 1194496633ce..bb6210dbcf0e 100644 --- a/arch/x86/mm/mktme.c +++ b/arch/x86/mm/mktme.c @@ -13,6 +13,15 @@ static inline bool mktme_enabled(void) return static_branch_unlikely(&mktme_enabled_key); } +void mktme_disable(void) +{ + physical_mask = (1ULL << __PHYSICAL_MASK_SHIFT) - 1; + mktme_keyid_mask = 0; + mktme_keyid_shift = 0; + mktme_nr_keyids = 0; + static_branch_disable(&mktme_enabled_key); +} + int page_keyid(const struct page *page) { if (!mktme_enabled()) -- 2.18.0