From: Heiko Carstens Date: Wed, 1 Jan 2014 15:09:21 +0000 (+0100) Subject: KVM: add kvm_is_error_gpa() helper X-Git-Tag: firefly_0821_release~3680^2~36^2~16^2^2~131 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9b937709747526fc1fcac118d605705f78424d3c;p=firefly-linux-kernel-4.4.55.git KVM: add kvm_is_error_gpa() helper It's quite common (in the s390 guest access code) to test if a guest physical address points to a valid guest memory area or not. So add a simple helper function in common code, since this might be of interest for other architectures as well. Signed-off-by: Heiko Carstens Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger (cherry picked from commit dfeec843fb237d73947e818f961e8d6f0df22b01) Signed-off-by: Christoffer Dall --- diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f6801d10e04c..eef946f92c0c 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -840,6 +840,13 @@ static inline hpa_t pfn_to_hpa(pfn_t pfn) return (hpa_t)pfn << PAGE_SHIFT; } +static inline bool kvm_is_error_gpa(struct kvm *kvm, gpa_t gpa) +{ + unsigned long hva = gfn_to_hva(kvm, gpa_to_gfn(gpa)); + + return kvm_is_error_hva(hva); +} + static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu) { set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);