svn commit: r197693 - in head/sys/i386: i386 include xen

Kip Macy kmacy at FreeBSD.org
Thu Oct 1 22:05:39 UTC 2009


Author: kmacy
Date: Thu Oct  1 22:05:38 2009
New Revision: 197693
URL: http://svn.freebsd.org/changeset/base/197693

Log:
  make read_eflags and write_eflags accomplish the same effect on PVM as native,
  simplifying interrupt handling

Modified:
  head/sys/i386/i386/vm_machdep.c
  head/sys/i386/include/cpufunc.h
  head/sys/i386/xen/xen_machdep.c

Modified: head/sys/i386/i386/vm_machdep.c
==============================================================================
--- head/sys/i386/i386/vm_machdep.c	Thu Oct  1 21:44:30 2009	(r197692)
+++ head/sys/i386/i386/vm_machdep.c	Thu Oct  1 22:05:38 2009	(r197693)
@@ -270,11 +270,7 @@ cpu_fork(td1, p2, td2, flags)
 	/*
 	 * XXX XEN need to check on PSL_USER is handled
 	 */
-#ifdef XEN
-	td2->td_md.md_saved_flags = 0;
-#else	
 	td2->td_md.md_saved_flags = PSL_KERNEL | PSL_I;
-#endif
 	/*
 	 * Now, cpu_switch() can schedule the new process.
 	 * pcb_esp is loaded pointing to the cpu_switch() stack frame
@@ -446,11 +442,7 @@ cpu_set_upcall(struct thread *td, struct
 
 	/* Setup to release spin count in fork_exit(). */
 	td->td_md.md_spinlock_count = 1;
-#ifdef XEN	
-	td->td_md.md_saved_flags = 0;	
-#else
 	td->td_md.md_saved_flags = PSL_KERNEL | PSL_I;
-#endif
 }
 
 /*

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Oct  1 21:44:30 2009	(r197692)
+++ head/sys/i386/include/cpufunc.h	Thu Oct  1 22:05:38 2009	(r197693)
@@ -49,8 +49,8 @@ extern u_int xen_rcr2(void);
 extern void xen_load_cr3(u_int data);
 extern void xen_tlb_flush(void);
 extern void xen_invlpg(u_int addr);
-extern int xen_save_and_cli(void);
-extern void xen_restore_flags(u_int eflags);
+extern void write_eflags(u_int eflags);
+extern u_int read_eflags(void);
 #endif
 
 struct region_descriptor;
@@ -293,7 +293,11 @@ ia32_pause(void)
 }
 
 static __inline u_int
+#ifdef XEN
+_read_eflags(void)
+#else	
 read_eflags(void)
+#endif
 {
 	u_int	ef;
 
@@ -335,7 +339,11 @@ wbinvd(void)
 }
 
 static __inline void
+#ifdef XEN
+_write_eflags(u_int ef)
+#else
 write_eflags(u_int ef)
+#endif
 {
 	__asm __volatile("pushl %0; popfl" : : "r" (ef));
 }
@@ -653,23 +661,15 @@ intr_disable(void)
 {
 	register_t eflags;
 
-#ifdef XEN
-	eflags = xen_save_and_cli();
-#else 	
 	eflags = read_eflags();
 	disable_intr();
-#endif	
 	return (eflags);
 }
 
 static __inline void
 intr_restore(register_t eflags)
 {
-#ifdef XEN
-	xen_restore_flags(eflags);
-#else
 	write_eflags(eflags);
-#endif
 }
 
 #else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */

Modified: head/sys/i386/xen/xen_machdep.c
==============================================================================
--- head/sys/i386/xen/xen_machdep.c	Thu Oct  1 21:44:30 2009	(r197692)
+++ head/sys/i386/xen/xen_machdep.c	Thu Oct  1 22:05:38 2009	(r197693)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
+#include <sys/ktr.h>
 #include <sys/lock.h>
 #include <sys/mount.h>
 #include <sys/malloc.h>
@@ -101,6 +102,7 @@ void ni_sti(void);
 void
 ni_cli(void)
 {
+	CTR0(KTR_SPARE2, "ni_cli disabling interrupts");
 	__asm__("pushl %edx;"
 		"pushl %eax;"
 		);
@@ -345,33 +347,53 @@ xen_load_cr3(u_int val)
 	PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
-void
-xen_restore_flags(u_int eflags)
+#ifdef KTR
+static __inline u_int
+rebp(void)
 {
-	if (eflags > 1)
-		eflags = ((eflags & PSL_I) == 0);
+	u_int	data;
 
-	__restore_flags(eflags);
+	__asm __volatile("movl 4(%%ebp),%0" : "=r" (data));	
+	return (data);
 }
+#endif
 
-int
-xen_save_and_cli(void)
+u_int
+read_eflags(void)
 {
-	int eflags;
-	
-	__save_and_cli(eflags);
+        vcpu_info_t *_vcpu;
+	u_int eflags;
+
+	eflags = _read_eflags();
+        _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; 
+	if (_vcpu->evtchn_upcall_mask)
+		eflags &= ~PSL_I;
+
 	return (eflags);
 }
 
 void
+write_eflags(u_int eflags)
+{
+	u_int intr;
+
+	CTR2(KTR_SPARE2, "%x xen_restore_flags eflags %x", rebp(), eflags);
+	intr = ((eflags & PSL_I) == 0);
+	__restore_flags(intr);
+	_write_eflags(eflags);
+}
+
+void
 xen_cli(void)
 {
+	CTR1(KTR_SPARE2, "%x xen_cli disabling interrupts", rebp());
 	__cli();
 }
 
 void
 xen_sti(void)
 {
+	CTR1(KTR_SPARE2, "%x xen_sti enabling interrupts", rebp());
 	__sti();
 }
 


More information about the svn-src-all mailing list