Skip to contentSkip to conversation

X86: Deliver Hyper-V interrupts on a seperate IDT vector

PATCH In review K. Y. Srinivasan 8 participants 42 messages Feb 4, 2013 – Apr 18, 2013 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover X86: Deliver Hyper-V interrupts on a seperate IDT vector

This patch-set implements the functionality to deliver Hyper-V VMBUS interrupts via a special IDT entry. Xen emulates Hyper-V and I have added code in this patch-set to properly manage this emulation when Linux is running on Hyper-V.

K. Y. Srinivasan (2):
X86: Add a check to catch Xen emulation of Hyper-V
X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Olaf Hering (1):
x86: Hyper-V: register clocksource only if its advertised

 arch/x86/include/asm/irq_vectors.h |    4 +-
 arch/x86/include/asm/mshyperv.h    |    4 ++
 arch/x86/kernel/cpu/mshyperv.c     |   54 +++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/entry_32.S         |    9 +++++-
 arch/x86/kernel/entry_64.S         |    7 ++++-
 drivers/xen/events.c               |    7 ++--
 6 files changed, 77 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/3 x86: Hyper-V: register clocksource only if its advertised

From: Olaf Hering <[mailto:[email protected]]>

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

---
 arch/x86/kernel/cpu/mshyperv.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +2 -1
index 0a630dd..646d192 100644
@@ -68,7 +68,8 @@ static void __init ms_hyperv_init_platform(void)
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
 
-	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
+		clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
Signature · 1 line
1.7.4.1
#29 lore raw

PATCH 3/3 X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Starting with win8, vmbus interrupts can be delivered on any VCPU in the guest and furthermore can be concurrently active on multiple VCPUs. Support this interrupt delivery model by setting up a separate IDT entry for Hyper-V vmbus. interrupts. I would like to thank Jan Beulich <[email protected]> and Thomas Gleixner <[email protected]>, for their help.

In this version of the patch, based on the feedback, I have merged the IDT vector for Xen and Hyper-V and made the necessary adjustments. Furhermore, based on Jan's feedback I have added the necessary compilation switches.

---
 arch/x86/include/asm/irq_vectors.h |    4 +-
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   44 ++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |    9 ++++++-
 arch/x86/kernel/entry_64.S         |    7 +++++-
 drivers/xen/events.c               |    7 +++--
 6 files changed, 68 insertions(+), 7 deletions(-)
arch/x86/include/asm/irq_vectors.h +2 -2
index 1508e51..aac5fa6 100644
@@ -109,8 +109,8 @@
 
 #define UV_BAU_MESSAGE			0xf5
 
-/* Xen vector callback to receive events in a HVM domain */
-#define XEN_HVM_EVTCHN_CALLBACK		0xf3
+/* Vector on which hypervisor callbacks will be delivered */
+#define HYPERVISOR_CALLBACK_VECTOR	0xf3
 
 /*
  * Local APIC timer IRQ vector is on a different priority level,
arch/x86/include/asm/mshyperv.h +4 -0
index 79ce568..c2934be 100644
@@ -11,4 +11,8 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
+void hyperv_callback_vector(void);
+void hyperv_vector_handler(struct pt_regs *regs);
+void hv_register_vmbus_handler(int irq, irq_handler_t handler);
+
 #endif
arch/x86/kernel/cpu/mshyperv.c +44 -0

63 lines not on this page · raw message

arch/x86/kernel/entry_32.S +8 -1
index 352e5a9..8f3e2de 100644
@@ -1046,11 +1046,18 @@ ENTRY(xen_failsafe_callback)
 	_ASM_EXTABLE(4b,9b)
 ENDPROC(xen_failsafe_callback)
 
-BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
+BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
 		xen_evtchn_do_upcall)
 
 #endif	/* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+
+BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
+	hyperv_vector_handler)
+
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_FUNCTION_TRACER
 #ifdef CONFIG_DYNAMIC_FTRACE
 
arch/x86/kernel/entry_64.S +6 -1
index d5113c3..c1d01e6 100644
@@ -1446,11 +1446,16 @@ ENTRY(xen_failsafe_callback)
 	CFI_ENDPROC
 END(xen_failsafe_callback)
 
-apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
 	xen_hvm_callback_vector xen_evtchn_do_upcall
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+	hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+
 /*
  * Some functions should be protected against kprobes
  */
drivers/xen/events.c +4 -3
index 4293c57..a54401e 100644
@@ -1787,7 +1787,7 @@ void xen_callback_vector(void)
 	int rc;
 	uint64_t callback_via;
 	if (xen_have_vector_callback) {
-		callback_via = HVM_CALLBACK_VECTOR(XEN_HVM_EVTCHN_CALLBACK);
+		callback_via = HVM_CALLBACK_VECTOR(HYPERVISOR_CALLBACK_VECTOR);
 		rc = xen_set_callback_via(callback_via);
 		if (rc) {
 			printk(KERN_ERR "Request for Xen HVM callback vector"
@@ -1798,8 +1798,9 @@ void xen_callback_vector(void)
 		printk(KERN_INFO "Xen HVM callback vector for event delivery is "
 				"enabled\n");
 		/* in the restore case the vector has already been allocated */
-		if (!test_bit(XEN_HVM_EVTCHN_CALLBACK, used_vectors))
-			alloc_intr_gate(XEN_HVM_EVTCHN_CALLBACK, xen_hvm_callback_vector);
+		if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
+			alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
+					xen_hvm_callback_vector);
 	}
 }
 #else
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/3 X86: Add a check to catch Xen emulation of Hyper-V

In reply to K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +7 -0
index 646d192..4dab317 100644
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
Signature · 1 line
1.7.4.1
#42 lore raw
In reply to K. Y. Srinivasan
Quoted 33 lines

-----Original Message-----
From: K. Y. Srinivasan [mailto:[email protected]]
Sent: Sunday, February 03, 2013 8:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: KY Srinivasan
Subject: [PATCH 0/3] X86: Deliver Hyper-V interrupts on a seperate IDT vector

This patch-set implements the functionality to deliver Hyper-V VMBUS interrupts via
a special IDT entry. Xen emulates Hyper-V and I have added code in this patch-set to
properly manage this emulation when Linux is running on Hyper-V.

K. Y. Srinivasan (2):
X86: Add a check to catch Xen emulation of Hyper-V
X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Olaf Hering (1):
x86: Hyper-V: register clocksource only if its advertised

 arch/x86/include/asm/irq_vectors.h |    4 +-
 arch/x86/include/asm/mshyperv.h    |    4 ++
 arch/x86/kernel/cpu/mshyperv.c     |   54
+++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/entry_32.S         |    9 +++++-
 arch/x86/kernel/entry_64.S         |    7 ++++-
 drivers/xen/events.c               |    7 ++--
 6 files changed, 77 insertions(+), 8 deletions(-)
Quoted 4 lines

--
1.7.4.1

Peter,

I have addressed all the comments I have received on these patches. Let me know if there is something you want me to address before these patches can be checked in.

Regards,

K. Y

#41 lore raw

[tip:x86/hyperv] x86: Hyper-V: register clocksource only if its advertised

In reply to K. Y. Srinivasan
Commit-ID:  32068f6527b8f1822a30671dedaf59c567325026
Gitweb:     http://git.kernel.org/tip/32068f6527b8f1822a30671dedaf59c567325026
Author:     Olaf Hering <[mailto:[email protected]]>
AuthorDate: Sun, 3 Feb 2013 17:22:37 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 16:25:48 -0800

x86: Hyper-V: register clocksource only if its advertised

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

---
 arch/x86/kernel/cpu/mshyperv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +2 -1
index 0a630dd..646d192 100644
@@ -68,7 +68,8 @@ static void __init ms_hyperv_init_platform(void)
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
 
-	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
+		clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
#3 lore raw

[tip:x86/hyperv] X86: Add a check to catch Xen emulation of Hyper-V

In reply to K. Y. Srinivasan
Commit-ID:  db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Gitweb:     http://git.kernel.org/tip/db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Author:     K. Y. Srinivasan <[email protected]>
AuthorDate: Sun, 3 Feb 2013 17:22:38 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 16:27:03 -0800

X86: Add a check to catch Xen emulation of Hyper-V

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

---
 arch/x86/kernel/cpu/mshyperv.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/mshyperv.c +7 -0
index 646d192..4dab317 100644
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
#30 lore raw

[tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

In reply to K. Y. Srinivasan
Commit-ID:  bc2b0331e077f576369a2b6c75d15ed4de4ef91f
Gitweb:     http://git.kernel.org/tip/bc2b0331e077f576369a2b6c75d15ed4de4ef91f
Author:     K. Y. Srinivasan <[email protected]>
AuthorDate: Sun, 3 Feb 2013 17:22:39 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 16:27:15 -0800

X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Starting with win8, vmbus interrupts can be delivered on any VCPU in the guest and furthermore can be concurrently active on multiple VCPUs. Support this interrupt delivery model by setting up a separate IDT entry for Hyper-V vmbus. interrupts. I would like to thank Jan Beulich <[email protected]> and Thomas Gleixner <[email protected]>, for their help.

In this version of the patch, based on the feedback, I have merged the IDT vector for Xen and Hyper-V and made the necessary adjustments. Furhermore, based on Jan's feedback I have added the necessary compilation switches.

---
 arch/x86/include/asm/irq_vectors.h |  4 ++--
 arch/x86/include/asm/mshyperv.h    |  4 ++++
 arch/x86/kernel/cpu/mshyperv.c     | 44 ++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |  9 +++++++-
 arch/x86/kernel/entry_64.S         |  7 +++++-
 drivers/xen/events.c               |  7 +++---
 6 files changed, 68 insertions(+), 7 deletions(-)
arch/x86/include/asm/irq_vectors.h +2 -2
index 1508e51..aac5fa6 100644
@@ -109,8 +109,8 @@
 
 #define UV_BAU_MESSAGE			0xf5
 
-/* Xen vector callback to receive events in a HVM domain */
-#define XEN_HVM_EVTCHN_CALLBACK		0xf3
+/* Vector on which hypervisor callbacks will be delivered */
+#define HYPERVISOR_CALLBACK_VECTOR	0xf3
 
 /*
  * Local APIC timer IRQ vector is on a different priority level,
arch/x86/include/asm/mshyperv.h +4 -0
index 79ce568..c2934be 100644
@@ -11,4 +11,8 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
+void hyperv_callback_vector(void);
+void hyperv_vector_handler(struct pt_regs *regs);
+void hv_register_vmbus_handler(int irq, irq_handler_t handler);
+
 #endif
arch/x86/kernel/cpu/mshyperv.c +44 -0

63 lines not on this page · raw message

arch/x86/kernel/entry_32.S +8 -1
index 6ed91d9..8831176 100644
@@ -1091,11 +1091,18 @@ ENTRY(xen_failsafe_callback)
 	_ASM_EXTABLE(4b,9b)
 ENDPROC(xen_failsafe_callback)
 
-BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
+BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
 		xen_evtchn_do_upcall)
 
 #endif	/* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+
+BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
+	hyperv_vector_handler)
+
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_FUNCTION_TRACER
 #ifdef CONFIG_DYNAMIC_FTRACE
 
arch/x86/kernel/entry_64.S +6 -1
index cb3c591..048f224 100644
@@ -1454,11 +1454,16 @@ ENTRY(xen_failsafe_callback)
 	CFI_ENDPROC
 END(xen_failsafe_callback)
 
-apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
 	xen_hvm_callback_vector xen_evtchn_do_upcall
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+	hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+
 /*
  * Some functions should be protected against kprobes
  */
drivers/xen/events.c +4 -3
index 74d77df..22f77c5 100644
@@ -1787,7 +1787,7 @@ void xen_callback_vector(void)
 	int rc;
 	uint64_t callback_via;
 	if (xen_have_vector_callback) {
-		callback_via = HVM_CALLBACK_VECTOR(XEN_HVM_EVTCHN_CALLBACK);
+		callback_via = HVM_CALLBACK_VECTOR(HYPERVISOR_CALLBACK_VECTOR);
 		rc = xen_set_callback_via(callback_via);
 		if (rc) {
 			printk(KERN_ERR "Request for Xen HVM callback vector"
@@ -1798,8 +1798,9 @@ void xen_callback_vector(void)
 		printk(KERN_INFO "Xen HVM callback vector for event delivery is "
 				"enabled\n");
 		/* in the restore case the vector has already been allocated */
-		if (!test_bit(XEN_HVM_EVTCHN_CALLBACK, used_vectors))
-			alloc_intr_gate(XEN_HVM_EVTCHN_CALLBACK, xen_hvm_callback_vector);
+		if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
+			alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
+					xen_hvm_callback_vector);
 	}
 }
 #else
#31 lore raw

[tip:x86/hyperv] x86, hyperv: HYPERV depends on X86_LOCAL_APIC

Commit-ID:  cb20e5f2c8d6ba7440a32f4d70c0755bceb36e78
Gitweb:     http://git.kernel.org/tip/cb20e5f2c8d6ba7440a32f4d70c0755bceb36e78
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Tue, 12 Feb 2013 17:46:23 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 17:46:23 -0800

x86, hyperv: HYPERV depends on X86_LOCAL_APIC

In order to compile in the special Hyper-V interrupt vector, we need infrastructure in arch/x86/apic/apic.c. At least for now, simply require CONFIG_X86_LOCAL_APIC in order to enable CONFIG_HYPERV.

---
 drivers/hv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig +1 -1
index b38ef6d..64630f1 100644
@@ -2,7 +2,7 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && PCI
+	depends on X86 && ACPI && PCI && X86_LOCAL_APIC
 	help
 	  Select this option to run Linux as a Hyper-V client operating
 	  system.
#32 lore raw

RE: [tip:x86/hyperv] x86, hyperv: HYPERV depends on X86_LOCAL_APIC

Quoted 39 lines

-----Original Message-----
From: tip tree robot [mailto:[email protected]] On Behalf Of tip-bot for H. Peter Anvin
Sent: Tuesday, February 12, 2013 8:59 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; [email protected]
Subject: [tip:x86/hyperv] x86, hyperv: HYPERV depends on X86_LOCAL_APIC

Commit-ID: cb20e5f2c8d6ba7440a32f4d70c0755bceb36e78 Gitweb:
http://git.kernel.org/tip/cb20e5f2c8d6ba7440a32f4d70c0755bceb36e78

Author:     H. Peter Anvin <[email protected]>
AuthorDate: Tue, 12 Feb 2013 17:46:23 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 17:46:23 -0800

x86, hyperv: HYPERV depends on X86_LOCAL_APIC

In order to compile in the special Hyper-V interrupt vector, we need infrastructure in arch/x86/apic/apic.c. At least for now, simply require CONFIG_X86_LOCAL_APIC in order to enable CONFIG_HYPERV.

[email protected]

Cc K. Y. Srinivasan <[email protected]>
---
 drivers/hv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/Kconfig +0 -0
index b38ef6d..64630f1 100644

drivers/hv/Kconfig menu "Microsoft Hyper-V guest support" · line 8

Quoted 8 lines
drivers/hv/Kconfig +1 -1
@@ -2,7 +2,7 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on X86 && ACPI && PCI
+	depends on X86 && ACPI && PCI && X86_LOCAL_APIC
 	help
 	  Select this option to run Linux as a Hyper-V client operating
 	  system.

Thank you.

K. Y ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#33 lore raw

Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

In reply to tip-bot for K. Y. Srinivasan
Quoted 162 lines · tip-bot for K. Y. Srinivasan
Commit-ID:  bc2b0331e077f576369a2b6c75d15ed4de4ef91f
Gitweb:     http://git.kernel.org/tip/bc2b0331e077f576369a2b6c75d15ed4de4ef91f
Author:     K. Y. Srinivasan <[email protected]>
AuthorDate: Sun, 3 Feb 2013 17:22:39 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 16:27:15 -0800

X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Starting with win8, vmbus interrupts can be delivered on any VCPU in the guest and furthermore can be concurrently active on multiple VCPUs. Support this interrupt delivery model by setting up a separate IDT entry for Hyper-V vmbus. interrupts. I would like to thank Jan Beulich <[email protected]> and Thomas Gleixner <[email protected]>, for their help.

In this version of the patch, based on the feedback, I have merged the IDT vector for Xen and Hyper-V and made the necessary adjustments. Furhermore, based on Jan's feedback I have added the necessary compilation switches.

---
 arch/x86/include/asm/irq_vectors.h |  4 ++--
 arch/x86/include/asm/mshyperv.h    |  4 ++++
 arch/x86/kernel/cpu/mshyperv.c     | 44 ++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |  9 +++++++-
 arch/x86/kernel/entry_64.S         |  7 +++++-
 drivers/xen/events.c               |  7 +++---
 6 files changed, 68 insertions(+), 7 deletions(-)
arch/x86/include/asm/irq_vectors.h +2 -2
index 1508e51..aac5fa6 100644
@@ -109,8 +109,8 @@
 
 #define UV_BAU_MESSAGE                 0xf5
 
-/* Xen vector callback to receive events in a HVM domain */
-#define XEN_HVM_EVTCHN_CALLBACK                0xf3
+/* Vector on which hypervisor callbacks will be delivered */
+#define HYPERVISOR_CALLBACK_VECTOR     0xf3
 
 /*
  * Local APIC timer IRQ vector is on a different priority level,
arch/x86/include/asm/mshyperv.h +4 -0
index 79ce568..c2934be 100644
@@ -11,4 +11,8 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
+void hyperv_callback_vector(void);
+void hyperv_vector_handler(struct pt_regs *regs);
+void hv_register_vmbus_handler(int irq, irq_handler_t handler);
+
 #endif
arch/x86/kernel/cpu/mshyperv.c +44 -0
index 4dab317..a7d26d8 100644
@@ -14,10 +14,15 @@
 #include <linux/time.h>
 #include <linux/clocksource.h>
 #include <linux/module.h>
+#include <linux/hardirq.h>
+#include <linux/interrupt.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 #include <asm/hyperv.h>
 #include <asm/mshyperv.h>
+#include <asm/desc.h>
+#include <asm/idle.h>
+#include <asm/irq_regs.h>
 
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
@@ -77,6 +82,12 @@ static void __init ms_hyperv_init_platform(void)
 
        if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
                clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+#if IS_ENABLED(CONFIG_HYPERV)
+       /*
+        * Setup the IDT for hypervisor callback.
+        */
+       alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
+#endif
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
@@ -85,3 +96,36 @@ const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
        .init_platform          = ms_hyperv_init_platform,
 };
 EXPORT_SYMBOL(x86_hyper_ms_hyperv);
+
+#if IS_ENABLED(CONFIG_HYPERV)
+static int vmbus_irq = -1;
+static irq_handler_t vmbus_isr;
+
+void hv_register_vmbus_handler(int irq, irq_handler_t handler)
+{
+       vmbus_irq = irq;
+       vmbus_isr = handler;
+}
+
+void hyperv_vector_handler(struct pt_regs *regs)
+{
+       struct pt_regs *old_regs = set_irq_regs(regs);
+       struct irq_desc *desc;
+
+       irq_enter();
+       exit_idle();
+
+       desc = irq_to_desc(vmbus_irq);
+
+       if (desc)
+               generic_handle_irq_desc(vmbus_irq, desc);
+
+       irq_exit();
+       set_irq_regs(old_regs);
+}
+#else
+void hv_register_vmbus_handler(int irq, irq_handler_t handler)
+{
+}
+#endif
+EXPORT_SYMBOL_GPL(hv_register_vmbus_handler);
arch/x86/kernel/entry_32.S +8 -1
index 6ed91d9..8831176 100644
@@ -1091,11 +1091,18 @@ ENTRY(xen_failsafe_callback)
        _ASM_EXTABLE(4b,9b)
 ENDPROC(xen_failsafe_callback)
 
-BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
+BUILD_INTERRUPT3(xen_hvm_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
                xen_evtchn_do_upcall)
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+
+BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
+       hyperv_vector_handler)
+
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_FUNCTION_TRACER
 #ifdef CONFIG_DYNAMIC_FTRACE
 
arch/x86/kernel/entry_64.S +0 -1
index cb3c591..048f224 100644
@@ -1454,11 +1454,16 @@ ENTRY(xen_failsafe_callback)
        CFI_ENDPROC
 END(xen_failsafe_callback)
 
-apicinterrupt XEN_HVM_EVTCHN_CALLBACK \

arch/x86/kernel/entry_64.S ENTRY(xen_failsafe_callback) · line 1466

Quoted 10 lines
arch/x86/kernel/entry_64.S +6 -0
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
        xen_hvm_callback_vector xen_evtchn_do_upcall
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+       hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+

so #ifdef CONFIG_HYPERV does not work here?

Yinghai

#34 lore raw

RE: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 192 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yinghai Lu
Sent: Tuesday, February 12, 2013 9:56 PM
To: [email protected]; [email protected]; [email protected]; KY Srinivasan; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 2 lines · tip-bot for K. Y. Srinivasan

Commit-ID: bc2b0331e077f576369a2b6c75d15ed4de4ef91f Gitweb:

http://git.kernel.org/tip/bc2b0331e077f576369a2b6c75d15ed4de4ef91f

Quoted 13 lines
Author:     K. Y. Srinivasan <[email protected]>
AuthorDate: Sun, 3 Feb 2013 17:22:39 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 12 Feb 2013 16:27:15 -0800

X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Starting with win8, vmbus interrupts can be delivered on any VCPU in the guest and furthermore can be concurrently active on multiple VCPUs. Support this interrupt delivery model by setting up a separate IDT entry for Hyper-V vmbus. interrupts. I would like to thank Jan Beulich <[email protected]> and Thomas Gleixner <[email protected]>, for their help.

Quoted 6 lines

In this version of the patch, based on the feedback, I have merged the IDT vector for Xen and Hyper-V and made the necessary adjustments. Furhermore, based on Jan's feedback I have added the necessary compilation switches.

[email protected]

Quoted 5 lines
---
 arch/x86/include/asm/irq_vectors.h |  4 ++--
 arch/x86/include/asm/mshyperv.h    |  4 ++++
 arch/x86/kernel/cpu/mshyperv.c     | 44

++++++++++++++++++++++++++++++++++++++

Review

Quoted 6 lines
 arch/x86/kernel/entry_32.S         |  9 +++++++-
 arch/x86/kernel/entry_64.S         |  7 +++++-
 drivers/xen/events.c               |  7 +++---
 6 files changed, 68 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/arch/x86/include/asm/irq_vectors.h

Review

Quoted 15 lines

index 1508e51..aac5fa6 100644

arch/x86/include/asm/irq_vectors.h +2 -2
@@ -109,8 +109,8 @@
 
 #define UV_BAU_MESSAGE                 0xf5
 
-/* Xen vector callback to receive events in a HVM domain */
-#define XEN_HVM_EVTCHN_CALLBACK                0xf3
+/* Vector on which hypervisor callbacks will be delivered */
+#define HYPERVISOR_CALLBACK_VECTOR     0xf3
 
 /*
  * Local APIC timer IRQ vector is on a different priority level,
(quoted diff) +0 -0

b/arch/x86/include/asm/mshyperv.h

Review

Quoted 13 lines

index 79ce568..c2934be 100644

arch/x86/include/asm/mshyperv.h +4 -0
@@ -11,4 +11,8 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
+void hyperv_callback_vector(void);
+void hyperv_vector_handler(struct pt_regs *regs);
+void hv_register_vmbus_handler(int irq, irq_handler_t handler);
+
 #endif
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 20 lines

index 4dab317..a7d26d8 100644

arch/x86/kernel/cpu/mshyperv.c +5 -0
@@ -14,10 +14,15 @@
 #include <linux/time.h>
 #include <linux/clocksource.h>
 #include <linux/module.h>
+#include <linux/hardirq.h>
+#include <linux/interrupt.h>
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 #include <asm/hyperv.h>
 #include <asm/mshyperv.h>
+#include <asm/desc.h>
+#include <asm/idle.h>
+#include <asm/irq_regs.h>
 
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);

arch/x86/kernel/cpu/mshyperv.c static void __init ms_hyperv_init_platform(void) · line 89

Quoted 8 lines
arch/x86/kernel/cpu/mshyperv.c +5 -0
@@ -77,6 +82,12 @@ static void __init ms_hyperv_init_platform(void)
 
        if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
                clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+#if IS_ENABLED(CONFIG_HYPERV)
+       /*
+        * Setup the IDT for hypervisor callback.
+        */
+       alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,

hyperv_callback_vector);

arch/x86/kernel/cpu/mshyperv.c const __refconst struct hypervisor_x86

Quoted 5 lines
arch/x86/kernel/cpu/mshyperv.c +1 -0
+#endif
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
@@ -85,3 +96,36 @@ const __refconst struct hypervisor_x86

x86_hyper_ms_hyperv = {

Quoted 41 lines
arch/x86/kernel/cpu/mshyperv.c +33 -0
        .init_platform          = ms_hyperv_init_platform,
 };
 EXPORT_SYMBOL(x86_hyper_ms_hyperv);
+
+#if IS_ENABLED(CONFIG_HYPERV)
+static int vmbus_irq = -1;
+static irq_handler_t vmbus_isr;
+
+void hv_register_vmbus_handler(int irq, irq_handler_t handler)
+{
+       vmbus_irq = irq;
+       vmbus_isr = handler;
+}
+
+void hyperv_vector_handler(struct pt_regs *regs)
+{
+       struct pt_regs *old_regs = set_irq_regs(regs);
+       struct irq_desc *desc;
+
+       irq_enter();
+       exit_idle();
+
+       desc = irq_to_desc(vmbus_irq);
+
+       if (desc)
+               generic_handle_irq_desc(vmbus_irq, desc);
+
+       irq_exit();
+       set_irq_regs(old_regs);
+}
+#else
+void hv_register_vmbus_handler(int irq, irq_handler_t handler)
+{
+}
+#endif
+EXPORT_SYMBOL_GPL(hv_register_vmbus_handler);
arch/x86/kernel/entry_32.S +0 -0
index 6ed91d9..8831176 100644

arch/x86/kernel/entry_32.S ENTRY(xen_failsafe_callback) · line 1094

Quoted 4 lines
arch/x86/kernel/entry_32.S +0 -1
@@ -1091,11 +1091,18 @@ ENTRY(xen_failsafe_callback)
        _ASM_EXTABLE(4b,9b)
 ENDPROC(xen_failsafe_callback)
 
-BUILD_INTERRUPT3(xen_hvm_callback_vector,

XEN_HVM_EVTCHN_CALLBACK,

arch/x86/kernel/entry_32.S ENTRY(xen_failsafe_callback) · line 1094

Quoted 1 line
arch/x86/kernel/entry_32.S +1 -0
+BUILD_INTERRUPT3(xen_hvm_callback_vector,

HYPERVISOR_CALLBACK_VECTOR,

arch/x86/kernel/entry_32.S ENTRY(xen_failsafe_callback)

Quoted 7 lines
arch/x86/kernel/entry_32.S +3 -0
                xen_evtchn_do_upcall)
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+
+BUILD_INTERRUPT3(hyperv_callback_vector,

HYPERVISOR_CALLBACK_VECTOR,

Quoted 21 lines
arch/x86/kernel/entry_32.S +4 -0
+       hyperv_vector_handler)
+
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_FUNCTION_TRACER
 #ifdef CONFIG_DYNAMIC_FTRACE
 
arch/x86/kernel/entry_64.S +1 -1
index cb3c591..048f224 100644
@@ -1454,11 +1454,16 @@ ENTRY(xen_failsafe_callback)
        CFI_ENDPROC
 END(xen_failsafe_callback)
 
-apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
        xen_hvm_callback_vector xen_evtchn_do_upcall
 
 #endif /* CONFIG_XEN */
 
Quoted 7 lines

arch/x86/kernel/entry_64.S ENTRY(xen_failsafe_callback) · line 1466

Quoted 5 lines
arch/x86/kernel/entry_64.S +5 -0
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+       hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+

so #ifdef CONFIG_HYPERV does not work here?

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

Regards,

K. Y

Quoted 3 lines

Yinghai

#35 lore raw

Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 9 lines · KY Srinivasan
Quoted 8 lines

arch/x86/kernel/entry_64.S ENTRY(xen_failsafe_callback) · line 1466

Quoted 6 lines
arch/x86/kernel/entry_64.S +5 -0
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+       hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+

so #ifdef CONFIG_HYPERV does not work here?

Quoted 3 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#36 lore raw

RE: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 21 lines

-----Original Message-----
From: H. Peter Anvin [mailto:[email protected]]
Sent: Tuesday, February 12, 2013 10:46 PM
To: KY Srinivasan
Cc: Yinghai Lu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 9 lines · KY Srinivasan
Quoted 8 lines

arch/x86/kernel/entry_64.S ENTRY(xen_failsafe_callback) · line 1466

Quoted 6 lines
arch/x86/kernel/entry_64.S +5 -0
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
+       hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+

so #ifdef CONFIG_HYPERV does not work here?

Quoted 6 lines
Quoted 3 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

My mistake!

K. Y

Quoted 8 lines

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#37 lore raw

Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 10 lines · KY Srinivasan
Quoted 7 lines
Quoted 4 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

My mistake!

Well, which one do you need?

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#38 lore raw

RE: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 17 lines

-----Original Message-----
From: H. Peter Anvin [mailto:[email protected]]
Sent: Tuesday, February 12, 2013 10:55 PM
To: KY Srinivasan
Cc: Yinghai Lu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 5 lines · KY Srinivasan
Quoted 5 lines
Quoted 4 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

My mistake!

Well, which one do you need?

I chose the IS_ENABLED() because I wanted to cover the case where HYPERV is configured as a module as well.

K. Y

Quoted 9 lines

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#39 lore raw

Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 20 lines · KY Srinivasan
Quoted 20 lines

-----Original Message-----
From: H. Peter Anvin [mailto:[email protected]]
Sent: Tuesday, February 12, 2013 10:55 PM
To: KY Srinivasan
Cc: Yinghai Lu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 8 lines · KY Srinivasan
Quoted 7 lines
Quoted 4 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

My mistake!

Well, which one do you need?

I chose the IS_ENABLED() because I wanted to cover the case where HYPERV is configured as a module as well.

ok, so when HYPERV is built as module, actually it is partially module as it put some code built-in already?
if user never load hyperv, those code will never not be used.

Can those code not be put in module _init function?

Thanks

Yinghai

#40 lore raw

RE: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 39 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yinghai Lu
Sent: Tuesday, February 12, 2013 11:43 PM
To: KY Srinivasan
Cc: H. Peter Anvin; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 20 lines · KY Srinivasan
Quoted 20 lines

-----Original Message-----
From: H. Peter Anvin [mailto:[email protected]]
Sent: Tuesday, February 12, 2013 10:55 PM
To: KY Srinivasan
Cc: Yinghai Lu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [tip:x86/hyperv] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 8 lines · KY Srinivasan
Quoted 7 lines
Quoted 4 lines

The issue was that you could turn on CONFIG_HYPERV without enabling CONFIG_X86_LOCAL_APIC. Peter fixed it.

He is asking why you are using IS_ENABLED() instead of #ifdef. The difference is that IS_ENABLED() works even for modules.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

My mistake!

Well, which one do you need?

I chose the IS_ENABLED() because I wanted to cover the case where HYPERV is

Quoted 8 lines

configured as a module as well.

Quoted 1 line

ok, so when HYPERV is built as module, actually it is partially module as it put some code built-in already?
if user never load hyperv, those code will never not be used.

Can those code not be put in module _init function?

Some code in mshyperv.c is built into the kernel. Registering an IDT entry is dependent on HYPERV drivers being configured - either as modules or built-in.

K. Y

Quoted 5 lines

Thanks

Yinghai

#4 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to K. Y. Srinivasan
Quoted 5 lines · K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Could you enlighten me please? :)

Quoted 30 lines
---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +7 -0
index 646d192..4dab317 100644
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
Signature · 7 lines
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#5 lore raw

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Hi!

Short:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

VVM>> KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

Quoted 1 line

It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems

Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:

==
KVM emulates Hyper-V to host enlightened Windows.

. . .

[ hpa: the problem here is that KVM doesn't emulate Hyper-V well
enough, . . ]

. . .

+ * KVM emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a KVM Hypervisor.
+ if (KVM_cpuid_base())
+ return false;
. . .
==

Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?

--
Full:

----- Original Message ----- From: "Michael S. Tsirkin"
To: "K. Y. Srinivasan"
Cc:
Sent: Wednesday, April 17, 2013 10:06 AM
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 14 lines · K. Y. Srinivasan
Quoted 5 lines

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

Signed-off-by K. Y. Srinivasan kys (at) microsoft.com

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

Quoted 6 lines

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Could you enlighten me please? :)

Short history of question:

{{
==

Quoted 10 lines
Quoted 3 lines

And hypercall has its own set of problems with Windows guests. When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

Can't we simply register a hypercall ID range with Microsoft?

Quoted 2 lines

may also affect WHQLing Windows drivers since driver will talk to HW bypassing Windows interfaces.

Then the WHQL'ed driver doesn't support the PV MMIO hcall?

==

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
}}

{{

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems:

==
Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*

+  * Xen emulates Hyper-V to support enlightened Windows.
+  * Check to see first if we are on a Xen Hypervisor.
+  */

+ if (xen_cpuid_base())
+ return false;
+
==
}}

Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:

==
KVM emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on KVM.

[ hpa: the problem here is that KVM doesn't emulate Hyper-V well
enough, and if the KVM support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*

+  * KVM emulates Hyper-V to support enlightened Windows.
+  * Check to see first if we are on a KVM Hypervisor.
+  */

+ if (KVM_cpuid_base())
+ return false;
+
==

Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.

----- Original Message ----- From: "Michael S. Tsirkin"
To: "Victor Miasnikov"
Sent: Wednesday, April 17, 2013 10:07 AM

I'm not sure what are we talking about then, but please use the mailing list appropriate for the subject.

----- Original Message ----- From: "Victor Miasnikov" vvm (a) tut (dot) by
To: "Michael S. Tsirkin"
Cc: "KY Srinivasan"
Sent: Tuesday, April 16, 2013 9:36 AM
Subject: Are You shue what is 100% _full_ emulation of Hyper-V? Re: It's not related Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

Hi!

Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems:

==
Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*

+  * Xen emulates Hyper-V to support enlightened Windows.
+  * Check to see first if we are on a Xen Hypervisor.
+  */

+ if (xen_cpuid_base())
+ return false;
+
==

( full see ib P.S.)

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.

==
----- Original Message ----- From: "tip-bot for K. Y. Srinivasan"

. . .

Sent: Wednesday, February 13, 2013 3:57 AM
Subject: [tip:x86/hyperv] X86: Add a check to catch Xen emulation of Hyper-V

Commit-ID:  db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Gitweb:     http://git.kernel.org/tip/db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Author:     K. Y. Srinivasan
AuthorDate: Sun, 3 Feb 2013 17:22:38 -0800
Committer:  H. Peter Anvin
CommitDate: Tue, 12 Feb 2013 16:27:03 -0800

X86: Add a check to catch Xen emulation of Hyper-V

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

Signed-off-by K. Y. Srinivasan
Signed-off-by H. Peter Anvin

---
arch/x86/kernel/cpu/mshyperv.c | 7 +++++++

1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/mshyperv.c +7 -0
index 646d192..4dab317 100644
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
  return false;
 
+ /*
+  * Xen emulates Hyper-V to support enlightened Windows.
+  * Check to see first if we are on a Xen Hypervisor.
+  */
+ if (xen_cpuid_base())
+  return false;
+
 cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
       &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 

--
==

----- Original Message ----- From: "Michael S. Tsirkin"
To: "Victor Miasnikov" vvm (a) tut (dot) by
Sent: Tuesday, April 16, 2013 1:11 AM
Subject: Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Fw: When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.

Quoted 12 lines · Victor Miasnikov
Quoted 11 lines

==

Quoted 9 lines
Quoted 3 lines

And hypercall has its own set of problems with Windows guests. When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

Can't we simply register a hypercall ID range with Microsoft?

Quoted 2 lines

may also affect WHQLing Windows drivers since driver will talk to HW bypassing Windows interfaces.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Then the WHQL'ed driver doesn't support the PV MMIO hcall?

==

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

It's not related.

----- Original Message ----- From: "Victor Miasnikov" vvm (a) tut (dot) by
To: "Michael S. Tsirkin"
Sent: Monday, April 15, 2013 4:00 PM
Subject: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Fw: When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.

Hi!

==

Quoted 10 lines
Quoted 3 lines

And hypercall has its own set of problems with Windows guests. When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
Mixing KVM hypercalls and Hyper-V requires some tricks. It

Can't we simply register a hypercall ID range with Microsoft?

Quoted 2 lines

may also affect WHQLing Windows drivers since driver will talk to HW bypassing Windows interfaces.

Then the WHQL'ed driver doesn't support the PV MMIO hcall?

==

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

#6 lore raw

Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · Victor Miasnikov

Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:

==
KVM emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on KVM.

Quoted 5 lines

[ hpa: the problem here is that KVM doesn't emulate Hyper-V well
enough, and if the KVM support isn't compiled in, we end up stubling over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

What's emulated not well enough?

Review

Quoted 4 lines

+ /*

(quoted diff) +3 -0
+  * KVM emulates Hyper-V to support enlightened Windows.
+  * Check to see first if we are on a KVM Hypervisor.
+  */

If the hypervisor says it's Hyper-V, that's because it wants guests to use Hyper-V. I don't see why is guest second-guessing this a good idea.

Quoted 6 lines

+ if (KVM_cpuid_base())

arch/x86/kernel/cpu/mshyperv.c +2 -0
+  return false;
+

==

Quoted 7 lines

Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.

No. You are using Hyper-V, not the KVM emulation of it. No patches dealing with this emulation should have any effect on you.

Signature · 1 line
MST
#7 lore raw

Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 4 lines
Quoted 1 line
Quoted 1 line · Michael S. Tsirkin

If the hypervisor says it's Hyper-V, that's because it wants guests to use Hyper-V. I don't see why is guest second-guessing this a good idea.

There are two reasons here: For one, when the hypervisor is not Hyper-V, but is providing some Hyper-V emulation, that's intended for Windows guests to use, not e.g. Linux ones, especially when such guests could use the native hypervisor interface with much greater benefit.

And second, there reportedly are features of (newer?) Hyper-V that some emulation may not provide, but that are also not easily detectable.

Jan

#8 lore raw

Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Michael S. Tsirkin

If the hypervisor says it's Hyper-V, that's because it wants guests to use Hyper-V. I don't see why is guest second-guessing this a good idea.

There are two reasons here: For one, when the hypervisor is not Hyper-V, but is providing some Hyper-V emulation, that's intended for Windows guests to use, not e.g. Linux ones,

Fact is that this patch changed the guest/hypervisor interface which should not be done lightly. We don't know all uses that Linux is put to. I gave what seems, to me, like a perfectly valid reason to use hyper-v emulation with Linux guests, which you snipped out :) Below is a scanario that will now be broken:
>>>It seems that one might want to use hyper-v emulation e.g. to test >>>hyper-v code without using windows, so the functionality >>>that this patch disables is not completely useless,
There could be others.

Quoted 2 lines

such guests could use the native hypervisor interface with much greater benefit.

Why not disable the emulation in the hypervisor? What overriding the hypervisor will lead to, is hypervisors will try harder and mask their real identity. No one will win in this arms race.

Quoted 5 lines

And second, there reportedly are features of (newer?) Hyper-V that some emulation may not provide, but that are also not easily detectable.

Jan

Could you be more explicit please? What are these features? How does a windows guest able to use them if they are both new and not detectable? Why not just fix the emulation? How will Linux use the new features when e.g. Xen adds them?

Signature · 1 line
MST
#12 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin
Quoted 26 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 5 lines · K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

Quoted 6 lines

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests. Clearly, this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen. Not all Hyper-V features are tagged with a CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Regards,

K. Y

Quoted 33 lines

Review

Quoted 6 lines
---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 25 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +7 -1
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#10 lore raw

Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to a message not in the archive
Quoted 40 lines · Victor M.

Hi!

2013/4/17 Jan Beulich

Quoted 4 lines
Quoted 1 line
Quoted 1 line · Michael S. Tsirkin

If the hypervisor says it's Hyper-V, that's because it wants guests to use Hyper-V. I don't see why is guest second-guessing this a good idea.

There are two reasons here: For one, when the hypervisor is not Hyper-V, but is providing some Hyper-V emulation, that's intended for Windows guests to use, not e.g. Linux ones, especially when such guests could use the native hypervisor interface with much greater benefit.

And second, there reportedly are features of (newer?) Hyper-V that some emulation may not provide, but that are also not easily detectable.

Yes

+

Quoted 7 lines · Victor Miasnikov
Quoted 6 lines

Question is very simple:  Hyper-V users/sysadmins need wait patch a-la this:
Or

"KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V emulates Hyper-V" as "Hyper-V emulates

Quoted 4 lines
Quoted 2 lines

Hyper-V" ?

No.  You are using Hyper-V, not the

Quoted 8 lines

KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V

Quoted 2 lines

emulation of it.
No patches dealing with this emulation should have any effect on you.

 This is _positive_ variant of possible future,
but on _practic_ very often we need prevent _negative_ variant of possible future

I don't really know what this means.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

==
+ /*
+  *

KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V emulates Hyper-V to support

Quoted 2 lines
Quoted 2 lines

enlightened Windows.
+  * Check to see first if we are on a

KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V

Quoted 4 lines
Quoted 4 lines

Hypervisor.
+  */
+
+ if

(KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V_cpuid_base ())

Quoted 3 lines
Quoted 1 line

+  return false;

Quoted 6 lines
Quoted 1 line

If the hypervisor says it's Hyper-V, that's because it wants guests to use

Hyper-V.

Quoted 1 line

 Even if guest ( i.e. Virtual Computer) contain Linux OS ?

Why not? If you don't want the hypervisor to emulate hyper-v, just don't tell it to emulate hyper-v.

Quoted 78 lines
Quoted 3 lines
Quoted 3 lines

== KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V

emulates Hyper-V to host enlightened

Quoted 6 lines
Quoted 6 lines

Windows.

. . .

[ hpa: the problem here is that KVM_and_or_XEN_or_other_Hypervisor_what_has_non-full-emulation_of_Hyper-V

doesn't emulate Hyper-V well enough,  .

Quoted 4 lines
Quoted 1 line

  . ]

What's emulated not well enough?

 In case of XEN variant non-full-emulation_of_Hyper-V , IMHO :

{{
----- Original Message -----
From: "Victor Miasnikov"
To: "Michael S. Tsirkin"
Sent: Wednesday, April 17, 2013 12:41 PM
Subject: IMHO, XEN emulation of Hyper-V not contain needed clocksource for Lunux guest Re: [PATCH 2/3] X86: Add a check
to catch Xen emulation of Hyper-V

Hi!

Quoted 4 lines

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

 As I undestand, XEN emulation of Hyper-V not contain  needed clocksource for Lunux guest ( virtual computers)

I.e. Linux VM "think" what is running on Hyper-V host call clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100) and a-la BSOD or vica verse . . .

Quoted 5 lines

I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

 IMHO, this related to:

- clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+ if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE) +  clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);

 See

https://lkml.org/lkml/2013/2/12/623
==
            Date Tue, 12 Feb 2013 16:56:07 -0800
            From tip-bot for Olaf Hering
            Subject [tip:x86/hyperv] x86: Hyper-V: register clocksource only if its advertised

 . . .

==

Best regards, Victor Miasnikov
}}

Quoted 2 lines

Best regards, Victor Miasnikov
Blog:  http://vvm.blog.tut.by/

Looks like a counter-example to me.

Apparently a Linux guest bug was found and fixed exactly because we trust the hypervisor. If it wasn't, and if in the future hyper-v hosts clear this feature bit, Linux will be broken.

Signature · 1 line
MST
#13 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to KY Srinivasan
Quoted 31 lines · KY Srinivasan
Quoted 31 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 5 lines · K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 7 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Quoted 34 lines
Quoted 33 lines

Review

Quoted 6 lines
---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 25 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +7 -1
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#24 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to KY Srinivasan
Quoted 3 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

To make this a little more precise - Xen is doing so only when the guest config tells it to.

Jan

#25 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 8 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

To make this a little more precise - Xen is doing so only when the guest config tells it to.

Jan

So it's something explicitly requested for this guest? Then I don't understand why does not make sense to override it in guest.

#11 lore raw

Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin

Hi!

Quoted 6 lines
Quoted 3 lines

This is _positive_ variant of possible future,
but on _practic_ very often we need prevent _negative_ variant of possible future

I don't really know what this means.

On practic: this means, that need test with KVM "Hyper-V emulation" not only Windows guest, but _all_ Linux guest

_all_ Linux need read -- not only RHEL, but -- Debian 7.X ( kernell v3.2 with own hotfixes set) , -- Ubuntu 12.04 LTS ( kernell v3.2 with hotfixes) -- Ubuntu 12.04.03 LTS ( kernell v3.5 with hotfixes)
-- Ubuntu 12.10 ( kernell v3.5 with hotfixes)
-- Linuxes with kernel v3.6 / or v3.7
-- Linuxes with latest stable kernel v3.8 ( for example Arch Linux)
-- other possible variants

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.
I'm personal not want, what KVM "Hyper-V emulation" initiative stopped implemented
If it work as need -- this is very good

#26 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Michael S. Tsirkin
Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

To make this a little more precise - Xen is doing so only when the guest config tells it to.

So it's something explicitly requested for this guest? Then I don't understand why does not make sense to override it in guest.

Iirc it was/is XenServer which enable Hyper-V emulation for all HVM guests, which clearly is the wrong thing. I was personally also not really in agreement with the override in the kernel, but it was decided to do it that way at that point in time. As a consequence, I don't object this to be reverted.

Jan

#28 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Quoted 7 lines
Quoted 4 lines

To make this a little more precise - Xen is doing so only when the guest config tells it to.

Jan

So it's something explicitly requested for this guest? Then I don't understand why does not make sense to override it in guest.

Typo, should have been "why does *it* make sense to override it in guest.

#14 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin
Quoted 66 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 8:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

[email protected];

Quoted 24 lines
Quoted 24 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 5 lines · K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 4 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Ideally, if Hyper-V could be emulated in a plug compatible way, in that the guest would not know
the difference as to whether Hyper-V was being emulated or indeed it was Hyper-V underneath, I would agree with you. Even in this case, I would argue that we would somehow give preference to the native implementation rather than the emulated environment. Having done the initial emulation of Hyper-V on Xen, I know the current emulation of Hyper-V is restricted to emulating a few features advertised via the CPUID bits. If I recall correctly, Xen did not implement the enlightened TLB flush scheme. Furthermore, none of the Hyper-V emulations implement the I/O related infrastructure. For Linux to run efficiently on Hyper-V, the I/O paths are significantly more important than what Hyper-V emulation there is in Xen and I suspect in KVM. So, I don't think we want to run Linux on Xen/KVM that is emulating Hyper-V (cpuids). The specific case I ran into that required this patch was when I moved the VMBUS interrupts to be delivered via a special hypervisor vector (to support full interrupt distribution amongst all VCPUs in the guest). This feature is not tagged in the CPUID feature bits and without this check, I would install an interrupt handler for the hypervisor vector that clearly did not make any sense in anything other than Hyper-V. I suspect there will be more such situations as we go forward.

Regards,

K. Y

Quoted 36 lines
Quoted 35 lines
Quoted 34 lines

Review

Quoted 7 lines

---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 25 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +7 -1
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#15 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 73 lines · KY Srinivasan
Quoted 66 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 8:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

[email protected];

Quoted 24 lines
Quoted 24 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 5 lines · K. Y. Srinivasan

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check and fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 4 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Quoted 8 lines

Ideally, if Hyper-V could be emulated in a plug compatible way, in that the guest would not know
the difference as to whether Hyper-V was being emulated or indeed it was Hyper-V underneath, I would agree with you. Even in this case, I would argue that we would somehow give preference to the native implementation rather than the emulated environment. Having done the initial emulation of Hyper-V on Xen, I know the current emulation of Hyper-V is restricted to emulating a few features advertised via the CPUID bits. If I recall correctly, Xen did not implement the enlightened TLB flush scheme. Furthermore, none of the Hyper-V emulations implement the I/O related infrastructure. For Linux to run efficiently on Hyper-V, the I/O paths are significantly more important than what Hyper-V emulation there is in Xen and I suspect in KVM. So, I don't think we want to run Linux on Xen/KVM that is emulating Hyper-V (cpuids).

No, it's a Xen specific bug. KVM in a hyper-v mode still emulates PCI
so can still use KVM PV devices which are all PCI devices. So there's no problem there.

Also, why override this in the guest? With time Xen hyper-v emulation might improve, meanwhile it's always possible to disable this in the hypervisor.

Quoted 8 lines

The specific case I ran into that required this patch was when I moved the VMBUS interrupts to be delivered via a special hypervisor vector (to support full interrupt distribution amongst all VCPUs in the guest). This feature is not tagged in the CPUID feature bits and without this check, I would install an interrupt handler for the hypervisor vector that clearly did not make any sense in anything other than Hyper-V. I suspect there will be more such situations as we go forward.

Regards,

K. Y

Why? Because there's no VMBUS on Xen? So check whether VMBUS exists?

Quoted 37 lines
Quoted 36 lines
Quoted 35 lines
Quoted 34 lines

Review

Quoted 7 lines

---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 25 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +7 -1
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
 
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#16 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 101 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 9:25 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 8:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

[email protected];

Quoted 13 lines
Quoted 13 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

Quoted 5 lines
Quoted 5 lines

[email protected];

Quoted 4 lines
Quoted 4 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of

Hyper-V

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · K. Y. Srinivasan
Quoted 2 lines

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check

and

Quoted 37 lines
Quoted 37 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines

fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 4 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Ideally, if Hyper-V could be emulated in a plug compatible way, in that the guest

would not know

Quoted 1 line

the difference as to whether Hyper-V was being emulated or indeed it was

Hyper-V underneath, I would agree with you.

Quoted 1 line

Even in this case, I would argue that we would somehow give preference to the

native implementation rather

Quoted 1 line

than the emulated environment. Having done the initial emulation of Hyper-V

on Xen, I know the current emulation of

Quoted 1 line

Hyper-V is restricted to emulating a few features advertised via the CPUID bits.

If I recall correctly, Xen did not implement

Quoted 1 line

the enlightened TLB flush scheme. Furthermore, none of the Hyper-V

emulations implement the I/O related infrastructure.

Quoted 8 lines
Quoted 1 line

For Linux to run efficiently on Hyper-V, the I/O paths are significantly more

important than what Hyper-V emulation there is

Quoted 1 line

in Xen and I suspect in KVM. So, I don't think we want to run Linux on Xen/KVM

that is emulating Hyper-V (cpuids).

No, it's a Xen specific bug. KVM in a hyper-v mode still emulates PCI so can still use KVM PV devices which are all PCI devices. So there's no problem there.

Even Xen does not have a problem here; Xen would install its PV drivers in the guest. So, the I/O infrastructure that would be installed in the guest would be based on the host.

Quoted 11 lines

Also, why override this in the guest? With time Xen hyper-v emulation might improve, meanwhile it's always possible to disable this in the hypervisor.

Quoted 1 line

The specific case I ran into that required this patch was when I moved the

VMBUS interrupts to be delivered via a special

Quoted 1 line

hypervisor vector (to support full interrupt distribution amongst all VCPUs in

the guest). This feature is not tagged in the CPUID

Quoted 1 line

feature bits and without this check, I would install an interrupt handler for the

hypervisor vector that clearly did not make

Quoted 8 lines
Quoted 1 line

any sense in anything other than Hyper-V. I suspect there will be more such

situations as we go forward.

Quoted 4 lines

Regards,

K. Y

Why? Because there's no VMBUS on Xen? So check whether VMBUS exists?

On Linux, Hyper-V detection is used to load hyper-V related drivers (VMBUS etc.). For the case in point, it was not clear to me how I could install the vmbus interrupt handler in a way that would make sense when Xen was unconditionally emulating Hyper-V.

Regards,

K. Y

Quoted 40 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

Review

Quoted 8 lines


---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 7 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +0 -0
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/x86/kernel/cpu/mshyperv.c static bool __init ms_hyperv_platform(void)

Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +7 -0
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1],

&hyp_signature[2]);

Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +0 -1
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#17 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 131 lines · KY Srinivasan
Quoted 101 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 9:25 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 8:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

[email protected];

Quoted 13 lines
Quoted 13 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

Quoted 5 lines
Quoted 5 lines

[email protected];

Quoted 4 lines
Quoted 4 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of

Hyper-V

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · K. Y. Srinivasan
Quoted 2 lines

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check

and

Quoted 37 lines
Quoted 37 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines

fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 4 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Ideally, if Hyper-V could be emulated in a plug compatible way, in that the guest

would not know

Quoted 1 line

the difference as to whether Hyper-V was being emulated or indeed it was

Hyper-V underneath, I would agree with you.

Quoted 1 line

Even in this case, I would argue that we would somehow give preference to the

native implementation rather

Quoted 1 line

than the emulated environment. Having done the initial emulation of Hyper-V

on Xen, I know the current emulation of

Quoted 1 line

Hyper-V is restricted to emulating a few features advertised via the CPUID bits.

If I recall correctly, Xen did not implement

Quoted 1 line

the enlightened TLB flush scheme. Furthermore, none of the Hyper-V

emulations implement the I/O related infrastructure.

Quoted 8 lines
Quoted 1 line

For Linux to run efficiently on Hyper-V, the I/O paths are significantly more

important than what Hyper-V emulation there is

Quoted 1 line

in Xen and I suspect in KVM. So, I don't think we want to run Linux on Xen/KVM

that is emulating Hyper-V (cpuids).

No, it's a Xen specific bug. KVM in a hyper-v mode still emulates PCI so can still use KVM PV devices which are all PCI devices. So there's no problem there.

Even Xen does not have a problem here; Xen would install its PV drivers in the guest. So, the I/O infrastructure that would be installed in the guest would be based on the host.

Quoted 18 lines

Also, why override this in the guest? With time Xen hyper-v emulation might improve, meanwhile it's always possible to disable this in the hypervisor.

Quoted 1 line

The specific case I ran into that required this patch was when I moved the

VMBUS interrupts to be delivered via a special

Quoted 1 line

hypervisor vector (to support full interrupt distribution amongst all VCPUs in

the guest). This feature is not tagged in the CPUID

Quoted 1 line

feature bits and without this check, I would install an interrupt handler for the

hypervisor vector that clearly did not make

Quoted 1 line

any sense in anything other than Hyper-V. I suspect there will be more such

situations as we go forward.

Quoted 4 lines

Regards,

K. Y

Quoted 8 lines
Quoted 1 line

Why? Because there's no VMBUS on Xen? So check whether VMBUS exists?

On Linux, Hyper-V detection is used to load hyper-V related drivers (VMBUS etc.). For the case in point, it was not clear to me how I could install the vmbus interrupt handler in a way that would make sense when Xen was unconditionally emulating Hyper-V.

Regards,

K. Y

For example, check whether there is anything on the vmbus?

Quoted 41 lines
Quoted 40 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

Review

Quoted 8 lines


---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 7 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +0 -0
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/x86/kernel/cpu/mshyperv.c static bool __init ms_hyperv_platform(void) · line 41

Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +7 -0
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1],

&hyp_signature[2]);

Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +0 -1
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#27 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

Iirc it was/is XenServer which enable Hyper-V emulation for all HVM guests, which clearly is the wrong thing. I was personally also not really in agreement with the override in the kernel, but it was decided to do it that way at that point in time. As a consequence, I don't object this to be reverted.

I was not exactly happy with the idea either. I'm sorry if I mixed up Xen and KVM.

Furthermore, as I recall, it only affected kernels where Xen was compiled out, or something like that.

It would definitely be best to fix the HyperV driver to be more robust... that may be important across HyperV releases, too.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#18 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

In reply to Michael S. Tsirkin
Quoted 159 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 9:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 9:25 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

[email protected];

Quoted 13 lines
Quoted 13 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 7 lines · KY Srinivasan
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 8:49 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

Quoted 5 lines
Quoted 5 lines

[email protected];

Quoted 4 lines
Quoted 4 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of

Hyper-V

Quoted 57 lines
Quoted 57 lines
Quoted 9 lines
Quoted 9 lines · KY Srinivasan
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 3:06 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; linux-

Quoted 5 lines
Quoted 5 lines

[email protected];

Quoted 4 lines
Quoted 4 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of

Hyper-V

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · K. Y. Srinivasan
Quoted 2 lines

Xen emulates Hyper-V to host enlightened Windows. Looks like this emulation may be turned on by default even for Linux guests. Check

and

Quoted 37 lines
Quoted 37 lines
Quoted 16 lines
Quoted 16 lines
Quoted 3 lines

fail Hyper-V detection if we are on Xen.

I'm very curious what's the specific bug that is fixed here? I went over the original discussion in
https://patchwork.kernel.org/patch/2064331/
and that's still not clear to me. Is there a configuration that is broken without this patch but starts working with this patch?

It seems that one might want to use hyper-v emulation e.g. to test hyper-v code without using windows, so the functionality that this patch disables is not completely useless,
so there should be a good reason for disabling it.

Quoted 6 lines
Quoted 1 line

Could you enlighten me please? :)

Michael,

If I recall correctly, the issue here was that Xen was enabling Hyper-V emulation un-conditionally even for Linux guests.

Okay so basically some Xen specific strangeness.

Quoted 4 lines

Clearly,
this was not the intention to begin with. This check was added to ensure that while hosting Linux we would not un-intentionally enable Hyper-V emulation in Xen.

What if you want to intentionally enable Hyper-V emulation in Xen? There's no way to do this now, right?

Quoted 4 lines

Not all Hyper-V features are tagged with a
CPUID feature bit and so it was agreed that it would be better to disable Hyper-V emulation when hosting Linux on Xen.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Regards,

K. Y

I was just asking whether there are any specific examples of a bug or is this change done just in case?

Ideally, if Hyper-V could be emulated in a plug compatible way, in that the

guest

Quoted 4 lines
Quoted 4 lines

would not know

Quoted 1 line

the difference as to whether Hyper-V was being emulated or indeed it was

Hyper-V underneath, I would agree with you.

Quoted 1 line

Even in this case, I would argue that we would somehow give preference to

the

Quoted 2 lines
Quoted 2 lines

native implementation rather

Quoted 1 line

than the emulated environment. Having done the initial emulation of

Hyper-V

Quoted 2 lines
Quoted 2 lines

on Xen, I know the current emulation of

Quoted 1 line

Hyper-V is restricted to emulating a few features advertised via the CPUID

bits.

Quoted 6 lines
Quoted 6 lines

If I recall correctly, Xen did not implement

Quoted 1 line

the enlightened TLB flush scheme. Furthermore, none of the Hyper-V

emulations implement the I/O related infrastructure.

Quoted 1 line

For Linux to run efficiently on Hyper-V, the I/O paths are significantly more

important than what Hyper-V emulation there is

Quoted 1 line

in Xen and I suspect in KVM. So, I don't think we want to run Linux on

Xen/KVM

Quoted 4 lines
Quoted 4 lines

that is emulating Hyper-V (cpuids).

No, it's a Xen specific bug. KVM in a hyper-v mode still emulates PCI so can still use KVM PV devices which are all PCI devices. So there's no

problem

Quoted 3 lines
Quoted 1 line

there.

Even Xen does not have a problem here; Xen would install its PV drivers in the

guest.

Quoted 1 line

So, the I/O infrastructure that would be installed in the guest would be based

on the

Quoted 11 lines

host.

Quoted 10 lines

Also, why override this in the guest? With time Xen hyper-v emulation might improve, meanwhile it's always possible to disable this in the hypervisor.

Quoted 1 line

The specific case I ran into that required this patch was when I moved the

VMBUS interrupts to be delivered via a special

Quoted 1 line

hypervisor vector (to support full interrupt distribution amongst all VCPUs in

the guest). This feature is not tagged in the CPUID

Quoted 1 line

feature bits and without this check, I would install an interrupt handler for

the

Quoted 10 lines
Quoted 9 lines

hypervisor vector that clearly did not make

Quoted 1 line

any sense in anything other than Hyper-V. I suspect there will be more such

situations as we go forward.

Quoted 4 lines

Regards,

K. Y

Why? Because there's no VMBUS on Xen? So check whether VMBUS exists?

On Linux, Hyper-V detection is used to load hyper-V related drivers (VMBUS

etc.). For the case in

Quoted 1 line

point, it was not clear to me how I could install the vmbus interrupt handler in a

Quoted 8 lines

way that would

Quoted 5 lines

make sense when Xen was unconditionally emulating Hyper-V.

Regards,

K. Y

For example, check whether there is anything on the vmbus?

I think the right solution to this problem is to ensure that the guest does not have to do what you are proposing. Based on the hypervisor detection, we load the drivers and setup the infrastructure to support these drivers. There is no independent way of verifying if the host is Windows other than the hypervisor detection code.

If Xen were to change where it would not unconditionally emulate Hyper-V, I would not be opposed to taking this check out.

K. Y

Quoted 45 lines
Quoted 28 lines
Quoted 28 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

Review

Quoted 9 lines



---
 arch/x86/kernel/cpu/mshyperv.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/x86/kernel/cpu/mshyperv.c

Quoted 7 lines

index 646d192..4dab317 100644

arch/x86/kernel/cpu/mshyperv.c +0 -0
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return false;
 
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/x86/kernel/cpu/mshyperv.c static bool __init ms_hyperv_platform(void) · line 41

Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +7 -0
+	/*
+	 * Xen emulates Hyper-V to support enlightened Windows.
+	 * Check to see first if we are on a Xen Hypervisor.
+	 */
+	if (xen_cpuid_base())
+		return false;
+
 	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
 	      &eax, &hyp_signature[0], &hyp_signature[1],

&hyp_signature[2]);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

--
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-

kernel" in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-

info.html

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Please read the FAQ at http://www.tux.org/lkml/

#19 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 4 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If Xen were to change where it would not unconditionally emulate Hyper-V, I would not be opposed to taking
this check out.

But it doesn't do this unconditionally, only upon admin request.

Jan

#20 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 11 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 11:51 AM
To: KY Srinivasan; Michael S. Tsirkin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If Xen were to change where it would not unconditionally emulate Hyper-V, I would not be opposed to taking
this check out.

But it doesn't do this unconditionally, only upon admin request.

From the discussion we had a couple of months ago, the default setting was to enable

Hyper-V emulation for all guests. If this is not the case, we ought to be able to drop this. However, I think it is not reasonable to add additional checks (in addition to hypervisor check) to customize the run-time in the guest for the specific Hypervisor.

Regards,

K. Y

Quoted 4 lines

Jan

#21 lore raw

Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 18 lines · KY Srinivasan
Quoted 17 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 11:51 AM
To: KY Srinivasan; Michael S. Tsirkin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 4 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If Xen were to change where it would not unconditionally emulate Hyper-V, I would not be opposed to taking
this check out.

But it doesn't do this unconditionally, only upon admin request.

Quoted 8 lines
Quoted 1 line

From the discussion we had a couple of months ago, the default setting was to enable

Hyper-V emulation for all guests. If this is not the case, we ought to be able to drop this. However, I think it is not reasonable to add additional checks (in addition to hypervisor check) to customize the run-time in the guest for the specific Hypervisor.

Regards,

K. Y

Parse error. What are you trying to say? I'm just saying it's best to do things in the way that make it possible for Xen to implement hyperv in a more complete way in the future and have things just work and in a way that does not change guest/hypervisor interface.

Quoted 5 lines
Quoted 4 lines

Jan

#22 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 41 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Thursday, April 18, 2013 3:48 AM
To: KY Srinivasan
Cc: Jan Beulich; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 8 lines · KY Srinivasan
Quoted 8 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 11:51 AM
To: KY Srinivasan; Michael S. Tsirkin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected];

[email protected];

Quoted 5 lines
Quoted 5 lines

[email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 2 lines
Quoted 1 line
Quoted 1 line · KY Srinivasan

If Xen were to change where it would not unconditionally emulate Hyper-V,

I

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

would not be opposed to taking
this check out.

But it doesn't do this unconditionally, only upon admin request.

From the discussion we had a couple of months ago, the default setting was to

enable

Quoted 1 line

Hyper-V emulation for all guests. If this is not the case, we ought to be able to

drop this.

Quoted 1 line

However, I think it is not reasonable to add additional checks (in addition to

hypervisor check)

Quoted 2 lines

to customize the run-time in the guest for the specific Hypervisor.

Quoted 8 lines
Quoted 3 lines

Regards,

K. Y

Parse error. What are you trying to say? I'm just saying it's best to do things in the way that make it possible for Xen to implement hyperv in a more complete way in the future and have things just work and in a way that does not change guest/hypervisor interface.

There is no error to parse here. I need to setup the vmbus interrupt before I
can contact the host. As I said I am fine with dropping this check if Xen behavior is changed appropriately. We have a mechanism for hypervisor detection and a mechanism for discovering features within a hypervisor. Once we confirm the existence of a specific hypervisor, we ought to be able to do what is needed for that hypervisor (unless the hypervisor feature flag precludes it) without having to go through hoops to discover if we are in a hypervisor emulation mode where the emulation may not be complete. In this particular case, the need for VMBUS related infrastructure cannot be currently determined via the feature detection mechanism.

For features that cannot be detected via CPUID feature bits, we can use some other CPUID based mechanism to discriminate. For instance in the case under discussion, I could install hyperv_callback_vector only if we are on an environment that supports the vmbus infrastructure. Unfortunately there is no positive test for this. The best we can do is a negative test. I could move the Xen check and conditionally install the hyperv_callback vector.

Regards,

K. Y

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

Jan

#23 lore raw

RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 78 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of KY Srinivasan
Sent: Thursday, April 18, 2013 9:23 AM
To: Michael S. Tsirkin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jan Beulich; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 13 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Thursday, April 18, 2013 3:48 AM
To: KY Srinivasan
Cc: Jan Beulich; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Quoted 2 lines · KY Srinivasan
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 11:51 AM
To: KY Srinivasan; Michael S. Tsirkin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines

[email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-

V

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines · KY Srinivasan

If Xen were to change where it would not unconditionally emulate Hyper-

V,

Quoted 7 lines

I

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

would not be opposed to taking
this check out.

But it doesn't do this unconditionally, only upon admin request.

From the discussion we had a couple of months ago, the default setting was

to

Quoted 7 lines

enable

Quoted 1 line

Hyper-V emulation for all guests. If this is not the case, we ought to be able to

drop this.

Quoted 1 line

However, I think it is not reasonable to add additional checks (in addition to

hypervisor check)

Quoted 2 lines

to customize the run-time in the guest for the specific Hypervisor.

Quoted 8 lines
Quoted 3 lines

Regards,

K. Y

Parse error. What are you trying to say? I'm just saying it's best to do things in the way that make it possible for Xen to implement hyperv in a more complete way in the future and have things just work and in a way that does not change guest/hypervisor interface.

There is no error to parse here. I need to setup the vmbus interrupt before I can contact the host. As I said I am fine with dropping this check if Xen behavior is changed appropriately. We have a mechanism for hypervisor detection and a mechanism for discovering features within a hypervisor. Once we confirm the existence of a specific hypervisor, we ought to be able to do what is needed for that hypervisor (unless the hypervisor feature flag precludes it) without having to go through hoops to discover if we are in a hypervisor emulation mode where the emulation
may not be complete. In this particular case, the need for VMBUS related infrastructure cannot be
currently determined via the feature detection mechanism.

Quoted 9 lines

For features that cannot be detected via CPUID feature bits, we can use some other CPUID based
mechanism to discriminate. For instance in the case under discussion, I could install
hyperv_callback_vector only if we are on an environment that supports the vmbus infrastructure.
Unfortunately there is no positive test for this. The best we can do is a negative test. I could move the
Xen check and conditionally install the hyperv_callback vector.

Michael,

I think I can address the problem you have raised. I will send a patch out soon.

Regards,

K. Y

Quoted 20 lines

Regards,

K. Y

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

Jan

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel