Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp781906imm; Fri, 15 Jun 2018 06:15:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOAPmc9d2wTL6vwgZjo6ALURx2imkCYHzs1Ql/rv9CJyLuo8MVYwMrTyyBcVUXqP7c+6X/ X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr2030530plb.110.1529068500469; Fri, 15 Jun 2018 06:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529068500; cv=none; d=google.com; s=arc-20160816; b=B+TioqqK+rGuF6CrDT2Fb6vV71TSLC9z7neOFcjcLop1M0Ti6NHSQsX58WHSsHYFlm aWIpDi9SovwLedxIGssr8KskqrG0f5MpkgIk+fToRQWX47//1xzxQPKZWugU0xufrzC7 yIf0gqvvlTo2muprosjbFd+2hKPNzyvPQtL1hXl1nLWy5dDOES6qZO26/66UPz7LJ/GM 9HsO4j6o5cXjR9ObvBqDCijMhKJbZ4Af/BeXwgB14xgvUMsBr5y1Yi8OAG048lnikhVx seqvHkpybRLDFsj8sFjyEnTy3oqVm47RU3Bt89zJcaI6XcRZ70Fg1F6b9kq/R95NzDGy P5gQ== 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=8YLktrbSJB3AxDl/ZKEkJ7YKCdKCXPrXXuWdEcjpYsk=; b=q0iL06c0HsljQmXvuW44DRVYtX35+LGT1f7s0wJXnc5WWe9LF4eNdPIUqBITgFhxdD 8v33hRVamLIdC33VU3eQ5koDZvohezHi8gZQvWAt7cnO4MD4oR1nZPynNUOLm2x0bXfn CpVi2UuhHM4/uNFOBxb8qj6zTOFvJtRE2dv94nSc8Cjxak2yprZ6/e4/MR6IBYOyrau+ P7NG9XBxtODGADUPlzPTbO/9J4XW7odb6QzwhY/ZnabLsXyZnAYH60El34UgvO9eum7J vKLXyOUKxabT3agJh04aGPkEP2UoDKe5CEmd0pwIKZJh7fQJaamkEjH/V2LdFfw3QdSz ZyDA== 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 u23-v6si8720084plk.487.2018.06.15.06.14.45; Fri, 15 Jun 2018 06:15:00 -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 S965624AbeFONOU (ORCPT + 99 others); Fri, 15 Jun 2018 09:14:20 -0400 Received: from mga14.intel.com ([192.55.52.115]:10375 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936209AbeFONOT (ORCPT ); Fri, 15 Jun 2018 09:14:19 -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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2018 06:14:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,227,1526367600"; d="scan'208";a="63487848" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2018 06:14:16 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 30ED3172; Fri, 15 Jun 2018 16:14:17 +0300 (EEST) Date: Fri, 15 Jun 2018 16:14:17 +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 08/17] x86/mm: Implement vma_is_encrypted() and vma_keyid() Message-ID: <20180615131416.sl7ib6kt2mg5ufya@black.fi.intel.com> References: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> <20180612143915.68065-9-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:18:05PM +0000, Dave Hansen wrote: > On 06/12/2018 07:39 AM, Kirill A. Shutemov wrote: > > +bool vma_is_encrypted(struct vm_area_struct *vma) > > +{ > > + return pgprot_val(vma->vm_page_prot) & mktme_keyid_mask; > > +} > > + > > +int vma_keyid(struct vm_area_struct *vma) > > +{ > > + pgprotval_t prot; > > + > > + if (!vma_is_anonymous(vma)) > > + return 0; > > + > > + prot = pgprot_val(vma->vm_page_prot); > > + return (prot & mktme_keyid_mask) >> mktme_keyid_shift; > > +} > > Why do we have a vma_is_anonymous() in one of these but not the other? It shouldn't be there. It's from earlier approach to the function. I'll fix this. And I'll drop vma_is_encrypted(). It is not very useful. > While this reuse of ->vm_page_prot is cute, is there any downside? It's > the first place I know of that we can't derive ->vm_page_prot from > ->vm_flags on non-VM_IO/PFNMAP VMAs. Is that a problem? I don't think so. It need to be covered in pte_modify() and such, but it's about it. That's relatively isolated change and we can move KeyID into a standalone field, if this approach proves to be problematic. -- Kirill A. Shutemov