Received: by 10.213.65.68 with SMTP id h4csp616792imn; Tue, 13 Mar 2018 15:09:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/zoUVA8VAQIQtBuJOYVuXwYp9+ieECPAs0hzSxvVZZyTwWJA+JDBSNvm3YufmUDzym9Y+ X-Received: by 2002:a17:902:7784:: with SMTP id o4-v6mr1952654pll.112.1520978956517; Tue, 13 Mar 2018 15:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520978956; cv=none; d=google.com; s=arc-20160816; b=Xed3i3qpsYM/SXnfrV522OSIH161BXpNNyrCwb3deDPaW3ZZaE/d0B1N3dvSlaRfxb IxbvZy+sGuFyY6hpT0wxZEMDuhdcYs4r/TxsZ1fiMxQu2xgriUWlXAiJxgT6j6Mq8F3B HmUwzbzFLiYB0176mGmC3xNB6oHfeykiDVhK6LGRKiYeBGjufjfSERr/K4NxZt1Y7PKd tsx9rSfzmTg2BS/eHnwQ0ZiKfc+7XoXQV0ANpO9g4vqrTBBxSKG3Q3YUaiaYsAFCI0xN 5CTwavi2Y5k3NnC1dNHMCQgJSJT1Jo2uZ1s6FsX/D7PAhJ4X07Szx+qq06MzxBUM5Sia 3+lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=E8n9CTvGpj0PFsU/49+nP6LKrWv60eeZm2K/hjT+/iI=; b=r9CNrmx6PN2deRFQJvgNsNuj9v/6ZszCAQzCrNsg0hVYiC3xn3l1vD5XVIaGyQPNXf r5VcS55woajo5zCQd3Bln2VyjSPhb99wBHppMaou82KJ0HUo7D4t2nXTVMre1vpelZEb lstQfdK12k6LxmrjFXOn3axkjt8RVI1s664VKMvqYcB5vwl3tDF+Reypu2LzRR2PNzgQ nJ8mfvGTKi6ku7tOdlG6uHR2X7scswOltgoIZf1hAmtNLoVJojRsQPmSxaXbem7aJW8H iG957lT45V5sRx1+5neDuIWF9jzFhHR62OZa8EgpWfZQxOnFKkXebmZQj9na3RdXgT+1 I+yA== 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 3-v6si809977plt.124.2018.03.13.15.09.00; Tue, 13 Mar 2018 15:09:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbeCMWIE (ORCPT + 99 others); Tue, 13 Mar 2018 18:08:04 -0400 Received: from mga02.intel.com ([134.134.136.20]:52634 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbeCMWID (ORCPT ); Tue, 13 Mar 2018 18:08:03 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 15:08:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,466,1515484800"; d="scan'208";a="37087576" Received: from khuang2-desk.gar.corp.intel.com ([10.254.187.24]) by fmsmga004.fm.intel.com with ESMTP; 13 Mar 2018 15:07:46 -0700 Message-ID: <1520978865.13820.3.camel@linux.intel.com> Subject: Re: [tip:x86/mm] x86/tme: Detect if TME and MKTME is activated by BIOS From: Kai Huang To: "Kirill A. Shutemov" Cc: dave.hansen@intel.com, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, kirill.shutemov@linux.intel.com, thomas.lendacky@amd.com, linux-tip-commits@vger.kernel.org Date: Wed, 14 Mar 2018 11:07:45 +1300 In-Reply-To: <20180313124956.z426zmsr4xl6zomx@node.shutemov.name> References: <20180305162610.37510-3-kirill.shutemov@linux.intel.com> <1520907122.6421.8.camel@linux.intel.com> <20180313124956.z426zmsr4xl6zomx@node.shutemov.name> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.6 (3.24.6-1.fc26) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-03-13 at 15:49 +0300, Kirill A. Shutemov wrote: > On Tue, Mar 13, 2018 at 03:12:02PM +1300, Kai Huang wrote: > > It seems setup_pku() will call get_cpu_cap to restore c- > > >x86_phys_bits > > later? In which case I think you need to change setup_pku as well. > > Thanks for catching this. > > I think setup_pku() shouldn't call get_cpu_cap(). > > Any objections against this: > > diff --git a/arch/x86/kernel/cpu/common.c > b/arch/x86/kernel/cpu/common.c > index 348cf4821240..ce10d8ae4cd6 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -362,6 +362,8 @@ static bool pku_disabled; > > static __always_inline void setup_pku(struct cpuinfo_x86 *c) > { > + u32 eax, ebx, ecx, edx; > + > /* check the boot processor, plus compile options for PKU: */ > if (!cpu_feature_enabled(X86_FEATURE_PKU)) > return; > @@ -377,7 +379,8 @@ static __always_inline void setup_pku(struct > cpuinfo_x86 *c) > * cpuid bit to be set. We need to ensure that we > * update that bit in this CPU's "cpu_info". > */ > - get_cpu_cap(c); > + cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx); > + c->x86_capability[CPUID_7_ECX] = ecx; > } > > #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS > > > And for the comments here, I think it can be refined. It is true > > that > > VM guest needs to know bits of physical address, but this info is > > not > > used only by VM. I think the reason we need to update is this is > > simply > > the fact. > > Fair enough. Like this? Yes good to me. Thanks. Thanks, -Kai > > diff --git a/arch/x86/kernel/cpu/intel.c > b/arch/x86/kernel/cpu/intel.c > index e8ddc6dcfd53..ac45ba7398d9 100644 > --- a/arch/x86/kernel/cpu/intel.c > +++ b/arch/x86/kernel/cpu/intel.c > @@ -612,11 +612,8 @@ static void detect_tme(struct cpuinfo_x86 *c) > #endif > > /* > - * Exclude KeyID bits from physical address bits. > - * > - * We have to do this even if we are not going to use KeyID > bits > - * ourself. VM guests still have to know that these bits are > not usable > - * for physical address. > + * KeyID bits effectively lower number of physical address > bits. > + * Let's update cpuinfo_x86::x86_phys_bits to reflect the > fact. > */ > c->x86_phys_bits -= keyid_bits; > }