Received: by 10.213.65.68 with SMTP id h4csp639509imn; Wed, 28 Mar 2018 10:00:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49AJzt/J9SwXDq0x/+CLaM5e/lb6KNfTCg1ydr3Z/+rBVUgUgTqtkxBqSt9uliJekQ3vODa X-Received: by 10.99.119.133 with SMTP id s127mr3049188pgc.441.1522256410550; Wed, 28 Mar 2018 10:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522256410; cv=none; d=google.com; s=arc-20160816; b=S8NGdsl8AlR/cgItO0dkK7gP3qu9j8t8D9Ubgs7p3jdPqMvwN9kY73Rp8e9iSwqhX/ YPUPFZ0rQ85o/MMIj1rPoyRc+oN7MEoHrD1f1hvLhvsC7IX1I854EIm5NKC6AmZJkmhj Uh8MtbOrHaUV6dUvBtIoMwfX4Mp6iB/UkX3xgijgA2BKCFMhYvb3SQ+sWPDDyk7FvDFi CvdH0fYttwkxlrtbhZzwBxUjgsgae8X6BV+4lOTigKDwUhqt3Nj/0OD+90LyE0qmJnmR ZoGnXafxMLr7iGfRa26oOT8oDCzsy4T4UoroupIqNV8pNCnK+hVna6TL332lK0N3u99d MAcA== 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=MdJjrps6rNvCSC2e41SvTtZL+e1Bw3cikptdFRIzHjg=; b=Nx63RnvqzqJVCi6I4hUEyKS0dH13w+eIYjJM6RVPM/oLKolFAkj1/lRGop5qQ9j9x1 dvLRfp2M5DqOac9j4T1qrIpxYfz8LCEXrH3B/S9WiUin9yKYJ6JZFdL8AHWco+2SVoRN coQRj9ox+aiOHfNpodcrXON5eJUOBwwxhuWO6u/4IK20T6keedd2CjCauJj+FN0QXnIC b/lzQ8EA7cqf38bFDWsTo4yM889ZwmVP84/4yTQlvKdFWo9lgUcgXVTczsEyCCtr9MdC IqKgVORx4swDuyDd55z6P3xarHw483/nU+Q4IURGlSyE+6XjW2H38yZfkhOb4Xk6UWeV X5eQ== 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 r6-v6si4299816plj.743.2018.03.28.09.59.56; Wed, 28 Mar 2018 10:00:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbeC1Q6L (ORCPT + 99 others); Wed, 28 Mar 2018 12:58:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:50175 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbeC1Qzu (ORCPT ); Wed, 28 Mar 2018 12:55:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 09:55:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,372,1517904000"; d="scan'208";a="28816298" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 28 Mar 2018 09:55:44 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4D15632D; Wed, 28 Mar 2018 19:55:43 +0300 (EEST) 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: [PATCHv2 04/14] mm: Do no merge vma with different encryption KeyIDs Date: Wed, 28 Mar 2018 19:55:30 +0300 Message-Id: <20180328165540.648-5-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180328165540.648-1-kirill.shutemov@linux.intel.com> References: <20180328165540.648-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 ad06d42adb1a..6c50f77c75d5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1479,6 +1479,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 9efdc021ad22..fa218d1c6bfa 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1208,7 +1208,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.16.2