Hollis Blanchard
2006-Mar-30 17:17 UTC
[Xen-devel] [patch] make hypercall_preempt_check() a little more sensitive
Since PowerPC has a hypervisor mode in the processor, Linux is able to disable interrupts directly using the EE bit in the MSR (Machine State Register), just like on hardware. This bit acts like the evtchn_upcall_mask bit. It would be an invasive patch to PowerPC Linux to modify the code that disables the EE bit and additionally have it modify vcpu_info->evtchn_upcall_mask, especially when that code is in assembly. Instead, we can have hypercall_preempt_check() also check MSR:EE directly. IA64 may be able to use this facility as well, so I''ve CC''ed that list. This patch fixes a problem where an event occurs, Linux calls back into Xen for e.g. console output, Xen sees that an event is pending and creates a continuation and returns... loop forever. Compile-tested on x86. Please apply. -- Hollis Blanchard IBM Linux Technology Center Signed-off-by: Jimi Xenidis <jimix@us.ibm.com> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> --- a/xen/include/asm-ia64/domain.h Wed Mar 29 16:42:19 2006 -0600 +++ b/xen/include/asm-ia64/domain.h Thu Mar 30 11:02:47 2006 -0600 @@ -143,6 +143,8 @@ extern struct mm_struct init_mm; #include <asm/uaccess.h> /* for KERNEL_DS */ #include <asm/pgtable.h> +#define arch_event_deliverable(v) (1) + #endif /* __ASM_DOMAIN_H__ */ /* diff -r d258c2f68943 xen/include/asm-x86/domain.h --- a/xen/include/asm-x86/domain.h Wed Mar 29 16:42:19 2006 -0600 +++ b/xen/include/asm-x86/domain.h Thu Mar 30 11:02:47 2006 -0600 @@ -173,6 +173,8 @@ struct arch_vcpu #define hvm_vmx hvm_vcpu.u.vmx #define hvm_svm hvm_vcpu.u.svm +#define arch_event_deliverable(v) (1) + #endif /* __ASM_DOMAIN_H__ */ /* diff -r d258c2f68943 xen/include/xen/sched.h --- a/xen/include/xen/sched.h Wed Mar 29 16:42:19 2006 -0600 +++ b/xen/include/xen/sched.h Thu Mar 30 11:02:47 2006 -0600 @@ -319,7 +319,8 @@ unsigned long hypercall_create_continuat #define hypercall_preempt_check() (unlikely( \ softirq_pending(smp_processor_id()) | \ - event_pending(current) \ + (event_pending(current) & \ + arch_event_deliverable(current)) \ )) /* This domain_hash and domain_list are protected by the domlist_lock. */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Mar-31 09:33 UTC
Re: [Xen-devel] [patch] make hypercall_preempt_check() a little more sensitive
On 30 Mar 2006, at 18:17, Hollis Blanchard wrote:> It would be an invasive patch to PowerPC Linux to modify the code that > disables the EE bit and additionally have it modify > vcpu_info->evtchn_upcall_mask, especially when that code is in > assembly. > Instead, we can have hypercall_preempt_check() also check MSR:EE > directly. > IA64 may be able to use this facility as well, so I''ve CC''ed that list. > > This patch fixes a problem where an event occurs, Linux calls back > into Xen > for e.g. console output, Xen sees that an event is pending and creates > a > continuation and returns... loop forever.I''d rather move event_pending() into asm/event.h and then you can monkey with it as you like. That''ll also catch other uses of event_pending() where you probably also want the same extra check. I don''t really want a proliferation of extra little functions called arch_xxx. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Apr-10 19:16 UTC
Re: [Xen-devel] [patch] make hypercall_preempt_check() a little more sensitive
On Fri, 2006-03-31 at 10:33 +0100, Keir Fraser wrote:> On 30 Mar 2006, at 18:17, Hollis Blanchard wrote: > > I''d rather move event_pending() into asm/event.h and then you can > monkey with it as you like. That''ll also catch other uses of > event_pending() where you probably also want the same extra check. I > don''t really want a proliferation of extra little functions called > arch_xxx.OK. Compile-tested on x86. -- Hollis Blanchard IBM Linux Technology Center Make event_pending() architecture-specific. PowerPC needs this because the domain can directly modify the hardware''s "interrupts enabled" bit, and we don''t want to patch Linux to replace all those accesses to use evtchn_upcall_mask instead. Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com> diff -r 4ed269ac7d84 xen/include/asm-ia64/event.h --- a/xen/include/asm-ia64/event.h Mon Apr 10 13:24:58 2006 +0100 +++ b/xen/include/asm-ia64/event.h Mon Apr 10 14:09:16 2006 -0500 @@ -32,4 +32,9 @@ static inline void evtchn_notify(struct vcpu_pend_interrupt(v, v->vcpu_info->arch.evtchn_vector); } +/* Note: Bitwise operations result in fast code with no branches. */ +#define event_pending(v) \ + (!!(v)->vcpu_info->evtchn_upcall_pending & \ + !(v)->vcpu_info->evtchn_upcall_mask) + #endif diff -r 4ed269ac7d84 xen/include/asm-x86/event.h --- a/xen/include/asm-x86/event.h Mon Apr 10 13:24:58 2006 +0100 +++ b/xen/include/asm-x86/event.h Mon Apr 10 14:09:16 2006 -0500 @@ -26,4 +26,9 @@ static inline void evtchn_notify(struct smp_send_event_check_cpu(v->processor); } +/* Note: Bitwise operations result in fast code with no branches. */ +#define event_pending(v) \ + (!!(v)->vcpu_info->evtchn_upcall_pending & \ + !(v)->vcpu_info->evtchn_upcall_mask) + #endif diff -r 4ed269ac7d84 xen/include/xen/event.h --- a/xen/include/xen/event.h Mon Apr 10 13:24:58 2006 +0100 +++ b/xen/include/xen/event.h Mon Apr 10 14:09:16 2006 -0500 @@ -38,11 +38,6 @@ extern void send_guest_global_virq(struc */ extern void send_guest_pirq(struct domain *d, int pirq); -/* Note: Bitwise operations result in fast code with no branches. */ -#define event_pending(v) \ - (!!(v)->vcpu_info->evtchn_upcall_pending & \ - !(v)->vcpu_info->evtchn_upcall_mask) - #define evtchn_pending(d, p) \ (test_bit((p), &(d)->shared_info->evtchn_pending[0])) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel