Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1851556rwi; Thu, 3 Nov 2022 09:45:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70Ipkb+/ZCnumihHIvghLx7FF375FJn2Hv5BO5UVRPtO6n4C9z1vhw+BD1Qnohn+tcgNJV X-Received: by 2002:a17:907:a067:b0:7a7:dc5e:eb2d with SMTP id ia7-20020a170907a06700b007a7dc5eeb2dmr30618405ejc.121.1667493915582; Thu, 03 Nov 2022 09:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667493915; cv=none; d=google.com; s=arc-20160816; b=Lpeq0Cm0pGUNhL6xSBMR9VTbINaYxctfeZuxkgFk4LUKhr5SPPU35LXc26PD+uEgjr Wm4EgJ1j1Rb/4GWxeiFInAYMy1UqGcm3vTe9UkYi8V2neYIjMfiW32k8cRDR3opv/gk+ axzX8Ww+odP/oKk6ehnK6AGcAPpa6jB3CnohRsc52OWNpBoFNaxy3F/udzIa23SAp780 jbNgy8vXNjkFQcVWUdT9BAV3t1Toa63Nmd7VAhuKbXRL5Wmf8gI/+dpM2rIk1Igfivhf J3ei2UL5gbcDFUNDrCt9xTIBW7j4Vh5AMWFahkXwKzdO7lu2Vj115eTfIhEcXKo9e1Ag 023A== 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:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=z/C3hpsaAUauBg1lNZ7x2lDFowPPF1DONENeXdvNlHg=; b=qHGtJ5QJSGqANRcTikksfb7DbAjAG6q7LvMVZyE3UUSwVubR7at48LCXrF4gku+yHl 616ujrhW6ck58R7RqPMrPcapjPHDE1cLaZcpaR664AFLN+AO7MHzw6vLnQY42hHUSGuy UgTU+16yJWKsUIw/aUZPNjjzg4W0r3LQw9zHH/yOM8bb2D8a6/5cyXESOo4hCoxz3mwH xCIF4Fvq3uc5K0WLkMjI5FJH/91OuILcr2s6KeG0bWIUNs5PWPByZBCzoMm67BxJfJIv C7VwTZUvy6UC9xtT4JB7bOewgO1oNANu3zjDzB4Mg9DVbLhaz+zSPYdjIsY9e54c8A2/ P4lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=cJt3hR7v; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="Xp/UUWwX"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a05640205c900b0045d189ac612si2206084edx.402.2022.11.03.09.44.50; Thu, 03 Nov 2022 09:45:15 -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=@shutemov.name header.s=fm2 header.b=cJt3hR7v; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="Xp/UUWwX"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231689AbiKCQaZ (ORCPT + 97 others); Thu, 3 Nov 2022 12:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiKCQaV (ORCPT ); Thu, 3 Nov 2022 12:30:21 -0400 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A039E68; Thu, 3 Nov 2022 09:30:20 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id B39505802BB; Thu, 3 Nov 2022 12:30:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 03 Nov 2022 12:30:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1667493017; x=1667500217; bh=z/ C3hpsaAUauBg1lNZ7x2lDFowPPF1DONENeXdvNlHg=; b=cJt3hR7v7SCNla7eXQ i90372/VJvPGU+ek4EklPY7Z1h9eNHAS6q98C2Pkp/Ks5TkT/I6+O+oiLSzUi3qG YQMXVCqPCd853tICbc9Ot5iuYoTcY9sDj153nfGnceQroa51z/zyStTVx6kKk+qk swy2GVse/rzWnvNiZyrkq9+QKIkMO6c+HBDbcT5815ZqaSg+CqMieNF+suoTkG9q d35+VbbvhhxHny0REo2fqtAFKjWH69jfafARLlrDEkwPR5G+OeeWexyMY69xWTQs 9hG31aLQZ1NBst4OsgmoFm7sgmmNccS27ItzTJewBOjAI1mf3W5sYVfz7O2QQkH2 KECw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667493017; x=1667500217; bh=z/C3hpsaAUauBg1lNZ7x2lDFowPP F1DONENeXdvNlHg=; b=Xp/UUWwX3MA3A3FhOL+uUmo98+p/mBAOVE6y3oteimnp BGsyKhPGyDalEGVnTkf9KbzLLGczmkIRzvTCBCbaWYaYtZJ7s5wGS5ox4pse97E8 ItmT6KnFilBemeBsPjQnDXYjjEjoHoULHaLQ5ONvcVTOm++bj/0zi0P2ns0QvcPP cS23hOm5hfOhMomcRE7PFy4MEYmjfnQ+MjemMLurvahmVpbBGyjQ/6JonkxsSyqd mpJ1O2FcOAHrD7eaBmcAr7R0mLw53nA40XEYmYrMS73USeELLLLl1ODQZhSxynXT atH9QYZog6S+m644Se0gu6hLvqJpioy/eHJRfVxNzQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudelgdekfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhirhhi lhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrdhnrg hmvgeqnecuggftrfgrthhtvghrnhephffgffehieelieefveeukeevtdevvdfhtdduvdet vdffhffhfffgieehfeehvdelnecuffhomhgrihhnpegrmhgurdgtohhmnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhu thgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Nov 2022 12:30:15 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 1EC92104769; Thu, 3 Nov 2022 19:30:12 +0300 (+03) Date: Thu, 3 Nov 2022 19:30:12 +0300 From: "Kirill A. Shutemov" To: Michael Roth Cc: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , 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, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , tabba@google.com, mhocko@suse.com, Muchun Song , wei.w.wang@intel.com Subject: Re: [PATCH v9 1/8] mm: Introduce memfd_restricted system call to create restricted user memory Message-ID: <20221103163012.25zof5lyxvizltwl@box.shutemov.name> References: <20221025151344.3784230-1-chao.p.peng@linux.intel.com> <20221025151344.3784230-2-chao.p.peng@linux.intel.com> <20221031174738.fklhlia5fmaiinpe@amd.com> <20221102211404.l5whyif3j3k67fv2@box.shutemov.name> <20221102220700.5u4mj7fm37m6ust2@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102220700.5u4mj7fm37m6ust2@amd.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS 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 Wed, Nov 02, 2022 at 05:07:00PM -0500, Michael Roth wrote: > On Thu, Nov 03, 2022 at 12:14:04AM +0300, Kirill A. Shutemov wrote: > > On Mon, Oct 31, 2022 at 12:47:38PM -0500, Michael Roth wrote: > > > > > > In v8 there was some discussion about potentially passing the page/folio > > > and order as part of the invalidation callback, I ended up needing > > > something similar for SEV-SNP, and think it might make sense for other > > > platforms. This main reasoning is: > > > > > > 1) restoring kernel directmap: > > > > > > Currently SNP (and I believe TDX) need to either split or remove kernel > > > direct mappings for restricted PFNs, since there is no guarantee that > > > other PFNs within a 2MB range won't be used for non-restricted > > > (which will cause an RMP #PF in the case of SNP since the 2MB > > > mapping overlaps with guest-owned pages) > > > > That's news to me. Where the restriction for SNP comes from? > > Sorry, missed your first question. > > For SNP at least, the restriction is documented in APM Volume 2, Section > 15.36.10, First row of Table 15-36 (preceeding paragraph has more > context). I forgot to mention this is only pertaining to writes by the > host to 2MB pages that contain guest-owned subpages, for reads it's > not an issue, but I think the implementation requirements end up being > the same either way: > > https://www.amd.com/system/files/TechDocs/24593.pdf Looks like you wanted restricted memfd to be backed by secretmem rather then normal memfd. It would help preserve directmap. -- Kiryl Shutsemau / Kirill A. Shutemov