Skip to content

Commit 570d666

Browse files
sean-jcbonzini
authored andcommitted
KVM: arm64: Use __gfn_to_page() when copying MTE tags to/from userspace
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. Tested-by: Alex Bennée <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Tested-by: Dmitry Osipenko <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-ID: <[email protected]>
1 parent f42e289 commit 570d666

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

arch/arm64/kvm/guest.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,20 +1051,18 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
10511051
}
10521052

10531053
while (length > 0) {
1054-
kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL);
1054+
struct page *page = __gfn_to_page(kvm, gfn, write);
10551055
void *maddr;
10561056
unsigned long num_tags;
1057-
struct page *page;
10581057

1059-
if (is_error_noslot_pfn(pfn)) {
1058+
if (!page) {
10601059
ret = -EFAULT;
10611060
goto out;
10621061
}
10631062

1064-
page = pfn_to_online_page(pfn);
1065-
if (!page) {
1063+
if (!pfn_to_online_page(page_to_pfn(page))) {
10661064
/* Reject ZONE_DEVICE memory */
1067-
kvm_release_pfn_clean(pfn);
1065+
kvm_release_page_unused(page);
10681066
ret = -EFAULT;
10691067
goto out;
10701068
}
@@ -1078,7 +1076,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
10781076
/* No tags in memory, so write zeros */
10791077
num_tags = MTE_GRANULES_PER_PAGE -
10801078
clear_user(tags, MTE_GRANULES_PER_PAGE);
1081-
kvm_release_pfn_clean(pfn);
1079+
kvm_release_page_clean(page);
10821080
} else {
10831081
/*
10841082
* Only locking to serialise with a concurrent
@@ -1093,8 +1091,7 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
10931091
if (num_tags != MTE_GRANULES_PER_PAGE)
10941092
mte_clear_page_tags(maddr);
10951093
set_page_mte_tagged(page);
1096-
1097-
kvm_release_pfn_dirty(pfn);
1094+
kvm_release_page_dirty(page);
10981095
}
10991096

11001097
if (num_tags != MTE_GRANULES_PER_PAGE) {

0 commit comments

Comments
 (0)