All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts
@ 2013-01-24  1:56 K. Y. Srinivasan
  2013-01-24  9:28 ` Borislav Petkov
  0 siblings, 1 reply; 33+ messages in thread
From: K. Y. Srinivasan @ 2013-01-24  1:56 UTC (permalink / raw)
  To: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	JBeulich, bp
  Cc: K. Y. Srinivasan

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 <JBeulich@suse.com> and
Thomas Gleixner <tglx@linutronix.de>, 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.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/irq_vectors.h |    4 +-
 arch/x86/include/asm/mshyperv.h    |    4 +++
 arch/x86/kernel/cpu/mshyperv.c     |   39 ++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/entry_32.S         |    9 +++++++-
 arch/x86/kernel/entry_64.S         |    7 +++++-
 drivers/xen/events.c               |    6 ++--
 6 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 1508e51..d09850b 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -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,
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 79ce568..c2934be 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -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
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 0a630dd..3689622 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -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(HYPERVISOR_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 = -1;
+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);
+}
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index e9dd4c4..7d2bb62 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1047,11 +1047,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
 
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1975122..803ca69 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -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
  */
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 4293c57..5c2e92e 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -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,8 @@ 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
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH 0/2] x86: Make Linux guest support optional
@ 2013-02-14 19:28 Borislav Petkov
  2013-02-14 19:28 ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov
  0 siblings, 1 reply; 33+ messages in thread
From: Borislav Petkov @ 2013-02-14 19:28 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: X86 ML, LKML, Borislav Petkov

From: Borislav Petkov <bp@suse.de>

Hi all,

two patches which make hypervisor glue for Linux running as a guest
ontop optional.

@hpa: this is against tip/master of today which also includes
tip:x86/hyperv.

Thanks.

Borislav Petkov (2):
  x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu
  x86: Make Linux guest support optional

 arch/x86/Kconfig                  | 89 ++++++++++++++++++++-------------------
 arch/x86/include/asm/hypervisor.h | 16 ++++---
 arch/x86/kernel/cpu/Makefile      |  3 +-
 arch/x86/lguest/Kconfig           |  3 +-
 arch/x86/xen/Kconfig              |  2 +-
 drivers/hv/Kconfig                |  2 +-
 drivers/misc/Kconfig              |  2 +-
 7 files changed, 62 insertions(+), 55 deletions(-)

-- 
1.8.1.3.535.ga923c31


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH 0/2] x86: Make Linux guest support optional
@ 2013-03-04 20:20 Borislav Petkov
  2013-03-04 20:20 ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov
  0 siblings, 1 reply; 33+ messages in thread
From: Borislav Petkov @ 2013-03-04 20:20 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: X86 ML, LKML, Borislav Petkov

From: Borislav Petkov <bp@suse.de>

Hi,

two patches which make hypervisor glue for Linux running as a guest
ontop optional. Same patches from before but rebased ontop of v3.9-rc1.

Thanks.

Borislav Petkov (2):
  x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu
  x86: Make Linux guest support optional

 arch/x86/Kconfig                  | 89 ++++++++++++++++++++-------------------
 arch/x86/include/asm/hypervisor.h | 16 ++++---
 arch/x86/kernel/cpu/Makefile      |  3 +-
 arch/x86/lguest/Kconfig           |  3 +-
 arch/x86/xen/Kconfig              |  2 +-
 drivers/hv/Kconfig                |  2 +-
 drivers/misc/Kconfig              |  2 +-
 7 files changed, 62 insertions(+), 55 deletions(-)

-- 
1.8.1.3.535.ga923c31


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

end of thread, other threads:[~2013-03-04 20:20 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24  1:56 [PATCH RESEND 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts K. Y. Srinivasan
2013-01-24  9:28 ` Borislav Petkov
2013-01-24 12:11   ` H. Peter Anvin
2013-01-24 17:35     ` Borislav Petkov
2013-01-24 17:36       ` H. Peter Anvin
2013-01-24 17:39       ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov
2013-01-24 17:39         ` [PATCH 2/2] x86: Make Linux guest support optional Borislav Petkov
2013-01-25  8:21         ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Ingo Molnar
2013-01-25  8:51           ` Borislav Petkov
2013-01-25  9:20             ` Ingo Molnar
2013-01-25  9:29               ` Borislav Petkov
2013-01-25  9:32                 ` Ingo Molnar
2013-01-25 10:06                   ` Borislav Petkov
2013-01-25 17:59                     ` [PATCH -v2 " Borislav Petkov
2013-01-25 17:59                     ` [PATCH -v2 2/2] x86: Make Linux guest support optional Borislav Petkov
2013-01-25 18:07                       ` Dmitry Torokhov
2013-01-25 18:23                         ` Borislav Petkov
2013-01-25 18:29                           ` Dmitry Torokhov
2013-01-25 18:35                             ` Borislav Petkov
2013-01-25 18:43                               ` Borislav Petkov
2013-01-27  1:26                                 ` H. Peter Anvin
2013-01-27 10:30                                   ` Borislav Petkov
2013-01-25 18:12                       ` Dmitry Torokhov
2013-01-25 18:32                         ` Borislav Petkov
2013-01-25 18:42                           ` Dmitry Torokhov
2013-01-25 19:03                             ` Borislav Petkov
2013-01-26 23:10                               ` [PATCH -v3 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov
2013-01-26 23:10                               ` [PATCH -v3 2/2] x86: Make Linux guest support optional Borislav Petkov
2013-01-27 11:06                                 ` Borislav Petkov
2013-01-28 10:18                                   ` [PATCH -v3.1] " Borislav Petkov
2013-01-24 17:42   ` [PATCH RESEND 1/1] X86: Handle Hyper-V vmbus interrupts as special hypervisor interrupts KY Srinivasan
2013-02-14 19:28 [PATCH 0/2] x86: Make Linux guest support optional Borislav Petkov
2013-02-14 19:28 ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov
2013-03-04 20:20 [PATCH 0/2] x86: Make Linux guest support optional Borislav Petkov
2013-03-04 20:20 ` [PATCH 1/2] x86, Kconfig: Move PARAVIRT_DEBUG into the paravirt menu Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.