Module Name:    src
Committed By:   bouyer
Date:           Sat Jan 12 21:09:10 UTC 2013

Modified Files:
        src/sys/arch/xen/include: hypervisor.h
        src/sys/arch/xen/x86: hypervisor_machdep.c
        src/sys/arch/xen/xen: evtchn.c

Log Message:
Revert these commits from november 2012:
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039125.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039126.html
http://mail-index.netbsd.org/source-changes/2012/11/25/msg039142.html

they cause a i386PAE domU to hang while running ATF tests, as shown in
http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/HEAD/

(we should pay more attention to test results, myself first).


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.67 -r1.68 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.41 src/sys/arch/xen/include/hypervisor.h:1.42
--- src/sys/arch/xen/include/hypervisor.h:1.41	Sat Jan 12 17:39:46 2013
+++ src/sys/arch/xen/include/hypervisor.h	Sat Jan 12 21:09:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.41 2013/01/12 17:39:46 bouyer Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.42 2013/01/12 21:09:10 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -142,7 +142,8 @@ void hypervisor_unmask_event(unsigned in
 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);
 void hypervisor_machdep_resume(void);
 

Index: src/sys/arch/xen/x86/hypervisor_machdep.c
diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.25 src/sys/arch/xen/x86/hypervisor_machdep.c:1.26
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.25	Sat Jan 12 17:39:46 2013
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Sat Jan 12 21:09:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.25 2013/01/12 17:39:46 bouyer Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.26 2013/01/12 21:09:10 bouyer Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.25 2013/01/12 17:39:46 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.26 2013/01/12 21:09:10 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,11 +87,11 @@ static void update_p2m_frame_list_list(v
 // #define EARLY_DEBUG_EVENT
 
 /* callback function type */
-typedef void (*iterate_func_t)(unsigned int, unsigned int,
-			       unsigned int, void *);
+typedef void (*iterate_func_t)(struct cpu_info *, unsigned int,
+			       unsigned int, unsigned int, void *);
 
 static inline void
-evt_iterate_bits(volatile unsigned long *pendingl1,
+evt_iterate_bits(struct cpu_info *ci, volatile unsigned long *pendingl1,
 		 volatile unsigned long *pendingl2, 
 		 volatile unsigned long *mask,
 		 iterate_func_t iterate_pending, void *iterate_args)
@@ -109,7 +109,7 @@ evt_iterate_bits(volatile unsigned long 
 		l1 &= ~(1UL << l1i);
 
 		l2 = pendingl2[l1i] & (mask != NULL ? ~mask[l1i] : -1UL);
-		l2 &= curcpu()->ci_evtmask[l1i];
+		l2 &= ci->ci_evtmask[l1i];
 
 		if (mask != NULL) xen_atomic_setbits_l(&mask[l1i], l2);
 		xen_atomic_clearbits_l(&pendingl2[l1i], l2);
@@ -120,7 +120,7 @@ evt_iterate_bits(volatile unsigned long 
 
 			port = (l1i << LONG_SHIFT) + l2i;
 
-			iterate_pending(port, l1i, l2i, iterate_args);
+			iterate_pending(ci, port, l1i, l2i, iterate_args);
 		}
 	}
 }
@@ -131,18 +131,20 @@ evt_iterate_bits(volatile unsigned long 
  */
    
 static inline void
-evt_set_pending(unsigned int port, unsigned int l1i,
+evt_set_pending(struct cpu_info *ci, unsigned int port, unsigned int l1i,
 		unsigned int l2i, void *args)
 {
 
 	KASSERT(args != NULL);
+	KASSERT(ci != NULL);
 
 	int *ret = args;
 
 	if (evtsource[port]) {
-		hypervisor_set_ipending(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 && curcpu()->ci_ilevel <
+		if (*ret == 0 && ci->ci_ilevel <
 		    evtsource[port]->ev_maxlevel)
 			*ret = 1;
 	}
@@ -191,7 +193,7 @@ stipending(void)
 
 		vci->evtchn_upcall_pending = 0;
 
-		evt_iterate_bits(&vci->evtchn_pending_sel,
+		evt_iterate_bits(ci, &vci->evtchn_pending_sel,
 		    s->evtchn_pending, s->evtchn_mask,
 		    evt_set_pending, &ret);
 
@@ -212,12 +214,12 @@ stipending(void)
 /* Iterate through pending events and call the event handler */
 
 static inline void
-evt_do_hypervisor_callback(unsigned int port, unsigned int l1i,
-			   unsigned int l2i, void *args)
+evt_do_hypervisor_callback(struct cpu_info *ci, unsigned int port,
+			   unsigned int l1i, unsigned int l2i, void *args)
 {
 	KASSERT(args != NULL);
+	KASSERT(ci == curcpu());
 
-	struct cpu_info *ci = curcpu();
 	struct intrframe *regs = args;
 
 #ifdef PORT_DEBUG
@@ -271,7 +273,7 @@ do_hypervisor_callback(struct intrframe 
 	while (vci->evtchn_upcall_pending) {
 		vci->evtchn_upcall_pending = 0;
 
-		evt_iterate_bits(&vci->evtchn_pending_sel,
+		evt_iterate_bits(ci, &vci->evtchn_pending_sel,
 		    s->evtchn_pending, s->evtchn_mask,
 		    evt_do_hypervisor_callback, regs);
 	}
@@ -388,9 +390,10 @@ hypervisor_clear_event(unsigned int ev)
 }
 
 static inline void
-evt_enable_event(unsigned int port, unsigned int l1i,
-		 unsigned int l2i, void *args)
+evt_enable_event(struct cpu_info *ci, unsigned int port,  
+		 unsigned int l1i, unsigned int l2i, void *args)
 {
+	KASSERT(ci != NULL);
 	KASSERT(args == NULL);
 	hypervisor_enable_event(port);
 }
@@ -406,21 +409,16 @@ hypervisor_enable_ipl(unsigned int ipl)
 	 * we know that all callback for this event have been processed.
 	 */
 
-	evt_iterate_bits(&ci->ci_isources[ipl]->ipl_evt_mask1,
+	evt_iterate_bits(ci, &ci->ci_isources[ipl]->ipl_evt_mask1,
 	    ci->ci_isources[ipl]->ipl_evt_mask2, NULL, 
 	    evt_enable_event, NULL);
 
 }
 
 void
-hypervisor_set_ipending(uint32_t iplmask, int l1, int l2)
+hypervisor_set_ipending(struct cpu_info *ci, uint32_t iplmask, int l1, int l2)
 {
-
-	/* This function is not re-entrant */
-	KASSERT(x86_read_psl() != 0);
-
 	int ipl;
-	struct cpu_info *ci = curcpu();
 
 	/* set pending bit for the appropriate IPLs */	
 	ci->ci_ipending |= iplmask;

Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.67 src/sys/arch/xen/xen/evtchn.c:1.68
--- src/sys/arch/xen/xen/evtchn.c:1.67	Sat Jan 12 17:39:46 2013
+++ src/sys/arch/xen/xen/evtchn.c	Sat Jan 12 21:09:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.67 2013/01/12 17:39:46 bouyer Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.68 2013/01/12 21:09:10 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.67 2013/01/12 17:39:46 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.68 2013/01/12 21:09:10 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -282,7 +282,8 @@ evtchn_do_event(int evtch, struct intrfr
 		    printf("evtsource[%d]->ev_maxlevel %d <= ilevel %d\n",
 		    evtch, evtsource[evtch]->ev_maxlevel, ilevel);
 #endif
-		hypervisor_set_ipending(evtsource[evtch]->ev_imask,
+		hypervisor_set_ipending(evtsource[evtch]->ev_cpu,
+					evtsource[evtch]->ev_imask,
 					evtch >> LONG_SHIFT,
 					evtch & LONG_MASK);
 
@@ -297,18 +298,21 @@ evtchn_do_event(int evtch, struct intrfr
 	ih = evtsource[evtch]->ev_handlers;
 	while (ih != NULL) {
 		if (ih->ih_cpu != ci) {
-			hypervisor_send_event(ih->ih_cpu, evtch);
+			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);
 #endif
 			cli();
-			hypervisor_set_ipending(iplmask,
+			hypervisor_set_ipending(ih->ih_cpu, iplmask,
 			    evtch >> LONG_SHIFT, evtch & LONG_MASK);
 			/* leave masked */
 			mutex_spin_exit(&evtlock[evtch]);
@@ -694,7 +698,7 @@ event_set_handler(int evtch, int (*func)
 		 * is more explicitly implemented.
 		 */
 		evts->ev_cpu = ci;
-		mutex_init(&evtlock[evtch], MUTEX_DEFAULT, IPL_NONE);
+		mutex_init(&evtlock[evtch], MUTEX_DEFAULT, IPL_HIGH);
 		evtsource[evtch] = evts;
 		if (evname)
 			strncpy(evts->ev_evname, evname,

Reply via email to