Message ID | 20200324074341.1770081-7-arilou@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/kvm/hyper-v: add support for synthetic debugger | expand |
Jon Doron <arilou@gmail.com> writes: > There is another mode for the synthetic debugger which uses hypercalls > to send/recv network data instead of the MSR interface. > > This interface is much slower and less recommended since you might get > a lot of VMExits while KDVM polling for new packets to recv, rather > than simply checking the pending page to see if there is data avialble > and then request. > > Signed-off-by: Jon Doron <arilou@gmail.com> > --- > arch/x86/kvm/hyperv.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c > index 59c6eadb7eca..45ff3098e079 100644 > --- a/arch/x86/kvm/hyperv.c > +++ b/arch/x86/kvm/hyperv.c > @@ -1832,6 +1832,34 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) > } > ret = kvm_hv_send_ipi(vcpu, ingpa, outgpa, true, false); > break; > + case HVCALL_POST_DEBUG_DATA: > + case HVCALL_RETRIEVE_DEBUG_DATA: > + if (unlikely(fast)) { > + ret = HV_STATUS_INVALID_PARAMETER; > + break; > + } > + fallthrough; > + case HVCALL_RESET_DEBUG_SESSION: { > + struct kvm_hv_syndbg *syndbg = vcpu_to_hv_syndbg(vcpu); > + > + if (!syndbg->active) { > + ret = HV_STATUS_INVALID_HYPERCALL_CODE; > + break; > + } > + > + if (!(syndbg->options & HV_X64_SYNDBG_OPTION_USE_HCALLS)) { > + ret = HV_STATUS_OPERATION_DENIED; > + break; > + } > + vcpu->run->exit_reason = KVM_EXIT_HYPERV; > + vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; > + vcpu->run->hyperv.u.hcall.input = param; > + vcpu->run->hyperv.u.hcall.params[0] = ingpa; > + vcpu->run->hyperv.u.hcall.params[1] = outgpa; > + vcpu->arch.complete_userspace_io = > + kvm_hv_hypercall_complete_userspace; We may want to split this into a helper in the future (as HVCALL_POST_MESSAGE handling is not any different - basically, we just pass the full hypercall input to the userspace, regardless of what the hypercall was). > + return 0; > + } > default: > ret = HV_STATUS_INVALID_HYPERCALL_CODE; > break; Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 59c6eadb7eca..45ff3098e079 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1832,6 +1832,34 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) } ret = kvm_hv_send_ipi(vcpu, ingpa, outgpa, true, false); break; + case HVCALL_POST_DEBUG_DATA: + case HVCALL_RETRIEVE_DEBUG_DATA: + if (unlikely(fast)) { + ret = HV_STATUS_INVALID_PARAMETER; + break; + } + fallthrough; + case HVCALL_RESET_DEBUG_SESSION: { + struct kvm_hv_syndbg *syndbg = vcpu_to_hv_syndbg(vcpu); + + if (!syndbg->active) { + ret = HV_STATUS_INVALID_HYPERCALL_CODE; + break; + } + + if (!(syndbg->options & HV_X64_SYNDBG_OPTION_USE_HCALLS)) { + ret = HV_STATUS_OPERATION_DENIED; + break; + } + vcpu->run->exit_reason = KVM_EXIT_HYPERV; + vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; + vcpu->run->hyperv.u.hcall.input = param; + vcpu->run->hyperv.u.hcall.params[0] = ingpa; + vcpu->run->hyperv.u.hcall.params[1] = outgpa; + vcpu->arch.complete_userspace_io = + kvm_hv_hypercall_complete_userspace; + return 0; + } default: ret = HV_STATUS_INVALID_HYPERCALL_CODE; break;
There is another mode for the synthetic debugger which uses hypercalls to send/recv network data instead of the MSR interface. This interface is much slower and less recommended since you might get a lot of VMExits while KDVM polling for new packets to recv, rather than simply checking the pending page to see if there is data avialble and then request. Signed-off-by: Jon Doron <arilou@gmail.com> --- arch/x86/kvm/hyperv.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)