Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4618995rwi; Mon, 17 Oct 2022 08:31:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yokqp6xbFtje5E/Xy8qYcTyx1RaARmvrIDjM/o3om5dYONgdcuO/RI5Sy8R5NlEu2uGXl X-Received: by 2002:a17:907:a062:b0:78d:d4c3:caf9 with SMTP id ia2-20020a170907a06200b0078dd4c3caf9mr9337633ejc.704.1666020699342; Mon, 17 Oct 2022 08:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666020699; cv=none; d=google.com; s=arc-20160816; b=fiktcZPaLGV5PKDbi5R90IWx/2D+LK7+abYd9o/UzKbz4DFICHKgweHCMxh8cOXwSY Vm2WoKPsgtjOH4SYZCwIQSvndNFRoT9zRW5cnqUPeaD6EXa68UDGsG+1UIFaErczpr// nY06FMEXe59Q2Fr6Gf/pWwDGq7A8+BGcHnKBiBJehyT5svNohFU8+/BvjE4eWTVZ3vTh aVEq+LkHuDURTeLA26qcW2bIL8T5gzj6XMBrjSKVxBEDaR3hPC//X9u86ehJYcSu1hOG 4Q5BdJp1YfXMLRoXh/zXrNxziRkdCwg+qYC7Nmtzs1Lrr/CkPfWQvfMaNwV7lIcr5DHa fPpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SmPEl3YZH+yvnx1ZNW7yWTDOzUnIm+7YZ7MaFsnPbIo=; b=iEeycgspIyvyYLTv1tAF9Z+Ot1H7TindHHI+s1PYBN+H4zADvdvu3wm9K1+O3dM1mn 8PGkOSVB12NDiNgNMrjzc509I1HKY+XmpBe/Ho/Mi0TaCvPBLpKaUB+P96Pr7/O6p7kj I9+7jGxsRTuJ3arXBv7t+tjuVj/PwoN+bRv1bq8gKSgfxq+fZZxtPkPdTpDsFNo9AvIe Xucd5Kzy6AOUd/HaNfns0B9tHKIXwt2bO/dRgNtn0kTVYC/WSHb+OrJYGdM729cct0yt Qb+KMsuz3NiqcoQHyKyHzg0WO/U4qr5TrvJSTtUtKurfZsMWLZy9Bxz7tPqB5qz6gLZZ zO9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IU3LmUkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qn24-20020a170907211800b0078d3ba4d567si8098146ejb.422.2022.10.17.08.31.10; Mon, 17 Oct 2022 08:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IU3LmUkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbiJQPGd (ORCPT + 99 others); Mon, 17 Oct 2022 11:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbiJQPGF (ORCPT ); Mon, 17 Oct 2022 11:06:05 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FFE6D547; Mon, 17 Oct 2022 08:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666019141; x=1697555141; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=PvgBjoYyaoMX/iKVZUi6GVXenC/pYD5E0G2UFDGF3Zw=; b=IU3LmUkLVt36rvVKa9l916RfDbpgiRFHzjy57j8VE5wsnRvfpKAlpOZd 2brl+HVkkRpDgs7erNYSqncIAX0+BRkq4+tdIRDIMCpISsSX48TyhAIYH VnQbj3GuBSvty8nqptQNxuxmOGH9mbkPpN92Ms9GY9vt6+ScHe/HrJ00Z pcweMnaz1AbVk57r2pqnh1tn46FvqCqDQVdhEXW8NkL0Dwn1vssEQQRbS tNz9bjTm8JYYwuDOLvDpzn4Vr87zueycm4qVj3chWuAC/Mpe720lkbPXY 37lO6G2qq5TUIONbfaVt7aKKZKBdMaNwTBawqKECCT8vPiOOYox7upECp w==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="370011931" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="370011931" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2022 08:03:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="691387974" X-IronPort-AV: E=Sophos;i="5.95,191,1661842800"; d="scan'208";a="691387974" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by fmsmga008.fm.intel.com with ESMTP; 17 Oct 2022 08:03:27 -0700 Date: Mon, 17 Oct 2022 22:58:56 +0800 From: Chao Peng To: Fuad Tabba Cc: Sean Christopherson , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com, Will Deacon , Marc Zyngier Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd Message-ID: <20221017145856.GB3417432@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220915142913.2213336-2-chao.p.peng@linux.intel.com> <20220926142330.GC2658254@chaop.bj.intel.com> <20221013133457.GA3263142@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 17, 2022 at 11:31:19AM +0100, Fuad Tabba wrote: > Hi, > > > > > > > Actually, for pKVM, there is no need for the guest memory to be > > > GUP'able at all if we use the new inaccessible_get_pfn(). > > > > If pKVM can use inaccessible_get_pfn() to get pfn and can avoid GUP (I > > think that is the major concern?), do you see any other gap from > > existing API? > > Actually for this part no, there aren't any gaps and > inaccessible_get_pfn() is sufficient. Thanks for the confirmation. > > > > This of > > > course goes back to what I'd mentioned before in v7; it seems that > > > representing the memslot memory as a file descriptor should be > > > orthogonal to whether the memory is shared or private, rather than a > > > private_fd for private memory and the userspace_addr for shared > > > memory. The host can then map or unmap the shared/private memory using > > > the fd, which allows it more freedom in even choosing to unmap shared > > > memory when not needed, for example. > > > > Using both private_fd and userspace_addr is only needed in TDX and other > > confidential computing scenarios, pKVM may only use private_fd if the fd > > can also be mmaped as a whole to userspace as Sean suggested. > > That does work in practice, for now at least, and is what I do in my > current port. However, the naming and how the API is defined as > implied by the name and the documentation. By calling the field > private_fd, it does imply that it should not be mapped, which is also > what api.rst says in PATCH v8 5/8. My worry is that in that case pKVM > would be mis/ab-using this interface, and that future changes could > cause unforeseen issues for pKVM. That is fairly enough. We can change the naming and the documents. > > Maybe renaming this to something like "guest_fp", and specifying in > the documentation that it can be restricted, e.g., instead of "the > content of the private memory is invisible to userspace" something > along the lines of "the content of the guest memory may be restricted > to userspace". Some other candidates in my mind: - restricted_fd: to pair with the mm side restricted_memfd - protected_fd: as Sean suggested before - fd: how it's explained relies on the memslot.flag. Thanks, Chao > > What do you think? > > Cheers, > /fuad > > > > > Thanks, > > Chao > > > > > > Cheers, > > > /fuad