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 235ECC3DA7F for ; Wed, 7 Aug 2024 14:16:20 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j4PgdtYlqWi1OKz9MHC8VuxLiUg7JvBnGcJXBZuMJHY=; b=sWJmmatP4tjy1V oLSxIXrQtma6sIpIYVTlM4vySAizZXxKv/AILkeJ31dpgU1W1ZH3We219dDSdyUkBbHAsA+AuBKTA En5zjvitf2o5M/PuFPoxaO37fVscZK/YXUddriMt7xk9b6pZzPP+nCajINFyq90+YXlQW5P8amQOu inyNSOghojkejexbzKqln/XFu3wVzaF1UnXmC+Fpt7vPYcpKcgJOoDaopbT8Ca9noV24XztyiJ2pg MrALnvAyRI1Kk7gjjGOPgSYcK+pKLK2FWs/ejn7D9fhpmbmMOgX+92S+Nv6adpN6xzjGDwkTToN6k atx7Y30qOSgiawVjBl8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbhSb-00000005IQd-0dlO; Wed, 07 Aug 2024 14:16:17 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbhRz-00000005IDI-36M6; Wed, 07 Aug 2024 14:15:41 +0000 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 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 , Steven Price 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-Disposition: inline In-Reply-To: <20240726235234.228822-2-seanjc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240807_071539_913510_110057EB X-CRM114-Status: GOOD ( 14.00 ) 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 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv