From patchwork Tue Jul 17 11:20:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 10529029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6806600F4 for ; Tue, 17 Jul 2018 11:22:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3875205A8 for ; Tue, 17 Jul 2018 11:22:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6B2528A05; Tue, 17 Jul 2018 11:22:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48E97205A8 for ; Tue, 17 Jul 2018 11:22:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3046C6B0272; Tue, 17 Jul 2018 07:21:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2496C6B0277; Tue, 17 Jul 2018 07:21:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0681C6B0276; Tue, 17 Jul 2018 07:21:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 8F3DA6B0272 for ; Tue, 17 Jul 2018 07:21:52 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id o16-v6so322099pgv.21 for ; Tue, 17 Jul 2018 04:21:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=D5oFOxR38ZDKm7jtbZVJJ8jELOPzD31wSekKyr61DdY=; b=CY2skqW3jvWAkbAvaytMclvvH33ulP9m88sOfAT5VszgCFsUEeGKC25+uJB/tzPBbT T+6s0Rxj6z9DFrvLiWbo+tbpXgvwubwhmMyflRsuOgfmaA/x4Ksi82MP4mbw+V80wGn2 E4SvvX5SAMIzxf7Ae/LLHxtIZ7sNgzmLQRotuEjedrHo6zXcijef0Kb5OCt/0z+TlYdi teJSF5XIZsbP7qrHMK7b6xaoL2t/sSEpw5FQybbWOqaHkV/WKhz6plNNDKwLLkwlw11I 8njFjbZLGrjIEtHpzVOaMCxB9bDQ0a7BLfscebROVGvIG1kdZXgyPqXwu3ueaqqkCAae BZ1g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlFjditxgAk4E5vHJngsil89NJrfB/wiFiuTmSAxtR5SnX1f3YWo SV9lnIK6dBJTj1noMrp6lHHc6MYwKes1z5hXwO5mlxq8abUSQ+na7k1cozWTOsptpRvnLK2iu86 mtC+uSXzOSeO2gRfMszK1q4Tah4ZZYdX79pCTh9J9rGtgkDH/e+wP9T2i5xwNCkqAuA== X-Received: by 2002:a62:4bc6:: with SMTP id d67-v6mr236857pfj.175.1531826512274; Tue, 17 Jul 2018 04:21:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcdvQci9R2bm86lynWLm0SbsELUZhXAGCAXgW0xe3jcyOzKAZj1pPgTwKUb1V+hBl4ENcOA X-Received: by 2002:a62:4bc6:: with SMTP id d67-v6mr236736pfj.175.1531826509709; Tue, 17 Jul 2018 04:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826509; cv=none; d=google.com; s=arc-20160816; b=p/DuB6GFgSpA21m6MdCJEnHIdDAGrjY+GINuoplSf02mRaWePxqW7PjCyZaBcCXyqw ohYiZ220+DvbQwbp/3kY1UH4ufR+9zVwi8M/mj+8fWyio/v30U2JIsVocd1Z3GaQ5GRb UixqqJra44DOE9gHmvlTPzQdgC+3EhPGOCrGqAN6S4uasuAPkP2A/JAOzYulVuKzL+qP tGiqhrBcsZJjdJhqHCUn7UnLB0vsnAKYsJTb+5xRkJOZTElZAJ1chJzlj2JN9yxwiJK5 EIM97eAppmkuZi+uboHNlvwgtA5wGhCpxpf8CvR5VfMspWeXCBgTggvx2QReLsy6JSXt zstg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=D5oFOxR38ZDKm7jtbZVJJ8jELOPzD31wSekKyr61DdY=; b=naf7opj3FOy2PxxoYs+J3+EPZHe/XjBnyQxVFtueIh4OmH4yEiswpOVFrZ3qZFdyD2 v9vTHKvtK0o7sC596ioRFVLcQA11oadHSWibPgVwRhE95wnK2ZUxtaja/XzroltKWR5+ GQHipiQFZ8HWbbcSbLLrRXfR9aK+g/OZerSM8mQJmaeALUckB7kBCtfpwsVcyG0tUdRX wsNEOeXfFtzaWrygS4NeZlx69vjht70rPi+AgmHqYoUrRRIPyzixWFSUXmTl/SuVB/K1 peXwfQPkWNyu/W7aHgpz2hmnIyJhdQmOKRVlaOmXdJxXPuFosVh+jW+q8Dw2kmW9toFt aZIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id l21-v6si690346pgo.272.2018.07.17.04.21.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 04:21:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 04:21:49 -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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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())