From patchwork Tue Jun 12 14:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 10460491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12490602A0 for ; Tue, 12 Jun 2018 14:39:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C7BF287AB for ; Tue, 12 Jun 2018 14:39:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00E76287E3; Tue, 12 Jun 2018 14:39:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0760287E2 for ; Tue, 12 Jun 2018 14:39:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEB366B0008; Tue, 12 Jun 2018 10:39:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9E056B000A; Tue, 12 Jun 2018 10:39:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E9086B000C; Tue, 12 Jun 2018 10:39:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 4ED016B0006 for ; Tue, 12 Jun 2018 10:39:25 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id 31-v6so14147576plf.19 for ; Tue, 12 Jun 2018 07:39:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=r1W83Hkjp1SFOleitCmeMxOSuBtc7EbffVUL8S90/3w=; b=Fv27BqNE3pQx/8C4wvu53iFeug+/0TqVe7J7RjBCa6ovyiiGM3pRqtz1u2LqusA0Mi jYlE3dGory53bT66E0wlcS+Aq4y3ndZFzToOOmxZXxy4vVDf0gcPdQsLjDT7Gc4cKemP iAKXveNXV2akvpIkloWsdwnxo4jOtUCYtJjFwvh3FO1jLrPvcDUNLmxbJanzYx2xBNdx ft//wmlnNsNxavlSc/ifL0/cWGAwiCm7/l+NGlv7BGFLZ6BjQC6EYtoxoSXzJcOys9Fk cnp0q+mPECAaEkp6uRQUP9dh6fICuyBUo9gx6s6//6piacUOu2CcuoEC7gilrnf9/uN8 oooA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E0S41JXzubRRmWozXvQorRkFiL7WlnfJwawgK/M1Q3OYi3rdxyf n9oJwd6IZ+2qfBxvMdGn8gTV7YE9eO88stt5uts8ggIVNzpWMF5jOrI8iIAjKCVhfPu+VmalFL0 nFq9dUa6M4Bnr+R5wzgeXOVCi1BUE2I2MAEBx7bb1qo59hXzkEla4Ykq7wT6BdUSJHg== X-Received: by 2002:a62:a21b:: with SMTP id m27-v6mr689108pff.248.1528814364968; Tue, 12 Jun 2018 07:39:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLeZe5f+7yM1yIBB5y78b7ND3VbQSgJoqkodpVn9ooSwogGZF1Kk1m9+pP+BtwcJexWSwUx X-Received: by 2002:a62:a21b:: with SMTP id m27-v6mr689048pff.248.1528814364103; Tue, 12 Jun 2018 07:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528814364; cv=none; d=google.com; s=arc-20160816; b=yQQoGp18YY9R+3hYev3ziAq7Fbzh4M8WpaXNgt+5pFZFKstgbKaCeNFUw+d94/pIXT sZXpwQAEeUf5eMlrt4iGrbLdsZiUOdbRTw8kcAWHaGLJKImSj1ufTY0W3ROCr8yBB+4F OsioFZHsh74BnzYAU1RI8QE9+DjFx2SCyAk6zfvQShiJlg8cFkjEUSlBLNaC3a0O+8o3 nv1ez57aecpZWH/CDQL921eW8tg9EKCjVClqaUPJq9GzGTXa5Ih/YMAKrD2UBB/nKF12 uEaR5KA6r3j3yJ6dgsMzSch1tBnXpAahGSe3tGcDBYaORnfbtzWSUsVmEyTsaTTmPV18 O2cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=r1W83Hkjp1SFOleitCmeMxOSuBtc7EbffVUL8S90/3w=; b=SJlQ2rJ/WArKY53efTBtiTd/suKJZvvwZBDfGXGcnykdM2fXwvzGHp4c8bDidAIe92 3Sjlh76szfVvmNoKGvB8ZR9wrv8IdyEnydogBohoX8yz63oeTfgPiHE46qOPk/KYMJJv WhJKGEtXL6Lqjzedasb6or9m6ntRGBLFzrhPqJrY+7GkcIRYcawAHYUcJbgWIV21UVGj ZbzeiD8X2fDFbForBRyGsmCD/HM+aaJ5CK0rHkYDo1BXtd3lFdPpcDoqTMwS3M+fIPcX HsLM4Lvl0iXt6a76GNUIOmcEgLBV8gb3d2szYAYsTUpQyCdmMifxqJDjL5Nkgc3SCw/5 ikxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id l5-v6si295495pls.360.2018.06.12.07.39.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 07:39:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of kirill.shutemov@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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); } /*