From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65275C47E49 for ; Mon, 28 Oct 2019 13:16:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2121620578 for ; Mon, 28 Oct 2019 13:16:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="utV3o3aT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2121620578 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A88A86B0006; Mon, 28 Oct 2019 09:16:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3A6F6B0008; Mon, 28 Oct 2019 09:16:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9013F6B000A; Mon, 28 Oct 2019 09:16:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 687376B0006 for ; Mon, 28 Oct 2019 09:16:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 0785A812A for ; Mon, 28 Oct 2019 13:16:24 +0000 (UTC) X-FDA: 76093242288.10.face16_54ebd1444d65f X-HE-Tag: face16_54ebd1444d65f X-Filterd-Recvd-Size: 5229 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Oct 2019 13:16:23 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id 139so11126859ljf.1 for ; Mon, 28 Oct 2019 06:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RcPtv5d4Xhg7Yg5t5dc7cf1sdnUkFOizbhSvjAdERFI=; b=utV3o3aTqHm5KCIW69feKUGPuTsUaHcp/zpYcTzvlXi3Olyfe1n4hKAzlQ3gdcEU3p +QuGe8rjB2g0Q7BIO4DNZGZICNhpkadVJx6bhQNCcPFHCbbNxkbF8orYFak5554TAru/ zMFayG+JhL2iTkDnZS3Ij6Xzb7NTBaWhtt+JCUB0Rwk/pt5gSDRIBDeaJ43vJywfeHAW SVXD2yhcM/0PInIsF3BvsDNaIHhqr3EAHAyEtdAxKawuv7fbhwNuNFOfPrC/zMa/xlJp RMwOt9XPvVBsYbuKzo3XnYLSDEEF3Q9ZhMMpv50JXGIKgrSy8rO2t6dogMuXPfXa0Yni l7eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RcPtv5d4Xhg7Yg5t5dc7cf1sdnUkFOizbhSvjAdERFI=; b=ST53kGJjqA9pe7S959KkvnecRZ3Rwa7p9ixFc7nfNqgsh//BJv35IefdX3huHGfJPY FOVg7VsozmgxDToCz21/9udk8BBJ1737xD0DiP3OZZpznM+uXTSIJBnTRqeGe80CsoAr 0xKkPPm6QOcb/X2AKoVaUDD/iE7dQU1xPw+di/Jxo6Yi2I20Hhm5fB9qU9780bxwKpse YyE27uzb6W1Bdm2xZ1z7+UyI1MN8yh/g9hxXkTaTuvbGezicZCreLVFSwGpVjz5RXAC0 WoSz+z33ZSXJJJ0x5nNmhGyGUux+RkMl2WcyzFhIelYaDH76lUrd+u3q6K2l3oFsj9z8 bOrQ== X-Gm-Message-State: APjAAAVipbCE5MK8nGgH1F9Pf4vDh1OLgDBd3M+JBiqHmt4Y1dVQOzxP AEz4mli7uxGFIwq9eyLG2CyXrw== X-Google-Smtp-Source: APXvYqyVfI0y1z4XXrCEM0pRrVCY4qmeS3CAaTSlq5hy1wZcRGDvnKux7ec6kYLSUeqeBO51XxbZtg== X-Received: by 2002:a2e:924a:: with SMTP id v10mr11766000ljg.134.1572268582067; Mon, 28 Oct 2019 06:16:22 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y20sm8981461ljd.99.2019.10.28.06.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 06:16:21 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 23644100242; Mon, 28 Oct 2019 16:16:23 +0300 (+03) Date: Mon, 28 Oct 2019 16:16:23 +0300 From: "Kirill A. Shutemov" To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Dave Hansen , James Bottomley , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-api@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, Mike Rapoport Subject: Re: [PATCH RFC] mm: add MAP_EXCLUSIVE to create exclusive user mappings Message-ID: <20191028131623.zwuwguhm4v4s5imh@box> References: <1572171452-7958-1-git-send-email-rppt@kernel.org> <1572171452-7958-2-git-send-email-rppt@kernel.org> <20191028123124.ogkk5ogjlamvwc2s@box> <20191028130018.GA7192@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191028130018.GA7192@rapoport-lnx> User-Agent: NeoMutt/20180716 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: On Mon, Oct 28, 2019 at 02:00:19PM +0100, Mike Rapoport wrote: > On Mon, Oct 28, 2019 at 03:31:24PM +0300, Kirill A. Shutemov wrote: > > On Sun, Oct 27, 2019 at 12:17:32PM +0200, Mike Rapoport wrote: > > > From: Mike Rapoport > > > > > > The mappings created with MAP_EXCLUSIVE are visible only in the context of > > > the owning process and can be used by applications to store secret > > > information that will not be visible not only to other processes but to the > > > kernel as well. > > > > > > The pages in these mappings are removed from the kernel direct map and > > > marked with PG_user_exclusive flag. When the exclusive area is unmapped, > > > the pages are mapped back into the direct map. > > > > I probably blind, but I don't see where you manipulate direct map... > > __get_user_pages() calls __set_page_user_exclusive() which in turn calls > set_direct_map_invalid_noflush() that makes the page not present. Ah. okay. I think active use of this feature will lead to performance degradation of the system with time. Setting a single 4k page non-present in the direct mapping will require splitting 2M or 1G page we usually map direct mapping with. And it's one way road. We don't have any mechanism to map the memory with huge page again after the application has freed the page. It might be okay if all these pages cluster together, but I don't think we have a way to achieve it easily. -- Kirill A. Shutemov