Skip to contentSkip to conversation

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

PATCH Superseded K. Y. Srinivasan 5 participants 11 messages Jan 18, 2013 – Jan 23, 2013

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

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

---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39 ++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
arch/x86/include/asm/irq_vectors.h +2 -0
index 1508e51..c2ff239 100644
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2
 /*
  * Local APIC timer IRQ vector is on a different priority level,
  * to work around the 'lost local interrupt if more than 2 IRQ
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 +39 -0
index 0a630dd..03be583 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);
@@ -69,6 +74,11 @@ static void __init ms_hyperv_init_platform(void)
 	       ms_hyperv.features, ms_hyperv.hints);
 
 	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+
+	/*
+	 * Setup the IDT for hypervisor callback.
+	 */
+	alloc_intr_gate(HYPER_V_CALLBACK_VECTOR, hyperv_callback_vector);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
@@ -77,3 +87,32 @@ const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
 	.init_platform		= ms_hyperv_init_platform,
 };
 EXPORT_SYMBOL(x86_hyper_ms_hyperv);
+
+static int vmbus_irq;
+static irq_handler_t vmbus_isr;
+
+void hv_register_vmbus_handler(int irq, irq_handler_t handler)
+{
+	vmbus_irq = irq;
+	vmbus_isr = handler;
+}
+EXPORT_SYMBOL_GPL(hv_register_vmbus_handler);
+
+void hyperv_vector_handler(struct pt_regs *regs)
+{
+	struct pt_regs *old_regs = set_irq_regs(regs);
+	struct irq_desc *desc;
+
+	irq_enter();
+#ifdef CONFIG_X86
+	exit_idle();
+#endif
+
+	desc = irq_to_desc(vmbus_irq);
+
+	if (desc)
+		generic_handle_irq_desc(vmbus_irq, desc);
+
+	irq_exit();
+	set_irq_regs(old_regs);
+}
arch/x86/kernel/entry_32.S +7 -0
index e9dd4c4..7743876 100644
@@ -1052,6 +1052,13 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
 
 #endif	/* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+
+BUILD_INTERRUPT3(hyperv_callback_vector, HYPER_V_CALLBACK_VECTOR,
+	hyperv_vector_handler)
+
+#endif /* CONFIG_HYPERV */
+
 #ifdef CONFIG_FUNCTION_TRACER
 #ifdef CONFIG_DYNAMIC_FTRACE
 
arch/x86/kernel/entry_64.S +5 -0
index 1975122..a1cb724 100644
@@ -1451,6 +1451,11 @@ apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
 
 #endif /* CONFIG_XEN */
 
+#if IS_ENABLED(CONFIG_HYPERV)
+apicinterrupt HYPER_V_CALLBACK_VECTOR \
+	hyperv_callback_vector hyperv_vector_handler
+#endif /* CONFIG_HYPERV */
+
 /*
  * Some functions should be protected against kprobes
  */
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 2 lines · K. Y. Srinivasan

No changelog entry describing the patch?

Quoted 7 lines
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39 ++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)

This patch needs to go through the x86 maintainers, which you didn't include all of on the To: line, any reason why?

greg k-h

#2 lore raw
Quoted 11 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Thursday, January 17, 2013 7:24 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

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

No changelog entry describing the patch?

I sent the wrong version of the patch by mistake. I will send the one with the changelog shortly.

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

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

Quoted 3 lines
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)

This patch needs to go through the x86 maintainers, which you didn't include all of on the To: line, any reason why?

I have included Thomas as this was an interrupt related patch. I will however include x86 maintainers when I resend with the change log.

Thank you,

K. Y

maintainer
#3 lore raw
In reply to K. Y. Srinivasan
Quoted 15 lines · K. Y. Srinivasan
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39 ++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
arch/x86/include/asm/irq_vectors.h +0 -0
index 1508e51..c2ff239 100644

arch/x86/include/asm/irq_vectors.h line 116

Quoted 5 lines
arch/x86/include/asm/irq_vectors.h +2 -0
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2

Btw, could those hypervisor vectors be merged into one VIRT_INTR_VECTOR and be shared between the hypervisors? I mean, you can't have a xen and hyperv hypervisor running next to each other and fihgting over that vector, right?

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#4 lore raw
Quoted 33 lines

-----Original Message-----
From: Borislav Petkov [mailto:[email protected]]
Sent: Friday, January 18, 2013 8:11 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; H. Peter Anvin; Ingo Molnar
Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 6 lines · K. Y. Srinivasan
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39

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

Review

Quoted 5 lines
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

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

Quoted 7 lines

index 1508e51..c2ff239 100644

arch/x86/include/asm/irq_vectors.h +0 -0
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
Quoted 7 lines

arch/x86/include/asm/irq_vectors.h line 116

Quoted 2 lines
arch/x86/include/asm/irq_vectors.h +2 -0
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2

Btw, could those hypervisor vectors be merged into one VIRT_INTR_VECTOR and be shared between the hypervisors? I mean, you can't have a xen and hyperv hypervisor running next to each other and fihgting over that vector, right?

You are right; we could just have one vector for this. Let me wait for other comments and input from Xen maintainers before I make this change.

Regards,

K. Y

Quoted 8 lines

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine. --

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

#5 lore raw
Quoted 41 lines · KY Srinivasan
Quoted 33 lines

-----Original Message-----
From: Borislav Petkov [mailto:[email protected]]
Sent: Friday, January 18, 2013 8:11 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; H. Peter Anvin; Ingo Molnar
Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 6 lines · K. Y. Srinivasan
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39

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

Review

Quoted 5 lines
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

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

Quoted 7 lines

index 1508e51..c2ff239 100644

arch/x86/include/asm/irq_vectors.h +0 -0
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
Quoted 7 lines

arch/x86/include/asm/irq_vectors.h line 116

Quoted 2 lines
arch/x86/include/asm/irq_vectors.h +2 -0
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2

Btw, could those hypervisor vectors be merged into one VIRT_INTR_VECTOR and be shared between the hypervisors? I mean, you can't have a xen and hyperv hypervisor running next to each other and fihgting over that vector, right?

Quoted 5 lines

You are right; we could just have one vector for this. Let me wait for other comments and input from Xen maintainers before I make this change.

Regards,

Looks OK to me.

Quoted 10 lines

K. Y

Quoted 8 lines

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine. --

#6 lore raw

Yes, how about we rename this the hypervisor vector...

Quoted 65 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Borislav Petkov [mailto:[email protected]]
Sent: Friday, January 18, 2013 8:11 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; H. Peter Anvin; Ingo

Molnar

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as

special

Quoted 23 lines
Quoted 23 lines

hypervisor interrupts

Quoted 6 lines · K. Y. Srinivasan
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39

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

Review

Quoted 5 lines
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

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

Quoted 7 lines

index 1508e51..c2ff239 100644

arch/x86/include/asm/irq_vectors.h +0 -0
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
Quoted 4 lines
Quoted 4 lines

arch/x86/include/asm/irq_vectors.h line 116

Quoted 2 lines
arch/x86/include/asm/irq_vectors.h +2 -0
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2

Btw, could those hypervisor vectors be merged into one

VIRT_INTR_VECTOR

Quoted 1 line
Quoted 1 line

and be shared between the hypervisors? I mean, you can't have a xen

and

Quoted 4 lines
Quoted 2 lines

hyperv hypervisor running next to each other and fihgting over that vector, right?

You are right; we could just have one vector for this. Let me wait

for other comments and

Quoted 4 lines

input from Xen maintainers before I make this change.

Regards,

Looks OK to me.

Quoted 10 lines

K. Y

Quoted 8 lines

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine. --

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
#7 lore raw
Quoted 1 line · H. Peter Anvin

Yes, how about we rename this the hypervisor vector...

HYPERVISOR_CALLBACK_VECTOR ?

#8 lore raw

Sounds good to me.

Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · H. Peter Anvin

Yes, how about we rename this the hypervisor vector...

HYPERVISOR_CALLBACK_VECTOR ?

Signature · 1 line
Sent from my mobile phone. Please excuse brevity and lack of formatting.
#9 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 13 lines

-----Original Message-----
From: Konrad Rzeszutek Wilk [mailto:[email protected]]
Sent: Wednesday, January 23, 2013 10:37 AM
To: H. Peter Anvin
Cc: KY Srinivasan; Borislav Petkov; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ingo Molnar; [email protected]; Jan Beulich ([email protected])
Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 4 lines
Quoted 1 line · H. Peter Anvin

Yes, how about we rename this the hypervisor vector...

HYPERVISOR_CALLBACK_VECTOR ?

Thanks Konrad. I will update the patch and send it out shortly.

Regards,

K. Y

Quoted 1 line
#10 lore raw
In reply to H. Peter Anvin
Quoted 13 lines

-----Original Message-----
From: H. Peter Anvin [mailto:[email protected]]
Sent: Tuesday, January 22, 2013 6:20 PM
To: Konrad Rzeszutek Wilk; KY Srinivasan
Cc: Borislav Petkov; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ingo Molnar; [email protected]; Jan Beulich ([email protected])
Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts

Quoted 1 line

Yes, how about we rename this the hypervisor vector...

Will do.

K. Y

Quoted 64 lines
Quoted 61 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Borislav Petkov [mailto:[email protected]]
Sent: Friday, January 18, 2013 8:11 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; H. Peter Anvin; Ingo

Molnar

Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 1/1] X86: Handle Hyper-V vmbus interrupts as

special

Quoted 23 lines
Quoted 23 lines

hypervisor interrupts

Quoted 6 lines · K. Y. Srinivasan
---
 arch/x86/include/asm/irq_vectors.h |    2 +
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39

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

Review

Quoted 5 lines
 arch/x86/kernel/entry_32.S         |    7 ++++++
 arch/x86/kernel/entry_64.S         |    5 ++++
 5 files changed, 57 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

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

Quoted 7 lines

index 1508e51..c2ff239 100644

arch/x86/include/asm/irq_vectors.h +0 -0
@@ -112,6 +112,8 @@
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
Quoted 4 lines
Quoted 4 lines

arch/x86/include/asm/irq_vectors.h line 116

Quoted 2 lines
arch/x86/include/asm/irq_vectors.h +2 -0
+/* Hyper-V vector callback to receive vmbus interrupts*/
+#define HYPER_V_CALLBACK_VECTOR		0xf2

Btw, could those hypervisor vectors be merged into one

VIRT_INTR_VECTOR

Quoted 1 line
Quoted 1 line

and be shared between the hypervisors? I mean, you can't have a xen

and

Quoted 4 lines
Quoted 2 lines

hyperv hypervisor running next to each other and fihgting over that vector, right?

You are right; we could just have one vector for this. Let me wait

for other comments and

Quoted 4 lines

input from Xen maintainers before I make this change.

Regards,

Looks OK to me.

Quoted 6 lines

K. Y

Quoted 5 lines

--
Regards/Gruss,
Boris.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Sent from a fat crate under my desk. Formatting is fine. --

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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