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 BC3D5C3DA7F for ; Mon, 5 Aug 2024 22:10:12 +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:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: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=C2PiU8MTrEuvmn4oJRZEcNoPreaY/lLc5L+V0JuLroE=; b=ognvuQk+H4b9ilWHVG0WDoPTB3 GcVE6QXI2jywsAqdRowtVzkJp5++TC8+XaUycgdonqQJvIwzXg6GV+WCPs3Bf+gw2o9669gXB+ept CJFjYHfCthFJdqm+Jhe1xGGu/OKSK31quY9TK2ONa4GPqUG3QTJtHrjHJK4bdf0DMTTutfXQFKvJd RxYBQblaBbO6VuzN2Vr71sRG4ZnqHIbWortGe4CcQwUYEwuUBxr/sYJm1px1zdHUhSW93ZbT0Gr3p GL2bG8WxJGs1WqW5WA4kn0UurLhYkyWbYxC4jflJZwIfGW71U22cdmgyx8PsdlSNuzrBYX+VqYK+0 4D3Q9XzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb5tu-0000000HQHU-1B2z; Mon, 05 Aug 2024 22:09:58 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb5tM-0000000HQ7U-2agD for linux-arm-kernel@lists.infradead.org; Mon, 05 Aug 2024 22:09:26 +0000 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-70d1c8d98baso10003215b3a.3 for ; Mon, 05 Aug 2024 15:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722895763; x=1723500563; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=C2PiU8MTrEuvmn4oJRZEcNoPreaY/lLc5L+V0JuLroE=; b=115nYEdRclej89a+1jgGo7pRGhtbQQfLhl/xoyMti8o6mzKAOYsl+70srkjAaT1ZTc 8yE1m2vdHqta1EDgYa2f69T9nG+S7WuXj9ZxPPRF9RrXxygTG2u7Wzk61CEP2ZURP41K TvkBkU+EYLga5Dkod9iRNw+udFADUOSojnD+u+/m3FAldXSpdyp2p05v9DVrYzHlZVid wI67tInY/EENIR1OLNBGdVI99xuj4lekCEhaeDMfRO9pqB5j5b7SU//iBtTC9gBbB2BZ YOLbJ5yG0gvMJuCitbLd8zSez2kh6O71y2N1f9+NVQE8eYIhVJKF4L1ZqcUH/KGH/YKu IEnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722895763; x=1723500563; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C2PiU8MTrEuvmn4oJRZEcNoPreaY/lLc5L+V0JuLroE=; b=xLppgqif4ji8asmUJ1NlVe2jiykRN40Qg5emmuYJDj50m4/QVJ/I0A1A/yB0dcoE/M KOFiwMDoBeFS4g1FSs2D0RDKErkVimH8P/S4RNTTFGketNgRS4OwjpilEmUD1VM0ilLu Rh1IsyQj/qlv0j04lDLFOT9XeKXK6721xyPprrb0f6T1xfHxkueuiwh6nCrhqY3YPkXz eU8ArK8Vq8e442z5DRnIAPtmPqysJsY2MpOfakajScTlXobM2C+f+QJ3xC8mhqbmexRx O5V3TbjnfNMvgUBFFwIlSKFrdqnVi2DquYJWvqSRr9caaRdoXzVYMcGhC3QP6vKJjGnL r+iQ== X-Forwarded-Encrypted: i=1; AJvYcCX+1Oozqci5+Epi4VDu16w/6koDJ373FBm/CJBZbbXqKdGCeCe0bs7pq7uTwoMhRQ5Uxaj6Y4QPzOl0sYC4KIbxqKaZ1z/TyiiRVrzkOVLjE1aUBdg= X-Gm-Message-State: AOJu0YyjJM99wsMalEpa+Ggiao+c5IR8T84Wt7SeZJF4Vokoz+Qng8yz eRhNgoo2bz9Wt7DP31x/x/4IV7RHVqt3OG/dSDn680QF1k6BsAia9IMUcUN2rpHcl/kjZMBBDzM cZw== X-Google-Smtp-Source: AGHT+IFHGqnQ2aZELEsNF/YUFUu/OdaSqANvJ2o5+KNT08fnEczrxRkzi5g08NacDnyiiIzp3YSr6oxKzK4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:6f0e:b0:710:4d08:e41f with SMTP id d2e1a72fcca58-7106d08296emr87588b3a.4.1722895762937; Mon, 05 Aug 2024 15:09:22 -0700 (PDT) Date: Mon, 5 Aug 2024 15:09:21 -0700 In-Reply-To: Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH v12 02/84] KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging From: Sean Christopherson To: "Aneesh Kumar K.V" 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 Content-Type: text/plain; charset="us-ascii" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_150924_704429_53B312C2 X-CRM114-Status: GOOD ( 24.16 ) 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 On Mon, Aug 05, 2024, Aneesh Kumar K.V wrote: > 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? Yes, that's my understanding as well. However, this series is already ludicruosly long, and I don't have the ability to test the affected code, so rather than blindly churn more arch code, I opted to add a FIXME in patch 76 instead. https://lore.kernel.org/all/20240726235234.228822-76-seanjc@google.com