Skip to content

Commit 31fccdd

Browse files
sean-jcbonzini
authored andcommitted
KVM: Make kvm_follow_pfn.refcounted_page a required field
Now that the legacy gfn_to_pfn() APIs are gone, and all callers of hva_to_pfn() pass in a refcounted_page pointer, make it a required field to ensure all future usage in KVM plays nice. 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 d0ef8d9 commit 31fccdd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

virt/kvm/kvm_main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,8 +2834,7 @@ static kvm_pfn_t kvm_resolve_pfn(struct kvm_follow_pfn *kfp, struct page *page,
28342834
pfn = page_to_pfn(page);
28352835
}
28362836

2837-
if (kfp->refcounted_page)
2838-
*kfp->refcounted_page = page;
2837+
*kfp->refcounted_page = page;
28392838

28402839
return pfn;
28412840
}
@@ -2986,6 +2985,9 @@ kvm_pfn_t hva_to_pfn(struct kvm_follow_pfn *kfp)
29862985

29872986
might_sleep();
29882987

2988+
if (WARN_ON_ONCE(!kfp->refcounted_page))
2989+
return KVM_PFN_ERR_FAULT;
2990+
29892991
if (hva_to_pfn_fast(kfp, &pfn))
29902992
return pfn;
29912993

0 commit comments

Comments
 (0)