mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: bsd@redhat.com, Andrey Smetanin <asmetanin@virtuozzo.com>,
	"Denis V. Lunev" <den@openvz.org>, Gleb Natapov <gleb@kernel.org>
Subject: [FYI PATCH 13/20] kvm/x86: Hyper-V HV_X64_MSR_RESET msr
Date: Mon, 28 Sep 2015 12:38:58 +0200	[thread overview]
Message-ID: <1443436745-38086-14-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1443436745-38086-1-git-send-email-pbonzini@redhat.com>

From: Andrey Smetanin <asmetanin@virtuozzo.com>

HV_X64_MSR_RESET msr is used by Hyper-V based Windows guest
to reset guest VM by hypervisor.

Necessary to support loading of winhv.sys in guest, which in turn is
required to support Windows VMBus.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Gleb Natapov <gleb@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/include/uapi/asm/hyperv.h |  3 +++
 arch/x86/kvm/hyperv.c              | 10 ++++++++++
 arch/x86/kvm/x86.c                 |  7 +++++++
 include/linux/kvm_host.h           |  1 +
 4 files changed, 21 insertions(+)

diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index f0412c50c47b..dab584bf7ddf 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -153,6 +153,9 @@
 /* MSR used to provide vcpu index */
 #define HV_X64_MSR_VP_INDEX			0x40000002
 
+/* MSR used to reset the guest OS. */
+#define HV_X64_MSR_RESET			0x40000003
+
 /* MSR used to read the per-partition time reference counter */
 #define HV_X64_MSR_TIME_REF_COUNT		0x40000020
 
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index a8160d2ae362..0ad11a232474 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -41,6 +41,7 @@ static bool kvm_hv_msr_partition_wide(u32 msr)
 	case HV_X64_MSR_TIME_REF_COUNT:
 	case HV_X64_MSR_CRASH_CTL:
 	case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4:
+	case HV_X64_MSR_RESET:
 		r = true;
 		break;
 	}
@@ -163,6 +164,12 @@ static int kvm_hv_set_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data,
 						 data);
 	case HV_X64_MSR_CRASH_CTL:
 		return kvm_hv_msr_set_crash_ctl(vcpu, data, host);
+	case HV_X64_MSR_RESET:
+		if (data == 1) {
+			vcpu_debug(vcpu, "hyper-v reset requested\n");
+			kvm_make_request(KVM_REQ_HV_RESET, vcpu);
+		}
+		break;
 	default:
 		vcpu_unimpl(vcpu, "Hyper-V uhandled wrmsr: 0x%x data 0x%llx\n",
 			    msr, data);
@@ -241,6 +248,9 @@ static int kvm_hv_get_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 						 pdata);
 	case HV_X64_MSR_CRASH_CTL:
 		return kvm_hv_msr_get_crash_ctl(vcpu, pdata);
+	case HV_X64_MSR_RESET:
+		data = 0;
+		break;
 	default:
 		vcpu_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
 		return 1;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b015ab357980..7e207de0a13f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -952,6 +952,7 @@ static u32 emulated_msrs[] = {
 	HV_X64_MSR_TIME_REF_COUNT, HV_X64_MSR_REFERENCE_TSC,
 	HV_X64_MSR_CRASH_P0, HV_X64_MSR_CRASH_P1, HV_X64_MSR_CRASH_P2,
 	HV_X64_MSR_CRASH_P3, HV_X64_MSR_CRASH_P4, HV_X64_MSR_CRASH_CTL,
+	HV_X64_MSR_RESET,
 	HV_X64_MSR_APIC_ASSIST_PAGE, MSR_KVM_ASYNC_PF_EN, MSR_KVM_STEAL_TIME,
 	MSR_KVM_PV_EOI_EN,
 
@@ -6325,6 +6326,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 			r = 0;
 			goto out;
 		}
+		if (kvm_check_request(KVM_REQ_HV_RESET, vcpu)) {
+			vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
+			vcpu->run->system_event.type = KVM_SYSTEM_EVENT_RESET;
+			r = 0;
+			goto out;
+		}
 	}
 
 	if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index a73d60d474dd..f3bd0fd0795e 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -141,6 +141,7 @@ static inline bool is_error_page(struct page *page)
 #define KVM_REQ_SMI               26
 #define KVM_REQ_HV_CRASH          27
 #define KVM_REQ_IOAPIC_EOI_EXIT   28
+#define KVM_REQ_HV_RESET          29
 
 #define KVM_USERSPACE_IRQ_SOURCE_ID		0
 #define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID	1
-- 
1.8.3.1



  parent reply	other threads:[~2015-09-28 10:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 10:38 [FYI PATCH 00/20] kvm/queue will be merged soon to kvm/next Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 01/20] KVM: x86: set TMR when the interrupt is accepted Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 02/20] KVM: x86: store IOAPIC-handled vectors in each VCPU Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 03/20] KVM: x86: replace vm_has_apicv hook with cpu_uses_apicv Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 04/20] KVM: x86: introduce lapic_in_kernel Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 05/20] KVM: x86: unify handling of interrupt window Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 06/20] KVM: x86: Split the APIC from the rest of IRQCHIP Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 07/20] KVM: x86: Add KVM exit for IOAPIC EOIs Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 08/20] KVM: x86: Add EOI exit bitmap inference Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 09/20] KVM: x86: Add support for local interrupt requests from userspace Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 10/20] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 11/20] kvm: add tracepoint for fast mmio Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 12/20] kvm: add capability for any-length ioeventfds Paolo Bonzini
2015-09-28 10:38 ` Paolo Bonzini [this message]
2015-09-28 10:38 ` [FYI PATCH 14/20] kvm/x86: Hyper-V HV_X64_MSR_VP_INDEX export for QEMU Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 15/20] kvm/x86: Hyper-V HV_X64_MSR_VP_RUNTIME support Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 16/20] KVM: VMX: adjust interface to allocate/free_vpid Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 17/20] KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 18/20] KVM: nVMX: emulate the INVVPID instruction Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 19/20] KVM: nVMX: nested VPID emulation Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 20/20] KVM: vmx: disable posted interrupts if no local APIC Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443436745-38086-14-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=asmetanin@virtuozzo.com \
    --cc=bsd@redhat.com \
    --cc=den@openvz.org \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®