qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls
@ 2016-02-11 13:44 Andrey Smetanin
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 1/5] kvm/x86: Rename Hyper-V long spin wait hypercall Andrey Smetanin
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:44 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

The patch implements userspace exit 'KVM_EXIT_HYPERV'
for Hyper-V VMBus hypercalls(postmsg, signalevent)
to handle these hypercalls by QEMU.

Changes v3:
* use vcpu->arch.complete_userspace_io to setup hypercall
result
* rebase for 'next-20160211'

Changes v2:
* use KVM_EXIT_HYPERV for hypercalls

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org

Andrey Smetanin (5):
  kvm/x86: Rename Hyper-V long spin wait hypercall
  drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
  kvm/x86: Pass return code of kvm_emulate_hypercall
  kvm/x86: Reject Hyper-V hypercall continuation
  kvm/x86: Hyper-V VMBus hypercall userspace exit

 Documentation/virtual/kvm/api.txt  |  6 +++++
 arch/x86/include/uapi/asm/hyperv.h |  4 ++-
 arch/x86/kvm/hyperv.c              | 50 +++++++++++++++++++++++++++++++-------
 arch/x86/kvm/svm.c                 |  3 +--
 arch/x86/kvm/vmx.c                 |  3 +--
 drivers/hv/connection.c            |  2 +-
 drivers/hv/hv.c                    |  2 +-
 drivers/hv/hyperv_vmbus.h          |  6 -----
 include/uapi/linux/kvm.h           |  6 +++++
 9 files changed, 60 insertions(+), 22 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 1/5] kvm/x86: Rename Hyper-V long spin wait hypercall
  2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
@ 2016-02-11 13:44 ` Andrey Smetanin
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header Andrey Smetanin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:44 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

Rename HV_X64_HV_NOTIFY_LONG_SPIN_WAIT
by HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT. So
the name better reflects hypercall codes accessory.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
---
 arch/x86/include/uapi/asm/hyperv.h | 2 +-
 arch/x86/kvm/hyperv.c              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 7956412..0c50fab 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -226,7 +226,7 @@
 		(~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
 
 /* Declare the various hypercall operations. */
-#define HV_X64_HV_NOTIFY_LONG_SPIN_WAIT		0x0008
+#define HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
 
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c58ba67..f1a42e1 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1084,7 +1084,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa);
 
 	switch (code) {
-	case HV_X64_HV_NOTIFY_LONG_SPIN_WAIT:
+	case HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
 	default:
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
  2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 1/5] kvm/x86: Rename Hyper-V long spin wait hypercall Andrey Smetanin
@ 2016-02-11 13:44 ` Andrey Smetanin
  2016-02-11 21:46   ` Paolo Bonzini
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 3/5] kvm/x86: Pass return code of kvm_emulate_hypercall Andrey Smetanin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:44 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

VMBus hypercall codes inside Hyper-V UAPI header will
be used by QEMU to implement VMBus host devices support.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
---
 arch/x86/include/uapi/asm/hyperv.h | 2 ++
 drivers/hv/connection.c            | 2 +-
 drivers/hv/hv.c                    | 2 +-
 drivers/hv/hyperv_vmbus.h          | 6 ------
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 0c50fab..bc1c8a9 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -227,6 +227,8 @@
 
 /* Declare the various hypercall operations. */
 #define HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
+#define HV_X64_HCALL_POST_MESSAGE			0x005c
+#define HV_X64_HCALL_SIGNAL_EVENT			0x005d
 
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
 #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index fa86b2c..84700c6 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -485,5 +485,5 @@ void vmbus_set_event(struct vmbus_channel *channel)
 			(child_relid >> 5));
 	}
 
-	hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
+	hv_do_hypercall(HV_X64_HCALL_SIGNAL_EVENT, channel->sig_event, NULL);
 }
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index ccb335f..48388dc 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -337,7 +337,7 @@ int hv_post_message(union hv_connection_id connection_id,
 	aligned_msg->payload_size = payload_size;
 	memcpy((void *)aligned_msg->payload, payload, payload_size);
 
-	status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
+	status = hv_do_hypercall(HV_X64_HCALL_POST_MESSAGE, aligned_msg, NULL);
 
 	put_cpu();
 	return status & 0xFFFF;
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index b9ea7f5..1dabaa4 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -256,12 +256,6 @@ struct hv_monitor_page {
 	u8 rsvdz4[1984];
 };
 
-/* Declare the various hypercall operations. */
-enum hv_call_code {
-	HVCALL_POST_MESSAGE	= 0x005c,
-	HVCALL_SIGNAL_EVENT	= 0x005d,
-};
-
 /* Definition of the hv_post_message hypercall input structure. */
 struct hv_input_post_message {
 	union hv_connection_id connectionid;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 3/5] kvm/x86: Pass return code of kvm_emulate_hypercall
  2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 1/5] kvm/x86: Rename Hyper-V long spin wait hypercall Andrey Smetanin
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header Andrey Smetanin
@ 2016-02-11 13:44 ` Andrey Smetanin
  2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 4/5] kvm/x86: Reject Hyper-V hypercall continuation Andrey Smetanin
  2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 5/5] kvm/x86: Hyper-V VMBus hypercall userspace exit Andrey Smetanin
  4 siblings, 0 replies; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:44 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

Pass the return code from kvm_emulate_hypercall on to the caller,
in order to allow it to indicate to the userspace that
the hypercall has to be handled there.

Also adjust all the existing code paths to return 1 to make sure the
hypercall isn't passed to the userspace without setting kvm_run
appropriately.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
---
 arch/x86/kvm/hyperv.c | 2 +-
 arch/x86/kvm/svm.c    | 3 +--
 arch/x86/kvm/vmx.c    | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index f1a42e1..0e7c90f 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1055,7 +1055,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	 */
 	if (kvm_x86_ops->get_cpl(vcpu) != 0 || !is_protmode(vcpu)) {
 		kvm_queue_exception(vcpu, UD_VECTOR);
-		return 0;
+		return 1;
 	}
 
 	longmode = is_64_bit_mode(vcpu);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index c13a64b..9507038 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1858,8 +1858,7 @@ static int halt_interception(struct vcpu_svm *svm)
 static int vmmcall_interception(struct vcpu_svm *svm)
 {
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	return kvm_emulate_hypercall(&svm->vcpu);
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 164eb9e..2edca5d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5747,8 +5747,7 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	return kvm_emulate_hypercall(vcpu);
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 4/5] kvm/x86: Reject Hyper-V hypercall continuation
  2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
                   ` (2 preceding siblings ...)
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 3/5] kvm/x86: Pass return code of kvm_emulate_hypercall Andrey Smetanin
@ 2016-02-11 13:45 ` Andrey Smetanin
  2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 5/5] kvm/x86: Hyper-V VMBus hypercall userspace exit Andrey Smetanin
  4 siblings, 0 replies; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:45 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

Currently we do not support Hyper-V hypercall continuation
so reject it.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
---
 arch/x86/kvm/hyperv.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 0e7c90f..e1daa8b 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1083,6 +1083,12 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 
 	trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa);
 
+	/* Hypercall continuation is not supported yet */
+	if (rep_cnt || rep_idx) {
+		res = HV_STATUS_INVALID_HYPERCALL_CODE;
+		goto set_result;
+	}
+
 	switch (code) {
 	case HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
@@ -1092,6 +1098,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 		break;
 	}
 
+set_result:
 	ret = res | (((u64)rep_done & 0xfff) << 32);
 	if (longmode) {
 		kvm_register_write(vcpu, VCPU_REGS_RAX, ret);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 5/5] kvm/x86: Hyper-V VMBus hypercall userspace exit
  2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
                   ` (3 preceding siblings ...)
  2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 4/5] kvm/x86: Reject Hyper-V hypercall continuation Andrey Smetanin
@ 2016-02-11 13:45 ` Andrey Smetanin
  4 siblings, 0 replies; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-11 13:45 UTC (permalink / raw)
  To: kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, Paolo Bonzini, K. Y. Srinivasan, Haiyang Zhang

The patch implements KVM_EXIT_HYPERV userspace exit
functionality for Hyper-V VMBus hypercalls:
HV_X64_HCALL_POST_MESSAGE, HV_X64_HCALL_SIGNAL_EVENT.

Changes v3:
* use vcpu->arch.complete_userspace_io to setup hypercall
result

Changes v2:
* use KVM_EXIT_HYPERV for hypercalls

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
---
 Documentation/virtual/kvm/api.txt |  6 ++++++
 arch/x86/kvm/hyperv.c             | 39 ++++++++++++++++++++++++++++++++-------
 include/uapi/linux/kvm.h          |  6 ++++++
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 07e4cdf..4a661e5 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -3339,6 +3339,7 @@ EOI was received.
 
 		struct kvm_hyperv_exit {
 #define KVM_EXIT_HYPERV_SYNIC          1
+#define KVM_EXIT_HYPERV_HCALL          2
 			__u32 type;
 			union {
 				struct {
@@ -3347,6 +3348,11 @@ EOI was received.
 					__u64 evt_page;
 					__u64 msg_page;
 				} synic;
+				struct {
+					__u64 input;
+					__u64 result;
+					__u64 params[2];
+				} hcall;
 			} u;
 		};
 		/* KVM_EXIT_HYPERV */
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index e1daa8b..f8d97ee 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1043,6 +1043,27 @@ bool kvm_hv_hypercall_enabled(struct kvm *kvm)
 	return kvm->arch.hyperv.hv_hypercall & HV_X64_MSR_HYPERCALL_ENABLE;
 }
 
+static void kvm_hv_hypercall_set_result(struct kvm_vcpu *vcpu, u64 result)
+{
+	bool longmode;
+
+	longmode = is_64_bit_mode(vcpu);
+	if (longmode)
+		kvm_register_write(vcpu, VCPU_REGS_RAX, result);
+	else {
+		kvm_register_write(vcpu, VCPU_REGS_RDX, result >> 32);
+		kvm_register_write(vcpu, VCPU_REGS_RAX, result & 0xffffffff);
+	}
+}
+
+static int kvm_hv_hypercall_complete_userspace(struct kvm_vcpu *vcpu)
+{
+	struct kvm_run *run = vcpu->run;
+
+	kvm_hv_hypercall_set_result(vcpu, run->hyperv.u.hcall.result);
+	return 1;
+}
+
 int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 {
 	u64 param, ingpa, outgpa, ret;
@@ -1093,6 +1114,16 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	case HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT:
 		kvm_vcpu_on_spin(vcpu);
 		break;
+	case HV_X64_HCALL_POST_MESSAGE:
+	case HV_X64_HCALL_SIGNAL_EVENT:
+		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:
 		res = HV_STATUS_INVALID_HYPERCALL_CODE;
 		break;
@@ -1100,12 +1131,6 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 
 set_result:
 	ret = res | (((u64)rep_done & 0xfff) << 32);
-	if (longmode) {
-		kvm_register_write(vcpu, VCPU_REGS_RAX, ret);
-	} else {
-		kvm_register_write(vcpu, VCPU_REGS_RDX, ret >> 32);
-		kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
-	}
-
+	kvm_hv_hypercall_set_result(vcpu, ret);
 	return 1;
 }
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index a2fe0ac..82581b6 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -157,6 +157,7 @@ struct kvm_s390_skeys {
 
 struct kvm_hyperv_exit {
 #define KVM_EXIT_HYPERV_SYNIC          1
+#define KVM_EXIT_HYPERV_HCALL          2
 	__u32 type;
 	union {
 		struct {
@@ -165,6 +166,11 @@ struct kvm_hyperv_exit {
 			__u64 evt_page;
 			__u64 msg_page;
 		} synic;
+		struct {
+			__u64 input;
+			__u64 result;
+			__u64 params[2];
+		} hcall;
 	} u;
 };
 
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
  2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header Andrey Smetanin
@ 2016-02-11 21:46   ` Paolo Bonzini
  2016-02-12  8:10     ` Andrey Smetanin
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2016-02-11 21:46 UTC (permalink / raw)
  To: Andrey Smetanin, kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, K. Y. Srinivasan, Haiyang Zhang



On 11/02/2016 14:44, Andrey Smetanin wrote:
> VMBus hypercall codes inside Hyper-V UAPI header will
> be used by QEMU to implement VMBus host devices support.
> 
> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
> Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
> CC: Gleb Natapov <gleb@kernel.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Joerg Roedel <joro@8bytes.org>
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Roman Kagan <rkagan@virtuozzo.com>
> CC: Denis V. Lunev <den@openvz.org>
> CC: qemu-devel@nongnu.org
> ---
>  arch/x86/include/uapi/asm/hyperv.h | 2 ++
>  drivers/hv/connection.c            | 2 +-
>  drivers/hv/hv.c                    | 2 +-
>  drivers/hv/hyperv_vmbus.h          | 6 ------
>  4 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
> index 0c50fab..bc1c8a9 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -227,6 +227,8 @@
>  
>  /* Declare the various hypercall operations. */
>  #define HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
> +#define HV_X64_HCALL_POST_MESSAGE			0x005c
> +#define HV_X64_HCALL_SIGNAL_EVENT			0x005d
>  
>  #define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
>  #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
> diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> index fa86b2c..84700c6 100644
> --- a/drivers/hv/connection.c
> +++ b/drivers/hv/connection.c
> @@ -485,5 +485,5 @@ void vmbus_set_event(struct vmbus_channel *channel)
>  			(child_relid >> 5));
>  	}
>  
> -	hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
> +	hv_do_hypercall(HV_X64_HCALL_SIGNAL_EVENT, channel->sig_event, NULL);

What tree does this apply to?

Paolo

>  }
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index ccb335f..48388dc 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -337,7 +337,7 @@ int hv_post_message(union hv_connection_id connection_id,
>  	aligned_msg->payload_size = payload_size;
>  	memcpy((void *)aligned_msg->payload, payload, payload_size);
>  
> -	status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
> +	status = hv_do_hypercall(HV_X64_HCALL_POST_MESSAGE, aligned_msg, NULL);
>  
>  	put_cpu();
>  	return status & 0xFFFF;
> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> index b9ea7f5..1dabaa4 100644
> --- a/drivers/hv/hyperv_vmbus.h
> +++ b/drivers/hv/hyperv_vmbus.h
> @@ -256,12 +256,6 @@ struct hv_monitor_page {
>  	u8 rsvdz4[1984];
>  };
>  
> -/* Declare the various hypercall operations. */
> -enum hv_call_code {
> -	HVCALL_POST_MESSAGE	= 0x005c,
> -	HVCALL_SIGNAL_EVENT	= 0x005d,
> -};
> -
>  /* Definition of the hv_post_message hypercall input structure. */
>  struct hv_input_post_message {
>  	union hv_connection_id connectionid;
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
  2016-02-11 21:46   ` Paolo Bonzini
@ 2016-02-12  8:10     ` Andrey Smetanin
  2016-02-12 13:16       ` Paolo Bonzini
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Smetanin @ 2016-02-12  8:10 UTC (permalink / raw)
  To: Paolo Bonzini, kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, K. Y. Srinivasan, Haiyang Zhang



On 02/12/2016 12:46 AM, Paolo Bonzini wrote:
>
>
> On 11/02/2016 14:44, Andrey Smetanin wrote:
>> VMBus hypercall codes inside Hyper-V UAPI header will
>> be used by QEMU to implement VMBus host devices support.
>>
>> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
>> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>> Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
>> CC: Gleb Natapov <gleb@kernel.org>
>> CC: Paolo Bonzini <pbonzini@redhat.com>
>> CC: Joerg Roedel <joro@8bytes.org>
>> CC: "K. Y. Srinivasan" <kys@microsoft.com>
>> CC: Haiyang Zhang <haiyangz@microsoft.com>
>> CC: Roman Kagan <rkagan@virtuozzo.com>
>> CC: Denis V. Lunev <den@openvz.org>
>> CC: qemu-devel@nongnu.org
>> ---
>>   arch/x86/include/uapi/asm/hyperv.h | 2 ++
>>   drivers/hv/connection.c            | 2 +-
>>   drivers/hv/hv.c                    | 2 +-
>>   drivers/hv/hyperv_vmbus.h          | 6 ------
>>   4 files changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
>> index 0c50fab..bc1c8a9 100644
>> --- a/arch/x86/include/uapi/asm/hyperv.h
>> +++ b/arch/x86/include/uapi/asm/hyperv.h
>> @@ -227,6 +227,8 @@
>>
>>   /* Declare the various hypercall operations. */
>>   #define HV_X64_HCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
>> +#define HV_X64_HCALL_POST_MESSAGE			0x005c
>> +#define HV_X64_HCALL_SIGNAL_EVENT			0x005d
>>
>>   #define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE		0x00000001
>>   #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT	12
>> diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
>> index fa86b2c..84700c6 100644
>> --- a/drivers/hv/connection.c
>> +++ b/drivers/hv/connection.c
>> @@ -485,5 +485,5 @@ void vmbus_set_event(struct vmbus_channel *channel)
>>   			(child_relid >> 5));
>>   	}
>>
>> -	hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
>> +	hv_do_hypercall(HV_X64_HCALL_SIGNAL_EVENT, channel->sig_event, NULL);
>
> What tree does this apply to?
next-20160211
>
> Paolo
>
>>   }
>> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
>> index ccb335f..48388dc 100644
>> --- a/drivers/hv/hv.c
>> +++ b/drivers/hv/hv.c
>> @@ -337,7 +337,7 @@ int hv_post_message(union hv_connection_id connection_id,
>>   	aligned_msg->payload_size = payload_size;
>>   	memcpy((void *)aligned_msg->payload, payload, payload_size);
>>
>> -	status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
>> +	status = hv_do_hypercall(HV_X64_HCALL_POST_MESSAGE, aligned_msg, NULL);
>>
>>   	put_cpu();
>>   	return status & 0xFFFF;
>> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
>> index b9ea7f5..1dabaa4 100644
>> --- a/drivers/hv/hyperv_vmbus.h
>> +++ b/drivers/hv/hyperv_vmbus.h
>> @@ -256,12 +256,6 @@ struct hv_monitor_page {
>>   	u8 rsvdz4[1984];
>>   };
>>
>> -/* Declare the various hypercall operations. */
>> -enum hv_call_code {
>> -	HVCALL_POST_MESSAGE	= 0x005c,
>> -	HVCALL_SIGNAL_EVENT	= 0x005d,
>> -};
>> -
>>   /* Definition of the hv_post_message hypercall input structure. */
>>   struct hv_input_post_message {
>>   	union hv_connection_id connectionid;
>>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
  2016-02-12  8:10     ` Andrey Smetanin
@ 2016-02-12 13:16       ` Paolo Bonzini
  0 siblings, 0 replies; 9+ messages in thread
From: Paolo Bonzini @ 2016-02-12 13:16 UTC (permalink / raw)
  To: asmetanin, kvm
  Cc: Gleb Natapov, Joerg Roedel, qemu-devel, Roman Kagan,
	Denis V. Lunev, K. Y. Srinivasan, Haiyang Zhang



On 12/02/2016 09:10, Andrey Smetanin wrote:
>>>
>>> -    hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
>>> +    hv_do_hypercall(HV_X64_HCALL_SIGNAL_EVENT, channel->sig_event,
>>> NULL);
>>
>> What tree does this apply to?
> next-20160211

Ok, I'll check whether I can just merge something from KY to get the
hv.c->connection.c code movement.  Otherwise we probably should just
leave the HVCALL_* constants unchanged.

Paolo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-12 13:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-11 13:44 [Qemu-devel] [PATCH v3 0/5] KVM: Hyper-V VMBus hypercalls Andrey Smetanin
2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 1/5] kvm/x86: Rename Hyper-V long spin wait hypercall Andrey Smetanin
2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 2/5] drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header Andrey Smetanin
2016-02-11 21:46   ` Paolo Bonzini
2016-02-12  8:10     ` Andrey Smetanin
2016-02-12 13:16       ` Paolo Bonzini
2016-02-11 13:44 ` [Qemu-devel] [PATCH v3 3/5] kvm/x86: Pass return code of kvm_emulate_hypercall Andrey Smetanin
2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 4/5] kvm/x86: Reject Hyper-V hypercall continuation Andrey Smetanin
2016-02-11 13:45 ` [Qemu-devel] [PATCH v3 5/5] kvm/x86: Hyper-V VMBus hypercall userspace exit Andrey Smetanin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).