From owner-svn-src-head@FreeBSD.ORG Thu Oct 1 22:05:39 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 107A6106568B; Thu, 1 Oct 2009 22:05:39 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0021D8FC0A; Thu, 1 Oct 2009 22:05:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n91M5cf1076256; Thu, 1 Oct 2009 22:05:38 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n91M5cTJ076251; Thu, 1 Oct 2009 22:05:38 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200910012205.n91M5cTJ076251@svn.freebsd.org> From: Kip Macy Date: Thu, 1 Oct 2009 22:05:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197693 - in head/sys/i386: i386 include xen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2009 22:05:39 -0000 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 #include #include +#include #include #include #include @@ -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(); }