Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5426841imm; Tue, 12 Jun 2018 07:42:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ0FUfwyMAVdfqsfThfX6yp5TYv2aRnadEf/LCh1zPAIX52tbDLHTgTbPQg+oU70hYQNRAZ X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr764635pln.290.1528814564072; Tue, 12 Jun 2018 07:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528814564; cv=none; d=google.com; s=arc-20160816; b=ZicWZK9LVIqEIGqQ+Mx9G+MLOkdcO9GU8OQjPewkp9zhhZFZBi1YsrQmBsU2zXnC3D b6ot1/8Xz8VowsN4PX539g7v8mcHk8C+qXt0u8Okmu+oSaynoEojWlExLO0hBWRsAnU+ PfimB3YKsbD4ynVVHYRVHfEwrsj+/ZCXwj54ysMFVyX3SZTIdIisxJaD+m1IcsNUiWkw g+MFvTMEX39b7IjlTqQ5+c6O6BWy6BUW8HvF1EAbgcBMSwW5+xKp8oNgaKHkCl4ya3Qq 8NwsrOqfG7ud1T0HEEyEZQEztmh4++eZrcoXVp12ZbcjNOXDNLwsJxqX88UK/WmcJnUI Cj6Q== 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=r1W83Hkjp1SFOleitCmeMxOSuBtc7EbffVUL8S90/3w=; b=WGdcemXmIPMuYW/Jag/dG1teNfKHMBBoZVN4PGpoA7vyouHi8YALkBV++pGqNDbgyD TZJx55S3CjNhPfcbH7KHkaNgA0XwRZLDI05kRUOgfdxyN/UOHHsbuyu3Yr7hjFQhctpi vHxQTZHhdqtmeEbBBSy4VoYX9GauOor8NR/9gdkNn0r33lP0Dowwp8UDv61nQvM+Jw4O HfUph+dVmAKphh+CIZkAnxSfMdxlNwABF/UZyNxOg0dmFR5TyLBnI17xsQAma5JAp/+s FQRZ+yV/lP8TcL9KCrlE6qEK+FClqXtqNuxqzyZhZQdaKJ0PKok99z33LpI54VdQrqWy Wi8Q== 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 q185-v6si301515pfb.216.2018.06.12.07.42.29; Tue, 12 Jun 2018 07:42:44 -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 S934280AbeFLOj2 (ORCPT + 99 others); Tue, 12 Jun 2018 10:39:28 -0400 Received: from mga04.intel.com ([192.55.52.120]:22209 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933419AbeFLOjY (ORCPT ); Tue, 12 Jun 2018 10:39:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 07:39:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,215,1526367600"; d="scan'208";a="63925661" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 12 Jun 2018 07:39:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 7B6C255; Tue, 12 Jun 2018 17:39:20 +0300 (EEST) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky Cc: Dave Hansen , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A. Shutemov" Subject: [PATCHv3 01/17] mm: Do no merge VMAs with different encryption KeyIDs Date: Tue, 12 Jun 2018 17:38:59 +0300 Message-Id: <20180612143915.68065-2-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> References: <20180612143915.68065-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 VMAs with different KeyID do not mix together. Only VMAs with the same KeyID are compatible. Signed-off-by: Kirill A. Shutemov --- include/linux/mm.h | 7 +++++++ mm/mmap.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 02a616e2f17d..1c3c15f37ed6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1492,6 +1492,13 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma) return !vma->vm_ops; } +#ifndef vma_keyid +static inline int vma_keyid(struct vm_area_struct *vma) +{ + return 0; +} +#endif + #ifdef CONFIG_SHMEM /* * The vma_is_shmem is not inline because it is used only by slow diff --git a/mm/mmap.c b/mm/mmap.c index d817764a9974..3ff89fc1752b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1217,7 +1217,8 @@ static int anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct * mpol_equal(vma_policy(a), vma_policy(b)) && a->vm_file == b->vm_file && !((a->vm_flags ^ b->vm_flags) & ~(VM_READ|VM_WRITE|VM_EXEC|VM_SOFTDIRTY)) && - b->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT); + b->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT) && + vma_keyid(a) == vma_keyid(b); } /* -- 2.17.1