diff mbox

[8/9] kvm/x86: add sending hyper-v crash notification to user space

Message ID 1435664007-4965-9-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev June 30, 2015, 11:33 a.m. UTC
From: Andrey Smetanin <asmetanin@virtuozzo.com>

Sending of notification is done by exiting vcpu to user space
if KVM_REQ_HV_CRASH is enabled for vcpu. kvm_run structure
will contains system_event with type KVM_SYSTEM_EVENT_CRASH
and flag KVM_SYSTEM_EVENT_FL_HV_CRASH to clarify that
crash occures inside Hyper-V based guest.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Gleb Natapov <gleb@kernel.org>
---
 arch/x86/kvm/x86.c       | 8 ++++++++
 include/uapi/linux/kvm.h | 2 ++
 2 files changed, 10 insertions(+)

Comments

Peter Hornyack July 1, 2015, 12:16 a.m. UTC | #1
On Tue, Jun 30, 2015 at 4:33 AM, Denis V. Lunev <den@openvz.org> wrote:
> From: Andrey Smetanin <asmetanin@virtuozzo.com>
>
> Sending of notification is done by exiting vcpu to user space
> if KVM_REQ_HV_CRASH is enabled for vcpu. kvm_run structure
> will contains system_event with type KVM_SYSTEM_EVENT_CRASH
> and flag KVM_SYSTEM_EVENT_FL_HV_CRASH to clarify that
> crash occures inside Hyper-V based guest.
>
> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Gleb Natapov <gleb@kernel.org>
Reviewed-by: Peter Hornyack <peterhornyack@google.com>

> ---
>  arch/x86/kvm/x86.c       | 8 ++++++++
>  include/uapi/linux/kvm.h | 2 ++
>  2 files changed, 10 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 47b7507..55a4b92 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6264,6 +6264,14 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>                         vcpu_scan_ioapic(vcpu);
>                 if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
>                         kvm_vcpu_reload_apic_access_page(vcpu);
> +               if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {
> +                       vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
> +                       vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;
> +                       vcpu->run->system_event.flags =
> +                                               KVM_SYSTEM_EVENT_FL_HV_CRASH;
> +                       r = 0;
> +                       goto out;
> +               }
>         }
>
>         if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 716ad4a..eefb8b9 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -317,6 +317,8 @@ struct kvm_run {
>                 struct {
>  #define KVM_SYSTEM_EVENT_SHUTDOWN       1
>  #define KVM_SYSTEM_EVENT_RESET          2
> +#define KVM_SYSTEM_EVENT_CRASH          3
> +#define KVM_SYSTEM_EVENT_FL_HV_CRASH    (1ULL << 0)
>                         __u32 type;
>                         __u64 flags;
>                 } system_event;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini July 1, 2015, 3:12 p.m. UTC | #2
On 30/06/2015 13:33, Denis V. Lunev wrote:
> From: Andrey Smetanin <asmetanin@virtuozzo.com>
> 
> Sending of notification is done by exiting vcpu to user space
> if KVM_REQ_HV_CRASH is enabled for vcpu. kvm_run structure
> will contains system_event with type KVM_SYSTEM_EVENT_CRASH
> and flag KVM_SYSTEM_EVENT_FL_HV_CRASH to clarify that
> crash occures inside Hyper-V based guest.

This needs to be documented in Documentation/virtual/kvm/api.txt.  Also,
please rename KVM_SYSTEM_EVENT_FL_HV_CRASH to
KVM_SYSTEM_EVENT_FLAG_HV_CRASH and move it to
arch/x86/include/uapi/asm/kvm.h.

You do not need to send the whole series again; just resend this one patch.

Paolo

> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Gleb Natapov <gleb@kernel.org>
> ---
>  arch/x86/kvm/x86.c       | 8 ++++++++
>  include/uapi/linux/kvm.h | 2 ++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 47b7507..55a4b92 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6264,6 +6264,14 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>  			vcpu_scan_ioapic(vcpu);
>  		if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
>  			kvm_vcpu_reload_apic_access_page(vcpu);
> +		if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {
> +			vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
> +			vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;
> +			vcpu->run->system_event.flags =
> +						KVM_SYSTEM_EVENT_FL_HV_CRASH;
> +			r = 0;
> +			goto out;
> +		}
>  	}
>  
>  	if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 716ad4a..eefb8b9 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -317,6 +317,8 @@ struct kvm_run {
>  		struct {
>  #define KVM_SYSTEM_EVENT_SHUTDOWN       1
>  #define KVM_SYSTEM_EVENT_RESET          2
> +#define KVM_SYSTEM_EVENT_CRASH          3
> +#define KVM_SYSTEM_EVENT_FL_HV_CRASH    (1ULL << 0)
>  			__u32 type;
>  			__u64 flags;
>  		} system_event;
>
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 47b7507..55a4b92 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6264,6 +6264,14 @@  static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 			vcpu_scan_ioapic(vcpu);
 		if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu))
 			kvm_vcpu_reload_apic_access_page(vcpu);
+		if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) {
+			vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
+			vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH;
+			vcpu->run->system_event.flags =
+						KVM_SYSTEM_EVENT_FL_HV_CRASH;
+			r = 0;
+			goto out;
+		}
 	}
 
 	if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 716ad4a..eefb8b9 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -317,6 +317,8 @@  struct kvm_run {
 		struct {
 #define KVM_SYSTEM_EVENT_SHUTDOWN       1
 #define KVM_SYSTEM_EVENT_RESET          2
+#define KVM_SYSTEM_EVENT_CRASH          3
+#define KVM_SYSTEM_EVENT_FL_HV_CRASH    (1ULL << 0)
 			__u32 type;
 			__u64 flags;
 		} system_event;