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 621BDCA9EC0 for ; Mon, 28 Oct 2019 13:16:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 364EE21734 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" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388774AbfJ1NQY (ORCPT ); Mon, 28 Oct 2019 09:16:24 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34075 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388553AbfJ1NQX (ORCPT ); Mon, 28 Oct 2019 09:16:23 -0400 Received: by mail-lj1-f195.google.com with SMTP id 139so11126856ljf.1 for ; Mon, 28 Oct 2019 06:16:22 -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=THABzz71MeP+9tnm5XeSEjxuNMh/qhvPC9UXyyZdjz473fP4y580O1L1RI1IiZY1KU Il+5ydsM0+wzCIkc4NsWK05g6W+P605iTZnkpISbIeE/Vlx8lOhfuLnMP7KxTtwlPSnP wsSDpCr+MryvKIUvrUDn5MSwvEa9+JBjccVn1XF2E9NLKsifuGKLwiv/BSJ030XJDGwy Ik2li4xYyBXF9g6pnr4J7ZiP6advFx4dZCZCk67ERAgH6cAzoKmSfvc5ysCm/o2FCVYn Mqd4EV+2UHGlP8bY/GXP32K4W+v7n0CaVIoXTzVZ8JEDrKjnCAc3eBBjmYPepMYgWeXa bqRQ== X-Gm-Message-State: APjAAAVMBxdyjA9lBmKoXsxcBPtCN8XGNYRgNYppEND9wNMH32rJ+ZrO oTPdquKvmfUPB+umFaZ/+3k1EQ== 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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