Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1795691iog; Tue, 14 Jun 2022 13:38:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2IMxtb3lT1veF5XL2bcWuMCOBVkr5c6QSNOvgRm0z1j1/LAOMNVpBl0Wr6JnUbCtSjUrb X-Received: by 2002:a17:903:2303:b0:166:313f:a85f with SMTP id d3-20020a170903230300b00166313fa85fmr6150838plh.57.1655239132664; Tue, 14 Jun 2022 13:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655239132; cv=none; d=google.com; s=arc-20160816; b=gqq+Du7KnJK0iBfrqPi4cPf7slVAqbmNkH39YEDr5jQJOKsir+VYouP3wzGpzV1duu FW6EAJVZ1aFU41HyvVK0yNh0utgZkwOH4jYF1LfXCI+7eTzMnaLbp1kcX0LJ1ousPKEV TfprmcTLuMXXxBT8OUltZQBi2cmiwCq7p9gwTZCjZYBTZJUQxMbwsP3sb40jGMqoSC0Z gODVghalNK6VcS6SjCGY+7Y1IRcorkkZ1jCuaFGNXw+wKm4YsHof+38IFZIW5aVgLuoz ATMUVv8668Ei0sp1qyS+ON3TSN3XfJj9Jp8nlKouPw+OtPAYNLra15xY+7ja0bwtsa2C Bc5A== 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:dkim-signature; bh=Nd9SDZzw4itSARkNaCG27mmeVq5npYFfTCjzHQFgRI4=; b=U2K1xC/eCdHAOLtU30i2Ev8VbpwqWOHj3Xv+DIE4UQipf5DvovK7M0EbPNjGz5LU9F VnqxZBPyIws0ZBxc3B5ukQHGN/GTOpXMrEGhfeLCr/UEUjv76R4k/z3uhVvASNTLAi6o NhVTZ2ritoZ221+7HdTYwAFdRBbDAl5iKQHX3vN1HYWkJsRHLXKwTeqxC9mtzfkmsg0j OVFluHHSg6IoY5vtKGWH0jf4+ohW/bICQdpqFB16ChYsT89Qp7NtuAe248zTHluda9zp HPYRezIlhEhmrNuSK9uXP85CXPpb8j+XM4WjLLxBzNnC3TrFJ45FbKfkA3+FJXjGZlRK CBbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=p6QyLSsT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a63070a000000b003fc5a7d389fsi14734334pgh.582.2022.06.14.13.38.40; Tue, 14 Jun 2022 13:38:52 -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=@google.com header.s=20210112 header.b=p6QyLSsT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357858AbiFNUX5 (ORCPT + 99 others); Tue, 14 Jun 2022 16:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352366AbiFNUXw (ORCPT ); Tue, 14 Jun 2022 16:23:52 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 384EF2FE79 for ; Tue, 14 Jun 2022 13:23:51 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id u18so8690364plb.3 for ; Tue, 14 Jun 2022 13:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Nd9SDZzw4itSARkNaCG27mmeVq5npYFfTCjzHQFgRI4=; b=p6QyLSsT1t1aB5YBfR2GG/BLaAyBd4SBkl0BGT8QMWZSi5jJc3YSPjRemJBh3+V6XA KZJATyUOoRYDsVVdw/kIipszAgNMJOgpPU5VatcEX6CEYZ1msrQWV4plcGh7LHLrtnTp akv4UMsMNSqOjHw8z8gAkkLexJuuDRkD0al4tVuHcbA4/DRZKLAipfO5H/hck9y5smTW jiYxM2MewOBOgmdWfXC/737eDQasC+s2HSxh9bvwM07zN5MWnT2Zz+E+Feg09WHMZxM2 83HEgL3ospPobrDW66NEE0GE3q3HMv0RpTANPilmJyUZeJf2Jck3uYuBgPD8az//34T/ Qlnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Nd9SDZzw4itSARkNaCG27mmeVq5npYFfTCjzHQFgRI4=; b=oCTdx7AOIU+vZPENpz/+bPq7MVu+Fd33anCZm3i9i8uP1S5OH0ty/gHgl8aLU8DyQx tK6AWIGuXGC/esd8Reimx9bvEgIqoTCcQezivOK0LQH6MJJenFeZiql6sZkGkmm3/slw yxy9W3PEYwBywGOrZiwkR9/zBuGa8zlgXRLkEIFsaHIMQQpuvbYkGDpxELXRVTlDXdQX 5bTVvYZV0QjUPTlzYpCCwnDRhEp9atx+xPV50agoNGpnhMLYCyfWzoSp0fJst1vI9HJ9 RP+eWhbB+Vg5knuj0/A7dkItPyewP6rTJ/2gz4DOMO5wObQ4a4BJZ4ocSw/4VrKPVbu1 tPCw== X-Gm-Message-State: AJIora+M8P90i9b+j10kQERJLhQPagnj5HeQ19LDMtEReRBeWU2sEONv +MLlTfKZql8gk1h56+78enfWFQ== X-Received: by 2002:a17:90a:728c:b0:1e2:e386:4448 with SMTP id e12-20020a17090a728c00b001e2e3864448mr6258934pjg.167.1655238230059; Tue, 14 Jun 2022 13:23:50 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id d4-20020a62f804000000b00518764d09cdsm7989625pfh.164.2022.06.14.13.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 13:23:49 -0700 (PDT) Date: Tue, 14 Jun 2022 20:23:46 +0000 From: Sean Christopherson To: Chao Peng Cc: "Gupta, Pankaj" , Vishal Annapurve , 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 , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Yu Zhang , "Kirill A . Shutemov" , Andy Lutomirski , Jun Nakajima , dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com Subject: Re: [PATCH v6 3/8] mm/memfd: Introduce MFD_INACCESSIBLE flag Message-ID: References: <20220519153713.819591-1-chao.p.peng@linux.intel.com> <20220519153713.819591-4-chao.p.peng@linux.intel.com> <20220601101747.GA1255243@chaop.bj.intel.com> <1f1b17e8-a16d-c029-88e0-01f522cc077a@amd.com> <20220602100733.GA1296997@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220602100733.GA1296997@chaop.bj.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Thu, Jun 02, 2022, Chao Peng wrote: > On Wed, Jun 01, 2022 at 02:11:42PM +0200, Gupta, Pankaj wrote: > > > > > > > Introduce a new memfd_create() flag indicating the content of the > > > > > created memfd is inaccessible from userspace through ordinary MMU > > > > > access (e.g., read/write/mmap). However, the file content can be > > > > > accessed via a different mechanism (e.g. KVM MMU) indirectly. > > > > > > > > > > > > > SEV, TDX, pkvm and software-only VMs seem to have usecases to set up > > > > initial guest boot memory with the needed blobs. > > > > TDX already supports a KVM IOCTL to transfer contents to private > > > > memory using the TDX module but rest of the implementations will need > > > > to invent > > > > a way to do this. > > > > > > There are some discussions in https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.org%2Flkml%2F2022%2F5%2F9%2F1292&data=05%7C01%7Cpankaj.gupta%40amd.com%7Cb81ef334e2dd44c6143308da43b87d17%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637896756895977587%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oQbM2Hj7GlhJTwnTM%2FPnwsfJlmTL7JR9ULBysAqm6V8%3D&reserved=0 > > > already. I somehow agree with Sean. TDX is using an dedicated ioctl to > > > copy guest boot memory to private fd so the rest can do that similarly. > > > The concern is the performance (extra memcpy) but it's trivial since the > > > initial guest payload is usually optimized in size. > > > > > > > > > > > Is there a plan to support a common implementation for either allowing > > > > initial write access from userspace to private fd or adding a KVM > > > > IOCTL to transfer contents to such a file, > > > > as part of this series through future revisions? > > > > > > Indeed, adding pre-boot private memory populating on current design > > > isn't impossible, but there are still some opens, e.g. how to expose > > > private fd to userspace for access, pKVM and CC usages may have > > > different requirements. Before that's well-studied I would tend to not > > > add that and instead use an ioctl to copy. Whether we need a generic > > > ioctl or feature-specific ioctl, I don't have strong opinion here. > > > Current TDX uses a feature-specific ioctl so it's not covered in this > > > series. > > > > Common function or ioctl to populate preboot private memory actually makes > > sense. > > > > Sorry, did not follow much of TDX code yet, Is it possible to filter out > > the current TDX specific ioctl to common function so that it can be used by > > other technologies? > > TDX code is here: > https://patchwork.kernel.org/project/kvm/patch/70ed041fd47c1f7571aa259450b3f9244edda48d.1651774250.git.isaku.yamahata@intel.com/ > > AFAICS It might be possible to filter that out to a common function. But > would like to hear from Paolo/Sean for their opinion. Eh, I wouldn't put too much effort into creating a common helper, I would be very surprised if TDX and SNP can share a meaningful amount of code that isn't already shared, e.g. provided by MMU helpers. The only part I truly care about sharing is whatever ioctl(s) get added, i.e. I don't want to end up with two ioctls that do the same thing for TDX vs. SNP.