Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6818267rwn; Tue, 13 Sep 2022 09:22:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mitoioIHbnSochYOsW7itK8v53uNhF1IjWPaU3y6NLef0nuyUDbpznRIqjMAU2t5H4U6O X-Received: by 2002:a05:6a00:2402:b0:52c:81cf:8df2 with SMTP id z2-20020a056a00240200b0052c81cf8df2mr33160461pfh.40.1663086148956; Tue, 13 Sep 2022 09:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086148; cv=none; d=google.com; s=arc-20160816; b=kflSLlY5wALMt15Oa2P1rlG0uHKkk53mjJrugRMkox5jNA9XuH8I0c2sCqNRN6+pkP r2FMDYhfkmKmuXJ0UAU1+6B9bmQE4OIftnq1ko/8f+PQV7UVgzjMTgMVHW4+cE4/rygm mxLLjABV8RU+SAVZkP/DbleEL+8N52Y7NLN603dvcTyVFP7vLjCxGQr+ufFfcrxhaSo4 uVkmLniJT100G23EeDStgdaP/eFTZK9vWZ6Z/0M27u2b0CLYMJcXnhKIWaUUhKF2Syqf YEjRidHOWFIThGIdJhgZZ+zFpBKndVLa5A5J8NJzTHTsAjjkBX7oOO42DB/VPrmOM2NJ 3dNA== 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=OJAIEjey9dL/oOlyHKJUty+rvUtRfrNcjV74l588HbE=; b=XgR8byMxWShtSCRHThp3mh+QthfNtqoFs50bEMS21eoaxznHA8isO/VTJG4gM4H3gk WJM3sdfdPPK4V2Vtf0pWLNMg3WAO/CdvVw0MRavcKu2FEBfldKgHgMa5lMmtBnPLg3me 0DZsECu7krfjrEtmkb+KjPRL1rPl0fu21GDCJYr0ksLIpCocXn8A2+CM+mLwcn+Dny0i YCknpP74iB8l6vTy2UiPVVSlDe3d3OBsfC0Pb2SuqlHbAbt2avEFZmhZqBvSB50nUFdH oPuf/QRmLiBhlwLyUPQT3RMHe7pfiSdbQkPzOP38x02EPHsYFGnUgTJFNTbCgZOd63J/ B8eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nipjUGyo; 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 f27-20020a63511b000000b0042b4defce13si11850472pgb.344.2022.09.13.09.22.15; Tue, 13 Sep 2022 09:22:28 -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=nipjUGyo; 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 S230411AbiIMQIp (ORCPT + 99 others); Tue, 13 Sep 2022 12:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbiIMQIP (ORCPT ); Tue, 13 Sep 2022 12:08:15 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EFBF41 for ; Tue, 13 Sep 2022 08:04:28 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id d64-20020a17090a6f4600b00202ce056566so6497448pjk.4 for ; Tue, 13 Sep 2022 08:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=OJAIEjey9dL/oOlyHKJUty+rvUtRfrNcjV74l588HbE=; b=nipjUGyopyRbnweevoI2Oq+FbDhrGlaD7wKP+k5xapkMVsoGweAQ6K2hQ8AZ+n3N71 J85U0qDe2D5AD8d1gpjf++nTpiIkyTFzNlFk+YTPVFtJCYSH/SE9jP8KJtPu7wQ0hfi5 wYDpgxyUrRwd1sYa/NGSuu4VudYk3GqiPthKN+bOi/ckST3RiIggvPeGp3bhm5p8ypVT 3f+MwrbGT4h/7a0VEnXrxvfZQW0KEOYcQaivu+1/UqQdLAEGFiH+0RbJHMUiEdIZPPCt MhVMuPS1IGUUE+HBMjXHJM9fAUIO8mG1oaSP0/UpGjTZuC/UI7ZeIyP4hCCX4seU5+Tv A0Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=OJAIEjey9dL/oOlyHKJUty+rvUtRfrNcjV74l588HbE=; b=XZka5ZZRREgucJwxqOnBA9TDJhIZm3TkBQcYT70pfJpiARJ7RLIcTOkwosajj6HqMH eQod6kDGMIWOzjFJbSKYxbmJsxoMU3wBj9Mg21oC/hbWmQ3dzWz/UmVImHvC6lB1qxPc ln4hgkAwntI7MdMN4OfkQ0Fflq2SzMoJSu9o4XqHf8m48FMWZk9MmKEwYaiwyRCSekkg xcTRcN7sBUM2o85+qY2w2Cwof0amSjHi9CVAGn3itFbcaxUu6H6uIlftc0wABdjov71r NdXuV3zbDQaBCOQ6ST8/FutqgaUh9XZ3qf9aEX3PjOIlGbfg7e9H6hwtfbzU1phdXi7a oBPg== X-Gm-Message-State: ACgBeo0C0pM66x7kzqWBUbgZn+qwYYqmIsn7AS4iot7AsjcDSbg7G9av lOijqsNPLIj/LDuxRoara2qaFR3JMGMJTA== X-Received: by 2002:a17:902:c7cc:b0:176:9fdd:ddb7 with SMTP id r12-20020a170902c7cc00b001769fddddb7mr32324812pla.150.1663080810301; Tue, 13 Sep 2022 07:53:30 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id k5-20020aa79985000000b00535d3caa66fsm7855085pfh.197.2022.09.13.07.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 07:53:29 -0700 (PDT) Date: Tue, 13 Sep 2022 14:53:25 +0000 From: Sean Christopherson To: "Kirill A. Shutemov" Cc: "Kirill A . Shutemov" , Hugh Dickins , Chao Peng , 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, linux-kselftest@vger.kernel.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" , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , 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 , Michael Roth , mhocko@suse.com, Muchun Song , "Gupta, Pankaj" , Elena Reshetova Subject: Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220818132421.6xmjqduempmxnnu2@box> <20220820002700.6yflrxklmpsavdzi@box.shutemov.name> <20220831142439.65q2gi4g2d2z4ofh@box.shutemov.name> <20220908011037.ez2cdorthqxkerwk@box.shutemov.name> <20220913132821.3ch5cv3rgdxqgz3i@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220913132821.3ch5cv3rgdxqgz3i@box.shutemov.name> 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 Tue, Sep 13, 2022, Kirill A. Shutemov wrote: > On Tue, Sep 13, 2022 at 09:44:27AM +0000, Sean Christopherson wrote: > > On Thu, Sep 08, 2022, Kirill A. Shutemov wrote: > > > On Wed, Aug 31, 2022 at 05:24:39PM +0300, Kirill A . Shutemov wrote: > > > > On Sat, Aug 20, 2022 at 10:15:32PM -0700, Hugh Dickins wrote: > > > > > > I will try next week to rework it as shim to top of shmem. Does it work > > > > > > for you? > > > > > > > > > > Yes, please do, thanks. It's a compromise between us: the initial TDX > > > > > case has no justification to use shmem at all, but doing it that way > > > > > will help you with some of the infrastructure, and will probably be > > > > > easiest for KVM to extend to other more relaxed fd cases later. > > > > > > > > Okay, below is my take on the shim approach. > > > > > > > > I don't hate how it turned out. It is easier to understand without > > > > callback exchange thing. > > > > > > > > The only caveat is I had to introduce external lock to protect against > > > > race between lookup and truncate. > > > > As before, I think this lock is unnecessary. Or at least it's unnessary to hold > > the lock across get/put. The ->invalidate() call will ensure that the pfn is > > never actually used if get() races with truncation. > > The updated version you replying to does not use the lock to protect > against truncation anymore. The lock protect notifier list. Gah, grabbed the patch when applying. > > Switching topics, what actually prevents mmapp() on the shim? I tried to follow, > > but I don't know these areas well enough. > > It has no f_op->mmap, so mmap() will fail with -ENODEV. See do_mmap(). > (I did not read the switch statement correctly at first. Note there are > two 'fallthrough' there.) Ah, validate_mmap_request(). Thought not implementing ->mmap() was the key, but couldn't find the actual check. Thanks much!