Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3934884imm; Mon, 18 Jun 2018 06:37:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLKw4BguF83jBIgY5CqqnKLDYH/evlx1qbxuxPfo9HGutSPLjr3MRkJGUCH5+Wbta8/Ekkm X-Received: by 2002:a17:902:6b84:: with SMTP id p4-v6mr14174665plk.272.1529329023131; Mon, 18 Jun 2018 06:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529329023; cv=none; d=google.com; s=arc-20160816; b=BWf9SEXTjq3UlpAoKgzrEk9NHa14UdKykewBxnnuCSNPqxtd41zyTAoPIVtsMcVhJF g8nq5JOlOxWTgk7Q5AOk4RwXSnw1mhZ5N+o8px2S10TvyzCn+gBegbfoBNGrOpT1roL9 NRCPcraHXOvdIdrYH+EDXbx+irNGw9xUqjp+PHyw76+Obz0N54wZobv6hj/u8ehiiIZH +3Z1SiO5kcDLopcYaQVBAiFK4QrBzq0WbbFmi91ZjUFBIDL8pEPNZOyO3ZbcuI1X4Rp5 x658hsSDpemJEKXaCybdjFEvUqEqecwjG7z1mEnv1eG/BSWF65+nDZYWr83q+xTyKuPe UtqA== 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=Uy9ge8dDQ7HWK01kA4MrVhbRoq22uen1uekH1yL0fV4=; b=vGYjb7zhiVY9yL4c2TYcs571AhE1vig8Dxh3ZbWiVPbouk9sveIAG0nAMxP/RPFOxZ jfMjOSedUbu3JYmiSmS+5diBczS5hOPlMGxA3pNs2nIF6nQjRNGaGgJLUnOkQiSr4KXp hNAXWGCgi4qCg6jnqbvCd/bMhOqdT73z2Ap80JtCJbvzfYoPG7E7mZWHHzruXw/6pziK bj9+oKIdGCAKbN8tCKViDQUKOm9TT40mTH8lnvyIHhkb253quINDJKyhWvlJpuCH4NSf 104UJKLuLayysyoQgDuD5PxrcaxywBzub7yYUG/SV5zXP+YIDNU2LAfSFUqmaUcRG2pL n42g== 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 w78-v6si15059910pfa.359.2018.06.18.06.36.49; Mon, 18 Jun 2018 06:37:03 -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 S934579AbeFRNe6 (ORCPT + 99 others); Mon, 18 Jun 2018 09:34:58 -0400 Received: from mga05.intel.com ([192.55.52.43]:58959 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933557AbeFRNe5 (ORCPT ); Mon, 18 Jun 2018 09:34:57 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2018 06:34:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,239,1526367600"; d="scan'208";a="58548044" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 18 Jun 2018 06:34:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id A657CFA; Mon, 18 Jun 2018 16:34:55 +0300 (EEST) Date: Mon, 18 Jun 2018 16:34:55 +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 16/17] x86/mm: Handle encrypted memory in page_to_virt() and __pa() Message-ID: <20180618133455.aumn4wihygvds543@black.fi.intel.com> References: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> <20180612143915.68065-17-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Jun 13, 2018 at 06:43:08PM +0000, Dave Hansen wrote: > > diff --git a/arch/x86/include/asm/mktme.h b/arch/x86/include/asm/mktme.h > > index efc0d4bb3b35..d6edcabacfc7 100644 > > --- a/arch/x86/include/asm/mktme.h > > +++ b/arch/x86/include/asm/mktme.h > > @@ -43,6 +43,9 @@ void mktme_disable(void); > > void setup_direct_mapping_size(void); > > int sync_direct_mapping(void); > > > > +#define page_to_virt(x) \ > > + (__va(PFN_PHYS(page_to_pfn(x))) + page_keyid(x) * direct_mapping_size) > > This looks like a super important memory management function being > defined in some obscure Intel-specific feature header. How does that work? No magic. It overwrites define in . > > #else > > #define mktme_keyid_mask ((phys_addr_t)0) > > #define mktme_nr_keyids 0 > > diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h > > index 53c32af895ab..ffad496aadad 100644 > > --- a/arch/x86/include/asm/page_64.h > > +++ b/arch/x86/include/asm/page_64.h > > @@ -23,7 +23,7 @@ static inline unsigned long __phys_addr_nodebug(unsigned long x) > > /* use the carry flag to determine if x was < __START_KERNEL_map */ > > x = y + ((x > y) ? phys_base : (__START_KERNEL_map - PAGE_OFFSET)); > > > > - return x; > > + return x % direct_mapping_size; > > } > > What are the performance implications of this patch? Let me collect the numbers. -- Kirill A. Shutemov