Received: by 10.223.185.116 with SMTP id b49csp2779567wrg; Mon, 5 Mar 2018 08:33:30 -0800 (PST) X-Google-Smtp-Source: AG47ELsc26JsmEw4gxVylHHlve8paCnqN+VhP4oQnp8tObcLdLLMNFXBI7q61I2h1cjPZEtC7e0S X-Received: by 2002:a17:902:26:: with SMTP id 35-v6mr13767710pla.42.1520267610182; Mon, 05 Mar 2018 08:33:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520267610; cv=none; d=google.com; s=arc-20160816; b=vkOslfVQU0f7jsw3hdoy4qtO+Gh3y/OPSFuHrOEfhKZtS3fttyuIFvrABva+4gA0Gq gl+Ex00DkDbbCgvAANu7sDy27KLF5t554dHdbT8d5AODvsoEalj/iPb2lF1SZPhrMv8O 1qoefB9dSWVHRrRsSqANGQ1JdgU9+j8xN7FPlnybT9DOREiDtYf185OA9vDQvYd7zMpZ tzPjQYJPPCVVx3xyqJPjeGiAq3NXhAmS552um/qd7aFk047M8MXHpnGy8tOLkKM8nWoQ Aw0v7Ncu6ulDl5/9fDOujecrbBkHaTo/1g0WRPpyQVg1H/64xiybSGzcnagsZ4VfGFgU zXNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=0Flwi1dGGmh5dZ9N3C4Cis8mlmFlVHkRYAxx0EdbaW4=; b=IvUDEw3TjOIrhqDyzRs5hPAWwct+Ur9Eoji8WMwn6c7kBPAMrvrxQOIQYjadAnjY5d OA4QVs0cbAHVnHTV917ZGY4pas+5hbQAHQ+azGDTSe3jvEYCI30zZXZ7DxdURkCmA6Rb u6bGuTiT7+y52sV7+UNjVF/KxkS0WySciatNuA5yzJXlS6NADNrk5tLyTD+uVUqipiYm gakW8ll4V1DcRv8E3bPHMSEwLZPd+Pqj2JRhpMO2ou4n5qDbGIB7BcePJubR0RITqlKK Nvr7+SLNVU/2JR6JYSM7SvqBcnK58RS997HectvgIFgYHa1MxVU2kDFNutapenvMesFS V4bA== 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 w21-v6si331420pll.735.2018.03.05.08.33.16; Mon, 05 Mar 2018 08:33:30 -0800 (PST) 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 S932210AbeCEQam (ORCPT + 99 others); Mon, 5 Mar 2018 11:30:42 -0500 Received: from mga05.intel.com ([192.55.52.43]:31633 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752440AbeCEQ01 (ORCPT ); Mon, 5 Mar 2018 11:26:27 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 08:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,427,1515484800"; d="scan'208";a="22683458" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 05 Mar 2018 08:26:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4FAA34A2; Mon, 5 Mar 2018 18:26:20 +0200 (EET) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [RFC, PATCH 09/22] mm, rmap: Add arch-specific field into anon_vma Date: Mon, 5 Mar 2018 19:25:57 +0300 Message-Id: <20180305162610.37510-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> References: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org MKTME enabling requires a way to find out which encryption KeyID has to be used to access the page. There's not enough space in struct page to store this information. As a way out we can store it in anon_vma for the page: all pages in the same anon_vma tree will be encrypted with the same KeyID. This patch adds arch-specific field into anon_vma. For x86 it will be used to store KeyID. Signed-off-by: Kirill A. Shutemov --- include/linux/rmap.h | 6 ++++++ mm/rmap.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 988d176472df..54c7ea330827 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -12,6 +12,10 @@ #include #include +#ifndef arch_anon_vma +struct arch_anon_vma {}; +#endif + /* * The anon_vma heads a list of private "related" vmas, to scan if * an anonymous page pointing to this anon_vma needs to be unmapped: @@ -59,6 +63,8 @@ struct anon_vma { /* Interval tree of private "related" vmas */ struct rb_root_cached rb_root; + + struct arch_anon_vma arch_anon_vma; }; /* diff --git a/mm/rmap.c b/mm/rmap.c index 47db27f8049e..c0470a69a4c9 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -74,7 +74,14 @@ static struct kmem_cache *anon_vma_cachep; static struct kmem_cache *anon_vma_chain_cachep; -static inline struct anon_vma *anon_vma_alloc(void) +#ifndef arch_anon_vma_init +static inline void arch_anon_vma_init(struct anon_vma *anon_vma, + struct vm_area_struct *vma) +{ +} +#endif + +static inline struct anon_vma *anon_vma_alloc(struct vm_area_struct *vma) { struct anon_vma *anon_vma; @@ -88,6 +95,8 @@ static inline struct anon_vma *anon_vma_alloc(void) * from fork, the root will be reset to the parents anon_vma. */ anon_vma->root = anon_vma; + + arch_anon_vma_init(anon_vma, vma); } return anon_vma; @@ -186,7 +195,7 @@ int __anon_vma_prepare(struct vm_area_struct *vma) anon_vma = find_mergeable_anon_vma(vma); allocated = NULL; if (!anon_vma) { - anon_vma = anon_vma_alloc(); + anon_vma = anon_vma_alloc(vma); if (unlikely(!anon_vma)) goto out_enomem_free_avc; allocated = anon_vma; @@ -337,7 +346,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma) return 0; /* Then add our own anon_vma. */ - anon_vma = anon_vma_alloc(); + anon_vma = anon_vma_alloc(vma); if (!anon_vma) goto out_error; avc = anon_vma_chain_alloc(GFP_KERNEL); -- 2.16.1