From patchwork Tue Jul 17 11:20:25 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: 10529037 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 5D7C8603ED for ; Tue, 17 Jul 2018 11:22:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BAD028C0F for ; Tue, 17 Jul 2018 11:22:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 404FC28C30; Tue, 17 Jul 2018 11:22:31 +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=unavailable 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 EB75828C0F for ; Tue, 17 Jul 2018 11:22:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 115846B027A; Tue, 17 Jul 2018 07:21:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA3566B027B; Tue, 17 Jul 2018 07:21:58 -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 BB3E76B027D; Tue, 17 Jul 2018 07:21:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 601D76B027B for ; Tue, 17 Jul 2018 07:21:58 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id b9-v6so325200pgq.17 for ; Tue, 17 Jul 2018 04:21:58 -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=sRsoGR7nI9fj+DvLdgMQSjhtx2NqQSl7PzkEYyGdBPI=; b=hKspqKxQ/JZs3o8lJaP7ovE6djsV7WIPniYsVpvyqcH2z3bVcY++gz6frjaXZGf829 PRtav/qQpYq0w3wXo5xYYiM53uXYKzD0c8KHrukwr4LT/r1UZGlH77v7A9WCb/ullnZQ XanBIegmAsyoWCoCPlmNmFz6pnt52EHDN0dEslUsLxbfdpEwwfJtgf5u/cxEHVg6E9i7 gAdQCFY1cZKgdRUJ6qfmcv2IscQcRx37F7Lh0GDuLsueJje0ssI/oFXwaftCNtCsXtb6 zDaDtQi3hyU48rgBH2ihLnnmViusa61P5czB3t/SFP61NwkFvoj9FpZdO2mnarzF75G/ Z0YQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.65 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: AOUpUlFDXhCmED9X/i2acoxrjnNcipl4Krxdt5/J87DSashk6DJbhNwr p4fawAaj9gxslI9d5/xaKAvcbA4E6+nutEvDJw5ahTb/ZTICjFiOeHKYDkDDvyP5rKkuP/bVFoO KBgMzYzIfi287NDHZr15ydLsfBaKLQgJcCdDqR1V8yn7axyfTiUrtZJR0HdDmms/jHQ== X-Received: by 2002:a17:902:d692:: with SMTP id v18-v6mr1247299ply.59.1531826518042; Tue, 17 Jul 2018 04:21:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfMRyW3Onqm+htplQ3NkFJJd0x5bXTVj9o4LAT66i7QXV50+2FeIj8vwxqm3FS0AIOBT4OU X-Received: by 2002:a17:902:d692:: with SMTP id v18-v6mr1247255ply.59.1531826517390; Tue, 17 Jul 2018 04:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826517; cv=none; d=google.com; s=arc-20160816; b=hXIKnc4w2P3sGvwvNC0pJD2Vbj5lrgw0n6KynTFpWqWXE08Erx0h8vUTKKHmObIN+G b8QVn6ODylZRHZBq2l2/XFuMxYjEKAws6AZpny49iHl8Lu1VQgSwrxtflfKRHmwZqDi/ CEvPv6lSneQqOmWAvIeQPa8ZX6gElwwG5cfnYpzQoyri0E8UXyftZw+ozsg50Ap8+S40 ZDNgX422MbKSE3uQTcE1ne2ErRpmlC9DeQVSCWD/HvPO1KuaX8VKnWbDuhNqX+IDkkTj lYMcv7OUZvB8CConn90xTSbcD9DoPpvnDgDspf9XJt3U2yX4FF313LDpKmMiLUYLSbsO f1Qg== 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=sRsoGR7nI9fj+DvLdgMQSjhtx2NqQSl7PzkEYyGdBPI=; b=vXeL1/efkd9nDajT6cDmCG1FXdSXd2oDq6IcDrgMkj7zJESvTOIjr8MVuucG6AJsHu oocf8CHWteYGq4t0nubeMis9I+Rus+DViyGGJntkybt0LfTPo9gFARYu3ESnDMeRBT1X 67X99p7kHdzNBsvLzrYe41sEcn4a78CijHEqYNbyesYriPPaSsEgPJ2GvkO08fYTyJXF sxqwTlxTBaVhHiVmA5b6tY3csH1RofSjqejbyQ4Lgw/ISN9mta7g3nTDHjdl4VSKjPQ+ oFRM8/JG1qQIOWvfkLN0D+TiTklrRbgPyvtt1CGJLy/VQ6qV90Qd3uNXZJKQk79+DXis k6nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga03.intel.com (mga03.intel.com. [134.134.136.65]) by mx.google.com with ESMTPS id u7-v6si691565pgn.194.2018.07.17.04.21.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 04:21:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.65 as permitted sender) client-ip=134.134.136.65; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.65 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 04:21:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="55628008" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 17 Jul 2018 04:21:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 5256A7EC; 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 15/19] x86/mm: Detect MKTME early Date: Tue, 17 Jul 2018 14:20:25 +0300 Message-Id: <20180717112029.42378-16-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 We need to know number of KeyIDs before KALSR is initialized. Number of KeyIDs would determinate how much address space would be needed for per-KeyID direct mapping. KALSR initialization happens before full CPU initizliation is complete. Move detect_tme() call to early_init_intel(). Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/cpu/intel.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 75e3b2602b4a..39830806dd42 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -158,6 +158,8 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c) return false; } +static void detect_tme(struct cpuinfo_x86 *c); + static void early_init_intel(struct cpuinfo_x86 *c) { u64 misc_enable; @@ -301,6 +303,9 @@ static void early_init_intel(struct cpuinfo_x86 *c) } check_mpx_erratum(c); + + if (cpu_has(c, X86_FEATURE_TME)) + detect_tme(c); } #ifdef CONFIG_X86_32 @@ -766,9 +771,6 @@ static void init_intel(struct cpuinfo_x86 *c) if (cpu_has(c, X86_FEATURE_VMX)) detect_vmx_virtcap(c); - if (cpu_has(c, X86_FEATURE_TME)) - detect_tme(c); - init_intel_energy_perf(c); init_intel_misc_features(c);