Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp931455imm; Fri, 15 Jun 2018 08:28:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIRJdFv6oFCuSUMjVo7RLEUy787W870u+2omwkNhPAE9E9Dl5DRccd7J9GY8+XlRRNI7Skc X-Received: by 2002:a63:902:: with SMTP id 2-v6mr1991466pgj.3.1529076500536; Fri, 15 Jun 2018 08:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529076500; cv=none; d=google.com; s=arc-20160816; b=rn9MY7h8iie89sRDjtd/91u5m8iOc6hbjuRYngOyKAnNTJYCHG0VkpcTZ0w/7NZSZV 6xn3qTxNCqkeI+YfJA/P/WmnVe0RK0SIfzKez+u9P3kDxR8f8CZppxlNalKAWXe/wrL3 W0rZCDasIQazqv9dZ0V3ZuTIeawHYg7QyrS+THWrffUlMxhrOl1/6UmH2FZZjpe9Wfv9 ydmoRLQmak1AXHmXDbCs8iGJZDxn830o67t8dzDUmj3yqcILoWm/I4oXO4i8UsvvvGz0 vfGOl//e4MDgvDczZyY4kEvJf+kVP5rGXgEB7Yd/OL+n6rzbz186sIZPC4SIVN8FNfrx EiFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=iXg5HT7WbAcInBbDTnIJgRctcCAQGByTbfWKWKjof9k=; b=UMoNiBLOOISNRjDydzewOz45tuicosE+KD6nlQC05tRii8ZHnemquuiu4Q6dumy4bc 5m7htVHE8OsTZHSRuTBTZIyo0oD6qXb1L26blmiRg1hepQHqup7MHrutlQna5oAVrVTd DdpQLH5j+ybibMjHPZEBej4Ug5sbS44Cna8GHBkHecsXleMxzhXl4Ay1ymLYgkmawA2N EXi+OkyexXiG5NI0rlycrDHOGB4jqrMNwQsdnuaVGcHL798Q62acFB5hmX8aK2VnLc7k uOEv7WKVHPw8HYOOqc8arwPk0Wnlv9VAuEJeNfbkl7sM/xiJXw2fMYJrwrXuRX9PU6aj vmdA== 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 u191-v6si6672538pgd.667.2018.06.15.08.28.05; Fri, 15 Jun 2018 08:28:20 -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 S965883AbeFOP1f (ORCPT + 99 others); Fri, 15 Jun 2018 11:27:35 -0400 Received: from mga11.intel.com ([192.55.52.93]:19947 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964936AbeFOP1e (ORCPT ); Fri, 15 Jun 2018 11:27:34 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2018 08:27:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,227,1526367600"; d="scan'208";a="63515419" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2018 08:27:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 5388B166; Fri, 15 Jun 2018 18:27:32 +0300 (EEST) Date: Fri, 15 Jun 2018 18:27:32 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv3 07/17] x86/mm: Preserve KeyID on pte_modify() and pgprot_modify() Message-ID: <20180615152731.3y6rre7g66rmncxr@black.fi.intel.com> References: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> <20180612143915.68065-8-kirill.shutemov@linux.intel.com> <8c31f6d2-6512-2726-763e-6dd1cbb0350a@intel.com> <20180615125720.r755xaegvfcqfr6x@black.fi.intel.com> <645a4ca8-ae77-dcdd-0cbc-0da467fc210d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <645a4ca8-ae77-dcdd-0cbc-0da467fc210d@intel.com> User-Agent: NeoMutt/20170714-126-deb55f (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 15, 2018 at 01:43:03PM +0000, Dave Hansen wrote: > On 06/15/2018 05:57 AM, Kirill A. Shutemov wrote: > >>> +#define _PAGE_CHG_MASK (PTE_PFN_MASK_MAX | _PAGE_PCD | _PAGE_PWT | \ > >>> _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \ > >>> _PAGE_SOFT_DIRTY) > >>> #define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE) > >> This makes me a bit nervous. We have some places (here) where we > >> pretend that the KeyID is part of the paddr and then other places like > >> pte_pfn() where it's not. > > Other option is to include KeyID mask into _PAGE_CHG_MASK. But it means > > _PAGE_CHG_MASK would need to reference *two* variables: physical_mask and > > mktme_keyid_mask. I mentioned this in the commit message. > > Why can't it be one variable with a different name that's populated by > OR'ing physical_mask and mktme_keyid_mask together? My point is that we don't need variables at all here. Architecture defines range of bits in PTE used for PFN. MKTME reduces the number of bits for PFN. PTE_PFN_MASK_MAX represents the original architectural range, before MKTME stole these bits. PTE_PFN_MASK_MAX is constant -- on x86-64 bits 51:12 -- regardless of MKTME support. > My issue here is that it this approach adds confusion around the logical > separation between physical address and the bits immediately above the > physical address in the PTE that are stolen for the keyID. Well, yes, with MKTME the meaning of PFN/physical address is not that clear cut. This comes from hardware design. I don't think we will be able to get rid of ambiguity completely. If you have suggestions on how to make it clearer, I would be glad to rework it. > Whatever you come up with will probably fine, as long as things that are > called "PFN" or physical address don't also get used for keyID bits. We are arguing about macros used exactly once. Is it really so confusing? -- Kirill A. Shutemov