[PATCH RFC 19/22] KVM: x86: hyper-v: Honor HV_DEBUGGING privilege bit

From: Vitaly Kuznetsov
Date: Tue Apr 13 2021 - 08:30:35 EST


Hyper-V partition must possess 'HV_DEBUGGING' privilege to issue
HVCALL_POST_DEBUG_DATA/HVCALL_RETRIEVE_DEBUG_DATA/
HVCALL_RESET_DEBUG_SESSION hypercalls.

Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
---
arch/x86/kvm/hyperv.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index b661f92d90c8..7cb1dd1a9fc1 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -2211,6 +2211,12 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
break;
}

+ if (unlikely(!(hv_vcpu->cpuid_cache.features_ebx &
+ HV_DEBUGGING))) {
+ ret = HV_STATUS_ACCESS_DENIED;
+ break;
+ }
+
if (!(syndbg->options & HV_X64_SYNDBG_OPTION_USE_HCALLS)) {
ret = HV_STATUS_OPERATION_DENIED;
break;
--
2.30.2