From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aneesh Kumar K.V Date: Thu, 01 Aug 2024 13:04:43 +0530 Subject: [PATCH v12 02/84] KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging In-Reply-To: <20240726235234.228822-3-seanjc@google.com> References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ? Should all those pin request fail if kvm->nr_memslots_dirty_logging != 0? > while (length > 0) { > kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); > void *maddr; > -- > 2.46.0.rc1.232.g9752f9e123-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D62E49626; Thu, 1 Aug 2024 07:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722497697; cv=none; b=C0LKgxEEixIvmvrz2Z71vPPn+rE7jB9LdR4DycUbwMvTH06/gu4HiRrcpjk3UmRiYz+Et59qLPerbK/FMgxrX3o8xuc+wbh71TJdCmSMxItWN+D3HxDT67sIfOwtr7+fYM9C0O/OSY2wLnZ5pU2VA4NGbSFTlL1RirBNwXMYR8Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722497697; c=relaxed/simple; bh=4fAL4cODCnjl0NV8qGw/Qqudnit/5hoHCsZrciMhbUs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=k5YpY4R0L2a3dtzCWqRnB773xA7F7htuHc5vID+7jZnEq6MkxZW+qSQzIdy50YMa4wXUnOP0Qd83IqLfYQwedCPAuQxxrx0/dAeA0CrSriyf1l8EywNnJAEh9BsXuqVJHS70NhnTqxbL1krEWKk+U1xrX6aY0+w7OG2FeyKEoSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hm6lqGrn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hm6lqGrn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C540CC4AF0A; Thu, 1 Aug 2024 07:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722497697; bh=4fAL4cODCnjl0NV8qGw/Qqudnit/5hoHCsZrciMhbUs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=hm6lqGrnGLdGUt29ZxrQ9cGwGC5e/My8adr9xG8pGwOWvxzaIy2wVVZecHcsaS7MD 2vhxDp5qw6P6jWSVDdYpSlndt26lYMY/9L3hrdQVP6XL1jiOwA3de3PchwMF07I1N4 2YEHskiwTzLI1+iwXeDgxTjbuc9HN0GjQyrYNiG+t6NhVrrxrlXYCf8VJMbSS/9yNs oHiP/3JEHHEyg0SbxiUkt+heXZ9wY3Uvo6jOHCc4TGv31tTJIER/7SKgCRJbrwGHtk ninurOs1MqcQM+fogPcJEhZWkju/RfarTKElxrf4Eq/YQ9RcoW3WZjBJcrAerVNRjv rukvhfzurLf/A== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Sean Christopherson , 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 , Sean Christopherson Cc: 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: <20240726235234.228822-3-seanjc@google.com> References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Date: Thu, 01 Aug 2024 13:04:43 +0530 Message-ID: Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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 ? Should all those pin request fail if kvm->nr_memslots_dirty_logging != 0? > while (length > 0) { > kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); > void *maddr; > -- > 2.46.0.rc1.232.g9752f9e123-goog 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 03739C3DA4A for ; Thu, 1 Aug 2024 07:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9LtEkDomjNu3rCcGbYz/VY06tJp5iGd/eGIL4IQws34=; b=v17s9r5zAmh0Yo BRUCNqKjcUKreK64VAmHt6AEcEm1tofPXjMwb4rTtLgTa50IDpXK1nWN9ykA4jfRZOMIqgyopYDR0 0k1B8G/HaGq0iGoqqfLtQUin1nlGxjn2udx5SA3fZXNoJYJuvww2GBc5Opfex5GovbOrK118XEs4K LSl0HBiatx1SP7o4P/O09X084M08vLGTOM3/tYDqCy+BeCiSK632NJVde3tm3bUENKHPt2zexxY5R 4ZWbXPLkVhsTGsNU9MfJVNnZDHrFxkEg2ffvr/Vm1pW2WG6eD2UM/7sxDR9ilaFgNmW/hlgbbHUDA rU41QN/3qEKl0ohkQTSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZQLS-00000004Blu-0HDE; Thu, 01 Aug 2024 07:35:30 +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 1sZQKx-00000004Bdh-3gKM; Thu, 01 Aug 2024 07:35:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B8D90CE11E0; Thu, 1 Aug 2024 07:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C540CC4AF0A; Thu, 1 Aug 2024 07:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722497697; bh=4fAL4cODCnjl0NV8qGw/Qqudnit/5hoHCsZrciMhbUs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=hm6lqGrnGLdGUt29ZxrQ9cGwGC5e/My8adr9xG8pGwOWvxzaIy2wVVZecHcsaS7MD 2vhxDp5qw6P6jWSVDdYpSlndt26lYMY/9L3hrdQVP6XL1jiOwA3de3PchwMF07I1N4 2YEHskiwTzLI1+iwXeDgxTjbuc9HN0GjQyrYNiG+t6NhVrrxrlXYCf8VJMbSS/9yNs oHiP/3JEHHEyg0SbxiUkt+heXZ9wY3Uvo6jOHCc4TGv31tTJIER/7SKgCRJbrwGHtk ninurOs1MqcQM+fogPcJEhZWkju/RfarTKElxrf4Eq/YQ9RcoW3WZjBJcrAerVNRjv rukvhfzurLf/A== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Sean Christopherson , 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 , Sean Christopherson Cc: 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: <20240726235234.228822-3-seanjc@google.com> References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Date: Thu, 01 Aug 2024 13:04:43 +0530 Message-ID: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240801_003500_118881_9CA7D5F5 X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 ? Should all those pin request fail if kvm->nr_memslots_dirty_logging != 0? > while (length > 0) { > kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); > void *maddr; > -- > 2.46.0.rc1.232.g9752f9e123-goog _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 6DCA5C3DA4A for ; Thu, 1 Aug 2024 07:35:41 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hm6lqGrn; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WZLNX0ZtMz3dFH for ; Thu, 1 Aug 2024 17:35:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hm6lqGrn; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=aneesh.kumar@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WZLMn0tL6z30T1 for ; Thu, 1 Aug 2024 17:35:01 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B8D90CE11E0; Thu, 1 Aug 2024 07:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C540CC4AF0A; Thu, 1 Aug 2024 07:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722497697; bh=4fAL4cODCnjl0NV8qGw/Qqudnit/5hoHCsZrciMhbUs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=hm6lqGrnGLdGUt29ZxrQ9cGwGC5e/My8adr9xG8pGwOWvxzaIy2wVVZecHcsaS7MD 2vhxDp5qw6P6jWSVDdYpSlndt26lYMY/9L3hrdQVP6XL1jiOwA3de3PchwMF07I1N4 2YEHskiwTzLI1+iwXeDgxTjbuc9HN0GjQyrYNiG+t6NhVrrxrlXYCf8VJMbSS/9yNs oHiP/3JEHHEyg0SbxiUkt+heXZ9wY3Uvo6jOHCc4TGv31tTJIER/7SKgCRJbrwGHtk ninurOs1MqcQM+fogPcJEhZWkju/RfarTKElxrf4Eq/YQ9RcoW3WZjBJcrAerVNRjv rukvhfzurLf/A== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Sean Christopherson , 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 , Sean Christopherson Subject: Re: [PATCH v12 02/84] KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging In-Reply-To: <20240726235234.228822-3-seanjc@google.com> References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-3-seanjc@google.com> Date: Thu, 01 Aug 2024 13:04:43 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , David Stevens , loongarch@lists.linux.dev, kvmarm@lists.linux.dev, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 ? Should all those pin request fail if kvm->nr_memslots_dirty_logging != 0? > while (length > 0) { > kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); > void *maddr; > -- > 2.46.0.rc1.232.g9752f9e123-goog