Module Name:    src
Committed By:   cherry
Date:           Sun Nov 25 08:39:36 UTC 2012

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:
Make hypervisor_set_ipending() and its consumers cpu unaware. This syncs syntax 
with semantics


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/xen/include/hypervisor.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/x86/hypervisor_machdep.c
cvs rdiff -u -r1.63 -r1.64 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.38 src/sys/arch/xen/include/hypervisor.h:1.39
--- src/sys/arch/xen/include/hypervisor.h:1.38	Fri Feb 17 18:42:19 2012
+++ src/sys/arch/xen/include/hypervisor.h	Sun Nov 25 08:39:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.38 2012/02/17 18:42:19 bouyer Exp $	*/
+/*	$NetBSD: hypervisor.h,v 1.39 2012/11/25 08:39:35 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -142,8 +142,7 @@ 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(struct cpu_info *, 
-			     uint32_t, int, int);
+void hypervisor_set_ipending(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.22 src/sys/arch/xen/x86/hypervisor_machdep.c:1.23
--- src/sys/arch/xen/x86/hypervisor_machdep.c:1.22	Sat Nov 10 16:28:06 2012
+++ src/sys/arch/xen/x86/hypervisor_machdep.c	Sun Nov 25 08:39:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor_machdep.c,v 1.22 2012/11/10 16:28:06 cherry Exp $	*/
+/*	$NetBSD: hypervisor_machdep.c,v 1.23 2012/11/25 08:39:36 cherry Exp $	*/
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.22 2012/11/10 16:28:06 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.23 2012/11/25 08:39:36 cherry 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)(struct cpu_info *, unsigned int,
-			       unsigned int, unsigned int, void *);
+typedef void (*iterate_func_t)(unsigned int, unsigned int,
+			       unsigned int, void *);
 
 static inline void
-evt_iterate_bits(struct cpu_info *ci, volatile unsigned long *pendingl1,
+evt_iterate_bits(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(struct cpu_info *ci, vo
 		l1 &= ~(1UL << l1i);
 
 		l2 = pendingl2[l1i] & (mask != NULL ? ~mask[l1i] : -1UL);
-		l2 &= ci->ci_evtmask[l1i];
+		l2 &= curcpu()->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(struct cpu_info *ci, vo
 
 			port = (l1i << LONG_SHIFT) + l2i;
 
-			iterate_pending(ci, port, l1i, l2i, iterate_args);
+			iterate_pending(port, l1i, l2i, iterate_args);
 		}
 	}
 }
@@ -131,20 +131,18 @@ evt_iterate_bits(struct cpu_info *ci, vo
  */
    
 static inline void
-evt_set_pending(struct cpu_info *ci, unsigned int port, unsigned int l1i,
+evt_set_pending(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_cpu,
-		    evtsource[port]->ev_imask, l1i, l2i);
+		hypervisor_set_ipending(evtsource[port]->ev_imask, l1i, l2i);
 		evtsource[port]->ev_evcnt.ev_count++;
-		if (*ret == 0 && ci->ci_ilevel <
+		if (*ret == 0 && curcpu()->ci_ilevel <
 		    evtsource[port]->ev_maxlevel)
 			*ret = 1;
 	}
@@ -193,7 +191,7 @@ stipending(void)
 
 		vci->evtchn_upcall_pending = 0;
 
-		evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+		evt_iterate_bits(&vci->evtchn_pending_sel,
 		    s->evtchn_pending, s->evtchn_mask,
 		    evt_set_pending, &ret);
 
@@ -214,12 +212,12 @@ stipending(void)
 /* Iterate through pending events and call the event handler */
 
 static inline void
-evt_do_hypervisor_callback(struct cpu_info *ci, unsigned int port,
-			   unsigned int l1i, unsigned int l2i, void *args)
+evt_do_hypervisor_callback(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
@@ -273,7 +271,7 @@ do_hypervisor_callback(struct intrframe 
 	while (vci->evtchn_upcall_pending) {
 		vci->evtchn_upcall_pending = 0;
 
-		evt_iterate_bits(ci, &vci->evtchn_pending_sel,
+		evt_iterate_bits(&vci->evtchn_pending_sel,
 		    s->evtchn_pending, s->evtchn_mask,
 		    evt_do_hypervisor_callback, regs);
 	}
@@ -390,10 +388,9 @@ hypervisor_clear_event(unsigned int ev)
 }
 
 static inline void
-evt_enable_event(struct cpu_info *ci, unsigned int port,  
-		 unsigned int l1i, unsigned int l2i, void *args)
+evt_enable_event(unsigned int port, unsigned int l1i,
+		 unsigned int l2i, void *args)
 {
-	KASSERT(ci != NULL);
 	KASSERT(args == NULL);
 	hypervisor_enable_event(port);
 }
@@ -409,16 +406,21 @@ hypervisor_enable_ipl(unsigned int ipl)
 	 * we know that all callback for this event have been processed.
 	 */
 
-	evt_iterate_bits(ci, &ci->ci_isources[ipl]->ipl_evt_mask1,
+	evt_iterate_bits(&ci->ci_isources[ipl]->ipl_evt_mask1,
 	    ci->ci_isources[ipl]->ipl_evt_mask2, NULL, 
 	    evt_enable_event, NULL);
 
 }
 
 void
-hypervisor_set_ipending(struct cpu_info *ci, uint32_t iplmask, int l1, int l2)
+hypervisor_set_ipending(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.63 src/sys/arch/xen/xen/evtchn.c:1.64
--- src/sys/arch/xen/xen/evtchn.c:1.63	Sun Nov 25 07:48:46 2012
+++ src/sys/arch/xen/xen/evtchn.c	Sun Nov 25 08:39:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.63 2012/11/25 07:48:46 cherry Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.64 2012/11/25 08:39:36 cherry Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.63 2012/11/25 07:48:46 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.64 2012/11/25 08:39:36 cherry Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -282,8 +282,7 @@ 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_cpu,
-					evtsource[evtch]->ev_imask,
+		hypervisor_set_ipending(evtsource[evtch]->ev_imask,
 					evtch >> LONG_SHIFT,
 					evtch & LONG_MASK);
 
@@ -309,7 +308,7 @@ evtchn_do_event(int evtch, struct intrfr
 		    printf("ih->ih_level %d <= ilevel %d\n", ih->ih_level, ilevel);
 #endif
 			cli();
-			hypervisor_set_ipending(ih->ih_cpu, iplmask,
+			hypervisor_set_ipending(iplmask,
 			    evtch >> LONG_SHIFT, evtch & LONG_MASK);
 			/* leave masked */
 			mutex_spin_exit(&evtlock[evtch]);

Reply via email to