Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch xen ipi infrastructure



details:   https://anonhg.NetBSD.org/src/rev/6b371effc20b
branches:  trunk
changeset: 768178:6b371effc20b
user:      cherry <cherry%NetBSD.org@localhost>
date:      Wed Aug 10 11:39:44 2011 +0000

description:
xen ipi infrastructure

diffstat:

 sys/arch/amd64/amd64/fpu.c     |    8 +-
 sys/arch/amd64/amd64/machdep.c |    8 +-
 sys/arch/i386/isa/npx.c        |    8 +-
 sys/arch/x86/x86/x86_machdep.c |   23 ++-
 sys/arch/xen/conf/files.xen    |    6 +-
 sys/arch/xen/include/intr.h    |   14 +-
 sys/arch/xen/x86/xen_ipi.c     |  311 +++++++++++++++++++++++++++++++++++++++++
 7 files changed, 358 insertions(+), 20 deletions(-)

diffs (truncated from 535 to 300 lines):

diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/amd64/amd64/fpu.c
--- a/sys/arch/amd64/amd64/fpu.c        Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/amd64/amd64/fpu.c        Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.35 2011/07/01 19:24:14 dyoung Exp $  */
+/*     $NetBSD: fpu.c,v 1.36 2011/08/10 11:39:44 cherry Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.35 2011/07/01 19:24:14 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.36 2011/08/10 11:39:44 cherry Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -406,7 +406,11 @@
                        break;
                }
                splx(s);
+#ifdef XEN
+               xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
+#else /* XEN */
                x86_send_ipi(oci, X86_IPI_SYNCH_FPU);
+#endif
                while (pcb->pcb_fpcpu == oci && ticks == hardclock_ticks) {
                        x86_pause();
                        spins++;
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.162 2011/07/17 15:16:58 jym Exp $        */
+/*     $NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.162 2011/07/17 15:16:58 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.163 2011/08/10 11:39:45 cherry Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -719,7 +719,11 @@
 #endif /* XEN */
        }
 
+#ifdef XEN
+       xen_broadcast_ipi(XEN_IPI_HALT);
+#else /* XEN */
        x86_broadcast_ipi(X86_IPI_HALT);
+#endif
 
        if (howto & RB_HALT) {
 #if NACPICA > 0
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/i386/isa/npx.c
--- a/sys/arch/i386/isa/npx.c   Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/i386/isa/npx.c   Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.c,v 1.140 2011/06/07 14:53:03 bouyer Exp $ */
+/*     $NetBSD: npx.c,v 1.141 2011/08/10 11:39:45 cherry Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.140 2011/06/07 14:53:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.141 2011/08/10 11:39:45 cherry Exp $");
 
 #if 0
 #define IPRINTF(x)     printf x
@@ -719,7 +719,11 @@
                        break;
                }
                splx(s);
+#ifdef XEN
+               xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
+#else /* XEN */
                x86_send_ipi(oci, X86_IPI_SYNCH_FPU);
+#endif
                while (pcb->pcb_fpcpu == oci &&
                    ticks == hardclock_ticks) {
                        x86_pause();
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.53 2011/08/01 11:26:31 jmcneill Exp $        */
+/*     $NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $  */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.53 2011/08/01 11:26:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.54 2011/08/10 11:39:45 cherry Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -204,10 +204,13 @@
        if (l == ci->ci_data.cpu_idlelwp) {
                if (ci == cur)
                        return;
-#ifndef XEN /* XXX review when Xen gets MP support */
-               if (x86_cpu_idle_ipi != false)
+               if (x86_cpu_idle_ipi != false) {
+#ifdef XEN
+                       xen_send_ipi(ci, XEN_IPI_KICK);
+#else /* XEN */
                        x86_send_ipi(ci, 0);
-#endif
+#endif /* XEN */
+               }
                return;
        }
 
@@ -228,7 +231,11 @@
                return;
        }
        if ((flags & RESCHED_IMMED) != 0) {
+#ifdef XEN
+               xen_send_ipi(ci, XEN_IPI_KICK);
+#else /* XEN */
                x86_send_ipi(ci, 0);
+#endif /* XEN */
        }
 }
 
@@ -239,7 +246,11 @@
        KASSERT(kpreempt_disabled());
        aston(l, X86_AST_GENERIC);
        if (l->l_cpu != curcpu())
+#ifdef XEN
+               xen_send_ipi(l->l_cpu, XEN_IPI_KICK);
+#else /* XEN */
                x86_send_ipi(l->l_cpu, 0);
+#endif /* XEN */
 }
 
 void
@@ -363,7 +374,7 @@
        else
                x86_cpu_idle_set(x86_cpu_idle_mwait, "mwait", false);
 #else
-       x86_cpu_idle_set(x86_cpu_idle_xen, "xen", false);
+       x86_cpu_idle_set(x86_cpu_idle_xen, "xen", true);
 #endif
 }
 
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/xen/conf/files.xen       Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.xen,v 1.121 2011/06/13 00:53:15 pgoyette Exp $
+#      $NetBSD: files.xen,v 1.122 2011/08/10 11:39:45 cherry Exp $
 #      NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #      NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -56,7 +56,6 @@
 file   arch/i386/i386/trap.c
 file   arch/i386/i386/lock_stubs.S
 
-file   arch/i386/i386/mptramp.S                multiprocessor
 
 file   arch/i386/i386/pmc.c                    perfctrs
 
@@ -82,7 +81,6 @@
 file   arch/amd64/amd64/trap.c
 file   arch/amd64/amd64/fpu.c
 file   arch/amd64/amd64/lock_stubs.S
-file   arch/amd64/amd64/mptramp.S              multiprocessor
 endif
 
 file   kern/subr_disk_mbr.c            disk
@@ -129,7 +127,7 @@
 file   arch/xen/x86/consinit.c
 file   arch/x86/x86/identcpu.c
 file   arch/xen/x86/intr.c
-file   arch/x86/x86/ipi.c
+file   arch/xen/x86/xen_ipi.c          multiprocessor
 file   arch/x86/x86/pmap.c
 file   arch/x86/x86/pmap_tlb.c
 file   arch/x86/x86/procfs_machdep.c   procfs
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/xen/include/intr.h
--- a/sys/arch/xen/include/intr.h       Wed Aug 10 11:31:49 2011 +0000
+++ b/sys/arch/xen/include/intr.h       Wed Aug 10 11:39:44 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.31 2009/07/29 12:02:06 cegger Exp $ */
+/*     $NetBSD: intr.h,v 1.32 2011/08/10 11:39:45 cherry Exp $ */
 /*     NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp       */
 
 /*-
@@ -175,9 +175,15 @@
 struct pic *intr_findpic(int);
 void intr_add_pcibus(struct pcibus_attach_args *);
 
-int x86_send_ipi(struct cpu_info *, int);
-void x86_broadcast_ipi(int);
-void x86_multicast_ipi(int, int);
+#ifdef MULTIPROCESSOR
+void xen_ipi_init(void);
+int xen_send_ipi(struct cpu_info *, uint32_t);
+void xen_broadcast_ipi(uint32_t);
+#else
+#define xen_ipi_init(_1) do {} while(0) /* nothing */
+#define xen_send_ipi(_i1, _i2) do {} while(0) /* nothing */
+#define xen_broadcast_ipi(_i1) do {} while(0) /* nothing */
+#endif /* MULTIPROCESSOR */
 
 #endif /* !_LOCORE */
 
diff -r ec962bfa7da3 -r 6b371effc20b sys/arch/xen/x86/xen_ipi.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/xen/x86/xen_ipi.c        Wed Aug 10 11:39:44 2011 +0000
@@ -0,0 +1,311 @@
+/* $NetBSD: xen_ipi.c,v 1.2 2011/08/10 11:39:46 cherry Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Cherry G. Mathew <cherry%zyx.in@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>                 /* RCS ID macro */
+
+/* 
+ * Based on: x86/ipi.c
+ * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.2 2011/08/10 11:39:46 cherry Exp $"); 
+ */
+
+__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.2 2011/08/10 11:39:46 cherry Exp $");
+
+#include <sys/types.h>
+
+#include <sys/atomic.h>
+#include <sys/mutex.h>
+#include <sys/cpu.h>
+#include <sys/device.h>
+#include <sys/xcall.h>
+#include <sys/errno.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#ifdef __x86_64__
+#include <machine/fpu.h>
+#else
+#include <machine/npx.h>
+#endif /* __x86_64__ */
+#include <machine/frame.h>
+#include <machine/segments.h>
+
+#include <xen/intr.h>
+#include <xen/intrdefs.h>
+#include <xen/hypervisor.h>
+#include <xen/xen3-public/vcpu.h>
+
+#ifdef __x86_64__
+extern void ddb_ipi(struct trapframe);
+#else
+extern void ddb_ipi(int, struct trapframe);
+#endif /* __x86_64__ */
+
+static void xen_ipi_halt(struct cpu_info *, struct intrframe *);
+static void xen_ipi_synch_fpu(struct cpu_info *, struct intrframe *);
+static void xen_ipi_ddb(struct cpu_info *, struct intrframe *);
+static void xen_ipi_xcall(struct cpu_info *, struct intrframe *);
+
+static void (*ipifunc[XEN_NIPIS])(struct cpu_info *, struct intrframe *) =



Home | Main Index | Thread Index | Old Index