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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62F1C54EE9 for ; Tue, 13 Sep 2022 14:53:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ADF66B0071; Tue, 13 Sep 2022 10:53:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25CB06B0072; Tue, 13 Sep 2022 10:53:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FD0B8D0001; Tue, 13 Sep 2022 10:53:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F3E126B0071 for ; Tue, 13 Sep 2022 10:53:31 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C7DFDC01DB for ; Tue, 13 Sep 2022 14:53:31 +0000 (UTC) X-FDA: 79907355822.11.639EFDA Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf07.hostedemail.com (Postfix) with ESMTP id 7C55240089 for ; Tue, 13 Sep 2022 14:53:31 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id k21so1538057pls.11 for ; Tue, 13 Sep 2022 07:53:31 -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=W2dpld+9fBQIU85xhzMY4YGk1TSrPvuCpWZWn8z6i3DnZjgPuJoHI6ehbVYo5i/ASL UoGf+KsCxzZGyJ7AIc09KreuZ2oLulI962j5djFgAoeogdvKVNy2MNF0wgu8CvnJUIC0 o32+S9MZ2XFwzDt/ToPM6sEsX0nB0Qt/mNzAg/sG5iy9OpIqR9f4FKv6kH+9vjGV41pa d8GNoKdm0KeLE+jq4sjMGg9OLweUCS73nj+NIi9rJHYNK1ZWALjghtihhd9aFRHFmzlV hyY1uwYNRZCgNLq/4gMTellCWHs6UvzjN91MSHa8Wf6TdHv3n3g2PsxvggFVeFAp3ZUX X1+w== X-Gm-Message-State: ACgBeo1yeO5RetfgkBpuXOhf+MYDU8ZCzlSjIhJtVK30IQyg34E7itOZ zZfk3OxueMXAvIFmrQFjT4aIMw== X-Google-Smtp-Source: AA6agR4hCeLSjZthMuJfgYlKUGutRaZadKKJTFOH4uT+lOP/oa9jwO7wbAgJCVwL7oqP3EbrVwcGew== 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> ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nipjUGyo; spf=pass (imf07.hostedemail.com: domain of seanjc@google.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663080811; a=rsa-sha256; cv=none; b=fk6hO3Rfkx17pDWhPGLTb5/ppQCuhX5GHu+4sxFux8FNCh6kTb8XPeXqwtgAVHdF1CCGCq /B/Ykk1GK6jfQ+4BiJHL3Gvunbj3+ezayiDTz6rsB2EPZKbjoimL57Dzz5Rvz487lIyJ3B oE9F/3TFS2wkl5sBFJkFqyxNQfd8rMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663080811; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OJAIEjey9dL/oOlyHKJUty+rvUtRfrNcjV74l588HbE=; b=tmaeBlCmnGK0sL5kvUntWyHvbUYNeJvv0ZRAD0xsgsSN6khhE9Q1Jsm8aJMTpQ6pUkqjvF U7XJbR0sseBWIqNjirhfTVVeBQW3KALyrPSJIN/GcGo0TVezH3mqyuQEEH2x/YrSEyGYaX mewWQdM0VCsIU5o5ftFZePnS/MYDUHg= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nipjUGyo; spf=pass (imf07.hostedemail.com: domain of seanjc@google.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Queue-Id: 7C55240089 X-Rspamd-Server: rspam04 X-Stat-Signature: 6zqqtgco3fn19374f1b3s8ce5utkcnru X-HE-Tag: 1663080811-936457 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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!