RE: [PATCH v2 2/4] x86/kvm/hyper-v: Add support for synthetic debugger capability

Michael Kelley
2020-03-06T15:45:21Z

From: Vitaly Kuznetsov <vkuznets@redhat.com> Sent: Friday, March 6, 2020 7:27 AM
>
> Jon Doron <arilou@gmail.com> writes:
>
> > Add support for Hyper-V synthetic debugger (syndbg) interface.
> > The syndbg interface is using MSRs to emulate a way to send/recv packets
> > data.
> >
> > The debug transport dll (kdvm/kdnet) will identify if Hyper-V is enabled
> > and if it supports the synthetic debugger interface it will attempt to
> > use it, instead of trying to initialize a network adapter.
> >
>
> I would suggest you split TLFS changes into it's own patch so Hyper-V
> folks can ACK (or they can ack the whole patch with KVM changes of
> course :-)

I have contacted the Hyper-V team for clarification of the status
of the synthetic debugging feature and the associated CPUID leaves and
MSRs. The first statement I got is that these are "deprecated", but I'm
trying to get more specifics about exactly what that means, if they
are going to be removed in a future release.

Michael

>
> > Signed-off-by: Jon Doron <arilou@gmail.com>
> > ---
> > arch/x86/include/asm/hyperv-tlfs.h | 16 ++++
> > arch/x86/include/asm/kvm_host.h | 13 ++++
> > arch/x86/kvm/hyperv.c | 114 ++++++++++++++++++++++++++++-
> > arch/x86/kvm/hyperv.h | 5 ++
> > arch/x86/kvm/trace.h | 25 +++++++
> > arch/x86/kvm/x86.c | 9 +++
> > include/uapi/linux/kvm.h | 10 +++
> > 7 files changed, 191 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
> > index 92abc1e42bfc..8efdf974c23f 100644
> > --- a/arch/x86/include/asm/hyperv-tlfs.h
> > +++ b/arch/x86/include/asm/hyperv-tlfs.h
> > @@ -33,6 +33,9 @@
> > #define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004
> > #define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005
> > #define HYPERV_CPUID_NESTED_FEATURES 0x4000000A
> > +#define HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS 0x40000080
> > +#define HYPERV_CPUID_SYNDBG_INTERFACE 0x40000081
> > +#define HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 0x40000082
> >
> > #define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000
> > #define HYPERV_CPUID_MIN 0x40000005
> > @@ -131,6 +134,8 @@
> > #define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE BIT(8)
> > /* Crash MSR available */
> > #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(10)
> > +/* Support for debug MSRs available */
> > +#define HV_FEATURE_DEBUG_MSRS_AVAILABLE BIT(11)
> > /* stimer Direct Mode is available */
> > #define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(19)
> >
> > @@ -194,6 +199,9 @@
> > #define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18)
> > #define HV_X64_NESTED_MSR_BITMAP BIT(19)
> >
> > +/* Hyper-V synthetic debugger platform capabilities */
> > +#define HV_X64_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING BIT(1)
> > +
>
> hyperv-tlfs.h is not perfectly structured but still there is some
> structure there,
> e.g. HV_X64_NESTED_GUEST_MAPPING_FLUSH/HV_X64_NESTED_MSR_BITMAP/... are
> said to be HYPERV_CPUID_ENLIGHTMENT_INFO.EAX
> bits (see above HV_X64_AS_SWITCH_RECOMMENDED).
>
> To make it clear that HV_X64_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING doesn't
> belong to these bits I'd suggest you add a comment like
>
> /*
> * Hyper-V synthetic debugger platform capabilities.
> * These are HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX bits.
> *
> */
>
> to make it clear.
>
> > /* Hyper-V specific model specific registers (MSRs) */
> >
> > /* MSR used to identify the guest OS. */
> > @@ -267,6 +275,14 @@
> > /* Hyper-V guest idle MSR */
> > #define HV_X64_MSR_GUEST_IDLE 0x400000F0
> >
> > +/* Hyper-V Synthetic debug options MSR */
> > +#define HV_X64_MSR_SYNDBG_CONTROL 0x400000F1
> > +#define HV_X64_MSR_SYNDBG_STATUS 0x400000F2
> > +#define HV_X64_MSR_SYNDBG_SEND_BUFFER 0x400000F3
> > +#define HV_X64_MSR_SYNDBG_RECV_BUFFER 0x400000F4
> > +#define HV_X64_MSR_SYNDBG_PENDING_BUFFER 0x400000F5
> > +#define HV_X64_MSR_SYNDBG_OPTIONS 0x400000FF
> > +
> > /* Hyper-V guest crash notification MSR's */
> > #define HV_X64_MSR_CRASH_P0 0x40000100
> > #define HV_X64_MSR_CRASH_P1 0x40000101