Message ID | 20240726235234.228822-77-seanjc@google.com |
---|---|
State | New |
Headers | show
Return-Path: <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=A13dni5G; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=Yo11wXaR; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=dKLp4urT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WW5Cg1Jm9z20FH for <incoming@patchwork.ozlabs.org>; Sat, 27 Jul 2024 10:31:43 +1000 (AEST) 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:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4HF5bvwnaEF8Mo8TlEAryL7xZtbA35klaqVU+lKuyho=; b=A13dni5GMVbj0K 93/JcDlvkTc2LXpmhKiKpQEA7Bfs7qYiVqG6PPBXTsCXMO9+n4fgwGLxK2kp4m8e2k8DbK2b0+pf4 NX09s2UJzMzVItGY52jAy2w1ZFMyWSkeet/2YHC8cvoGI5PiPvTdP6c7072AF7ksPrdVJmI7HLLTR 0+L3NQw0+I9a4+UfJxm3GXC8BymmqUamlkKvWNYAfWeSpLRL/kuuP+ol/Va6261fhlUuy9GfvRrkQ UGb7lf0BQnM+NZDsycueJhQ4R7c5jF4bAFcoIAZJ7/q+wnzevcO5YybBFIAxLomlEAPIseAaqiMNl vFrZi1Pk16rggnDxBnVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVLZ-00000005jUO-3ZPO; Sat, 27 Jul 2024 00:31:41 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUmP-00000005RNi-0zqG for kvm-riscv@bombadil.infradead.org; Fri, 26 Jul 2024 23:55:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gSJgbeqW0EjFVjI/rvx0LQaQxVZn1dW4kzDKJHwZpGY=; b=Yo11wXaR2EPVxT8tETHSj7dvtj Bc/BJgWIL3PANsBz6EQqSVvyEoYOTiIS9TfeNYEtgQGsK3S2T85ARJL6o/jno8c1flogzt7pH5jOl MMd8mv7IDZcKIcu+9UV7dB7ZFmkcE+PIZBrGBYkMz5X6EgbqMh+aDavzJput8Ot1qaVk7oxFSQC5N HeFJ0I9xGsmGSr25DvjnUcFvF+J2OD5gJsUs8Rzb97Levmsvn6e1j4RkoyAC5/TTWGrpniT2mUNX6 L9RqBiSugKvDiW+9FmYyCbXucA8/NRun2jgQrvt6fQSHCcvJBhYJTapYAtmSZ/sN6kEG9oTJxV5rL 6eK0K2MA==; Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUmM-00000004K4M-0bqt for kvm-riscv@lists.infradead.org; Fri, 26 Jul 2024 23:55:20 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1fc5e61f0bbso13367885ad.1 for <kvm-riscv@lists.infradead.org>; Fri, 26 Jul 2024 16:55:17 -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=RWiWUmuoNsGrGUacPO2xy3FzDxX83uMlTrxLcvKfzVWlSSQfJSP7eDg2WsIDgqyRKZ 8BAnWMS9iKcawC0uLg4yNV40R8jqKJTvH1IC3GXAm2U+Gs2WJMEl11AuzAoAtyI/KVzM 5epwnZPGxda6/stOgzlCEbMGCYx8nkLPT9v81XQ50LFsBnwRzOVjvRtLIkoUCOM54Ztq buZJgG77APryZLKgAS8YpU4FCWiTByNne7aSiw5ZbmkpzxcPKjFGtT7mMEWKDssSAjjB k7/Ehn3bPa5wi4aC7NahqZ/KdrC2D0fI1UiJj16hNirwZS/nBhr9vJj7gkn/Ngsg0Wns oTLQ== X-Forwarded-Encrypted: i=1; AJvYcCULUEXqQbpD0RIAfKi6DX8G8lxwzKqq1bEd2u5CWkM7SnH0iZFU9hglfBQUvaHR3PNz9fhH+76eZZSlVGqgIqCVZWs3bsHdl0+tPasRyg== X-Gm-Message-State: AOJu0YzJlVzfXat1hl39zxxiOT5NYY8RYjPHh4FVaVgeGTqKXtzcW48R DgwcEQtHaFcl7Mc66A4gVeanavdZiUK7QmsBGXNF4JJFmBO6AebIU4S2H/Nknxb+ZbstdzPjnV0 w4g== 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240727_005518_367807_87CDB465 X-CRM114-Status: GOOD ( 11.38 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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(-) Content analysis details: (-7.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:64a listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <kvm-riscv.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/kvm-riscv>, <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/kvm-riscv/> List-Post: <mailto:kvm-riscv@lists.infradead.org> List-Help: <mailto:kvm-riscv-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/kvm-riscv>, <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe> Reply-To: Sean Christopherson <seanjc@google.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kvm-riscv" <kvm-riscv-bounces@lists.infradead.org> Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.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(-)