Message ID | 20240726235234.228822-77-seanjc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 C3D20C3DA49 for <linux-arm-kernel@archiver.kernel.org>; Sat, 27 Jul 2024 00:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To: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: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gSJgbeqW0EjFVjI/rvx0LQaQxVZn1dW4kzDKJHwZpGY=; b=L9W3MqxqtoHtHduUkI/hs269AU xWZUvWtUI8gb3Aqr+ePBe7qI+TwteeGFygbKahwKhJ0KfgNp2SqQnUf9M9JjWd7USeDNhddvbW7sS rAr2iZTUiKp99ZGdtvciDWdpEJr7zvDRXLy12kQzPZazSd/VDsfW770J6QKh7GWTaD+y2CP6RGUib hTyJdHe+s5Zr77BhJ/0oq6IpSFmcMBG6n44tpI+PmGULLxuURjpTxhD+DuG8Aq2q2BgEMSTAfF98W IRYhvLzzJpAJ0YyGlglGsjCN64Wv9vHOJk4l8wgXqdEjKKQHu9/dAn+znMcVZ24NhR5c56R7PExAb jQ1imr2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVOR-00000005knS-3bgI; Sat, 27 Jul 2024 00:34:39 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUmL-00000005RKI-0OKt for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:55:21 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1fc5e61f0bbso13367865ad.1 for <linux-arm-kernel@lists.infradead.org>; Fri, 26 Jul 2024 16:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038116; x=1722642916; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=gSJgbeqW0EjFVjI/rvx0LQaQxVZn1dW4kzDKJHwZpGY=; b=dKLp4urTYxrMqWnh5jJzqr/fuqAAiRZmLGEYFfqMSjamPxxYI/rYGNYvxyFrPOfisz AFBinzC0qq1IayWZHdNsSTTRlU47sfBlyOb65kgFIAAAUR0dF+6ZjQHJZO4hbcEa7vdE It0VKyTq2bCDLg8Qj/LjbQyx/G9rcUHA2ZDOLP1GhivjReHm734NvWYNT/J4WKLBHCok 1xaPTSvMEDkHqOfC5FxlXcTPlzjfhKCwxeQJ/KvcPQrO1i+Xc2QSUt0nvkdqp+qkQNHl ytEUxKgq6APH6ehph8mxslmoJn4srt8DHQ3NejdesJriaNo/nKumleAAlQSLkbTRZLqF WsrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038116; x=1722642916; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gSJgbeqW0EjFVjI/rvx0LQaQxVZn1dW4kzDKJHwZpGY=; b=iRo1nCOwJDVsfdLzbpdcMiS0F2++n3ekPrNml5mzdDDmBEhZPiLXdhvrI+F5inPsJD 1CmJudBoVUeu20ayCC6qyB5UJ0C2c31WYOuAN5A18MGsRsXwbAz+ekvLkOS05dqRS9Lt NYIjYTJ1ROJ/PkEEYz2SEy0yLoM9ImoU+Y74P+k6hQQHmduItYWlXMuO1ohCq+rfnbJh awzsEMC4gaRbU2Q2acQi0Sy2dIizcq3HHkyly57BgYMD7zOLyXk9X6lOI9qF5GFcrnPv K9pqjWzBk4pcTup9djBII5v/dy90Blo5vDcBhM33NY8no8UZhpQD4GkhQJxu9hDp+qJH iVcQ== X-Forwarded-Encrypted: i=1; AJvYcCVGFpveQB7cKo5VkyYOtsZmiVA1ruSbs+IvJ7k9qxwaP+9fyM8I/pBFSdaKqJDLK7OC6bPOYymewzVcgpXYUbyqpohd2eyvvxKxaod7NRzKL9+LczM= X-Gm-Message-State: AOJu0YyMSgUUoPzdsfAAGE+wcjpaElnK3zQR9EuDHBKF/Se8atpmHUxa JmpW+WXHi8HWTHebZURYL11ABMT0cPyVyMAfXnr/rNLiGhWfF3/arPss10Q/eO7AXvTA6IReTHY uiw== X-Google-Smtp-Source: AGHT+IHxrkKUWCeUEpiaW8aWqxkJkE+eVd4nhH8cGKa9NS3y3LrlRDBQyz/B78NptpquvhhjWf0asoH4ivY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c945:b0:1fc:733d:8465 with SMTP id d9443c01a7336-1ff0488cadamr599925ad.8.1722038115596; Fri, 26 Jul 2024 16:55:15 -0700 (PDT) Date: Fri, 26 Jul 2024 16:52:25 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240726235234.228822-77-seanjc@google.com> Subject: [PATCH v12 76/84] KVM: arm64: Use __gfn_to_page() when copying MTE tags to/from userspace From: Sean Christopherson <seanjc@google.com> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, Tianrui Zhao <zhaotianrui@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Michael Ellerman <mpe@ellerman.id.au>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Sean Christopherson <seanjc@google.com> 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 <dmatlack@google.com>, David Stevens <stevensd@chromium.org> Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_165517_382840_AC016A03 X-CRM114-Status: GOOD ( 12.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Reply-To: Sean Christopherson <seanjc@google.com> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: Stop grabbing references to PFNMAP'd pages
|
expand
|
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 962f985977c2..4cd7ffa76794 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -1051,20 +1051,18 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, } while (length > 0) { - kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); + struct page *page = __gfn_to_page(kvm, gfn, write); void *maddr; unsigned long num_tags; - struct page *page; - if (is_error_noslot_pfn(pfn)) { - ret = -EFAULT; - goto out; - } - - page = pfn_to_online_page(pfn); if (!page) { + ret = -EFAULT; + goto out; + } + + if (!pfn_to_online_page(page_to_pfn(page))) { /* Reject ZONE_DEVICE memory */ - kvm_release_pfn_clean(pfn); + kvm_release_page_unused(page); ret = -EFAULT; goto out; } @@ -1078,7 +1076,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, /* No tags in memory, so write zeros */ num_tags = MTE_GRANULES_PER_PAGE - clear_user(tags, MTE_GRANULES_PER_PAGE); - kvm_release_pfn_clean(pfn); + kvm_release_page_clean(page); } else { /* * Only locking to serialise with a concurrent @@ -1093,8 +1091,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, if (num_tags != MTE_GRANULES_PER_PAGE) mte_clear_page_tags(maddr); set_page_mte_tagged(page); - - kvm_release_pfn_dirty(pfn); + kvm_release_page_dirty(page); } if (num_tags != MTE_GRANULES_PER_PAGE) {
Use __gfn_to_page() instead when copying MTE tags between guest and userspace. This will eventually allow removing gfn_to_pfn_prot(), gfn_to_pfn(), kvm_pfn_to_refcounted_page(), and related APIs. Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/arm64/kvm/guest.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)