Re: [PATCH v1 2/4] hyperv: Add definitions for syndbg
On 16/02/2022, Emanuele Giuseppe Esposito wrote: On 04/02/2022 11:07, Jon Doron wrote: Add all required definitions for hyperv synthetic debugger interface. Signed-off-by: Jon Doron --- include/hw/hyperv/hyperv-proto.h | 52 target/i386/kvm/hyperv-proto.h | 37 +++ 2 files changed, 89 insertions(+) diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-proto.h index 21dc28aee9..94c9658eb0 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -24,12 +24,17 @@ #define HV_STATUS_INVALID_PORT_ID 17 #define HV_STATUS_INVALID_CONNECTION_ID 18 #define HV_STATUS_INSUFFICIENT_BUFFERS19 +#define HV_STATUS_NOT_ACKNOWLEDGED20 +#define HV_STATUS_NO_DATA 27 /* * Hypercall numbers */ #define HV_POST_MESSAGE 0x005c #define HV_SIGNAL_EVENT 0x005d +#define HV_POST_DEBUG_DATA0x0069 +#define HV_RETREIVE_DEBUG_DATA0x006a s/RETREIVE/RETRIEVE? Done +#define HV_RESET_DEBUG_SESSION0x006b #define HV_HYPERCALL_FAST (1u << 16) /* @@ -127,4 +132,51 @@ struct hyperv_event_flags_page { struct hyperv_event_flags slot[HV_SINT_COUNT]; }; +/* + * Kernel debugger structures + */ + +/* Options flags for hyperv_reset_debug_session */ +#define HV_DEBUG_PURGE_INCOMING_DATA0x0001 +#define HV_DEBUG_PURGE_OUTGOING_DATA0x0002 +struct hyperv_reset_debug_session_input { +uint32_t options; +} __attribute__ ((__packed__)); + +struct hyperv_reset_debug_session_output { +uint32_t host_ip; +uint32_t target_ip; +uint16_t host_port; +uint16_t target_port; +uint8_t host_mac[6]; +uint8_t target_mac[6]; +} __attribute__ ((__packed__)); + +/* Options for hyperv_post_debug_data */ +#define HV_DEBUG_POST_LOOP 0x0001 + +struct hyperv_post_debug_data_input { +uint32_t count; +uint32_t options; +/*uint8_t data[HV_HYP_PAGE_SIZE - 2 * sizeof(uint32_t)];*/ What is this comment for? It's a reference how the data really looks like. +} __attribute__ ((__packed__)); + +struct hyperv_post_debug_data_output { +uint32_t pending_count; +} __attribute__ ((__packed__)); + +/* Options for hyperv_retrieve_debug_data */ +#define HV_DEBUG_RETRIEVE_LOOP 0x0001 +#define HV_DEBUG_RETRIEVE_TEST_ACTIVITY 0x0002 + +struct hyperv_retrieve_debug_data_input { +uint32_t count; +uint32_t options; +uint64_t timeout; +} __attribute__ ((__packed__)); + +struct hyperv_retrieve_debug_data_output { +uint32_t retrieved_count; +uint32_t remaining_count; +} __attribute__ ((__packed__)); #endif diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index 89f81afda7..9480bcdf04 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -19,6 +19,9 @@ #define HV_CPUID_ENLIGHTMENT_INFO 0x4004 #define HV_CPUID_IMPLEMENT_LIMITS 0x4005 #define HV_CPUID_NESTED_FEATURES 0x400A +#define HV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS0x4080 +#define HV_CPUID_SYNDBG_INTERFACE 0x4081 +#define HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 0x4082 #define HV_CPUID_MIN 0x4005 #define HV_CPUID_MAX 0x4000 #define HV_HYPERVISOR_PRESENT_BIT 0x8000 @@ -55,8 +58,14 @@ #define HV_GUEST_IDLE_STATE_AVAILABLE (1u << 5) #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) #define HV_GUEST_CRASH_MSR_AVAILABLE(1u << 10) +#define HV_FEATURE_DEBUG_MSRS_AVAILABLE (1u << 11) #define HV_STIMER_DIRECT_MODE_AVAILABLE (1u << 19) +/* + * HV_CPUID_FEATURES.EBX bits + */ +#define HV_PARTITION_DEUBGGING_ALLOWED (1u << 12) s/DEUBGGING/DEBUGGING Done + /* * HV_CPUID_ENLIGHTMENT_INFO.EAX bits */ @@ -72,6 +81,11 @@ #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) #define HV_NO_NONARCH_CORESHARING (1u << 18) +/* + * HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX bits + */ +#define HV_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING(1u << 1) + /* * Basic virtualized MSRs */ @@ -130,6 +144,18 @@ #define HV_X64_MSR_STIMER3_CONFIG 0x40B6 #define HV_X64_MSR_STIMER3_COUNT0x40B7 +/* + * Hyper-V Synthetic debug options MSR + */ +#define HV_X64_MSR_SYNDBG_CONTROL 0x40F1 +#define HV_X64_MSR_SYNDBG_STATUS0x40F2 +#define HV_X64_MSR_SYNDBG_SEND_BUFFER 0x40F3 +#define HV_X64_MSR_SYNDBG_RECV_BUFFER 0x40F4 +#define HV_X64_MSR_SYNDBG_PENDING_BUFFER0x40F5 +#define HV_X64_MSR_SYNDBG_OPTIONS 0x40FF + +#define HV_X64_SYNDBG_OPTION_USE_HCALLS BIT(2) + /* * Guest crash notification MSRs */ @@ -168,5 +194,1
Re: [PATCH v1 2/4] hyperv: Add definitions for syndbg
On 04/02/2022 11:07, Jon Doron wrote: > Add all required definitions for hyperv synthetic debugger interface. > > Signed-off-by: Jon Doron > --- > include/hw/hyperv/hyperv-proto.h | 52 > target/i386/kvm/hyperv-proto.h | 37 +++ > 2 files changed, 89 insertions(+) > > diff --git a/include/hw/hyperv/hyperv-proto.h > b/include/hw/hyperv/hyperv-proto.h > index 21dc28aee9..94c9658eb0 100644 > --- a/include/hw/hyperv/hyperv-proto.h > +++ b/include/hw/hyperv/hyperv-proto.h > @@ -24,12 +24,17 @@ > #define HV_STATUS_INVALID_PORT_ID 17 > #define HV_STATUS_INVALID_CONNECTION_ID 18 > #define HV_STATUS_INSUFFICIENT_BUFFERS19 > +#define HV_STATUS_NOT_ACKNOWLEDGED20 > +#define HV_STATUS_NO_DATA 27 > > /* > * Hypercall numbers > */ > #define HV_POST_MESSAGE 0x005c > #define HV_SIGNAL_EVENT 0x005d > +#define HV_POST_DEBUG_DATA0x0069 > +#define HV_RETREIVE_DEBUG_DATA0x006a s/RETREIVE/RETRIEVE? > +#define HV_RESET_DEBUG_SESSION0x006b > #define HV_HYPERCALL_FAST (1u << 16) > > /* > @@ -127,4 +132,51 @@ struct hyperv_event_flags_page { > struct hyperv_event_flags slot[HV_SINT_COUNT]; > }; > > +/* > + * Kernel debugger structures > + */ > + > +/* Options flags for hyperv_reset_debug_session */ > +#define HV_DEBUG_PURGE_INCOMING_DATA0x0001 > +#define HV_DEBUG_PURGE_OUTGOING_DATA0x0002 > +struct hyperv_reset_debug_session_input { > +uint32_t options; > +} __attribute__ ((__packed__)); > + > +struct hyperv_reset_debug_session_output { > +uint32_t host_ip; > +uint32_t target_ip; > +uint16_t host_port; > +uint16_t target_port; > +uint8_t host_mac[6]; > +uint8_t target_mac[6]; > +} __attribute__ ((__packed__)); > + > +/* Options for hyperv_post_debug_data */ > +#define HV_DEBUG_POST_LOOP 0x0001 > + > +struct hyperv_post_debug_data_input { > +uint32_t count; > +uint32_t options; > +/*uint8_t data[HV_HYP_PAGE_SIZE - 2 * sizeof(uint32_t)];*/ What is this comment for? > +} __attribute__ ((__packed__)); > + > +struct hyperv_post_debug_data_output { > +uint32_t pending_count; > +} __attribute__ ((__packed__)); > + > +/* Options for hyperv_retrieve_debug_data */ > +#define HV_DEBUG_RETRIEVE_LOOP 0x0001 > +#define HV_DEBUG_RETRIEVE_TEST_ACTIVITY 0x0002 > + > +struct hyperv_retrieve_debug_data_input { > +uint32_t count; > +uint32_t options; > +uint64_t timeout; > +} __attribute__ ((__packed__)); > + > +struct hyperv_retrieve_debug_data_output { > +uint32_t retrieved_count; > +uint32_t remaining_count; > +} __attribute__ ((__packed__)); > #endif > diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h > index 89f81afda7..9480bcdf04 100644 > --- a/target/i386/kvm/hyperv-proto.h > +++ b/target/i386/kvm/hyperv-proto.h > @@ -19,6 +19,9 @@ > #define HV_CPUID_ENLIGHTMENT_INFO 0x4004 > #define HV_CPUID_IMPLEMENT_LIMITS 0x4005 > #define HV_CPUID_NESTED_FEATURES 0x400A > +#define HV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS0x4080 > +#define HV_CPUID_SYNDBG_INTERFACE 0x4081 > +#define HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 0x4082 > #define HV_CPUID_MIN 0x4005 > #define HV_CPUID_MAX 0x4000 > #define HV_HYPERVISOR_PRESENT_BIT 0x8000 > @@ -55,8 +58,14 @@ > #define HV_GUEST_IDLE_STATE_AVAILABLE (1u << 5) > #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) > #define HV_GUEST_CRASH_MSR_AVAILABLE(1u << 10) > +#define HV_FEATURE_DEBUG_MSRS_AVAILABLE (1u << 11) > #define HV_STIMER_DIRECT_MODE_AVAILABLE (1u << 19) > > +/* > + * HV_CPUID_FEATURES.EBX bits > + */ > +#define HV_PARTITION_DEUBGGING_ALLOWED (1u << 12) s/DEUBGGING/DEBUGGING > + > /* > * HV_CPUID_ENLIGHTMENT_INFO.EAX bits > */ > @@ -72,6 +81,11 @@ > #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) > #define HV_NO_NONARCH_CORESHARING (1u << 18) > > +/* > + * HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX bits > + */ > +#define HV_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING(1u << 1) > + > /* > * Basic virtualized MSRs > */ > @@ -130,6 +144,18 @@ > #define HV_X64_MSR_STIMER3_CONFIG 0x40B6 > #define HV_X64_MSR_STIMER3_COUNT0x40B7 > > +/* > + * Hyper-V Synthetic debug options MSR > + */ > +#define HV_X64_MSR_SYNDBG_CONTROL 0x40F1 > +#define HV_X64_MSR_SYNDBG_STATUS0x40F2 > +#define HV_X64_MSR_SYNDBG_SEND_BUFFER 0x40F3 > +#define HV_X64_MSR_SYNDBG_RECV_BUFFER 0x40F4 > +#define HV_X64_MSR_SYNDBG_PENDING_BUFFER0x40F5 > +#define HV_X64_MSR
[PATCH v1 2/4] hyperv: Add definitions for syndbg
Add all required definitions for hyperv synthetic debugger interface. Signed-off-by: Jon Doron --- include/hw/hyperv/hyperv-proto.h | 52 target/i386/kvm/hyperv-proto.h | 37 +++ 2 files changed, 89 insertions(+) diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-proto.h index 21dc28aee9..94c9658eb0 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -24,12 +24,17 @@ #define HV_STATUS_INVALID_PORT_ID 17 #define HV_STATUS_INVALID_CONNECTION_ID 18 #define HV_STATUS_INSUFFICIENT_BUFFERS19 +#define HV_STATUS_NOT_ACKNOWLEDGED20 +#define HV_STATUS_NO_DATA 27 /* * Hypercall numbers */ #define HV_POST_MESSAGE 0x005c #define HV_SIGNAL_EVENT 0x005d +#define HV_POST_DEBUG_DATA0x0069 +#define HV_RETREIVE_DEBUG_DATA0x006a +#define HV_RESET_DEBUG_SESSION0x006b #define HV_HYPERCALL_FAST (1u << 16) /* @@ -127,4 +132,51 @@ struct hyperv_event_flags_page { struct hyperv_event_flags slot[HV_SINT_COUNT]; }; +/* + * Kernel debugger structures + */ + +/* Options flags for hyperv_reset_debug_session */ +#define HV_DEBUG_PURGE_INCOMING_DATA0x0001 +#define HV_DEBUG_PURGE_OUTGOING_DATA0x0002 +struct hyperv_reset_debug_session_input { +uint32_t options; +} __attribute__ ((__packed__)); + +struct hyperv_reset_debug_session_output { +uint32_t host_ip; +uint32_t target_ip; +uint16_t host_port; +uint16_t target_port; +uint8_t host_mac[6]; +uint8_t target_mac[6]; +} __attribute__ ((__packed__)); + +/* Options for hyperv_post_debug_data */ +#define HV_DEBUG_POST_LOOP 0x0001 + +struct hyperv_post_debug_data_input { +uint32_t count; +uint32_t options; +/*uint8_t data[HV_HYP_PAGE_SIZE - 2 * sizeof(uint32_t)];*/ +} __attribute__ ((__packed__)); + +struct hyperv_post_debug_data_output { +uint32_t pending_count; +} __attribute__ ((__packed__)); + +/* Options for hyperv_retrieve_debug_data */ +#define HV_DEBUG_RETRIEVE_LOOP 0x0001 +#define HV_DEBUG_RETRIEVE_TEST_ACTIVITY 0x0002 + +struct hyperv_retrieve_debug_data_input { +uint32_t count; +uint32_t options; +uint64_t timeout; +} __attribute__ ((__packed__)); + +struct hyperv_retrieve_debug_data_output { +uint32_t retrieved_count; +uint32_t remaining_count; +} __attribute__ ((__packed__)); #endif diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index 89f81afda7..9480bcdf04 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -19,6 +19,9 @@ #define HV_CPUID_ENLIGHTMENT_INFO 0x4004 #define HV_CPUID_IMPLEMENT_LIMITS 0x4005 #define HV_CPUID_NESTED_FEATURES 0x400A +#define HV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS0x4080 +#define HV_CPUID_SYNDBG_INTERFACE 0x4081 +#define HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES 0x4082 #define HV_CPUID_MIN 0x4005 #define HV_CPUID_MAX 0x4000 #define HV_HYPERVISOR_PRESENT_BIT 0x8000 @@ -55,8 +58,14 @@ #define HV_GUEST_IDLE_STATE_AVAILABLE (1u << 5) #define HV_FREQUENCY_MSRS_AVAILABLE (1u << 8) #define HV_GUEST_CRASH_MSR_AVAILABLE(1u << 10) +#define HV_FEATURE_DEBUG_MSRS_AVAILABLE (1u << 11) #define HV_STIMER_DIRECT_MODE_AVAILABLE (1u << 19) +/* + * HV_CPUID_FEATURES.EBX bits + */ +#define HV_PARTITION_DEUBGGING_ALLOWED (1u << 12) + /* * HV_CPUID_ENLIGHTMENT_INFO.EAX bits */ @@ -72,6 +81,11 @@ #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) #define HV_NO_NONARCH_CORESHARING (1u << 18) +/* + * HV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX bits + */ +#define HV_SYNDBG_CAP_ALLOW_KERNEL_DEBUGGING(1u << 1) + /* * Basic virtualized MSRs */ @@ -130,6 +144,18 @@ #define HV_X64_MSR_STIMER3_CONFIG 0x40B6 #define HV_X64_MSR_STIMER3_COUNT0x40B7 +/* + * Hyper-V Synthetic debug options MSR + */ +#define HV_X64_MSR_SYNDBG_CONTROL 0x40F1 +#define HV_X64_MSR_SYNDBG_STATUS0x40F2 +#define HV_X64_MSR_SYNDBG_SEND_BUFFER 0x40F3 +#define HV_X64_MSR_SYNDBG_RECV_BUFFER 0x40F4 +#define HV_X64_MSR_SYNDBG_PENDING_BUFFER0x40F5 +#define HV_X64_MSR_SYNDBG_OPTIONS 0x40FF + +#define HV_X64_SYNDBG_OPTION_USE_HCALLS BIT(2) + /* * Guest crash notification MSRs */ @@ -168,5 +194,16 @@ #define HV_STIMER_COUNT 4 +/* + * Synthetic debugger control definitions + */ +#define HV_SYNDBG_CONTROL_SEND (1u << 0) +#define HV_SYNDBG_CONTROL_RECV (1u << 1) +#define H