mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: linux-kernel@vger.kernel.org
Cc: xen-devel@lists.xensource.com, virtualization@lists.osdl.org,
	Ian Pratt <ian.pratt@xensource.com>,
	Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Subject: [RFC PATCH 15/35] subarch support for controlling interrupt delivery
Date: Tue, 21 Mar 2006 22:30:55 -0800	[thread overview]
Message-ID: <20060322063751.830556000@sorel.sous-sol.org> (raw)
In-Reply-To: <20060322063040.960068000@sorel.sous-sol.org>

[-- Attachment #1: 14-i386-interrupt-control --]
[-- Type: text/plain, Size: 6191 bytes --]

Abstract the code that controls interrupt delivery, and add a separate
subarch implementation for Xen that manipulates a shared-memory event
delivery mask.

Signed-off-by: Ian Pratt <ian.pratt@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 include/asm-i386/mach-default/mach_system.h |   24 ++++++
 include/asm-i386/mach-xen/mach_system.h     |  103 ++++++++++++++++++++++++++++
 include/asm-i386/system.h                   |   20 -----
 3 files changed, 128 insertions(+), 19 deletions(-)

--- xen-subarch-2.6.orig/include/asm-i386/system.h
+++ xen-subarch-2.6/include/asm-i386/system.h
@@ -551,25 +551,7 @@ struct alt_instr { 
 
 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
 
-/* interrupt control.. */
-#define local_save_flags(x)	do { typecheck(unsigned long,x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while (0)
-#define local_irq_restore(x) 	do { typecheck(unsigned long,x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc"); } while (0)
-#define local_irq_disable() 	__asm__ __volatile__("cli": : :"memory")
-#define local_irq_enable()	__asm__ __volatile__("sti": : :"memory")
-/* used in the idle loop; sti takes one instruction cycle to complete */
-#define safe_halt()		__asm__ __volatile__("sti; hlt": : :"memory")
-/* used when interrupts are already enabled or to shutdown the processor */
-#define halt()			__asm__ __volatile__("hlt": : :"memory")
-
-#define irqs_disabled()			\
-({					\
-	unsigned long flags;		\
-	local_save_flags(flags);	\
-	!(flags & (1<<9));		\
-})
-
-/* For spinlocks etc */
-#define local_irq_save(x)	__asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
+#include <mach_system.h>
 
 /*
  * disable hlt during certain critical i/o operations
--- /dev/null
+++ xen-subarch-2.6/include/asm-i386/mach-default/mach_system.h
@@ -0,0 +1,24 @@
+#ifndef __ASM_MACH_SYSTEM_H
+#define __ASM_MACH_SYSTEM_H
+
+/* interrupt control.. */
+#define local_save_flags(x)	do { typecheck(unsigned long,x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while (0)
+#define local_irq_restore(x) 	do { typecheck(unsigned long,x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc"); } while (0)
+#define local_irq_disable() 	__asm__ __volatile__("cli": : :"memory")
+#define local_irq_enable()	__asm__ __volatile__("sti": : :"memory")
+/* used in the idle loop; sti takes one instruction cycle to complete */
+#define safe_halt()		__asm__ __volatile__("sti; hlt": : :"memory")
+/* used when interrupts are already enabled or to shutdown the processor */
+#define halt()			__asm__ __volatile__("hlt": : :"memory")
+
+#define irqs_disabled()			\
+({					\
+	unsigned long flags;		\
+	local_save_flags(flags);	\
+	!(flags & (1<<9));		\
+})
+
+/* For spinlocks etc */
+#define local_irq_save(x)	__asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
+
+#endif /* __ASM_MACH_SYSTEM_H */
--- /dev/null
+++ xen-subarch-2.6/include/asm-i386/mach-xen/mach_system.h
@@ -0,0 +1,103 @@
+#ifndef __ASM_MACH_SYSTEM_H
+#define __ASM_MACH_SYSTEM_H
+
+#ifdef __KERNEL__
+
+#include <asm/hypervisor.h>
+
+#ifdef CONFIG_SMP
+#define __vcpu_id smp_processor_id()
+#else
+#define __vcpu_id 0
+#endif
+
+/* interrupt control.. */
+
+/*
+ * The use of 'barrier' in the following reflects their use as local-lock
+ * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
+ * critical operations are executed. All critical operations must complete
+ * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
+ * includes these barriers, for example.
+ */
+
+#define __cli()								\
+do {									\
+	struct vcpu_info *_vcpu;					\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	_vcpu->evtchn_upcall_mask = 1;					\
+	preempt_enable_no_resched();					\
+	barrier();							\
+} while (0)
+
+#define __sti()								\
+do {									\
+	struct vcpu_info *_vcpu;					\
+	barrier();							\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	_vcpu->evtchn_upcall_mask = 0;					\
+	barrier(); /* unmask then check (avoid races) */		\
+	if (unlikely(_vcpu->evtchn_upcall_pending))			\
+		force_evtchn_callback();				\
+	preempt_enable();						\
+} while (0)
+
+#define __save_flags(x)							\
+do {									\
+	struct vcpu_info *_vcpu;					\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	(x) = _vcpu->evtchn_upcall_mask;				\
+	preempt_enable();						\
+} while (0)
+
+#define __restore_flags(x)						\
+do {									\
+	struct vcpu_info *_vcpu;					\
+	barrier();							\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	if ((_vcpu->evtchn_upcall_mask = (x)) == 0) {			\
+		barrier(); /* unmask then check (avoid races) */	\
+		if (unlikely(_vcpu->evtchn_upcall_pending))		\
+			force_evtchn_callback();			\
+		preempt_enable();					\
+	} else								\
+		preempt_enable_no_resched();				\
+} while (0)
+
+#define safe_halt()		((void)0)
+#define halt()			((void)0)
+
+#define __save_and_cli(x)						\
+do {									\
+	struct vcpu_info *_vcpu;					\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	(x) = _vcpu->evtchn_upcall_mask;				\
+	_vcpu->evtchn_upcall_mask = 1;					\
+	preempt_enable_no_resched();					\
+	barrier();							\
+} while (0)
+
+#define local_irq_save(x)	__save_and_cli(x)
+#define local_irq_restore(x)	__restore_flags(x)
+#define local_save_flags(x)	__save_flags(x)
+#define local_irq_disable()	__cli()
+#define local_irq_enable()	__sti()
+
+/* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
+#define irqs_disabled()							\
+({	int ___x;							\
+	struct vcpu_info *_vcpu;					\
+	preempt_disable();						\
+	_vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];		\
+	___x = (_vcpu->evtchn_upcall_mask != 0);			\
+	preempt_enable_no_resched();					\
+	___x; })
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_MACH_SYSTEM_H */

--

  parent reply	other threads:[~2006-03-22  6:43 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22  6:30 [RFC PATCH 00/35] Xen i386 paravirtualization support Chris Wright
2006-03-22  6:30 ` [RFC PATCH 01/35] Add XEN config options and disable unsupported config options Chris Wright
2006-03-22  6:30 ` [RFC PATCH 02/35] Makefile support to build Xen subarch Chris Wright
2006-03-22  6:30 ` [RFC PATCH 03/35] Add Xen interface header files Chris Wright
2006-03-22  6:30 ` [RFC PATCH 04/35] Hypervisor " Chris Wright
2006-03-22  8:28   ` Arjan van de Ven
2006-03-22  9:31     ` Keir Fraser
2006-03-22  9:46       ` Arjan van de Ven
2006-03-22 11:32       ` David Schwartz
2006-03-22 14:29         ` Keir Fraser
2006-03-22  6:30 ` [RFC PATCH 05/35] Add sync bitops Chris Wright
2006-03-22  6:30 ` [RFC PATCH 06/35] Add vmlinuz build target Chris Wright
2006-03-22  6:30 ` [RFC PATCH 07/35] Make LOAD_OFFSET defined by subarch Chris Wright
2006-03-22 22:57   ` Dan Hecht
2006-03-27  8:18     ` Gerd Hoffmann
2006-03-22  6:30 ` [RFC PATCH 08/35] Add Xen-specific memory management definitions Chris Wright
2006-03-22  6:30 ` [RFC PATCH 09/35] Change __FIXADDR_TOP to leave room for the hypervisor Chris Wright
2006-03-22 17:27   ` Anthony Liguori
2006-03-22 17:32     ` Chris Wright
2006-03-22  6:30 ` [RFC PATCH 10/35] Add a new head.S start-of-day file for booting on Xen Chris Wright
2006-03-22 13:43   ` Andi Kleen
2006-03-22 18:58     ` Chris Wright
2006-03-22 18:45       ` Andi Kleen
2006-03-22 19:26         ` Chris Wright
2006-03-22  6:30 ` [RFC PATCH 11/35] Add support for Xen to entry.S Chris Wright
2006-03-22 13:55   ` Andi Kleen
2006-03-22 17:24     ` [Xen-devel] " Zachary Amsden
2006-03-22  6:30 ` [RFC PATCH 12/35] Add start-of-day setup hooks to subarch Chris Wright
2006-03-22  6:30 ` [RFC PATCH 13/35] Support loading an initrd when running on Xen Chris Wright
2006-03-22 14:22   ` Andi Kleen
2006-03-22 19:20     ` Chris Wright
2006-03-22  6:30 ` [RFC PATCH 14/35] subarch modify CPU capabilities Chris Wright
2006-03-22  8:35   ` [Xen-devel] " Zachary Amsden
2006-03-22  9:33     ` Keir Fraser
2006-03-22 19:29       ` Chris Wright
2006-03-22  6:30 ` Chris Wright [this message]
2006-03-22  6:30 ` [RFC PATCH 16/35] subarch support for interrupt and exception gates Chris Wright
2006-03-22 13:45   ` Andi Kleen
2006-03-22 20:54     ` Chris Wright
2006-03-22  6:30 ` [RFC PATCH 17/35] Segment register changes for Xen Chris Wright
2006-03-22 14:24   ` Andi Kleen
2006-03-22 19:33     ` Chris Wright
2006-03-23  0:16   ` Zachary Amsden
2006-03-22  6:30 ` [RFC PATCH 18/35] Support gdt/idt/ldt handling on Xen Chris Wright
2006-03-22 14:30   ` Andi Kleen
2006-03-22 17:51     ` [Xen-devel] " Zachary Amsden
2006-03-22 17:36       ` Andi Kleen
2006-03-22  6:30 ` [RFC PATCH 19/35] subarch support for control register accesses Chris Wright
2006-03-22  8:55   ` Zachary Amsden
2006-03-22 21:45     ` Chris Wright
2006-03-22  6:31 ` [RFC PATCH 20/35] subarch stack pointer update Chris Wright
2006-03-22  6:31 ` [RFC PATCH 21/35] subarch TLB support Chris Wright
2006-03-22  6:31 ` [RFC PATCH 22/35] subarch suport for idle loop (NO_IDLE_HZ for Xen) Chris Wright
2006-03-22  6:31 ` [RFC PATCH 23/35] Add support for Xen event channels Chris Wright
2006-03-22  8:36   ` Arjan van de Ven
2006-03-22 11:30     ` Keir Fraser
2006-03-22 14:07   ` Andi Kleen
2006-03-22  6:31 ` [RFC PATCH 24/35] subarch support for mask value for irq nubmers Chris Wright
2006-03-22  6:31 ` [RFC PATCH 25/35] Add Xen time abstractions Chris Wright
2006-03-22  8:38   ` Arjan van de Ven
2006-03-22 19:37     ` Chris Wright
2006-03-22 22:26       ` [Xen-devel] " Dan Hecht
2006-03-23  3:23   ` [Xen-devel] " Eli Collins
2006-03-23  6:47     ` Chris Wright
2006-03-22  6:31 ` [RFC PATCH 26/35] Add Xen subarch reboot support Chris Wright
2006-03-22  8:40   ` Arjan van de Ven
2006-03-22 10:22     ` Keir Fraser
2006-03-22 10:39       ` Arjan van de Ven
2006-03-22 10:52         ` Keir Fraser
2006-03-22 14:21   ` Andi Kleen
2006-03-22 20:59     ` Pavel Machek
2006-03-22  6:31 ` [RFC PATCH 27/35] Add nosegneg capability to the vsyscall page notes Chris Wright
2006-03-22  6:31 ` [RFC PATCH 28/35] add support for Xen feature queries Chris Wright
2006-03-22  8:42   ` Arjan van de Ven
2006-03-22  6:31 ` [RFC PATCH 29/35] Add the Xen virtual console driver Chris Wright
2006-03-22  8:43   ` Arjan van de Ven
2006-03-22  9:29     ` Keir Fraser
2006-03-22 14:17   ` Andi Kleen
2006-03-22 16:00   ` Anthony Liguori
2006-03-22 16:07     ` Keir Fraser
2006-03-22 16:14       ` Anthony Liguori
2006-03-22  6:31 ` [RFC PATCH 30/35] Add generic_page_range() function Chris Wright
2006-03-22  8:51   ` Zachary Amsden
2006-03-22  9:27     ` [Xen-devel] " Keir Fraser
2006-03-22 11:21   ` Nick Piggin
2006-03-22 14:33     ` Keir Fraser
2006-03-22 15:35       ` Keir Fraser
2006-03-23  0:15         ` Nick Piggin
2006-03-23  0:26       ` Nick Piggin
2006-03-22  6:31 ` [RFC PATCH 31/35] Add Xen grant table support Chris Wright
2006-03-22  8:45   ` Arjan van de Ven
2006-03-22 18:38     ` Chris Wright
2006-03-22  6:31 ` [RFC PATCH 32/35] Add Xen driver utility functions Chris Wright
2006-03-22 14:12   ` Andi Kleen
2006-03-22  6:31 ` [RFC PATCH 33/35] Add the Xenbus sysfs and virtual device hotplug driver Chris Wright
2006-03-22  8:53   ` Arjan van de Ven
2006-03-22 11:14     ` Keir Fraser
2006-03-22  6:31 ` [RFC PATCH 34/35] Add the Xen virtual network device driver Chris Wright
2006-03-22  8:59   ` Arjan van de Ven
2006-03-22 15:29   ` James Morris
2006-03-22 17:17   ` Stephen Hemminger
2006-03-22  6:31 ` [RFC PATCH 35/35] Add Xen virtual block " Chris Wright
2006-03-22 16:39   ` Anthony Liguori
2006-03-22 16:54     ` Christoph Hellwig
2006-03-27  8:42     ` Gerd Hoffmann
2006-03-22 17:15 ` [RFC PATCH 00/35] Xen i386 paravirtualization support Anthony Liguori
2006-03-22 17:27   ` Chris Wright
2006-03-22 17:50     ` Anthony Liguori
2006-05-09  8:49 Chris Wright
2006-05-09  7:00 ` [RFC PATCH 15/35] subarch support for controlling interrupt delivery Chris Wright
2006-05-09 14:49   ` Martin J. Bligh
2006-05-09 14:55     ` Nick Piggin
2006-05-09 15:51     ` Christian Limpach
2006-05-09 16:02       ` Martin J. Bligh
2006-05-09 16:07       ` Andi Kleen
2006-05-09 16:29         ` Christian Limpach
2006-05-09 16:31           ` Andi Kleen
2006-05-09 20:42             ` Christian Limpach
2006-05-09 21:56               ` Andi Kleen
2006-05-10 10:35                 ` Christian Limpach
2006-05-10 10:54                   ` Andi Kleen
2006-05-09 21:56               ` Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060322063751.830556000@sorel.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=Christian.Limpach@cl.cam.ac.uk \
    --cc=ian.pratt@xensource.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.osdl.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome