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 435D8C52D71 for ; Wed, 7 Aug 2024 14:16:38 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WfC0N5YHxz3dX5 for ; Thu, 8 Aug 2024 00:16:36 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4641:c500::1; helo=dfw.source.kernel.org; envelope-from=cmarinas@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (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 4WfBzx6ZHJz2y8r for ; Thu, 8 Aug 2024 00:16:13 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E687E612CC; Wed, 7 Aug 2024 14:15:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3C09C4AF0B; Wed, 7 Aug 2024 14:15:33 +0000 (UTC) Date: Wed, 7 Aug 2024 15:15:31 +0100 From: Catalin Marinas To: Sean Christopherson Subject: Re: [PATCH v12 01/84] KVM: arm64: Release pfn, i.e. put page, if copying MTE tags hits ZONE_DEVICE Message-ID: References: <20240726235234.228822-1-seanjc@google.com> <20240726235234.228822-2-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240726235234.228822-2-seanjc@google.com> 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@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , linux-riscv@lists.infradead.org, Claudio Imbrenda , Janosch Frank , Marc Zyngier , Huacai Chen , Steven Price , Christian Borntraeger , Albert Ou , Bibo Mao , loongarch@lists.linux.dev, Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, Oliver Upton , Palmer Dabbelt , David Stevens , kvm-riscv@lists.infradead.org, Anup Patel , Paolo Bonzini , Tianrui Zhao , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Jul 26, 2024 at 04:51:10PM -0700, Sean Christopherson wrote: > Put the page reference acquired by gfn_to_pfn_prot() if > kvm_vm_ioctl_mte_copy_tags() runs into ZONE_DEVICE memory. KVM's less- > than-stellar heuristics for dealing with pfn-mapped memory means that KVM > can get a page reference to ZONE_DEVICE memory. > > Fixes: f0376edb1ddc ("KVM: arm64: Add ioctl to fetch/store tags in a guest") > Signed-off-by: Sean Christopherson > --- > arch/arm64/kvm/guest.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 11098eb7eb44..e1f0ff08836a 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -1059,6 +1059,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, > page = pfn_to_online_page(pfn); > if (!page) { > /* Reject ZONE_DEVICE memory */ > + kvm_release_pfn_clean(pfn); > ret = -EFAULT; > goto out; > } This patch makes sense irrespective of whether the above pfn is a ZONE_DEVICE or not. gfn_to_pfn_prot() increased the page refcount via GUP, so it must be released before bailing out of this loop. Reviewed-by: Catalin Marinas