Skip to contentSkip to conversation

X86: Handle Xen emulation of Hyper-V more gracefully

PATCH In review K. Y. Srinivasan 4 participants 4 messages Apr 18, 2013

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

PATCH 1/1 X86: Handle Xen emulation of Hyper-V more gracefully

Install the Hyper-V specific interrupt handler only when needed. This would permit us to get rid of the Xen check. Note that when the vmbus drivers invokes the call to register its handler, we are sure to be running on Hyper-V.

---
 arch/x86/kernel/cpu/mshyperv.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +5 -13
index a7d26d8..8f4be53 100644
@@ -35,13 +35,6 @@ 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]);
 
@@ -82,12 +75,6 @@ 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 = {
@@ -103,6 +90,11 @@ static irq_handler_t vmbus_isr;
 
 void hv_register_vmbus_handler(int irq, irq_handler_t handler)
 {
+	/*
+	 * Setup the IDT for hypervisor callback.
+	 */
+	alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
+
 	vmbus_irq = irq;
 	vmbus_isr = handler;
 }
Signature · 1 line
1.7.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · K. Y. Srinivasan

Install the Hyper-V specific interrupt handler only when needed. This would permit us to get rid of the Xen check. Note that when the vmbus drivers invokes the call to register its handler, we are sure to be running on Hyper-V.

Looks good to me, this will address the concern. FWIW

Any chance we can fast-path this patch into 3.9 so that we don't release a kernel with hyper-v on Xen completely disabled?

Quoted 49 lines
---
 arch/x86/kernel/cpu/mshyperv.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +5 -13
index a7d26d8..8f4be53 100644
@@ -35,13 +35,6 @@ 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]);
 
@@ -82,12 +75,6 @@ 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 = {
@@ -103,6 +90,11 @@ static irq_handler_t vmbus_isr;
 
 void hv_register_vmbus_handler(int irq, irq_handler_t handler)
 {
+	/*
+	 * Setup the IDT for hypervisor callback.
+	 */
+	alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
+
 	vmbus_irq = irq;
 	vmbus_isr = handler;
 }
Signature · 1 line
1.7.4.1
#2 lore raw

Please, apply patch both 3.10 and 3.9 Re: [PATCH 1/1] X86: Handle Xen emulation of Hyper-V more gracefully

Hi!

Quoted 6 lines
Quoted 6 lines

- /*
- * 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;

. . .

Quoted 7 lines
Quoted 7 lines

void hv_register_vmbus_handler(int irq, irq_handler_t handler) {
+ /*
+ * Setup the IDT for hypervisor callback.
+ */
+ alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector); +

Michael S. Tsirkin> Any chance we can fast-path this patch into 3.9 so Michael S. Tsirkin> that we don't release a kernel with hyper-v on Xen completely disabled?

Yes, this backport from linux-next ( future 3.10 ) to 3.9 ( on 2013-04-18 -- 3.9-rc(7+N) ) look like usefull . . .

Please, apply patch both 3.10 and 3.9

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

----- Original Message ----- From: "Michael S. Tsirkin" To: "K. Y. Srinivasan" Cc:
Sent: Thursday, April 18, 2013 5:17 PM
Subject: Re: [PATCH 1/1] X86: Handle Xen emulation of Hyper-V more gracefully

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

Install the Hyper-V specific interrupt handler only when needed. This would permit us to get rid of the Xen check. Note that when the vmbus drivers invokes the call to register its handler, we are sure to be running on Hyper-V.

Quoted 10 lines
Quoted 1 line
Signed-off-by K. Y. Srinivasan

Looks good to me, this will address the concern. FWIW

Acked-by Michael S. Tsirkin

Any chance we can fast-path this patch into 3.9 so that we don't release a kernel with hyper-v on Xen completely disabled?

Quoted 1 line

---

. . .

Quoted 12 lines
Quoted 12 lines

- /*
- * 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;

arch/x86/kernel/cpu/mshyperv.c +0 -1
-
 cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
       &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
@@ -82,12 +75,6 @@ static void __init ms_hyperv_init_platform(void)
 
Quoted 9 lines

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

Quoted 9 lines
arch/x86/kernel/cpu/mshyperv.c +0 -6
 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
 }

. . .

Quoted 8 lines

arch/x86/kernel/cpu/mshyperv.c static irq_handler_t vmbus_isr; · line 98

Quoted 8 lines
arch/x86/kernel/cpu/mshyperv.c +5 -0
 void hv_register_vmbus_handler(int irq, irq_handler_t handler)
 {
+ /*
+ * Setup the IDT for hypervisor callback.
+ */
+ alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
+
 vmbus_irq = irq;

. . .

Quoted 1 line
Quoted 1 line
#3 lore raw

[tip:x86/urgent] x86, hyperv: Handle Xen emulation of Hyper-V more gracefully

In reply to K. Y. Srinivasan
x86, hyperv: Handle Xen emulation of Hyper-V more gracefully
Commit-ID:  7eff7ded02d1b15ba8321664839b353fa6c0c1e4
Gitweb:     http://git.kernel.org/tip/7eff7ded02d1b15ba8321664839b353fa6c0c1e4
Author:     K. Y. Srinivasan <[email protected]>
AuthorDate: Thu, 18 Apr 2013 08:44:46 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Thu, 18 Apr 2013 08:59:20 -0700

x86, hyperv: Handle Xen emulation of Hyper-V more gracefully

Install the Hyper-V specific interrupt handler only when needed. This would permit us to get rid of the Xen check. Note that when the vmbus drivers invokes the call to register its handler, we are sure to be running on Hyper-V.

---
 arch/x86/kernel/cpu/mshyperv.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +5 -13
index a7d26d8..8f4be53 100644
@@ -35,13 +35,6 @@ 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]);
 
@@ -82,12 +75,6 @@ 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 = {
@@ -103,6 +90,11 @@ static irq_handler_t vmbus_isr;
 
 void hv_register_vmbus_handler(int irq, irq_handler_t handler)
 {
+	/*
+	 * Setup the IDT for hypervisor callback.
+	 */
+	alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector);
+
 	vmbus_irq = irq;
 	vmbus_isr = handler;
 }