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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51126C3DA7F for ; Mon, 5 Aug 2024 07:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bCV7PuBhZnuU08yHLBxcNzah1OGymFqSjoymTM+R2OQ=; b=I/+CsP0k4loN71By+CpqbM44lp uOAhP0Pu3gwAYJkq8pT38tNI/3zJbFzM/gFVOcIWjw3KsWxUhmhLzgHKRU4BoibydGon91+M4JZn2 lZOTev2sd9JhkvymUpM6lsp6Iq8R9GWisArwvxXdWRoMCnAbWwkWflKWmI9zVK2XbW156OkBYaS/L 5j+xDCB9euxSxzZE6zHH6vR6s75Me2rOcz3WkeixXGtZ8cecHMgL7XZWMKS/kg8mQyRtjNNmaABzn U2X8iNmU6/RVIvLSv9MUEbup8ReWvOPpFEFXdl7cMUfb8jXAk9cu07OtoVSZ03OwHLk4wyGcbBtW/ z8WVPq6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sasbV-0000000F1mj-3tqp; Mon, 05 Aug 2024 07:58:05 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sasaz-0000000F1fa-2yPo; Mon, 05 Aug 2024 07:57:35 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 74B89CE0018; Mon, 5 Aug 2024 07:57:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59266C32782; Mon, 5 Aug 2024 07:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722844650; bh=Geket5xHj+rV/lTGgYhI+mobx7QxgrRmSJGYSEDRkpk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UBQwR8Dv5k7JtkeG4laWC2Xs0oOnozRLy+3hVYnDYQn2Ed5eCrDNKiqSjdoXT4acx 1hPdTL4JDstUhQJJ7lCM7YYqnV4Qh1m6C+CK460q8siGoQwJJKzkWsjMOX4qcfmelz A6Yt57Xlk92ABmDDhigDShW3vM0pnXKBZJdZWOrnwttmRyqlw3hP4oeUm/b5LanIcX fVlLRwpf9c9nuW6b7SobjiC6lu0VN8iuGUvVZHCooHxsAnFt7ePn4zwuEV1kg+BLX4 tQQRPbEFjC/HMt7oQ6FPHcOxgz1D3ofgxyEIT69W/KjqEASCYIB1LwhYcesfg0NZf1 asOwN60f4YLIQ== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , David Stevens Subject: Re: [PATCH v12 02/84] KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging In-Reply-To: References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Date: Mon, 05 Aug 2024 13:27:18 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_005734_126733_0913C9CB X-CRM114-Status: GOOD ( 18.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sean Christopherson writes: > On Thu, Aug 01, 2024, Aneesh Kumar K.V wrote: >> Sean Christopherson writes: >> >> > Disallow copying MTE tags to guest memory while KVM is dirty logging, as >> > writing guest memory without marking the gfn as dirty in the memslot could >> > result in userspace failing to migrate the updated page. Ideally (maybe?), >> > KVM would simply mark the gfn as dirty, but there is no vCPU to work with, >> > and presumably the only use case for copy MTE tags _to_ the guest is when >> > restoring state on the target. >> > >> > Fixes: f0376edb1ddc ("KVM: arm64: Add ioctl to fetch/store tags in a guest") >> > Signed-off-by: Sean Christopherson >> > --- >> > arch/arm64/kvm/guest.c | 5 +++++ >> > 1 file changed, 5 insertions(+) >> > >> > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c >> > index e1f0ff08836a..962f985977c2 100644 >> > --- a/arch/arm64/kvm/guest.c >> > +++ b/arch/arm64/kvm/guest.c >> > @@ -1045,6 +1045,11 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, >> > >> > mutex_lock(&kvm->slots_lock); >> > >> > + if (write && atomic_read(&kvm->nr_memslots_dirty_logging)) { >> > + ret = -EBUSY; >> > + goto out; >> > + } >> > + >> > >> >> is this equivalent to kvm_follow_pfn() with kfp->pin = 1 ? > > No, gfn_to_pfn_prot() == FOLL_GET, kfp->pin == FOLL_PIN. But that's not really > relevant. > What I meant was, should we consider mte_copy_tags_from_user() as one that update the page contents (even though it is updating tags) and use kvm_follow_pfn() with kfp->pin = 1 instead? Is my understanding correct in that, if we want to look up a pfn/page from gfn with the intent of updating the page contents, we should use kfp->pin == 1? -aneesh