make read_eflags and write_eflags accomplish the same effect on PVM as native,

simplifying interrupt handling
This commit is contained in:
kmacy 2009-10-01 22:05:38 +00:00
parent 93e81ca098
commit 46de945b60
3 changed files with 43 additions and 29 deletions

View File

@ -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 thread *td0)
/* 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
}
/*

View File

@ -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) */

View File

@ -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
u_int
read_eflags(void)
{
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);
}
int
xen_save_and_cli(void)
void
write_eflags(u_int eflags)
{
int eflags;
__save_and_cli(eflags);
return (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();
}