CVS commit: [cherry-xenmp] src/sys/arch/i386/isa

2011-10-25 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Oct 25 20:16:13 UTC 2011

Modified Files:
src/sys/arch/i386/isa [cherry-xenmp]: npx.c

Log Message:
Make this build without options MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.139.6.2 -r1.139.6.3 src/sys/arch/i386/isa/npx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/isa/npx.c
diff -u src/sys/arch/i386/isa/npx.c:1.139.6.2 src/sys/arch/i386/isa/npx.c:1.139.6.3
--- src/sys/arch/i386/isa/npx.c:1.139.6.2	Sun Jul 31 20:49:11 2011
+++ src/sys/arch/i386/isa/npx.c	Tue Oct 25 20:16:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: npx.c,v 1.139.6.2 2011/07/31 20:49:11 cherry Exp $	*/
+/*	$NetBSD: npx.c,v 1.139.6.3 2011/10/25 20:16:12 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: npx.c,v 1.139.6.2 2011/07/31 20:49:11 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: npx.c,v 1.139.6.3 2011/10/25 20:16:12 bouyer Exp $);
 
 #if 0
 #define IPRINTF(x)	printf x
@@ -720,7 +720,7 @@ npxsave_lwp(struct lwp *l, bool save)
 		}
 		splx(s);
 #ifdef XEN
-		xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
+		(void)xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
 #else /* XEN */
 		x86_send_ipi(oci, X86_IPI_SYNCH_FPU);
 #endif



CVS commit: [cherry-xenmp] src/sys/arch

2011-10-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 22 19:21:57 UTC 2011

Modified Files:
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/xen/x86 [cherry-xenmp]: hypervisor_machdep.c
src/sys/arch/xen/xen [cherry-xenmp]: evtchn.c

Log Message:
Various interrupt fixes, mainly:
keep a per-cpu mask of enabled events, and use it to get pending events.
A cpu-specific event (all of them at this time) should not be ever masked
by another CPU, because it may prevent the target CPU from seeing it
(the clock events all fires at once for example).


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.6 -r1.34.2.7 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.14.2.5 -r1.14.2.6 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.47.6.5 -r1.47.6.6 src/sys/arch/xen/xen/evtchn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.34.2.6 src/sys/arch/x86/include/cpu.h:1.34.2.7
--- src/sys/arch/x86/include/cpu.h:1.34.2.6	Thu Sep  1 08:04:46 2011
+++ src/sys/arch/x86/include/cpu.h	Sat Oct 22 19:21:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.34.2.6 2011/09/01 08:04:46 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.34.2.7 2011/10/22 19:21:57 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -126,6 +126,7 @@ struct cpu_info {
 
 #ifdef XEN
 	struct iplsource  *ci_isources[NIPL];
+	u_long ci_evtmask[NR_EVENT_CHANNELS]; /* events allowed on this CPU */
 #else
 	struct intrsource *ci_isources[MAX_INTR_SOURCES];
 #endif

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.5 src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.6
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.5	Sun Sep 18 18:46:40 2011
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Sat Oct 22 19:21:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.6 2011/10/22 19:21:57 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.6 2011/10/22 19:21:57 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -109,6 +109,7 @@ evt_iterate_bits(struct cpu_info *ci, vo
 		l1 = ~(1UL  l1i);
 
 		l2 = pendingl2[l1i]  (mask != NULL ? ~mask[l1i] : -1UL);
+		l2 = ci-ci_evtmask[l1i];
 
 		if (mask != NULL) xen_atomic_setbits_l(mask[l1i], l2);
 		xen_atomic_clearbits_l(pendingl2[l1i], l2);
@@ -405,6 +406,13 @@ hypervisor_set_ipending(struct cpu_info 
 	KASSERT(ci-ci_isources[ipl] != NULL);
 	ci-ci_isources[ipl]-ipl_evt_mask1 |= 1UL  l1;
 	ci-ci_isources[ipl]-ipl_evt_mask2[l1] |= 1UL  l2;
+	if (__predict_false(ci != curcpu())) {
+		if (xen_send_ipi(ci, XEN_IPI_HVCB)) {
+			panic(hypervisor_set_ipending: 
+			xen_send_ipi(cpu%d, XEN_IPI_HVCB) failed\n,
+			(int) ci-ci_cpuid);
+		}
+	}
 }
 
 void

Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.47.6.5 src/sys/arch/xen/xen/evtchn.c:1.47.6.6
--- src/sys/arch/xen/xen/evtchn.c:1.47.6.5	Sun Sep 18 18:46:40 2011
+++ src/sys/arch/xen/xen/evtchn.c	Sat Oct 22 19:21:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.47.6.5 2011/09/18 18:46:40 cherry Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.47.6.6 2011/10/22 19:21:57 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.47.6.5 2011/09/18 18:46:40 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.47.6.6 2011/10/22 19:21:57 bouyer Exp $);
 
 #include opt_xen.h
 #include isa.h
@@ -190,6 +190,7 @@ events_init(void)
 	 * be called.
 	 */
 	evtsource[debug_port] = (void *)-1;
+	xen_atomic_set_bit(curcpu()-ci_evtmask[0], debug_port);
 	hypervisor_enable_event(debug_port);
 
 	x86_enable_intr();		/* at long last... */
@@ -263,8 +264,16 @@ evtchn_do_event(int evtch, struct intrfr
 	mutex_spin_enter(evtlock[evtch]);
 	ih = evtsource[evtch]-ev_handlers;
 	while (ih != NULL) {
-		if (ih-ih_level = ilevel ||
-		   ih-ih_cpu != ci) {
+		if (ih-ih_cpu != ci) {
+			hypervisor_set_ipending(ih-ih_cpu, 1  ih-ih_level,
+			evtch  LONG_SHIFT, evtch  LONG_MASK);
+			iplmask = ~IUNMASK(ci, ih-ih_level);
+			ih = ih-ih_evt_next;
+			continue;
+		}
+		if (ih-ih_level = ilevel) {
+			hypervisor_set_ipending(ih-ih_cpu, iplmask,
+			evtch  LONG_SHIFT, evtch  LONG_MASK);
 #ifdef IRQ_DEBUG
 		if (evtch == IRQ_DEBUG)
 		printf(ih-ih_level %d = ilevel %d\n, ih-ih_level, ilevel);
@@ -390,7 +399,11 @@ bind_virq_to_evtch(int virq)
 			panic(Failed to bind virtual IRQ %d\n, virq);
 		evtchn = op.u.bind_virq.port;
 
-		virq_to_evtch[virq] = evtchn;
+		if (virq == VIRQ_TIMER) {
+			virq_timer_to_evtch[ci-ci_cpuid] = 

CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-10-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 22 19:26:16 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
Various clock fixes:
- xen_get_timecount() is CPU specific, so get the time from this
  virtual CPU and not VCPU0. Also keep xen_clock_bias per-cpu.
- The periodic timer looks buggy, we stop receiving events after a (short)
  while. Linux is using the one-shoot timer so use it too (and disable
  the periodic timer), but rearm it from the event handler, not idle_block()
  as the later may not be called if the CPU is busy, resulting it clock
  event loss.
- use  HYPERVISOR_block() in idle_block() again, now that interrupts are
  working properly.


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.4 -r1.54.6.5 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.4 src/sys/arch/xen/xen/clock.c:1.54.6.5
--- src/sys/arch/xen/xen/clock.c:1.54.6.4	Sun Sep 18 18:54:32 2011
+++ src/sys/arch/xen/xen/clock.c	Sat Oct 22 19:26:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.4 2011/09/18 18:54:32 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.5 2011/10/22 19:26:16 bouyer Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.4 2011/09/18 18:54:32 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.5 2011/10/22 19:26:16 bouyer Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -94,7 +94,7 @@ static volatile uint64_t vcpu_system_tim
  * back to maintain the illusion that hardclock(9) was called when it
  * was supposed to be, not when Xen got around to scheduling us.
  */
-static volatile uint64_t xen_clock_bias;
+static volatile uint64_t xen_clock_bias[MAXCPUS];
 
 #ifdef DOM0OPS
 /* If we're dom0, send our time to Xen every minute or so. */
@@ -416,9 +416,10 @@ u_int
 xen_get_timecount(struct timecounter *tc)
 {
 	uint64_t ns;
+	struct cpu_info *ci = curcpu();
 
 	mutex_enter(tmutex);
-	ns = get_system_time() - xen_clock_bias;
+	ns = get_vcpu_time(ci) - xen_clock_bias[ci-ci_cpuid];
 	mutex_exit(tmutex);
 
 	return (u_int)ns;
@@ -439,12 +440,10 @@ xen_initclocks(void)
 	int err, evtch;
 	static bool tcdone = false;
 
-	struct vcpu_set_periodic_timer hardclock_period = { NS_PER_TICK };
-
 	struct cpu_info *ci = curcpu();
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
-	xen_clock_bias = 0;
+	xen_clock_bias[ci-ci_cpuid] = 0;
 
 	evcnt_attach_dynamic(hardclock_called[ci-ci_cpuid],
 			 EVCNT_TYPE_INTR,
@@ -468,12 +467,19 @@ xen_initclocks(void)
 	}
 	/* The splhigh requirements start here. */
 
-	/* Set hardclock() frequency */
-	err = HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer,
+	/*
+	 * The periodic timer looks buggy, we stop receiving events
+	 * after a while. Use the one-shot timer every NS_PER_TICK
+	 * and rearm it from the event handler.
+	 */
+	err = HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
  ci-ci_cpuid,
- hardclock_period);
+ NULL);
 
 	KASSERT(err == 0);
+	err = HYPERVISOR_set_timer_op(
+	vcpu_system_time[ci-ci_cpuid] + NS_PER_TICK);
+	KASSERT(err == 0);
 
 	event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
 	ci, IPL_CLOCK, clock);
@@ -504,25 +510,34 @@ xen_timer_handler(void *arg, struct intr
 	int64_t delta;
 	struct cpu_info *ci = curcpu();
 	KASSERT(arg == ci);
+	int err;
+again:
 	mutex_enter(tmutex);
-
 	delta = (int64_t)(get_vcpu_time(ci) - vcpu_system_time[ci-ci_cpuid]);
-
 	mutex_exit(tmutex);
 
 	/* Several ticks may have passed without our being run; catch up. */
 	while (delta = (int64_t)NS_PER_TICK) {
 		mutex_enter(tmutex);
 		vcpu_system_time[ci-ci_cpuid] += NS_PER_TICK;
-		xen_clock_bias = (delta -= NS_PER_TICK);
+		xen_clock_bias[ci-ci_cpuid] = (delta -= NS_PER_TICK);
 		mutex_exit(tmutex);
 		hardclock((struct clockframe *)regs);
 		hardclock_called[ci-ci_cpuid].ev_count++;
 	}
+
+	/*
+	 * rearm the timer. If it fails it's probably because the date
+	 * is in the past, update our local time and try again.
+	 */
+	err = HYPERVISOR_set_timer_op(
+	vcpu_system_time[ci-ci_cpuid] + NS_PER_TICK);
+	if (err)
+		goto again;
 	
-	if (xen_clock_bias) {
+	if (xen_clock_bias[ci-ci_cpuid]) {
 		mutex_enter(tmutex);
-		xen_clock_bias = 0;
+		xen_clock_bias[ci-ci_cpuid] = 0;
 		mutex_exit(tmutex);
 	}
 
@@ -537,6 +552,18 @@ setstatclockrate(int arg)
 void
 idle_block(void)
 {
+#ifdef MULTIPROCESSOR
 	HYPERVISOR_yield();
 	__sti();
+#else
+	struct cpu_info *ci = curcpu();
+	int r;
+
+	r = HYPERVISOR_set_timer_op(
+	vcpu_system_time[ci-ci_cpuid] + NS_PER_TICK);
+	if (r == 0)
+		HYPERVISOR_block();
+	else
+		__sti();
+#endif
 }



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-10-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 22 21:16:59 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
Really use HYPERVISOR_block()


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.5 -r1.54.6.6 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.5 src/sys/arch/xen/xen/clock.c:1.54.6.6
--- src/sys/arch/xen/xen/clock.c:1.54.6.5	Sat Oct 22 19:26:16 2011
+++ src/sys/arch/xen/xen/clock.c	Sat Oct 22 21:16:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.5 2011/10/22 19:26:16 bouyer Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.6 2011/10/22 21:16:59 bouyer Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.5 2011/10/22 19:26:16 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.6 2011/10/22 21:16:59 bouyer Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -552,18 +552,6 @@ setstatclockrate(int arg)
 void
 idle_block(void)
 {
-#ifdef MULTIPROCESSOR
-	HYPERVISOR_yield();
-	__sti();
-#else
-	struct cpu_info *ci = curcpu();
-	int r;
-
-	r = HYPERVISOR_set_timer_op(
-	vcpu_system_time[ci-ci_cpuid] + NS_PER_TICK);
-	if (r == 0)
-		HYPERVISOR_block();
-	else
-		__sti();
-#endif
+	KASSERT(curcpu()-ci_ipending == 0);
+	HYPERVISOR_block();
 }



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-10-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Oct 22 22:42:21 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
More improvements:
- Precise what tmutex protects
- springle some KASSERT(mutex_owned(tmutex))
- the system time uses the CPU timecounter to get some precision;
  don't mix local CPU timecounter with VCPU0's time, it won't work well.
  Always use curcpu()'s time.


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.6 -r1.54.6.7 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.6 src/sys/arch/xen/xen/clock.c:1.54.6.7
--- src/sys/arch/xen/xen/clock.c:1.54.6.6	Sat Oct 22 21:16:59 2011
+++ src/sys/arch/xen/xen/clock.c	Sat Oct 22 22:42:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.6 2011/10/22 21:16:59 bouyer Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.7 2011/10/22 22:42:20 bouyer Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.6 2011/10/22 21:16:59 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.7 2011/10/22 22:42:20 bouyer Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -79,11 +79,12 @@ struct shadow {
 	struct timespec ts;
 };
 
+/* Protects volatile variables ci_shadow  xen_clock_bias */
+static kmutex_t tmutex;
+
 /* Per CPU shadow time values */
 static volatile struct shadow ci_shadow[MAXCPUS];
 
-static kmutex_t tmutex; /* Protects volatile variables, below */
-
 /* The time when the last hardclock(9) call should have taken place,
  * per cpu.
  */
@@ -116,6 +117,7 @@ get_time_values_from_xen(struct cpu_info
 	volatile struct vcpu_time_info *t = ci-ci_vcpu-time;
 	uint32_t tversion;
 
+	KASSERT(mutex_owned(tmutex));
 	do {
 		shadow-time_version = t-version;
 		xen_rmb();
@@ -142,9 +144,11 @@ static inline int
 time_values_up_to_date(struct cpu_info *ci)
 {
 	int rv;
+	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
+
 	KASSERT(ci != NULL);
+	KASSERT(mutex_owned(tmutex));
 
-	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
 	xen_rmb();
 	rv = shadow-time_version == ci-ci_vcpu-time.version;
@@ -187,6 +191,7 @@ get_tsc_offset_ns(struct cpu_info *ci)
 	uint64_t tsc_delta, offset;
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
+	KASSERT(mutex_owned(tmutex));
 	tsc_delta = cpu_counter() - shadow-tsc_stamp;
 	offset = scale_delta(tsc_delta, shadow-freq_mul,
 	shadow-freq_shift);
@@ -212,53 +217,36 @@ get_vcpu_time(struct cpu_info *ci)
 	uint64_t offset, stime;
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 	
-	for (;;) {
+	KASSERT(mutex_owned(tmutex));
+	do {
+		get_time_values_from_xen(ci);
 		offset = get_tsc_offset_ns(ci);
 		stime = shadow-system_time + offset;
 		
 		/* if the timestamp went stale before we used it, refresh */
-		if (time_values_up_to_date(ci)) {
-			/*
-			 * Work around an intermittent Xen2 bug where, for
-			 * a period of 132 ns, currently running domains
-			 * don't get their timer events as usual (and also
-			 * aren't preempted in favor of other runnable
-			 * domains).  Setting the timer into the past in
-			 * this way causes it to fire immediately.
-			 */
-			break;
-		}
-		get_time_values_from_xen(ci);
-	}
+	} while (!time_values_up_to_date(ci));
 
 	return stime;
 }
 
-/*
- * SMP note: system time always derives from Boot Processor.
- * Must be called at splhigh. See comment above on get_vcpu_time()
- */
-static uint64_t
-get_system_time(void)
-{
-	return get_vcpu_time(cpu_info_primary);
-
-}
-
 static void
 xen_wall_time(struct timespec *wt)
 {
 	uint64_t nsec;
-	struct cpu_info *ci = cpu_info_primary;
+	struct cpu_info *ci = curcpu();
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
 	mutex_enter(tmutex);
-	get_time_values_from_xen(ci);
-	*wt = shadow-ts;
-	nsec = wt-tv_nsec;
+	do {
+		/*
+		 * Under Xen3, shadow-ts is the wall time less system time
+		 * get_vcpu_time() will update shadow
+		 */
+		nsec = get_vcpu_time(curcpu());
+		*wt = shadow-ts;
+		nsec += wt-tv_nsec;
 
-	/* Under Xen3, this is the wall time less system time */
-	nsec += get_system_time();
+	} while (!time_values_up_to_date(ci));
 	mutex_exit(tmutex);
 	wt-tv_sec += nsec / 10L;
 	wt-tv_nsec = nsec % 10L;
@@ -300,7 +288,7 @@ xen_rtc_set(todr_chip_handle_t todr, str
 		op.u.settime.secs	 = tvp-tv_sec;
 		op.u.settime.nsecs	 = tvp-tv_usec * 1000;
 		mutex_enter(tmutex);
-		op.u.settime.system_time = get_system_time();
+		op.u.settime.system_time = get_vcpu_time(curcpu());
 		mutex_exit(tmutex);
 #if __XEN_INTERFACE_VERSION__  0x00030204
 		return HYPERVISOR_dom0_op(op);
@@ -363,6 +351,7 @@ xen_delay(unsigned int n)
 		when = shadow-system_time + n * 1000;
 		while (shadow-system_time  when) {
 			mutex_exit(tmutex);
+			HYPERVISOR_yield();
 			mutex_enter(tmutex);
 

CVS commit: [cherry-xenmp] src/sys/arch

2011-10-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Oct 21 18:08:44 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64 [cherry-xenmp]: fpu.c
src/sys/arch/x86/x86 [cherry-xenmp]: x86_machdep.c
src/sys/arch/xen/x86 [cherry-xenmp]: x86_xpmap.c

Log Message:
Make this build without 'options MULTIPROCESSOR'


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.1 -r1.34.2.2 src/sys/arch/amd64/amd64/fpu.c
cvs rdiff -u -r1.50.2.2 -r1.50.2.3 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.26.2.11 -r1.26.2.12 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/fpu.c
diff -u src/sys/arch/amd64/amd64/fpu.c:1.34.2.1 src/sys/arch/amd64/amd64/fpu.c:1.34.2.2
--- src/sys/arch/amd64/amd64/fpu.c:1.34.2.1	Fri Jun  3 13:27:37 2011
+++ src/sys/arch/amd64/amd64/fpu.c	Fri Oct 21 18:08:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.34.2.1 2011/06/03 13:27:37 cherry Exp $	*/
+/*	$NetBSD: fpu.c,v 1.34.2.2 2011/10/21 18:08:44 bouyer 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.34.2.1 2011/06/03 13:27:37 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: fpu.c,v 1.34.2.2 2011/10/21 18:08:44 bouyer Exp $);
 
 #include opt_multiprocessor.h
 
@@ -407,7 +407,7 @@ fpusave_lwp(struct lwp *l, bool save)
 		}
 		splx(s);
 #ifdef XEN
-		xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
+		(void)xen_send_ipi(oci, XEN_IPI_SYNCH_FPU);
 #else /* XEN */
 		x86_send_ipi(oci, X86_IPI_SYNCH_FPU);
 #endif

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.50.2.2 src/sys/arch/x86/x86/x86_machdep.c:1.50.2.3
--- src/sys/arch/x86/x86/x86_machdep.c:1.50.2.2	Thu Jun 23 14:19:49 2011
+++ src/sys/arch/x86/x86/x86_machdep.c	Fri Oct 21 18:08:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.50.2.2 2011/06/23 14:19:49 cherry Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.50.2.3 2011/10/21 18:08:44 bouyer 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.50.2.2 2011/06/23 14:19:49 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_machdep.c,v 1.50.2.3 2011/10/21 18:08:44 bouyer Exp $);
 
 #include opt_modular.h
 #include opt_physmem.h
@@ -201,7 +201,7 @@ cpu_need_resched(struct cpu_info *ci, in
 			return;
 		if (x86_cpu_idle_ipi != false) {
 #ifdef XEN
-			xen_send_ipi(ci, XEN_IPI_KICK);
+			(void)xen_send_ipi(ci, XEN_IPI_KICK);
 #else /* XEN */
 			x86_send_ipi(ci, 0);
 #endif /* XEN */
@@ -227,7 +227,7 @@ cpu_need_resched(struct cpu_info *ci, in
 	}
 	if ((flags  RESCHED_IMMED) != 0) {
 #ifdef XEN
-		xen_send_ipi(ci, XEN_IPI_KICK);
+		(void)xen_send_ipi(ci, XEN_IPI_KICK);
 #else /* XEN */
 		x86_send_ipi(ci, 0);
 #endif /* XEN */
@@ -242,7 +242,7 @@ cpu_signotify(struct lwp *l)
 	aston(l, X86_AST_GENERIC);
 	if (l-l_cpu != curcpu())
 #ifdef XEN
-		xen_send_ipi(l-l_cpu, XEN_IPI_KICK);
+		(void)xen_send_ipi(l-l_cpu, XEN_IPI_KICK);
 #else /* XEN */
 		x86_send_ipi(l-l_cpu, 0);
 #endif /* XEN */

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.11 src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.12
--- src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.11	Tue Sep 20 18:57:53 2011
+++ src/sys/arch/xen/x86/x86_xpmap.c	Fri Oct 21 18:08:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.26.2.11 2011/09/20 18:57:53 cherry Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.26.2.12 2011/10/21 18:08:44 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert m...@adviseo.fr
@@ -69,7 +69,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.11 2011/09/20 18:57:53 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.12 2011/10/21 18:08:44 bouyer Exp $);
 
 #include opt_xen.h
 #include opt_ddb.h
@@ -165,9 +165,7 @@ void xpq_debug_dump(void);
 static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
 static int xpq_idx_array[MAXCPUS];
 
-#ifdef MULTIPROCESSOR
 extern struct cpu_info * (*xpq_cpu)(void);
-#endif /* MULTIPROCESSOR */
 
 void
 xpq_flush_queue(void)



CVS commit: [cherry-xenmp] src/sys/arch

2011-09-20 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Tue Sep 20 18:57:54 UTC 2011

Modified Files:
src/sys/arch/amd64/include [cherry-xenmp]: pmap.h
src/sys/arch/i386/i386 [cherry-xenmp]: gdt.c machdep.c
src/sys/arch/i386/include [cherry-xenmp]: pmap.h
src/sys/arch/x86/include [cherry-xenmp]: pmap.h
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c pmap_tlb.c
src/sys/arch/xen/include [cherry-xenmp]: xenpmap.h
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c xen_bus_dma.c
xen_pmap.c xenfunc.c
src/sys/arch/xen/xen [cherry-xenmp]: if_xennet_xenbus.c
xennetback_xenbus.c

Log Message:
Remove the xpq lock, since we have per-cpu mmu queues now. This may need 
further testing. Also add some preliminary locking around queue-ops in the 
network backend driver


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.2 -r1.24.2.3 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.50.10.2 -r1.50.10.3 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.702.2.6 -r1.702.2.7 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.109.2.2 -r1.109.2.3 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.121.2.7 -r1.121.2.8 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.3.2.4 -r1.3.2.5 src/sys/arch/x86/x86/pmap_tlb.c
cvs rdiff -u -r1.27.2.4 -r1.27.2.5 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.56.2.11 -r1.56.2.12 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.10 -r1.26.2.11 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.22.6.1 -r1.22.6.2 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.2.2.4 -r1.2.2.5 src/sys/arch/xen/x86/xen_pmap.c
cvs rdiff -u -r1.11.6.2 -r1.11.6.3 src/sys/arch/xen/x86/xenfunc.c
cvs rdiff -u -r1.51.2.1 -r1.51.2.2 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.46.2.1 -r1.46.2.2 src/sys/arch/xen/xen/xennetback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.24.2.2 src/sys/arch/amd64/include/pmap.h:1.24.2.3
--- src/sys/arch/amd64/include/pmap.h:1.24.2.2	Sat Aug 20 19:22:46 2011
+++ src/sys/arch/amd64/include/pmap.h	Tue Sep 20 18:57:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.24.2.2 2011/08/20 19:22:46 cherry Exp $	*/
+/*	$NetBSD: pmap.h,v 1.24.2.3 2011/09/20 18:57:50 cherry Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -277,9 +277,7 @@
 pmap_pte_set(pt_entry_t *pte, pt_entry_t npte)
 {
 	int s = splvm();
-	xpq_queue_lock();
 	xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
-	xpq_queue_unlock();
 	splx(s);
 }
 
@@ -288,14 +286,12 @@
 {
 	int s = splvm();
 
-	xpq_queue_lock();
 	pt_entry_t opte = *ptep;
 
 	if (opte == o) {
 		xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(ptep)), n);
 		xpq_flush_queue();
 	}
-	xpq_queue_unlock();
 	splx(s);
 	return opte;
 }
@@ -304,11 +300,9 @@
 pmap_pte_testset(volatile pt_entry_t *pte, pt_entry_t npte)
 {
 	int s = splvm();
-	xpq_queue_lock();
 	pt_entry_t opte = *pte;
 	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)), npte);
 	xpq_flush_queue();
-	xpq_queue_unlock();
 	splx(s);
 	return opte;
 }
@@ -317,10 +311,8 @@
 pmap_pte_setbits(volatile pt_entry_t *pte, pt_entry_t bits)
 {
 	int s = splvm();
-	xpq_queue_lock();
 	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)), (*pte) | bits);
 	xpq_flush_queue();
-	xpq_queue_unlock();
 	splx(s);
 }
 
@@ -328,11 +320,9 @@
 pmap_pte_clearbits(volatile pt_entry_t *pte, pt_entry_t bits)
 {	
 	int s = splvm();
-	xpq_queue_lock();
 	xpq_queue_pte_update(xpmap_ptetomach(__UNVOLATILE(pte)),
 	(*pte)  ~bits);
 	xpq_flush_queue();
-	xpq_queue_unlock();
 	splx(s);
 }
 
@@ -340,9 +330,7 @@
 pmap_pte_flush(void)
 {
 	int s = splvm();
-	xpq_queue_lock();
 	xpq_flush_queue();
-	xpq_queue_unlock();
 	splx(s);
 }
 #endif

Index: src/sys/arch/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.50.10.2 src/sys/arch/i386/i386/gdt.c:1.50.10.3
--- src/sys/arch/i386/i386/gdt.c:1.50.10.2	Sat Aug  6 14:05:35 2011
+++ src/sys/arch/i386/i386/gdt.c	Tue Sep 20 18:57:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.50.10.2 2011/08/06 14:05:35 cherry Exp $	*/
+/*	$NetBSD: gdt.c,v 1.50.10.3 2011/09/20 18:57:51 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.50.10.2 2011/08/06 14:05:35 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.50.10.3 2011/09/20 18:57:51 cherry Exp $);
 
 #include opt_multiprocessor.h
 #include opt_xen.h
@@ -214,11 +214,9 @@
 		* properly yet, ie; curcpu() won't work at this
 		* point and spl() will break.
 		*/
-		   xpq_queue_lock();
 		   xpq_queue_pte_update(xpmap_ptetomach(ptp),
 	*ptp  ~PG_RW);
 		   xpq_flush_queue();
-		   xpq_queue_unlock();
 		}
 	}
 

Index: 

CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-09-18 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Sep 18 16:48:23 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: x86_xpmap.c

Log Message:
Make the xpq locking per-cpu


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.9 -r1.26.2.10 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.9 src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.10
--- src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.9	Fri Sep  9 11:53:43 2011
+++ src/sys/arch/xen/x86/x86_xpmap.c	Sun Sep 18 16:48:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.26.2.9 2011/09/09 11:53:43 cherry Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.26.2.10 2011/09/18 16:48:23 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert m...@adviseo.fr
@@ -69,7 +69,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.9 2011/09/09 11:53:43 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.10 2011/09/18 16:48:23 cherry Exp $);
 
 #include opt_xen.h
 #include opt_ddb.h
@@ -168,26 +168,26 @@
 static int xpq_idx_array[MAXCPUS];
 
 #ifdef MULTIPROCESSOR
-static struct simplelock xpq_lock = SIMPLELOCK_INITIALIZER;
+static struct simplelock xpq_lock[MAXCPUS];
 
 extern struct cpu_info * (*xpq_cpu)(void);
 
 void
 xpq_queue_lock(void)
 {
-	simple_lock(xpq_lock);
+	simple_lock(xpq_lock[xpq_cpu()-ci_cpuid]);
 }
 
 void
 xpq_queue_unlock(void)
 {
-	simple_unlock(xpq_lock);
+	simple_unlock(xpq_lock[xpq_cpu()-ci_cpuid]);
 }
 
 bool
 xpq_queue_locked(void)
 {
-	return simple_lock_held(xpq_lock);
+	return simple_lock_held(xpq_lock[xpq_cpu()-ci_cpuid]);
 }
 #endif /* MULTIPROCESSOR */
 
@@ -589,12 +589,15 @@
 vaddr_t
 xen_pmap_bootstrap(void)
 {
-	int count, oldcount;
+	int count, oldcount, i;
 	long mapsize;
 	vaddr_t bootstrap_tables, init_tables;
 
 	memset(xpq_idx_array, 0, sizeof xpq_idx_array);
-	
+	for (i = 0; i  MAXCPUS;i++) {
+		simple_lock_init(xpq_lock[i]);
+	}
+
 	xpmap_phys_to_machine_mapping =
 	(unsigned long *)xen_start_info.mfn_list;
 	init_tables = xen_start_info.pt_base;



CVS commit: [cherry-xenmp] src/sys/arch/xen

2011-09-18 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Sep 18 18:46:41 UTC 2011

Modified Files:
src/sys/arch/xen/include [cherry-xenmp]: hypervisor.h intrdefs.h
src/sys/arch/xen/x86 [cherry-xenmp]: hypervisor_machdep.c xen_ipi.c
src/sys/arch/xen/xen [cherry-xenmp]: evtchn.c

Log Message:
Use an IPI to re-route events to the cpu where the handler has been registered


To generate a diff of this commit:
cvs rdiff -u -r1.31.10.2 -r1.31.10.3 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.9.34.2 -r1.9.34.3 src/sys/arch/xen/include/intrdefs.h
cvs rdiff -u -r1.14.2.4 -r1.14.2.5 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.47.6.4 -r1.47.6.5 src/sys/arch/xen/xen/evtchn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.31.10.2 src/sys/arch/xen/include/hypervisor.h:1.31.10.3
--- src/sys/arch/xen/include/hypervisor.h:1.31.10.2	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/xen/include/hypervisor.h	Sun Sep 18 18:46:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.31.10.2 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.31.10.3 2011/09/18 18:46:40 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -134,12 +134,12 @@
 void hypervisor_enable_event(unsigned int);
 
 /* hypervisor_machdep.c */
+void hypervisor_send_event(struct cpu_info *, unsigned int);
 void hypervisor_unmask_event(unsigned int);
 void hypervisor_mask_event(unsigned int);
 void hypervisor_clear_event(unsigned int);
 void hypervisor_enable_ipl(unsigned int);
-void hypervisor_set_ipending(struct cpu_info *, 
-			 uint32_t, int, int);
+void hypervisor_set_ipending(struct cpu_info *, uint32_t, int, int);
 void hypervisor_machdep_attach(void);
 
 /* 

Index: src/sys/arch/xen/include/intrdefs.h
diff -u src/sys/arch/xen/include/intrdefs.h:1.9.34.2 src/sys/arch/xen/include/intrdefs.h:1.9.34.3
--- src/sys/arch/xen/include/intrdefs.h:1.9.34.2	Fri Jun  3 13:27:40 2011
+++ src/sys/arch/xen/include/intrdefs.h	Sun Sep 18 18:46:40 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: intrdefs.h,v 1.9.34.2 2011/06/03 13:27:40 cherry Exp $ */
+/* $NetBSD: intrdefs.h,v 1.9.34.3 2011/09/18 18:46:40 cherry Exp $ */
 
 /* This file co-exists, and is included via machine/intrdefs.h */
 
@@ -11,7 +11,8 @@
 #define XEN_IPI_SYNCH_FPU	0x0002
 #define XEN_IPI_DDB		0x0004
 #define XEN_IPI_XCALL		0x0008
+#define XEN_IPI_HVCB		0x0010
 
-#define XEN_NIPIS 4 /* IPI_KICK doesn't have a handler */
+#define XEN_NIPIS 5 /* IPI_KICK doesn't have a handler */
 
 #endif /* _XEN_INTRDEFS_H_ */

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.4 src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.5
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.4	Mon Aug 22 16:48:03 2011
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Sun Sep 18 18:46:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.5 2011/09/18 18:46:40 cherry Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -281,6 +281,36 @@
 }
 
 void
+hypervisor_send_event(struct cpu_info *ci, unsigned int ev)
+{
+	KASSERT(ci != NULL);
+
+	volatile shared_info_t *s = HYPERVISOR_shared_info;
+	volatile struct vcpu_info *vci = ci-ci_vcpu;
+
+#ifdef PORT_DEBUG
+	if (ev == PORT_DEBUG)
+		printf(hypervisor_send_event %d\n, ev);
+#endif
+
+	xen_atomic_set_bit(s-evtchn_pending[0], ev);
+	xen_atomic_set_bit(vci-evtchn_pending_sel,
+			   ev  LONG_SHIFT);
+
+	xen_atomic_set_bit(vci-evtchn_upcall_pending, 0);
+
+	xen_atomic_clear_bit(s-evtchn_mask[0], ev);
+
+	if (__predict_true(ci == curcpu())) {
+		hypervisor_force_callback();
+	} else {
+		if (xen_send_ipi(ci, XEN_IPI_HVCB)) {
+			panic(xen_send_ipi(cpu%d, XEN_IPI_HVCB) failed\n, (int) ci-ci_cpuid);
+		}
+	}
+}
+
+void
 hypervisor_unmask_event(unsigned int ev)
 {
 	volatile shared_info_t *s = HYPERVISOR_shared_info;

Index: src/sys/arch/xen/x86/xen_ipi.c
diff -u src/sys/arch/xen/x86/xen_ipi.c:1.1.2.3 src/sys/arch/xen/x86/xen_ipi.c:1.1.2.4
--- src/sys/arch/xen/x86/xen_ipi.c:1.1.2.3	Wed Aug 17 09:40:40 2011
+++ src/sys/arch/xen/x86/xen_ipi.c	Sun Sep 18 18:46:40 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_ipi.c,v 1.1.2.3 2011/08/17 09:40:40 cherry Exp $ */
+/* $NetBSD: xen_ipi.c,v 1.1.2.4 2011/09/18 18:46:40 cherry Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -33,10 +33,10 @@
 
 /* 
  * Based on: x86/ipi.c
- * __KERNEL_RCSID(0, $NetBSD: xen_ipi.c,v 1.1.2.3 2011/08/17 09:40:40 

CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-09-18 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Sep 18 18:54:32 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
Register the clock handler at the appropriate ipl (IPL_CLOCK). Cleanup the 
idle_block()


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.3 -r1.54.6.4 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.3 src/sys/arch/xen/xen/clock.c:1.54.6.4
--- src/sys/arch/xen/xen/clock.c:1.54.6.3	Tue Aug 23 16:19:12 2011
+++ src/sys/arch/xen/xen/clock.c	Sun Sep 18 18:54:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.3 2011/08/23 16:19:12 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.4 2011/09/18 18:54:32 cherry Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.3 2011/08/23 16:19:12 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.4 2011/09/18 18:54:32 cherry Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -463,7 +463,7 @@
 	get_time_values_from_xen(ci);
 	vcpu_system_time[ci-ci_cpuid] = shadow-system_time;
 	if (!tcdone) { /* Do this only once */
-		mutex_init(tmutex, MUTEX_DEFAULT, IPL_HIGH);
+		mutex_init(tmutex, MUTEX_DEFAULT, IPL_CLOCK);
 		tc_init(xen_timecounter);
 	}
 	/* The splhigh requirements start here. */
@@ -537,19 +537,6 @@
 void
 idle_block(void)
 {
-	int r;
-
-	/*
-	 * We set the timer to when we expect the next timer
-	 * interrupt.  We could set the timer to later if we could
-	 * easily find out when we will have more work (callouts) to
-	 * process from hardclock.
-	 */
-	r = 0; //HYPERVISOR_set_timer_op(vcpu_system_time[ci-ci_cpuid] + NS_PER_TICK);
-	if (r == 0) {
-		HYPERVISOR_yield();
-		__sti();
-	}
-	else
-		__sti();
+	HYPERVISOR_yield();
+	__sti();
 }



CVS commit: [cherry-xenmp] src/sys/arch/amd64/amd64

2011-09-09 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Sep  9 08:14:39 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64 [cherry-xenmp]: trap.c

Log Message:
Use appropriate format strings.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.66.2.1 src/sys/arch/amd64/amd64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.66 src/sys/arch/amd64/amd64/trap.c:1.66.2.1
--- src/sys/arch/amd64/amd64/trap.c:1.66	Sun Apr  3 22:29:25 2011
+++ src/sys/arch/amd64/amd64/trap.c	Fri Sep  9 08:14:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.66 2011/04/03 22:29:25 dyoung Exp $	*/
+/*	$NetBSD: trap.c,v 1.66.2.1 2011/09/09 08:14:39 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.66 2011/04/03 22:29:25 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.66.2.1 2011/09/09 08:14:39 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -733,7 +733,7 @@
 	(void *)tf-tf_r13, (void *)tf-tf_r14, (void *)tf-tf_r15);
 	printf(rbp %p  rbx %p  rax %p\n,
 	(void *)tf-tf_rbp, (void *)tf-tf_rbx, (void *)tf-tf_rax);
-	printf(cs %p  ds %p  es %p  fs %p  gs %p  ss %p\n,
+	printf(cs %lx  ds %lx  es %lx  fs %lx  gs %lx  ss %lx\n,
 		tf-tf_cs  0x, tf-tf_ds  0x, tf-tf_es  0x,
 		tf-tf_fs  0x, tf-tf_gs  0x, tf-tf_ss  0x);
 	



CVS commit: [cherry-xenmp] src/sys/arch

2011-09-09 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Sep  9 11:38:21 UTC 2011

Modified Files:
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c
src/sys/arch/xen/include [cherry-xenmp]: xenpmap.h

Log Message:
make #define PG_k visible on all xen archs


To generate a diff of this commit:
cvs rdiff -u -r1.121.2.6 -r1.121.2.7 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.27.2.3 -r1.27.2.4 src/sys/arch/xen/include/xenpmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.121.2.6 src/sys/arch/x86/x86/pmap.c:1.121.2.7
--- src/sys/arch/x86/x86/pmap.c:1.121.2.6	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/x86/x86/pmap.c	Fri Sep  9 11:38:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.121.2.6 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.121.2.7 2011/09/09 11:38:20 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.6 2011/08/20 19:22:47 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.7 2011/09/09 11:38:20 cherry Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -211,13 +211,6 @@
 #include xen/hypervisor.h
 #endif
 
-/* flag to be used for kernel mappings: PG_u on Xen/amd64, 0 otherwise */
-#if defined(XEN)  defined(__x86_64__)
-#define PG_k PG_u
-#else
-#define PG_k 0
-#endif
-
 /*
  * general info:
  *

Index: src/sys/arch/xen/include/xenpmap.h
diff -u src/sys/arch/xen/include/xenpmap.h:1.27.2.3 src/sys/arch/xen/include/xenpmap.h:1.27.2.4
--- src/sys/arch/xen/include/xenpmap.h:1.27.2.3	Wed Aug 17 09:40:39 2011
+++ src/sys/arch/xen/include/xenpmap.h	Fri Sep  9 11:38:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: xenpmap.h,v 1.27.2.3 2011/08/17 09:40:39 cherry Exp $	*/
+/*	$NetBSD: xenpmap.h,v 1.27.2.4 2011/09/09 11:38:20 cherry Exp $	*/
 
 /*
  *
@@ -34,6 +34,13 @@
 #include opt_xen.h
 #endif
 
+/* flag to be used for kernel mappings: PG_u on Xen/amd64, 0 otherwise */
+#if defined(XEN)  defined(__x86_64__)
+#define PG_k PG_u
+#else
+#define PG_k 0
+#endif
+
 #define	INVALID_P2M_ENTRY	(~0UL)
 
 #ifdef MULTIPROCESSOR



CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-09-09 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Sep  9 11:53:43 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c

Log Message:
fix amd64 boot.


To generate a diff of this commit:
cvs rdiff -u -r1.56.2.10 -r1.56.2.11 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.8 -r1.26.2.9 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.10 src/sys/arch/xen/x86/cpu.c:1.56.2.11
--- src/sys/arch/xen/x86/cpu.c:1.56.2.10	Thu Sep  1 08:04:46 2011
+++ src/sys/arch/xen/x86/cpu.c	Fri Sep  9 11:53:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.56.2.11 2011/09/09 11:53:43 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.11 2011/09/09 11:53:43 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -712,6 +712,7 @@
  * work. 
  */
 extern void x86_64_tls_switch(struct lwp *);
+
 void
 cpu_hatch(void *v)
 {
@@ -918,7 +919,8 @@
 	 * Use pmap_kernel() L4 PD directly, until we setup the
 	 * per-cpu L4 PD in pmap_cpu_init_late()
 	 */
-	initctx-ctrlreg[3] = xpmap_ptom(pcb-pcb_cr3);
+
+	initctx-ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci-ci_kpm_pdirpa)));
 	initctx-ctrlreg[4] = CR4_PAE | CR4_OSFXSR | CR4_OSXMMEXCPT;
 
 
@@ -1281,7 +1283,7 @@
 	}
 
 	if (__predict_true(pmap != pmap_kernel())) {
-		xen_set_user_pgd(ci-ci_kpm_pdirpa);
+		xen_set_user_pgd(pmap_pdirpa(pmap, 0));
 		ci-ci_xen_current_user_pgd = pmap_pdirpa(pmap, 0);
 	}
 	else {
@@ -1299,6 +1301,27 @@
 
 /*
  * pmap_cpu_init_late: perform late per-CPU initialization.
+ * Short note about percpu PDIR pages:
+ * Both the PAE and __x86_64__ architectures have per-cpu PDIR
+ * tables. This is to get around Xen's pagetable setup constraints for
+ * PAE (multiple L3[3]s cannot point to the same L2 - Xen
+ * will refuse to pin a table setup this way.) and for multiple cpus
+ * to map in different user pmaps on __x86_64__ (see: cpu_load_pmap())
+ *
+ * What this means for us is that the PDIR of the pmap_kernel() is
+ * considered to be a canonical SHADOW PDIR with the following
+ * properties: 
+ * - Its recursive mapping points to itself
+ * - per-cpu recurseive mappings point to themselves
+ * - per-cpu L4 pages' kernel entries are expected to be in sync with
+ *   the shadow
+ * - APDP_PDE_SHADOW accesses the shadow pdir
+ * - APDP_PDE accesses the per-cpu pdir
+ * - alternate mappings are considered per-cpu - however, x86 pmap
+ *   currently partially consults the shadow - this works because the
+ *   shadow PDE is updated together with the per-cpu entry (see:
+ *   xen_pmap.c: pmap_map_ptes(), and the pmap is locked while the
+ * alternate ptes are mapped in.
  */
 
 void
@@ -1315,7 +1338,7 @@
 
 	KASSERT(ci != NULL);
 
-#ifdef PAE
+#if defined(PAE)
 	ci-ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
 	UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
 
@@ -1344,26 +1367,32 @@
 	}
 	ci-ci_kpm_pdirpa = vtophys((vaddr_t) ci-ci_kpm_pdir);
 	KASSERT(ci-ci_kpm_pdirpa != 0);
+
+#if defined(__x86_64__)
 	/*
-	 * Copy over kernel pmd entries from boot
-	 * cpu. XXX:locking/races
+	 * Copy over the pmap_kernel() shadow L4 entries 
 	 */
 
-	memcpy(ci-ci_kpm_pdir,
-	pmap_kernel()-pm_pdir[PDIR_SLOT_KERN],
-	nkptp[PTP_LEVELS - 1] * sizeof(pd_entry_t));
+	memcpy(ci-ci_kpm_pdir, pmap_kernel()-pm_pdir, PAGE_SIZE);
+
+	/* Recursive kernel mapping */
+	ci-ci_kpm_pdir[PDIR_SLOT_PTE] = xpmap_ptom_masked(ci-ci_kpm_pdirpa) | PG_k | PG_V;
+#elif defined(PAE)
+	/* Copy over the pmap_kernel() shadow L2 entries that map the kernel */
+	memcpy(ci-ci_kpm_pdir, pmap_kernel()-pm_pdir + PDIR_SLOT_KERN, nkptp[PTP_LEVELS - 1] * sizeof(pd_entry_t));
+#endif /* __x86_64__ else PAE */
 
 	/* Xen wants R/O */
 	pmap_kenter_pa((vaddr_t)ci-ci_kpm_pdir, ci-ci_kpm_pdirpa,
 	VM_PROT_READ, 0);
 
-#ifdef PAE
+#if defined(PAE)
 	/* Initialise L3 entry 3. This mapping is shared across all
 	 * pmaps and is static, ie; loading a new pmap will not update
 	 * this entry.
 	 */
 	
-	ci-ci_pae_l3_pdir[3] = xpmap_ptom_masked(ci-ci_kpm_pdirpa) | PG_V;
+	ci-ci_pae_l3_pdir[3] = xpmap_ptom_masked(ci-ci_kpm_pdirpa) | PG_k | PG_V;
 
 	/* Mark L3 R/O (Xen wants this) */
 	pmap_kenter_pa((vaddr_t)ci-ci_pae_l3_pdir, ci-ci_pae_l3_pdirpa,

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.8 src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.9
--- src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.8	Tue Aug 30 12:53:46 2011
+++ src/sys/arch/xen/x86/x86_xpmap.c	Fri Sep  9 11:53:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.26.2.8 2011/08/30 12:53:46 

CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-09-03 Thread Michael L. Hitch
Module Name:src
Committed By:   mhitch
Date:   Sun Sep  4 01:15:14 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: xengnt.c

Log Message:
Use a mutex to protect updates to gnt_entries.  Fixes a KASSERT panic
with an MP kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.18.2.1 -r1.18.2.2 src/sys/arch/xen/xen/xengnt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xengnt.c
diff -u src/sys/arch/xen/xen/xengnt.c:1.18.2.1 src/sys/arch/xen/xen/xengnt.c:1.18.2.2
--- src/sys/arch/xen/xen/xengnt.c:1.18.2.1	Thu Jun 23 14:19:50 2011
+++ src/sys/arch/xen/xen/xengnt.c	Sun Sep  4 01:15:13 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.18.2.1 2011/06/23 14:19:50 cherry Exp $  */
+/*  $NetBSD: xengnt.c,v 1.18.2.2 2011/09/04 01:15:13 mhitch Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.18.2.1 2011/06/23 14:19:50 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.18.2.2 2011/09/04 01:15:13 mhitch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -35,6 +35,7 @@
 #include sys/queue.h
 #include sys/extent.h
 #include sys/kernel.h
+#include sys/mutex.h
 #include uvm/uvm.h
 
 #include xen/hypervisor.h
@@ -62,6 +63,8 @@
 /* empty entry in the list */
 #define XENGNT_NO_ENTRY 0x
 
+static kmutex_t	gnt_mutex;
+
 /* VM address of the grant table */
 grant_entry_t *grant_table;
 
@@ -101,6 +104,7 @@
 		gnt_entries[i] = XENGNT_NO_ENTRY;
 
 	last_gnt_entry = 0;
+	mutex_init(gnt_mutex, MUTEX_DEFAULT, IPL_VM);
 	xengnt_resume();
 
 }
@@ -192,13 +196,13 @@
 xengnt_get_entry(void)
 {
 	grant_ref_t entry;
-	int s = splvm();
 	static struct timeval xengnt_nonmemtime;
 	static const struct timeval xengnt_nonmemintvl = {5,0};
 
+	mutex_enter(gnt_mutex);
 	if (last_gnt_entry == 0) {
 		if (xengnt_more_entries()) {
-			splx(s);
+			mutex_exit(gnt_mutex);
 			if (ratecheck(xengnt_nonmemtime, xengnt_nonmemintvl))
 printf(xengnt_get_entry: out of grant 
 table entries\n);
@@ -209,7 +213,7 @@
 	last_gnt_entry--;
 	entry = gnt_entries[last_gnt_entry];
 	gnt_entries[last_gnt_entry] = XENGNT_NO_ENTRY;
-	splx(s);
+	mutex_exit(gnt_mutex);
 	KASSERT(entry != XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry = 0);
 	KASSERT(last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
@@ -222,13 +226,13 @@
 static void
 xengnt_free_entry(grant_ref_t entry)
 {
-	int s = splvm();
+	mutex_enter(gnt_mutex);
 	KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry = 0);
 	KASSERT(last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
 	gnt_entries[last_gnt_entry] = entry;
 	last_gnt_entry++;
-	splx(s);
+	mutex_exit(gnt_mutex);
 }
 
 int



CVS commit: [cherry-xenmp] src/sys/arch

2011-09-01 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Sep  1 08:04:46 UTC 2011

Modified Files:
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c

Log Message:
fix %cr3 init. from mhitch@, tested by riz@  mhitch@


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.5 -r1.34.2.6 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.56.2.9 -r1.56.2.10 src/sys/arch/xen/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.34.2.5 src/sys/arch/x86/include/cpu.h:1.34.2.6
--- src/sys/arch/x86/include/cpu.h:1.34.2.5	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/x86/include/cpu.h	Thu Sep  1 08:04:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.34.2.5 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.34.2.6 2011/09/01 08:04:46 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -176,7 +176,7 @@
 #endif
 
 #ifdef PAE
-	uint32_t	ci_pae_l3_pdirpa; /* PA of L3 PD */
+	paddr_t	ci_pae_l3_pdirpa; /* PA of L3 PD */
 	pd_entry_t *	ci_pae_l3_pdir; /* VA pointer to L3 PD */
 #endif
 

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.9 src/sys/arch/xen/x86/cpu.c:1.56.2.10
--- src/sys/arch/xen/x86/cpu.c:1.56.2.9	Tue Aug 30 12:53:46 2011
+++ src/sys/arch/xen/x86/cpu.c	Thu Sep  1 08:04:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.10 2011/09/01 08:04:46 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -1023,9 +1023,9 @@
 	 * per-cpu L4 PD in pmap_cpu_init_late()
 	 */
 #ifdef PAE
-	initctx-ctrlreg[3] = xpmap_ptom(ci-ci_pae_l3_pdirpa);
+	initctx-ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(ci-ci_pae_l3_pdirpa)));
 #else /* PAE */
-	initctx-ctrlreg[3] = xpmap_ptom(pcb-pcb_cr3);
+	initctx-ctrlreg[3] = xen_pfn_to_cr3(x86_btop(xpmap_ptom(pcb-pcb_cr3)));
 #endif /* PAE */
 	initctx-ctrlreg[4] = /* CR4_PAE |  */CR4_OSFXSR | CR4_OSXMMEXCPT;
 
@@ -1316,35 +1316,16 @@
 	KASSERT(ci != NULL);
 
 #ifdef PAE
-	{
-		int ret;
-		struct pglist pg;
-		struct vm_page *vmap;
-
-		/*
-		 * Allocate a page for the per-CPU L3 PD. cr3 being 32 bits, PA musts
-		 * resides below the 4GB boundary.
-		 */
-		ret = uvm_pglistalloc(PAGE_SIZE, 0,
-		0x1ULL, 32, 0, pg, 1, 0);
-
-		vmap = TAILQ_FIRST(pg);
-
-		if (ret != 0 || vmap == NULL)
-			panic(%s: failed to allocate L3 pglist for CPU %d (ret %d)\n,
-			__func__, cpu_index(ci), ret);
-
-		ci-ci_pae_l3_pdirpa = vmap-phys_addr;
-
-		ci-ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
-		UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+	ci-ci_pae_l3_pdir = (paddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
+	UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
 
-		if (ci-ci_pae_l3_pdir == NULL)
-			panic(%s: failed to allocate L3 PD for CPU %d\n,
-			__func__, cpu_index(ci));
-		pmap_kenter_pa((vaddr_t)ci-ci_pae_l3_pdir, ci-ci_pae_l3_pdirpa,
-		VM_PROT_READ | VM_PROT_WRITE, 0);
+	if (ci-ci_pae_l3_pdir == NULL) {
+		panic(%s: failed to allocate L3 per-cpu PD for CPU %d\n,
+		  __func__, cpu_index(ci));
 	}
+	ci-ci_pae_l3_pdirpa = vtophys((vaddr_t) ci-ci_pae_l3_pdir);
+	KASSERT(ci-ci_pae_l3_pdirpa != 0);
+
 	/* Initialise L2 entries 0 - 2: Point them to pmap_kernel() */
 	ci-ci_pae_l3_pdir[0] =
 	xpmap_ptom_masked(pmap_kernel()-pm_pdirpa[0]) | PG_V;



CVS commit: [cherry-xenmp] src/sys/arch

2011-08-30 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Tue Aug 30 12:53:46 UTC 2011

Modified Files:
src/sys/arch/i386/i386 [cherry-xenmp]: machdep.c
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c

Log Message:
Add per-cpu mmu queues


To generate a diff of this commit:
cvs rdiff -u -r1.702.2.5 -r1.702.2.6 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.56.2.8 -r1.56.2.9 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.7 -r1.26.2.8 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.702.2.5 src/sys/arch/i386/i386/machdep.c:1.702.2.6
--- src/sys/arch/i386/i386/machdep.c:1.702.2.5	Sat Aug 20 19:22:46 2011
+++ src/sys/arch/i386/i386/machdep.c	Tue Aug 30 12:53:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.702.2.6 2011/08/30 12:53:45 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.6 2011/08/30 12:53:45 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -539,6 +539,9 @@
 }
 
 #ifdef XEN
+/* Shim for curcpu() until %fs is ready */
+extern struct cpu_info	* (*xpq_cpu)(void);
+
 /*
  * Switch context:
  * - honor CR0_TS in saved CR0 and request DNA exception on FPU use
@@ -566,6 +569,12 @@
 	update_descriptor(ci-ci_gdt[GUGS_SEL], 
 			  (union descriptor *) pcb-pcb_gsd);
 
+	/* setup curcpu() to use %fs now */
+	/* XXX: find a way to do this, just once */
+	if (__predict_false(xpq_cpu != x86_curcpu)) {
+		xpq_cpu = x86_curcpu;
+	}
+
 	physop.cmd = PHYSDEVOP_SET_IOPL;
 	physop.u.set_iopl.iopl = pcb-pcb_iopl;
 	HYPERVISOR_physdev_op(physop);

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.8 src/sys/arch/xen/x86/cpu.c:1.56.2.9
--- src/sys/arch/xen/x86/cpu.c:1.56.2.8	Fri Aug 26 13:33:34 2011
+++ src/sys/arch/xen/x86/cpu.c	Tue Aug 30 12:53:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.56.2.8 2011/08/26 13:33:34 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.8 2011/08/26 13:33:34 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.9 2011/08/30 12:53:46 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -1104,7 +1104,14 @@
 
 }
 
-void
+/* curcpu() uses %fs - shim for until cpu_init_msrs(), below */
+static struct cpu_info *cpu_primary(void)
+{
+	return cpu_info_primary;
+}
+struct cpu_info	* (*xpq_cpu)(void) = cpu_primary;
+
+	void
 cpu_init_msrs(struct cpu_info *ci, bool full)
 {
 #ifdef __x86_64__
@@ -1112,6 +1119,7 @@
 		HYPERVISOR_set_segment_base (SEGBASE_FS, 0);
 		HYPERVISOR_set_segment_base (SEGBASE_GS_KERNEL, (uint64_t) ci);
 		HYPERVISOR_set_segment_base (SEGBASE_GS_USER, 0);
+		xpq_cpu = x86_curcpu;
 	}
 #endif	/* __x86_64__ */
 

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.7 src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.8
--- src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.7	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/xen/x86/x86_xpmap.c	Tue Aug 30 12:53:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.26.2.7 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.26.2.8 2011/08/30 12:53:46 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert m...@adviseo.fr
@@ -69,7 +69,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.7 2011/08/20 19:22:47 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.8 2011/08/30 12:53:46 cherry Exp $);
 
 #include opt_xen.h
 #include opt_ddb.h
@@ -164,12 +164,14 @@
 #endif
 
 #define XPQUEUE_SIZE 2048
-static mmu_update_t xpq_queue[XPQUEUE_SIZE];
-static int xpq_idx = 0;
+static mmu_update_t xpq_queue_array[MAXCPUS][XPQUEUE_SIZE];
+static int xpq_idx_array[MAXCPUS];
 
 #ifdef MULTIPROCESSOR
 static struct simplelock xpq_lock = SIMPLELOCK_INITIALIZER;
 
+extern struct cpu_info * (*xpq_cpu)(void);
+
 void
 xpq_queue_lock(void)
 {
@@ -195,7 +197,11 @@
 {
 	int i, ok, ret;
 
+	mmu_update_t *xpq_queue = xpq_queue_array[xpq_cpu()-ci_cpuid];
+	int xpq_idx = xpq_idx_array[xpq_cpu()-ci_cpuid];
+
 	KASSERT(xpq_queue_locked());
+
 	XENPRINTK2((flush queue %p entries %d\n, xpq_queue, xpq_idx));
 	for (i = 0; i  xpq_idx; i++)
 		XENPRINTK2((%d: 0x%08 PRIx64  0x%08 PRIx64 \n, i,
@@ -211,7 +217,7 @@
 			   xpq_queue[i].ptr, xpq_queue[i].val);
 		panic(HYPERVISOR_mmu_update failed, ret: %d\n, ret);
 	}
-	xpq_idx = 0;
+	xpq_idx_array[xpq_cpu()-ci_cpuid] = 0;
 }
 
 /* Must be called with xpq_lock held */
@@ -220,14 +226,17 @@
 {
 
 	

CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-08-26 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Aug 26 13:33:34 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c

Log Message:
Name the L4 per-cpu pointer appropriately.
User cr3 should point to the per-cpu L4, not the user pmap pdir


To generate a diff of this commit:
cvs rdiff -u -r1.56.2.7 -r1.56.2.8 src/sys/arch/xen/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.7 src/sys/arch/xen/x86/cpu.c:1.56.2.8
--- src/sys/arch/xen/x86/cpu.c:1.56.2.7	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/xen/x86/cpu.c	Fri Aug 26 13:33:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.56.2.7 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.56.2.8 2011/08/26 13:33:34 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.7 2011/08/20 19:22:47 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.8 2011/08/26 13:33:34 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -1253,10 +1253,10 @@
 	int i, s;
 	pd_entry_t *new_pgd;
 	struct cpu_info *ci;
-	paddr_t l3_shadow_pa;
+	paddr_t l4_pd_ma;
 
 	ci = curcpu();
-	l3_shadow_pa = xpmap_ptom_masked(ci-ci_kpm_pdirpa);
+	l4_pd_ma = xpmap_ptom_masked(ci-ci_kpm_pdirpa);
 
 	/*
 	 * Map user space address in kernel space and load
@@ -1269,15 +1269,15 @@
 
 	/* Copy user pmap L4 PDEs (in user addr. range) to per-cpu L4 */
 	for (i = 0; i  PDIR_SLOT_PTE; i++) {
-		xpq_queue_pte_update(l3_shadow_pa + i * sizeof(pd_entry_t), new_pgd[i]);
+		xpq_queue_pte_update(l4_pd_ma + i * sizeof(pd_entry_t), new_pgd[i]);
 	}
 
 	if (__predict_true(pmap != pmap_kernel())) {
-		xen_set_user_pgd(pmap_pdirpa(pmap, 0));
+		xen_set_user_pgd(ci-ci_kpm_pdirpa);
 		ci-ci_xen_current_user_pgd = pmap_pdirpa(pmap, 0);
 	}
 	else {
-		xpq_queue_pt_switch(l3_shadow_pa);
+		xpq_queue_pt_switch(l4_pd_ma);
 		ci-ci_xen_current_user_pgd = 0;
 	}
 	xpq_queue_unlock();



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-08-23 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Tue Aug 23 16:19:12 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
MP-fy clock. per-cpu hardclock(). Use the periodic timer, instead of the 
one-shot reload.

idle_loop() does not block the domain anymore. Instead, it yields to the 
hypervisor(). We can thus remove the one-shot wakeup timer.


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.2 -r1.54.6.3 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.2 src/sys/arch/xen/xen/clock.c:1.54.6.3
--- src/sys/arch/xen/xen/clock.c:1.54.6.2	Mon Jul 25 17:29:43 2011
+++ src/sys/arch/xen/xen/clock.c	Tue Aug 23 16:19:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.2 2011/07/25 17:29:43 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.3 2011/08/23 16:19:12 cherry Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.2 2011/07/25 17:29:43 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.3 2011/08/23 16:19:12 cherry Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -38,12 +38,14 @@
 #include sys/timetc.h
 #include sys/timevar.h
 #include sys/kernel.h
+#include sys/mutex.h
 #include sys/device.h
 #include sys/sysctl.h
 
 #include xen/xen.h
 #include xen/hypervisor.h
 #include xen/evtchn.h
+#include xen/xen3-public/vcpu.h
 #include machine/cpu_counter.h
 
 #include dev/clock_subr.h
@@ -80,6 +82,8 @@
 /* Per CPU shadow time values */
 static volatile struct shadow ci_shadow[MAXCPUS];
 
+static kmutex_t tmutex; /* Protects volatile variables, below */
+
 /* The time when the last hardclock(9) call should have taken place,
  * per cpu.
  */
@@ -90,7 +94,7 @@
  * back to maintain the illusion that hardclock(9) was called when it
  * was supposed to be, not when Xen got around to scheduling us.
  */
-static volatile uint64_t xen_clock_bias[MAXCPUS];
+static volatile uint64_t xen_clock_bias;
 
 #ifdef DOM0OPS
 /* If we're dom0, send our time to Xen every minute or so. */
@@ -245,18 +249,17 @@
 xen_wall_time(struct timespec *wt)
 {
 	uint64_t nsec;
-	int s;
 	struct cpu_info *ci = cpu_info_primary;
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
-	s = splhigh();
+	mutex_enter(tmutex);
 	get_time_values_from_xen(ci);
 	*wt = shadow-ts;
 	nsec = wt-tv_nsec;
 
 	/* Under Xen3, this is the wall time less system time */
 	nsec += get_system_time();
-	splx(s);
+	mutex_exit(tmutex);
 	wt-tv_sec += nsec / 10L;
 	wt-tv_nsec = nsec % 10L;
 }
@@ -282,8 +285,6 @@
 #else
 	xen_platform_op_t op;
 #endif
-	int s;
-
 	if (xendomain_is_privileged()) {
  		/* needs to set the RTC chip too */
  		struct clock_ymdhms dt;
@@ -298,9 +299,9 @@
 		/* XXX is rtc_offset handled correctly everywhere? */
 		op.u.settime.secs	 = tvp-tv_sec;
 		op.u.settime.nsecs	 = tvp-tv_usec * 1000;
-		s = splhigh();
+		mutex_enter(tmutex);
 		op.u.settime.system_time = get_system_time();
-		splx(s);
+		mutex_exit(tmutex);
 #if __XEN_INTERFACE_VERSION__  0x00030204
 		return HYPERVISOR_dom0_op(op);
 #else
@@ -355,18 +356,17 @@
 		return;
 	} else {
 		uint64_t when;
-		int s;
 		/* for large delays, shadow-system_time is OK */
 		
-		s = splhigh();
+		mutex_enter(tmutex);
 		get_time_values_from_xen(ci);
 		when = shadow-system_time + n * 1000;
 		while (shadow-system_time  when) {
-			splx(s);
-			s = splhigh();
+			mutex_exit(tmutex);
+			mutex_enter(tmutex);
 			get_time_values_from_xen(ci);
 		}
-		splx(s);
+		mutex_exit(tmutex);
 	}
 }
 
@@ -416,11 +416,10 @@
 xen_get_timecount(struct timecounter *tc)
 {
 	uint64_t ns;
-	int s;
 
-	s = splhigh();
-	ns = get_system_time() - xen_clock_bias[0];
-	splx(s);
+	mutex_enter(tmutex);
+	ns = get_system_time() - xen_clock_bias;
+	mutex_exit(tmutex);
 
 	return (u_int)ns;
 }
@@ -437,13 +436,15 @@
 void
 xen_initclocks(void)
 {
-	int evtch;
+	int err, evtch;
 	static bool tcdone = false;
 
+	struct vcpu_set_periodic_timer hardclock_period = { NS_PER_TICK };
+
 	struct cpu_info *ci = curcpu();
 	volatile struct shadow *shadow = ci_shadow[ci-ci_cpuid];
 
-	xen_clock_bias[ci-ci_cpuid] = 0;
+	xen_clock_bias = 0;
 
 	evcnt_attach_dynamic(hardclock_called[ci-ci_cpuid],
 			 EVCNT_TYPE_INTR,
@@ -462,10 +463,18 @@
 	get_time_values_from_xen(ci);
 	vcpu_system_time[ci-ci_cpuid] = shadow-system_time;
 	if (!tcdone) { /* Do this only once */
+		mutex_init(tmutex, MUTEX_DEFAULT, IPL_HIGH);
 		tc_init(xen_timecounter);
 	}
 	/* The splhigh requirements start here. */
 
+	/* Set hardclock() frequency */
+	err = HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer,
+ ci-ci_cpuid,
+ hardclock_period);
+
+	KASSERT(err == 0);
+
 	event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
 	ci, IPL_CLOCK, clock);
 	hypervisor_enable_event(evtch);
@@ -493,43 +502,30 @@
 

CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-08-22 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Aug 22 16:48:03 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: hypervisor_machdep.c

Log Message:
Do not trust the hypervisor to route events to the right cpu. Enforce this in 
stipending()


To generate a diff of this commit:
cvs rdiff -u -r1.14.2.3 -r1.14.2.4 src/sys/arch/xen/x86/hypervisor_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.3 src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.4
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.3	Wed Aug 17 09:40:39 2011
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Mon Aug 22 16:48:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.3 2011/08/17 09:40:39 cherry Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.3 2011/08/17 09:40:39 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.4 2011/08/22 16:48:03 cherry Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -140,8 +140,8 @@
 	int *ret = args;
 
 	if (evtsource[port]) {
-		hypervisor_set_ipending(ci, evtsource[port]-ev_imask,
-		l1i, l2i);
+		hypervisor_set_ipending(evtsource[port]-ev_cpu,
+		evtsource[port]-ev_imask, l1i, l2i);
 		evtsource[port]-ev_evcnt.ev_count++;
 		if (*ret == 0  ci-ci_ilevel 
 		evtsource[port]-ev_maxlevel)



CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-08-22 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Aug 22 17:39:19 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: xen_pmap.c

Log Message:
Remove spurious locks


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.3 -r1.2.2.4 src/sys/arch/xen/x86/xen_pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/xen_pmap.c
diff -u src/sys/arch/xen/x86/xen_pmap.c:1.2.2.3 src/sys/arch/xen/x86/xen_pmap.c:1.2.2.4
--- src/sys/arch/xen/x86/xen_pmap.c:1.2.2.3	Sat Aug 20 19:22:47 2011
+++ src/sys/arch/xen/x86/xen_pmap.c	Mon Aug 22 17:39:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_pmap.c,v 1.2.2.3 2011/08/20 19:22:47 cherry Exp $	*/
+/*	$NetBSD: xen_pmap.c,v 1.2.2.4 2011/08/22 17:39:19 cherry Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xen_pmap.c,v 1.2.2.3 2011/08/20 19:22:47 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: xen_pmap.c,v 1.2.2.4 2011/08/22 17:39:19 cherry Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -212,7 +212,6 @@
 
 	/* the kernel's pmap is always accessible */
 	if (pmap == pmap_kernel()) {
-		mutex_enter(pmap-pm_lock);
 		*pmap2 = NULL;
 		*ptepp = PTE_BASE;
 		*pdeppp = normal_pdes;
@@ -327,7 +326,6 @@
 {
 
 	if (pmap == pmap_kernel()) {
-		mutex_exit(pmap-pm_lock);
 		return;
 	}
 	KASSERT(kpreempt_disabled());



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-08-21 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Aug 21 11:24:11 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: if_xennet_xenbus.c
xennetback_xenbus.c

Log Message:
add locking around mmu flush xpq ops


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.51.2.1 src/sys/arch/xen/xen/if_xennet_xenbus.c
cvs rdiff -u -r1.46 -r1.46.2.1 src/sys/arch/xen/xen/xennetback_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.51 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.51.2.1
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.51	Mon May 30 13:03:56 2011
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sun Aug 21 11:24:10 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.51 2011/05/30 13:03:56 joerg Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.51.2.1 2011/08/21 11:24:10 cherry Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_xennet_xenbus.c,v 1.51 2011/05/30 13:03:56 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_xennet_xenbus.c,v 1.51.2.1 2011/08/21 11:24:10 cherry Exp $);
 
 #include opt_xen.h
 #include opt_nfs_boot.h
@@ -663,7 +663,9 @@
 		 * those first!
 		 */
 		s2 = splvm();
+		xpq_queue_lock();
 		xpq_flush_queue();
+		xpq_queue_unlock();		
 		splx(s2);
 		/* now decrease reservation */
 		xenguest_handle(reservation.extent_start) = xennet_pages;

Index: src/sys/arch/xen/xen/xennetback_xenbus.c
diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.46 src/sys/arch/xen/xen/xennetback_xenbus.c:1.46.2.1
--- src/sys/arch/xen/xen/xennetback_xenbus.c:1.46	Mon May 30 14:34:58 2011
+++ src/sys/arch/xen/xen/xennetback_xenbus.c	Sun Aug 21 11:24:10 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xennetback_xenbus.c,v 1.46 2011/05/30 14:34:58 joerg Exp $  */
+/*  $NetBSD: xennetback_xenbus.c,v 1.46.2.1 2011/08/21 11:24:10 cherry Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xennetback_xenbus.c,v 1.46 2011/05/30 14:34:58 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: xennetback_xenbus.c,v 1.46.2.1 2011/08/21 11:24:10 cherry Exp $);
 
 #include opt_xen.h
 
@@ -1077,7 +1077,9 @@
 			 * we flush those first!
 			 */
 			int svm = splvm();
+			xpq_queue_lock();
 			xpq_flush_queue();
+			xpq_queue_unlock();
 			splx(svm);
 			mclp[-1].args[MULTI_UVMFLAGS_INDEX] =
 			UVMF_TLB_FLUSH|UVMF_ALL;



CVS commit: [cherry-xenmp] src/sys/arch

2011-08-20 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Aug 20 19:22:47 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64 [cherry-xenmp]: machdep.c
src/sys/arch/amd64/include [cherry-xenmp]: pmap.h
src/sys/arch/i386/i386 [cherry-xenmp]: machdep.c
src/sys/arch/i386/include [cherry-xenmp]: pmap.h
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c
src/sys/arch/xen/include [cherry-xenmp]: hypervisor.h
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c xen_pmap.c

Log Message:
PAE MP support (preliminary), amd64 per-cpu L4 model redesigned, i386 
pmap_pa_start/end fixup


To generate a diff of this commit:
cvs rdiff -u -r1.160.2.2 -r1.160.2.3 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.24.2.1 -r1.24.2.2 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.702.2.4 -r1.702.2.5 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.109.2.1 -r1.109.2.2 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.34.2.4 -r1.34.2.5 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.121.2.5 -r1.121.2.6 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.31.10.1 -r1.31.10.2 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.56.2.6 -r1.56.2.7 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.6 -r1.26.2.7 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/sys/arch/xen/x86/xen_pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.160.2.2 src/sys/arch/amd64/amd64/machdep.c:1.160.2.3
--- src/sys/arch/amd64/amd64/machdep.c:1.160.2.2	Thu Jun 23 14:18:56 2011
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Aug 20 19:22:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.160.2.2 2011/06/23 14:18:56 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.160.2.3 2011/08/20 19:22:46 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.160.2.2 2011/06/23 14:18:56 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.160.2.3 2011/08/20 19:22:46 cherry Exp $);
 
 /* #define XENDEBUG_LOW  */
 
@@ -1320,8 +1320,8 @@
 	/* Determine physical address space */
 	avail_start = first_avail;
 	avail_end = ctob(xen_start_info.nr_pages);
-	pmap_pa_start = (KERNTEXTOFF - KERNBASE);
-	pmap_pa_end = avail_end;
+	pmap_pa_start = XPMAP_OFFSET;
+	pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
 	__PRINTK((pmap_pa_start 0x%lx avail_start 0x%lx avail_end 0x%lx\n,
 	pmap_pa_start, avail_start, avail_end));
 #endif	/* !XEN */

Index: src/sys/arch/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.24.2.1 src/sys/arch/amd64/include/pmap.h:1.24.2.2
--- src/sys/arch/amd64/include/pmap.h:1.24.2.1	Fri Jun  3 13:27:38 2011
+++ src/sys/arch/amd64/include/pmap.h	Sat Aug 20 19:22:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.24.2.1 2011/06/03 13:27:38 cherry Exp $	*/
+/*	$NetBSD: pmap.h,v 1.24.2.2 2011/08/20 19:22:46 cherry Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -191,7 +191,8 @@
 #define AL4_BASE ((pd_entry_t *)((char *)AL3_BASE + L4_SLOT_PTE * NBPD_L1))
 
 #define PDP_PDE		(L4_BASE + PDIR_SLOT_PTE)
-#define APDP_PDE	(L4_BASE + PDIR_SLOT_APTE)
+#define APDP_PDE	(curcpu()-ci_kpm_pdir[PDIR_SLOT_APTE])
+#define APDP_PDE_SHADOW	(L4_BASE + PDIR_SLOT_APTE)
 
 #define PDP_BASE	L4_BASE
 #define APDP_BASE	AL4_BASE

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.702.2.4 src/sys/arch/i386/i386/machdep.c:1.702.2.5
--- src/sys/arch/i386/i386/machdep.c:1.702.2.4	Sun Aug  7 19:48:07 2011
+++ src/sys/arch/i386/i386/machdep.c	Sat Aug 20 19:22:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.5 2011/08/20 19:22:46 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1437,7 +1437,7 @@
 	avail_start = first_avail;
 	avail_end = ctob(xen_start_info.nr_pages) + XPMAP_OFFSET;
 	pmap_pa_start = (KERNTEXTOFF - KERNBASE);
-	pmap_pa_end = avail_end;
+	pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
 	mem_clusters[0].start = avail_start;
 	mem_clusters[0].size = avail_end - avail_start;
 	mem_cluster_cnt++;

Index: src/sys/arch/i386/include/pmap.h
diff -u src/sys/arch/i386/include/pmap.h:1.109.2.1 src/sys/arch/i386/include/pmap.h:1.109.2.2
--- src/sys/arch/i386/include/pmap.h:1.109.2.1	Sun Jul 31 20:49:11 2011
+++ src/sys/arch/i386/include/pmap.h	Sat Aug 20 19:22:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: 

CVS commit: [cherry-xenmp] src/sys/arch

2011-08-17 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Wed Aug 17 09:40:40 UTC 2011

Modified Files:
src/sys/arch/i386/include [cherry-xenmp]: cpu.h
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c
src/sys/arch/xen/include [cherry-xenmp]: evtchn.h intr.h xenpmap.h
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c hypervisor_machdep.c intr.c
x86_xpmap.c xen_ipi.c
src/sys/arch/xen/xen [cherry-xenmp]: evtchn.c xentests.c

Log Message:
Pullup relevant changes from -current


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.176.12.1 src/sys/arch/i386/include/cpu.h
cvs rdiff -u -r1.34.2.3 -r1.34.2.4 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.121.2.4 -r1.121.2.5 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.18.10.2 -r1.18.10.3 src/sys/arch/xen/include/evtchn.h
cvs rdiff -u -r1.31.10.3 -r1.31.10.4 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.27.2.2 -r1.27.2.3 src/sys/arch/xen/include/xenpmap.h
cvs rdiff -u -r1.56.2.5 -r1.56.2.6 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.27.6.1 -r1.27.6.2 src/sys/arch/xen/x86/intr.c
cvs rdiff -u -r1.26.2.5 -r1.26.2.6 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.47.6.3 -r1.47.6.4 src/sys/arch/xen/xen/evtchn.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/xen/xen/xentests.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/include/cpu.h
diff -u src/sys/arch/i386/include/cpu.h:1.176 src/sys/arch/i386/include/cpu.h:1.176.12.1
--- src/sys/arch/i386/include/cpu.h:1.176	Mon Dec 29 19:59:09 2008
+++ src/sys/arch/i386/include/cpu.h	Wed Aug 17 09:40:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.176 2008/12/29 19:59:09 pooka Exp $	*/
+/*	$NetBSD: cpu.h,v 1.176.12.1 2011/08/17 09:40:39 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -68,6 +68,7 @@
 	(*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp)));
 	return l;
 }
+
 __inline static void __unused
 cpu_set_curpri(int pri)
 {

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.34.2.3 src/sys/arch/x86/include/cpu.h:1.34.2.4
--- src/sys/arch/x86/include/cpu.h:1.34.2.3	Sat Jul 16 10:59:45 2011
+++ src/sys/arch/x86/include/cpu.h	Wed Aug 17 09:40:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.34.2.3 2011/07/16 10:59:45 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.34.2.4 2011/08/17 09:40:39 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -67,8 +67,6 @@
 #include sys/evcnt.h
 #include sys/device_if.h /* for device_t */
 
-#include sys/device_if.h /* for device_t */
-
 #ifdef XEN
 #include xen/xen3-public/xen.h
 #include xen/xen3-public/event_channel.h
@@ -316,6 +314,8 @@
 void cpu_init_idle_lwps(void);
 void cpu_init_msrs(struct cpu_info *, bool);
 void cpu_load_pmap(struct pmap *);
+void cpu_broadcast_halt(void);
+void cpu_kick(struct cpu_info *);
 
 extern uint32_t cpus_attached;
 

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.121.2.4 src/sys/arch/x86/x86/pmap.c:1.121.2.5
--- src/sys/arch/x86/x86/pmap.c:1.121.2.4	Sun Jul 31 20:49:11 2011
+++ src/sys/arch/x86/x86/pmap.c	Wed Aug 17 09:40:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.121.2.4 2011/07/31 20:49:11 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.121.2.5 2011/08/17 09:40:39 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.4 2011/07/31 20:49:11 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.5 2011/08/17 09:40:39 cherry Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -1619,10 +1619,6 @@
 		VM_PROT_READ | VM_PROT_WRITE, 0);
 
 	pmap_update(pmap_kernel());
-
-	xpq_queue_lock();
-	xpq_queue_pin_l3_table(xpmap_ptom_masked(ci-ci_pae_l3_pdirpa));
-	xpq_queue_unlock();
 #endif
 #if defined(XEN)  defined (__x86_64)
 	KASSERT(ci != NULL);

Index: src/sys/arch/xen/include/evtchn.h
diff -u src/sys/arch/xen/include/evtchn.h:1.18.10.2 src/sys/arch/xen/include/evtchn.h:1.18.10.3
--- src/sys/arch/xen/include/evtchn.h:1.18.10.2	Thu Aug  4 09:07:46 2011
+++ src/sys/arch/xen/include/evtchn.h	Wed Aug 17 09:40:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.h,v 1.18.10.2 2011/08/04 09:07:46 cherry Exp $	*/
+/*	$NetBSD: evtchn.h,v 1.18.10.3 2011/08/17 09:40:39 cherry Exp $	*/
 
 /*
  *
@@ -41,10 +41,9 @@
 int event_set_handler(int, int (*func)(void *), void *, int, const char *);
 int event_remove_handler(int, int (*func)(void *), void *);
 
+struct cpu_info;
 struct intrhand;
-void event_set_iplhandler(struct cpu_info *ci,
-			  struct intrhand *, 
-			  int);
+void event_set_iplhandler(struct cpu_info *, struct intrhand *, int);
 
 extern int 

CVS commit: [cherry-xenmp] src/sys/arch

2011-08-07 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Aug  7 19:48:08 UTC 2011

Modified Files:
src/sys/arch/i386/i386 [cherry-xenmp]: machdep.c
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c

Log Message:
Fix XEN3PAE_DOMx build


To generate a diff of this commit:
cvs rdiff -u -r1.702.2.3 -r1.702.2.4 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.56.2.4 -r1.56.2.5 src/sys/arch/xen/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.702.2.3 src/sys/arch/i386/i386/machdep.c:1.702.2.4
--- src/sys/arch/i386/i386/machdep.c:1.702.2.3	Sat Aug  6 21:06:34 2011
+++ src/sys/arch/i386/i386/machdep.c	Sun Aug  7 19:48:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.702.2.3 2011/08/06 21:06:34 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.3 2011/08/06 21:06:34 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.4 2011/08/07 19:48:07 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1195,7 +1195,7 @@
 		pt_entry_t pg_nx = (cpu_feature[2]  CPUID_NOX ? PG_NX : 0);
 
 		pte = kvtopte((vaddr_t)gdt);
-		npte = pmap_pa2pte((paddr_t)gdt - KERNBASE);
+		npte = pmap_pa2pte((vaddr_t)gdt - KERNBASE);
 		npte |= PG_RO | pg_nx | PG_V;
 
 		xpq_queue_lock();

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.56.2.4 src/sys/arch/xen/x86/cpu.c:1.56.2.5
--- src/sys/arch/xen/x86/cpu.c:1.56.2.4	Sun Jul 31 20:49:11 2011
+++ src/sys/arch/xen/x86/cpu.c	Sun Aug  7 19:48:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.56.2.4 2011/07/31 20:49:11 cherry Exp $	*/
+/*	$NetBSD: cpu.c,v 1.56.2.5 2011/08/07 19:48:08 cherry Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.4 2011/07/31 20:49:11 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.56.2.5 2011/08/07 19:48:08 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -140,7 +140,7 @@
 	bool sc_wasonline;
 };
 
-int mp_cpu_start(struct cpu_info *, paddr_t);
+int mp_cpu_start(struct cpu_info *, vaddr_t);
 void mp_cpu_start_cleanup(struct cpu_info *);
 const struct cpu_functions mp_cpu_funcs = { mp_cpu_start, NULL,
   mp_cpu_start_cleanup };



CVS commit: [cherry-xenmp] src/sys/arch/i386/i386

2011-08-06 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Aug  6 14:05:35 UTC 2011

Modified Files:
src/sys/arch/i386/i386 [cherry-xenmp]: gdt.c

Log Message:
gdtgrow() must extend the gdt size on all cpus, not just the primary


To generate a diff of this commit:
cvs rdiff -u -r1.50.10.1 -r1.50.10.2 src/sys/arch/i386/i386/gdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.50.10.1 src/sys/arch/i386/i386/gdt.c:1.50.10.2
--- src/sys/arch/i386/i386/gdt.c:1.50.10.1	Sun Jul 31 20:49:10 2011
+++ src/sys/arch/i386/i386/gdt.c	Sat Aug  6 14:05:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.50.10.1 2011/07/31 20:49:10 cherry Exp $	*/
+/*	$NetBSD: gdt.c,v 1.50.10.2 2011/08/06 14:05:35 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.50.10.1 2011/07/31 20:49:10 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.50.10.2 2011/08/06 14:05:35 cherry Exp $);
 
 #include opt_multiprocessor.h
 #include opt_xen.h
@@ -266,15 +266,17 @@
 			gdt_size[which] = MINGDTSIZ;
 			new_len = gdt_size[which] * sizeof(gdt[0]);
 		}
-		for(va = (vaddr_t)(cpu_info_primary.ci_gdt) + old_len + max_len;
-		va  (vaddr_t)(cpu_info_primary.ci_gdt) + new_len + max_len;
-		va += PAGE_SIZE) {
-			while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
-			== NULL) {
-uvm_wait(gdt_grow);
+		for (CPU_INFO_FOREACH(cii, ci)) {
+			for(va = (vaddr_t)(ci-ci_gdt) + old_len + max_len;
+			va  (vaddr_t)(ci-ci_gdt) + new_len + max_len;
+			va += PAGE_SIZE) {
+while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
+   == NULL) {
+	uvm_wait(gdt_grow);
+}
+pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
+	   VM_PROT_READ | VM_PROT_WRITE, 0);
 			}
-			pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
-			VM_PROT_READ | VM_PROT_WRITE, 0);
 		}
 		return;
 	}



CVS commit: [cherry-xenmp] src/sys/arch/i386/i386

2011-08-06 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Aug  6 21:06:34 UTC 2011

Modified Files:
src/sys/arch/i386/i386 [cherry-xenmp]: machdep.c

Log Message:
Update cpu local GDT entries for TLS registers %gs and %fs


To generate a diff of this commit:
cvs rdiff -u -r1.702.2.2 -r1.702.2.3 src/sys/arch/i386/i386/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.702.2.2 src/sys/arch/i386/i386/machdep.c:1.702.2.3
--- src/sys/arch/i386/i386/machdep.c:1.702.2.2	Sun Jul 31 20:49:10 2011
+++ src/sys/arch/i386/i386/machdep.c	Sat Aug  6 21:06:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.702.2.2 2011/07/31 20:49:10 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.702.2.3 2011/08/06 21:06:34 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.2 2011/07/31 20:49:10 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.702.2.3 2011/08/06 21:06:34 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -560,6 +560,12 @@
 
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb-pcb_esp0);
 
+	/* Update TLS segment pointers */
+	update_descriptor(ci-ci_gdt[GUFS_SEL],
+			  (union descriptor *) pcb-pcb_fsd);
+	update_descriptor(ci-ci_gdt[GUGS_SEL], 
+			  (union descriptor *) pcb-pcb_gsd);
+
 	physop.cmd = PHYSDEVOP_SET_IOPL;
 	physop.u.set_iopl.iopl = pcb-pcb_iopl;
 	HYPERVISOR_physdev_op(physop);



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-08-05 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Fri Aug  5 17:26:27 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: xentests.c

Log Message:
pmap_enter() test needs an address that work for both i386 and amd64


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/xen/xentests.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/xentests.c
diff -u src/sys/arch/xen/xen/xentests.c:1.1.2.1 src/sys/arch/xen/xen/xentests.c:1.1.2.2
--- src/sys/arch/xen/xen/xentests.c:1.1.2.1	Fri Jun  3 13:27:42 2011
+++ src/sys/arch/xen/xen/xentests.c	Fri Aug  5 17:26:27 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xentests.c,v 1.1.2.1 2011/06/03 13:27:42 cherry Exp $ */
+/* $NetBSD: xentests.c,v 1.1.2.2 2011/08/05 17:26:27 cherry Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: xentests.c,v 1.1.2.1 2011/06/03 13:27:42 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: xentests.c,v 1.1.2.2 2011/08/05 17:26:27 cherry Exp $);
 
 #include sys/types.h
 
@@ -997,6 +997,7 @@
 	return result;
 }
 
+#define USEFULLUSERLANDADDRESS 0x1
 
 /* pmap enter and extract */
 
@@ -1006,7 +1007,7 @@
 	KASSERT(arg != NULL);
 	struct test_args *ta = arg;
 
-	vaddr_t va = 0xfeedface  ~PAGE_MASK; /* PAGE_SIZE aligned */
+	vaddr_t va = USEFULLUSERLANDADDRESS  ~PAGE_MASK; /* PAGE_SIZE aligned */
 	paddr_t pa;
 	struct vm_page *pg;
 



CVS commit: [cherry-xenmp] src/sys/arch/xen

2011-08-04 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Aug  4 09:07:47 UTC 2011

Modified Files:
src/sys/arch/xen/include [cherry-xenmp]: evtchn.h hypervisor.h intr.h
src/sys/arch/xen/x86 [cherry-xenmp]: hypervisor_machdep.c
src/sys/arch/xen/xen [cherry-xenmp]: evtchn.c xenevt.c

Log Message:
first cut at per-cpu event handling


To generate a diff of this commit:
cvs rdiff -u -r1.18.10.1 -r1.18.10.2 src/sys/arch/xen/include/evtchn.h
cvs rdiff -u -r1.31 -r1.31.10.1 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.31.10.2 -r1.31.10.3 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.14.2.1 -r1.14.2.2 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.47.6.1 -r1.47.6.2 src/sys/arch/xen/xen/evtchn.c
cvs rdiff -u -r1.37 -r1.37.2.1 src/sys/arch/xen/xen/xenevt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/include/evtchn.h
diff -u src/sys/arch/xen/include/evtchn.h:1.18.10.1 src/sys/arch/xen/include/evtchn.h:1.18.10.2
--- src/sys/arch/xen/include/evtchn.h:1.18.10.1	Fri Jun  3 13:27:40 2011
+++ src/sys/arch/xen/include/evtchn.h	Thu Aug  4 09:07:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.h,v 1.18.10.1 2011/06/03 13:27:40 cherry Exp $	*/
+/*	$NetBSD: evtchn.h,v 1.18.10.2 2011/08/04 09:07:46 cherry Exp $	*/
 
 /*
  *
@@ -42,7 +42,9 @@
 int event_remove_handler(int, int (*func)(void *), void *);
 
 struct intrhand;
-void event_set_iplhandler(struct intrhand *, int);
+void event_set_iplhandler(struct cpu_info *ci,
+			  struct intrhand *, 
+			  int);
 
 extern int debug_port;
 extern int xen_debug_handler(void *);

Index: src/sys/arch/xen/include/hypervisor.h
diff -u src/sys/arch/xen/include/hypervisor.h:1.31 src/sys/arch/xen/include/hypervisor.h:1.31.10.1
--- src/sys/arch/xen/include/hypervisor.h:1.31	Mon Oct 19 18:41:10 2009
+++ src/sys/arch/xen/include/hypervisor.h	Thu Aug  4 09:07:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.31 2009/10/19 18:41:10 bouyer Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.31.10.1 2011/08/04 09:07:46 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -91,6 +91,7 @@
 #include xen/xen3-public/io/netif.h
 #include xen/xen3-public/io/blkif.h
 
+#include machine/cpu.h
 #include machine/hypercalls.h
 
 #undef u8
@@ -136,7 +137,8 @@
 void hypervisor_mask_event(unsigned int);
 void hypervisor_clear_event(unsigned int);
 void hypervisor_enable_ipl(unsigned int);
-void hypervisor_set_ipending(uint32_t, int, int);
+void hypervisor_set_ipending(struct cpu_info *, 
+			 uint32_t, int, int);
 void hypervisor_machdep_attach(void);
 
 /* 

Index: src/sys/arch/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.31.10.2 src/sys/arch/xen/include/intr.h:1.31.10.3
--- src/sys/arch/xen/include/intr.h:1.31.10.2	Sun Jun 26 12:56:32 2011
+++ src/sys/arch/xen/include/intr.h	Thu Aug  4 09:07:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.31.10.2 2011/06/26 12:56:32 cherry Exp $	*/
+/*	$NetBSD: intr.h,v 1.31.10.3 2011/08/04 09:07:46 cherry Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -58,13 +58,8 @@
 	struct intrhand *ev_handlers;	/* handler chain */
 	struct evcnt ev_evcnt;		/* interrupt counter */
 	char ev_evname[32];		/* event counter name */
+	struct cpu_info *ev_cpu;	/* cpu on which this event is bound */
 	struct simplelock ev_lock;	/* protects this structure */
-
-	/* 
-	 * XXX: The lock is quite coursegrained ( for the entire
-	 * handler list ), but contention is expected to be low. See
-	 * how this performs and revisit.
-	 */
 };
 
 /*

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.1 src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.2
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.14.2.1	Fri Jun  3 13:27:41 2011
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Thu Aug  4 09:07:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.1 2011/06/03 13:27:41 cherry Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.14.2.2 2011/08/04 09:07:47 cherry Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.1 2011/06/03 13:27:41 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor_machdep.c,v 1.14.2.2 2011/08/04 09:07:47 cherry Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -86,13 +86,101 @@
 // #define PORT_DEBUG 4
 // #define EARLY_DEBUG_EVENT
 
+static inline unsigned int
+evt_bitstr_to_port(unsigned long l1, unsigned long l2)
+{
+	unsigned int l1i, l2i, port;
+
+	l1i = xen_ffs(l1) - 1;
+	l2i = xen_ffs(l2) - 1;
+
+	port = (l1i  LONG_SHIFT) + l2i;
+	return port;
+}
+
+/* callback function type */
+typedef void (*iterate_func_t)(struct cpu_info *,
+			   unsigned int,
+			   unsigned int,
+			   unsigned int,
+			   void *);
+
+
+static inline void
+evt_iterate_pending(struct cpu_info *ci,
+		volatile unsigned long *pendingl1,
+		volatile 

CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-08-04 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Aug  4 13:04:20 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: evtchn.c

Log Message:
Send an ipi at IPL_HIGH to remote cpu, in order to get it to run spllower()


To generate a diff of this commit:
cvs rdiff -u -r1.47.6.2 -r1.47.6.3 src/sys/arch/xen/xen/evtchn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.47.6.2 src/sys/arch/xen/xen/evtchn.c:1.47.6.3
--- src/sys/arch/xen/xen/evtchn.c:1.47.6.2	Thu Aug  4 09:07:47 2011
+++ src/sys/arch/xen/xen/evtchn.c	Thu Aug  4 13:04:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.47.6.2 2011/08/04 09:07:47 cherry Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.47.6.3 2011/08/04 13:04:20 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.47.6.2 2011/08/04 09:07:47 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.47.6.3 2011/08/04 13:04:20 cherry Exp $);
 
 #include opt_xen.h
 #include isa.h
@@ -245,7 +245,16 @@
 	evtsource[evtch]-ev_imask,
 	evtch  LONG_SHIFT,
 	evtch  LONG_MASK);
-		/* leave masked */
+
+		if (evtsource[evtch]-ev_cpu != ci) { 
+			/* facilitate spllower() on remote cpu */
+			struct cpu_info *rci = evtsource[evtch]-ev_cpu;
+			if (xen_send_ipi(rci, XEN_IPI_KICK)) {
+panic(xen_send_ipi(%s, XEN_IPI_KICK) failed\n, cpu_name(rci));
+			}
+		}
+
+		/* leave masked */ 
 		return 0;
 	}
 	ci-ci_ilevel = evtsource[evtch]-ev_maxlevel;



CVS commit: [cherry-xenmp] src/sys/arch

2011-07-31 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Jul 31 20:49:12 UTC 2011

Modified Files:
src/sys/arch/amd64/amd64 [cherry-xenmp]: db_interface.c
src/sys/arch/i386/i386 [cherry-xenmp]: db_interface.c gdt.c machdep.c
src/sys/arch/i386/include [cherry-xenmp]: intrdefs.h pmap.h
src/sys/arch/i386/isa [cherry-xenmp]: npx.c
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c pmap_tlb.c
src/sys/arch/xen/conf [cherry-xenmp]: std.xen
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c xen_ipi.c
xenfunc.c

Log Message:
grow MP support for i386. boots to single user


To generate a diff of this commit:
cvs rdiff -u -r1.23.2.1 -r1.23.2.2 src/sys/arch/amd64/amd64/db_interface.c
cvs rdiff -u -r1.66 -r1.66.2.1 src/sys/arch/i386/i386/db_interface.c
cvs rdiff -u -r1.50 -r1.50.10.1 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.702.2.1 -r1.702.2.2 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.3 -r1.3.140.1 src/sys/arch/i386/include/intrdefs.h
cvs rdiff -u -r1.109 -r1.109.2.1 src/sys/arch/i386/include/pmap.h
cvs rdiff -u -r1.139.6.1 -r1.139.6.2 src/sys/arch/i386/isa/npx.c
cvs rdiff -u -r1.121.2.3 -r1.121.2.4 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.3.2.2 -r1.3.2.3 src/sys/arch/x86/x86/pmap_tlb.c
cvs rdiff -u -r1.6 -r1.6.12.1 src/sys/arch/xen/conf/std.xen
cvs rdiff -u -r1.56.2.3 -r1.56.2.4 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.4 -r1.26.2.5 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/x86/xen_ipi.c
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 src/sys/arch/xen/x86/xenfunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/db_interface.c
diff -u src/sys/arch/amd64/amd64/db_interface.c:1.23.2.1 src/sys/arch/amd64/amd64/db_interface.c:1.23.2.2
--- src/sys/arch/amd64/amd64/db_interface.c:1.23.2.1	Fri Jun  3 13:27:37 2011
+++ src/sys/arch/amd64/amd64/db_interface.c	Sun Jul 31 20:49:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.23.2.1 2011/06/03 13:27:37 cherry Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.23.2.2 2011/07/31 20:49:10 cherry Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.23.2.1 2011/06/03 13:27:37 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.23.2.2 2011/07/31 20:49:10 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -82,7 +82,9 @@
 #ifdef MULTIPROCESSOR
 extern void ddb_ipi(struct trapframe);
 static void ddb_suspend(struct trapframe *);
+#ifndef XEN
 int ddb_vec;
+#endif /* XEN */
 static bool ddb_mp_online;
 #endif
 

Index: src/sys/arch/i386/i386/db_interface.c
diff -u src/sys/arch/i386/i386/db_interface.c:1.66 src/sys/arch/i386/i386/db_interface.c:1.66.2.1
--- src/sys/arch/i386/i386/db_interface.c:1.66	Sun Apr  3 22:29:26 2011
+++ src/sys/arch/i386/i386/db_interface.c	Sun Jul 31 20:49:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.66.2.1 2011/07/31 20:49:10 cherry Exp $	*/
 
 /*
  * Mach Operating System
@@ -33,7 +33,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.66.2.1 2011/07/31 20:49:10 cherry Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -86,7 +86,9 @@
 extern void ddb_ipi(int, struct trapframe);
 extern void ddb_ipi_tss(struct i386tss *);
 static void ddb_suspend(struct trapframe *);
+#ifndef XEN
 int ddb_vec;
+#endif /* XEN */
 static bool ddb_mp_online;
 #endif
 
@@ -104,8 +106,12 @@
 {
 
 #ifdef MULTIPROCESSOR
+#ifndef XEN
 	ddb_vec = idt_vec_alloc(0xf0, 0xff);
 	idt_vec_set(ddb_vec, Xintrddbipi);
+#else
+	/* Initialised as part of xen_ipi_init() */
+#endif /* XEN */
 #endif
 }
 
@@ -119,8 +125,10 @@
 	int cpu_me = cpu_number();
 	int win;
 
+#ifndef XEN
 	if (ddb_vec == 0)
 		return 1;
+#endif /* XEN */
 
 	__cpu_simple_lock(db_lock);
 	if (ddb_cpu == NOCPU)
@@ -128,7 +136,11 @@
 	win = (ddb_cpu == cpu_me);
 	__cpu_simple_unlock(db_lock);
 	if (win) {
+#ifdef XEN
+		xen_broadcast_ipi(XEN_IPI_DDB);
+#else
 		x86_ipi(ddb_vec, LAPIC_DEST_ALLEXCL, LAPIC_DLMODE_FIXED);
+#endif /* XEN */
 	}
 	ddb_mp_online = x86_mp_online;
 	x86_mp_online = false;

Index: src/sys/arch/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.50 src/sys/arch/i386/i386/gdt.c:1.50.10.1
--- src/sys/arch/i386/i386/gdt.c:1.50	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/gdt.c	Sun Jul 31 20:49:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.50 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: gdt.c,v 1.50.10.1 2011/07/31 20:49:10 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.50 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, 

CVS commit: [cherry-xenmp] src/sys/arch/x86/x86

2011-07-31 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Jul 31 20:55:22 UTC 2011

Modified Files:
src/sys/arch/x86/x86 [cherry-xenmp]: pmap_tlb.c

Log Message:
Oops. remove spurious #undef MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.3.2.3 -r1.3.2.4 src/sys/arch/x86/x86/pmap_tlb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap_tlb.c
diff -u src/sys/arch/x86/x86/pmap_tlb.c:1.3.2.3 src/sys/arch/x86/x86/pmap_tlb.c:1.3.2.4
--- src/sys/arch/x86/x86/pmap_tlb.c:1.3.2.3	Sun Jul 31 20:49:11 2011
+++ src/sys/arch/x86/x86/pmap_tlb.c	Sun Jul 31 20:55:22 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_tlb.c,v 1.3.2.3 2011/07/31 20:49:11 cherry Exp $	*/
+/*	$NetBSD: pmap_tlb.c,v 1.3.2.4 2011/07/31 20:55:22 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2008-2011 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_tlb.c,v 1.3.2.3 2011/07/31 20:49:11 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_tlb.c,v 1.3.2.4 2011/07/31 20:55:22 cherry Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -57,7 +57,7 @@
 #endif /* XEN */
 #include x86/i82489reg.h
 #include x86/i82489var.h
-#undef MULTIPROCESSOR
+
 /*
  * TLB shootdown structures.
  */



CVS commit: [cherry-xenmp] src/sys/arch/xen/xen

2011-07-25 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Jul 25 17:29:43 UTC 2011

Modified Files:
src/sys/arch/xen/xen [cherry-xenmp]: clock.c

Log Message:
Do not register the same callback more than once.


To generate a diff of this commit:
cvs rdiff -u -r1.54.6.1 -r1.54.6.2 src/sys/arch/xen/xen/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.54.6.1 src/sys/arch/xen/xen/clock.c:1.54.6.2
--- src/sys/arch/xen/xen/clock.c:1.54.6.1	Fri Jun  3 13:27:42 2011
+++ src/sys/arch/xen/xen/clock.c	Mon Jul 25 17:29:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.54.6.1 2011/06/03 13:27:42 cherry Exp $	*/
+/*	$NetBSD: clock.c,v 1.54.6.2 2011/07/25 17:29:43 cherry Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include opt_xen.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.1 2011/06/03 13:27:42 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.54.6.2 2011/07/25 17:29:43 cherry Exp $);
 
 #include sys/param.h
 #include sys/cpu.h
@@ -452,7 +452,9 @@
 			 hardclock);
 
 #ifdef DOM0OPS
-	callout_init(xen_timepush_co, 0);
+	if (!tcdone) { /* Do this only once */
+		callout_init(xen_timepush_co, 0);
+	}
 #endif
 	evtch = bind_virq_to_evtch(VIRQ_TIMER);
 	aprint_verbose(Xen clock: using event channel %d\n, evtch);



CVS commit: [cherry-xenmp] src/sys/arch/x86/x86

2011-07-23 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Jul 23 09:21:53 UTC 2011

Modified Files:
src/sys/arch/x86/x86 [cherry-xenmp]: ipi.c

Log Message:
Remove the bogus TLB ipi wrapper code. We don't use it in xen anyway.
This syncs back, with -current.


To generate a diff of this commit:
cvs rdiff -u -r1.18.6.1 -r1.18.6.2 src/sys/arch/x86/x86/ipi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/ipi.c
diff -u src/sys/arch/x86/x86/ipi.c:1.18.6.1 src/sys/arch/x86/x86/ipi.c:1.18.6.2
--- src/sys/arch/x86/x86/ipi.c:1.18.6.1	Fri Jun  3 13:27:39 2011
+++ src/sys/arch/x86/x86/ipi.c	Sat Jul 23 09:21:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipi.c,v 1.18.6.1 2011/06/03 13:27:39 cherry Exp $	*/
+/*	$NetBSD: ipi.c,v 1.18.6.2 2011/07/23 09:21:52 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2008, 2009 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ipi.c,v 1.18.6.1 2011/06/03 13:27:39 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: ipi.c,v 1.18.6.2 2011/07/23 09:21:52 cherry Exp $);
 
 #include opt_mtrr.h
 
@@ -107,16 +107,6 @@
 x86_send_ipi(struct cpu_info *ci, int ipimask)
 {
 	int ret;
-	
-	KASSERT(ci != NULL);
-
-	if (ipimask  X86_IPI_TLB) { 	/* Wrapper for TLB event */
-		KASSERT(ipimask == X86_IPI_TLB);
-
-		ret = x86_ipi(LAPIC_TLB_MCAST_VECTOR,
-			  ci-ci_cpuid, LAPIC_DLMODE_FIXED);		
-		return ret;
-	}
 
 	atomic_or_32(ci-ci_ipis, ipimask);
 
@@ -142,15 +132,6 @@
 	int count = 0;
 	CPU_INFO_ITERATOR cii;
 
-	if (ipimask  X86_IPI_TLB) { 	/* Wrapper for TLB event */
-		KASSERT(ipimask == X86_IPI_TLB);
-
-		if (x86_ipi(LAPIC_TLB_BCAST_VECTOR, LAPIC_DEST_ALLEXCL,
-			LAPIC_DLMODE_FIXED)) {
-			panic(x86_ipi() failed on Broadcast via lapic.\n);
-		}
-	}
-
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		if (ci == self)
 			continue;



CVS commit: [cherry-xenmp] src/sys/arch

2011-07-16 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Jul 16 10:59:46 UTC 2011

Modified Files:
src/sys/arch/x86/include [cherry-xenmp]: cpu.h
src/sys/arch/x86/x86 [cherry-xenmp]: pmap.c
src/sys/arch/xen/x86 [cherry-xenmp]: cpu.c x86_xpmap.c xen_pmap.c

Log Message:
Introduce a per-cpu shadow for pmap_kernel()'s L4 page


To generate a diff of this commit:
cvs rdiff -u -r1.34.2.2 -r1.34.2.3 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.121.2.2 -r1.121.2.3 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.56.2.2 -r1.56.2.3 src/sys/arch/xen/x86/cpu.c
cvs rdiff -u -r1.26.2.3 -r1.26.2.4 src/sys/arch/xen/x86/x86_xpmap.c
cvs rdiff -u -r1.2.2.1 -r1.2.2.2 src/sys/arch/xen/x86/xen_pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.34.2.2 src/sys/arch/x86/include/cpu.h:1.34.2.3
--- src/sys/arch/x86/include/cpu.h:1.34.2.2	Thu Jun 23 14:19:48 2011
+++ src/sys/arch/x86/include/cpu.h	Sat Jul 16 10:59:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.34.2.2 2011/06/23 14:19:48 cherry Exp $	*/
+/*	$NetBSD: cpu.h,v 1.34.2.3 2011/07/16 10:59:45 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -184,6 +184,8 @@
 
 #if defined(XEN)  defined(__x86_64__)
 	/* Currently active user PGD (can't use rcr3() with Xen) */
+	pd_entry_t *	ci_kpm_pdir;	/* per-cpu L4 PD (va) */
+	paddr_t		ci_kpm_pdirpa; /* per-cpu L4 PD (pa) */
 	paddr_t		ci_xen_current_user_pgd;
 #endif
 
@@ -232,6 +234,11 @@
 	int		ci_padout __aligned(64);
 };
 
+#ifdef __x86_64__
+#define ci_pdirpa(ci, index) \
+	((ci)-ci_kpm_pdirpa + (index) * sizeof(pd_entry_t))
+#endif /* __x86_64__ */
+
 /*
  * Macros to handle (some) trapframe registers for common x86 code.
  */

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.121.2.2 src/sys/arch/x86/x86/pmap.c:1.121.2.3
--- src/sys/arch/x86/x86/pmap.c:1.121.2.2	Thu Jun 23 14:19:48 2011
+++ src/sys/arch/x86/x86/pmap.c	Sat Jul 16 10:59:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.121.2.2 2011/06/23 14:19:48 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.121.2.3 2011/07/16 10:59:46 cherry Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.2 2011/06/23 14:19:48 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.121.2.3 2011/07/16 10:59:46 cherry Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -778,7 +778,7 @@
 		ci-ci_tlbstate = TLBSTATE_VALID;
 		atomic_or_32(pmap-pm_cpus, cpumask);
 		atomic_or_32(pmap-pm_kernel_cpus, cpumask);
-		lcr3(pmap_pdirpa(pmap, 0));
+		cpu_load_pmap(pmap);
 	}
 	pmap-pm_ncsw = l-l_ncsw;
 	*pmap2 = curpmap;
@@ -1515,6 +1515,15 @@
 			break;
 		pdes_pa = newp;
 	}
+
+	/* sync to per-cpu PD */
+	xpq_queue_lock();
+	xpq_queue_pte_update(
+		xpmap_ptom_masked(ci_pdirpa(cpu_info_primary,
+	pl_i(0, PTP_LEVELS))),
+  pmap_kernel()-pm_pdir[pl_i(0, PTP_LEVELS)]);
+	xpq_queue_unlock();
+	pmap_pte_flush();
 #else /* XEN */
 	pd_entry_t *pdes;
 
@@ -1575,15 +1584,18 @@
 void
 pmap_cpu_init_late(struct cpu_info *ci)
 {
+	/*
+	 * The BP has already its own PD page allocated during early
+	 * MD startup.
+	 */
+	if (ci == cpu_info_primary)
+		return;
+
 #ifdef PAE
 	int ret;
 	struct pglist pg;
 	struct vm_page *vmap;
 
-	/* The BP has already its own L3 page allocated in locore.S. */
-	if (ci == cpu_info_primary)
-		return;
-
 	/*
 	 * Allocate a page for the per-CPU L3 PD. cr3 being 32 bits, PA musts
 	 * resides below the 4GB boundary.
@@ -1607,7 +1619,35 @@
 		VM_PROT_READ | VM_PROT_WRITE, 0);
 
 	pmap_update(pmap_kernel());
+
+	xpq_queue_lock();
+	xpq_queue_pin_l3_table(xpmap_ptom_masked(ci-ci_pae_l3_pdirpa));
+	xpq_queue_unlock();
 #endif
+#if defined(XEN)  defined (__x86_64)
+	KASSERT(ci != NULL);
+
+	ci-ci_kpm_pdir = (pd_entry_t *)uvm_km_alloc(kernel_map,
+		 PAGE_SIZE, 0, UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_NOWAIT);
+	if (ci-ci_kpm_pdir == NULL) {
+		panic(%s: failed to allocate L4 per-cpu PD for CPU %d\n,
+		  __func__, cpu_index(ci));
+	}
+	ci-ci_kpm_pdirpa = vtophys((vaddr_t) ci-ci_kpm_pdir);
+	KASSERT(ci-ci_kpm_pdirpa != 0);
+
+	cpu_load_pmap(pmap_kernel());
+
+	pmap_kenter_pa((vaddr_t)ci-ci_kpm_pdir, ci-ci_kpm_pdirpa,
+		VM_PROT_READ, 0);
+
+	pmap_update(pmap_kernel());
+
+	xpq_queue_lock();
+	xpq_queue_pin_l4_table(xpmap_ptom_masked(ci-ci_kpm_pdirpa));
+	xpq_queue_unlock();
+
+#endif /* defined(XEN)  defined (__x86_64__) */
 }
 
 /*
@@ -1825,8 +1865,24 @@
 		 * clear it before freeing
 		 */
 		if (pmap_pdirpa(pmap, 0) == curcpu()-ci_xen_current_user_pgd
-		 level == PTP_LEVELS - 1)
+		 level == PTP_LEVELS - 1) {
 			pmap_pte_set(pmap_kernel()-pm_pdir[index], 0);
+			/*
+			 * Update the per-cpu PD on all cpus the current
+			 * pmap is active on 
+			 */ 
+			CPU_INFO_ITERATOR cii;
+			

CVS commit: [cherry-xenmp] src/sys/arch/xen/conf

2011-06-27 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Jun 27 10:21:53 UTC 2011

Modified Files:
src/sys/arch/xen/conf [cherry-xenmp]: files.xen

Log Message:
Conditionally compile xen_ipi.c


To generate a diff of this commit:
cvs rdiff -u -r1.118.2.2 -r1.118.2.3 src/sys/arch/xen/conf/files.xen

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.118.2.2 src/sys/arch/xen/conf/files.xen:1.118.2.3
--- src/sys/arch/xen/conf/files.xen:1.118.2.2	Thu Jun 23 14:19:49 2011
+++ src/sys/arch/xen/conf/files.xen	Mon Jun 27 10:21:52 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.118.2.2 2011/06/23 14:19:49 cherry Exp $
+#	$NetBSD: files.xen,v 1.118.2.3 2011/06/27 10:21:52 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 
 
@@ -127,7 +127,7 @@
 file	arch/xen/x86/consinit.c
 file	arch/x86/x86/identcpu.c
 file	arch/xen/x86/intr.c
-file	arch/xen/x86/xen_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



CVS commit: [cherry-xenmp] src/sys/arch/xen/x86

2011-06-27 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Jun 27 10:23:21 UTC 2011

Modified Files:
src/sys/arch/xen/x86 [cherry-xenmp]: x86_xpmap.c

Log Message:
Add xpq locking around xpq-QUEUE_TLB_FLUSH()


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.2 -r1.26.2.3 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.2 src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.3
--- src/sys/arch/xen/x86/x86_xpmap.c:1.26.2.2	Thu Jun 23 14:19:50 2011
+++ src/sys/arch/xen/x86/x86_xpmap.c	Mon Jun 27 10:23:21 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.26.2.2 2011/06/23 14:19:50 cherry Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.26.2.3 2011/06/27 10:23:21 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert m...@adviseo.fr
@@ -69,7 +69,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.2 2011/06/23 14:19:50 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.26.2.3 2011/06/27 10:23:21 cherry Exp $);
 
 #include opt_xen.h
 #include opt_ddb.h
@@ -658,7 +658,9 @@
 	(UPAGES + 1) * NBPG);
 
 	/* Finally, flush TLB. */
+	xpq_queue_lock();
 	xpq_queue_tlb_flush();
+	xpq_queue_unlock();
 
 	return (init_tables + ((count + l2_4_count) * PAGE_SIZE));
 }



CVS commit: [cherry-xenmp] src/sys/arch/xen

2011-06-26 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Jun 26 12:56:33 UTC 2011

Modified Files:
src/sys/arch/xen/include [cherry-xenmp]: intr.h
src/sys/arch/xen/xen [cherry-xenmp]: hypervisor.c

Log Message:
Unbreak uniprocessor build


To generate a diff of this commit:
cvs rdiff -u -r1.31.10.1 -r1.31.10.2 src/sys/arch/xen/include/intr.h
cvs rdiff -u -r1.55.2.1 -r1.55.2.2 src/sys/arch/xen/xen/hypervisor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/include/intr.h
diff -u src/sys/arch/xen/include/intr.h:1.31.10.1 src/sys/arch/xen/include/intr.h:1.31.10.2
--- src/sys/arch/xen/include/intr.h:1.31.10.1	Fri Jun  3 13:27:40 2011
+++ src/sys/arch/xen/include/intr.h	Sun Jun 26 12:56:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.31.10.1 2011/06/03 13:27:40 cherry Exp $	*/
+/*	$NetBSD: intr.h,v 1.31.10.2 2011/06/26 12:56:32 cherry Exp $	*/
 /*	NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp	*/
 
 /*-
@@ -185,9 +185,15 @@
 struct pic *intr_findpic(int);
 void intr_add_pcibus(struct pcibus_attach_args *);
 
+#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 */
 

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.55.2.1 src/sys/arch/xen/xen/hypervisor.c:1.55.2.2
--- src/sys/arch/xen/xen/hypervisor.c:1.55.2.1	Fri Jun  3 13:27:42 2011
+++ src/sys/arch/xen/xen/hypervisor.c	Sun Jun 26 12:56:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.55.2.1 2011/06/03 13:27:42 cherry Exp $ */
+/* $NetBSD: hypervisor.c,v 1.55.2.2 2011/06/26 12:56:33 cherry Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.55.2.1 2011/06/03 13:27:42 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.55.2.2 2011/06/26 12:56:33 cherry Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -128,7 +128,6 @@
 hypervisor_match, hypervisor_attach, NULL, NULL);
 
 static int hypervisor_print(void *, const char *);
-static int hypervisor_vcpu_print(void *, const char *);
 
 union hypervisor_attach_cookie {
 	const char *hac_device;		/* first elem of all */
@@ -183,6 +182,15 @@
 	return 0;
 }
 
+#ifdef MULTIPROCESSOR
+static int
+hypervisor_vcpu_print(void *aux, const char *parent)
+{
+	/* Unconfigured cpus are ignored quietly. */
+	return (QUIET);
+}
+#endif /* MULTIPROCESSOR */
+
 /*
  * Attach the hypervisor.
  */
@@ -190,7 +198,6 @@
 hypervisor_attach(device_t parent, device_t self, void *aux)
 {
 	int xen_version;
-	cpuid_t vcpuid;
 
 #if NPCI 0
 #ifdef PCI_BUS_FIXUP
@@ -226,6 +233,7 @@
 	 * allocated vcpus (See: cpu.c:vcpu_match()) by iterating
 	 * through the maximum supported by NetBSD MP.
 	 */
+	cpuid_t vcpuid;
 
 	for (vcpuid = 1; vcpuid  maxcpus; vcpuid++) {
 		memset(hac, 0, sizeof(hac));
@@ -331,13 +339,6 @@
 	return (UNCONF);
 }
 
-static int
-hypervisor_vcpu_print(void *aux, const char *parent)
-{
-	/* Unconfigured cpus are ignored quietly. */
-	return (QUIET);
-}
-
 #if defined(DOM0OPS)
 
 #define DIR_MODE	(S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)