File 19266-19365-event-channel-access-fix.patch of Package xen
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1237301047 0
# Node ID bc1fc6635e3ee7d389ca3e49e788fb2e54f20740
# Parent 587e81dd35408742134a4dda26eb9eda8a3c9995
x86: Fix event-channel access for 32-bit HVM guests.
Based on a patch by Joe Jin <joe.jin@oracle.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset: 19266:71af89e70fee39954496130e92807c42d1405489
xen-unstable date: Tue Mar 03 13:17:05 2009 +0000
Fix MAX_EVTCHNS() definition.
Pointed out by Jan Beulich.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset: 19365:2dcdd2fcb945c66ad3b8fcb91d19a9b5115b30f1
xen-unstable date: Tue Mar 17 13:21:46 2009 +0000
Index: xen-3.3.1-testing/xen/arch/x86/domain.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/domain.c
+++ xen-3.3.1-testing/xen/arch/x86/domain.c
@@ -794,7 +794,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
* lost. The domain will get a spurious event, but it can cope.
*/
vcpu_info(v, evtchn_upcall_pending) = 1;
- for ( i = 0; i < BITS_PER_GUEST_LONG(d); i++ )
+ for ( i = 0; i < BITS_PER_EVTCHN_WORD(d); i++ )
set_bit(i, &vcpu_info(v, evtchn_pending_sel));
return 0;
Index: xen-3.3.1-testing/xen/arch/x86/domctl.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/domctl.c
+++ xen-3.3.1-testing/xen/arch/x86/domctl.c
@@ -502,7 +502,8 @@ long arch_do_domctl(
break;
}
- domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
+ domctl->u.address_size.size =
+ is_pv_32on64_domain(d) ? 32 : BITS_PER_LONG;
ret = 0;
rcu_unlock_domain(d);
Index: xen-3.3.1-testing/xen/arch/x86/irq.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/irq.c
+++ xen-3.3.1-testing/xen/arch/x86/irq.c
@@ -1011,7 +1011,8 @@ static void dump_irqs(unsigned char key)
(test_bit(d->pirq_to_evtchn[irq],
&shared_info(d, evtchn_pending)) ?
'P' : '-'),
- (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_GUEST_LONG(d),
+ (test_bit(d->pirq_to_evtchn[irq] /
+ BITS_PER_EVTCHN_WORD(d),
&vcpu_info(d->vcpu[0], evtchn_pending_sel)) ?
'S' : '-'),
(test_bit(d->pirq_to_evtchn[irq],
Index: xen-3.3.1-testing/xen/arch/x86/traps.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/traps.c
+++ xen-3.3.1-testing/xen/arch/x86/traps.c
@@ -3080,7 +3080,8 @@ long register_guest_nmi_callback(unsigne
t->vector = TRAP_nmi;
t->flags = 0;
- t->cs = !IS_COMPAT(d) ? FLAT_KERNEL_CS : FLAT_COMPAT_KERNEL_CS;
+ t->cs = (is_pv_32on64_domain(d) ?
+ FLAT_COMPAT_KERNEL_CS : FLAT_KERNEL_CS);
t->address = address;
TI_SET_IF(t, 1);
Index: xen-3.3.1-testing/xen/common/domctl.c
===================================================================
--- xen-3.3.1-testing.orig/xen/common/domctl.c
+++ xen-3.3.1-testing/xen/common/domctl.c
@@ -242,13 +242,15 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
if ( (c.nat = xmalloc(struct vcpu_guest_context)) == NULL )
goto svc_out;
- if ( !IS_COMPAT(v->domain) )
- ret = copy_from_guest(c.nat, op->u.vcpucontext.ctxt, 1);
#ifdef CONFIG_COMPAT
+ if ( !is_pv_32on64_vcpu(v) )
+ ret = copy_from_guest(c.nat, op->u.vcpucontext.ctxt, 1);
else
ret = copy_from_guest(c.cmp,
guest_handle_cast(op->u.vcpucontext.ctxt,
void), 1);
+#else
+ ret = copy_from_guest(c.nat, op->u.vcpucontext.ctxt, 1);
#endif
ret = ret ? -EFAULT : 0;
@@ -593,12 +595,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
if ( v != current )
vcpu_unpause(v);
- if ( !IS_COMPAT(v->domain) )
- ret = copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1);
#ifdef CONFIG_COMPAT
+ if ( !is_pv_32on64_vcpu(v) )
+ ret = copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1);
else
ret = copy_to_guest(guest_handle_cast(op->u.vcpucontext.ctxt,
void), c.cmp, 1);
+#else
+ ret = copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1);
#endif
if ( copy_to_guest(u_domctl, op, 1) || ret )
Index: xen-3.3.1-testing/xen/common/event_channel.c
===================================================================
--- xen-3.3.1-testing.orig/xen/common/event_channel.c
+++ xen-3.3.1-testing/xen/common/event_channel.c
@@ -548,7 +548,7 @@ static int evtchn_set_pending(struct vcp
return 1;
if ( !test_bit (port, &shared_info(d, evtchn_mask)) &&
- !test_and_set_bit(port / BITS_PER_GUEST_LONG(d),
+ !test_and_set_bit(port / BITS_PER_EVTCHN_WORD(d),
&vcpu_info(v, evtchn_pending_sel)) )
{
vcpu_mark_events_pending(v);
@@ -783,7 +783,7 @@ int evtchn_unmask(unsigned int port)
*/
if ( test_and_clear_bit(port, &shared_info(d, evtchn_mask)) &&
test_bit (port, &shared_info(d, evtchn_pending)) &&
- !test_and_set_bit (port / BITS_PER_GUEST_LONG(d),
+ !test_and_set_bit (port / BITS_PER_EVTCHN_WORD(d),
&vcpu_info(v, evtchn_pending_sel)) )
{
vcpu_mark_events_pending(v);
Index: xen-3.3.1-testing/xen/common/keyhandler.c
===================================================================
--- xen-3.3.1-testing.orig/xen/common/keyhandler.c
+++ xen-3.3.1-testing/xen/common/keyhandler.c
@@ -225,7 +225,7 @@ static void dump_domains(unsigned char k
test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
&shared_info(d, evtchn_mask)),
test_bit(v->virq_to_evtchn[VIRQ_DEBUG] /
- BITS_PER_GUEST_LONG(d),
+ BITS_PER_EVTCHN_WORD(d),
&vcpu_info(v, evtchn_pending_sel)));
send_guest_vcpu_virq(v, VIRQ_DEBUG);
}
Index: xen-3.3.1-testing/xen/common/trace.c
===================================================================
--- xen-3.3.1-testing.orig/xen/common/trace.c
+++ xen-3.3.1-testing/xen/common/trace.c
@@ -37,10 +37,8 @@
#define xen_t_buf t_buf
CHECK_t_buf;
#undef xen_t_buf
-#define TB_COMPAT IS_COMPAT(dom0)
#else
#define compat_t_rec t_rec
-#define TB_COMPAT 0
#endif
/* opt_tbuf_size: trace buffer size (in pages) */
Index: xen-3.3.1-testing/xen/common/xenoprof.c
===================================================================
--- xen-3.3.1-testing.orig/xen/common/xenoprof.c
+++ xen-3.3.1-testing/xen/common/xenoprof.c
@@ -208,7 +208,7 @@ static int alloc_xenoprof_struct(
bufsize = sizeof(struct xenoprof_buf);
i = sizeof(struct event_log);
#ifdef CONFIG_COMPAT
- d->xenoprof->is_compat = IS_COMPAT(is_passive ? dom0 : d);
+ d->xenoprof->is_compat = is_pv_32on64_domain(is_passive ? dom0 : d);
if ( XENOPROF_COMPAT(d->xenoprof) )
{
bufsize = sizeof(struct compat_oprof_buf);
Index: xen-3.3.1-testing/xen/include/asm-x86/domain.h
===================================================================
--- xen-3.3.1-testing.orig/xen/include/asm-x86/domain.h
+++ xen-3.3.1-testing/xen/include/asm-x86/domain.h
@@ -17,7 +17,6 @@
#define is_pv_32on64_domain(d) (0)
#endif
#define is_pv_32on64_vcpu(v) (is_pv_32on64_domain((v)->domain))
-#define IS_COMPAT(d) (is_pv_32on64_domain(d))
struct trap_bounce {
uint32_t error_code;
Index: xen-3.3.1-testing/xen/include/xen/compat.h
===================================================================
--- xen-3.3.1-testing.orig/xen/include/xen/compat.h
+++ xen-3.3.1-testing/xen/include/xen/compat.h
@@ -178,15 +178,10 @@ void xlat_vcpu_runstate_info(struct vcpu
int switch_compat(struct domain *);
int switch_native(struct domain *);
-#define BITS_PER_GUEST_LONG(d) \
- (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG)
-
#else
#define compat_handle_is_null(hnd) 0
-#define BITS_PER_GUEST_LONG(d) BITS_PER_LONG
-
#endif
#endif /* __XEN_COMPAT_H__ */
Index: xen-3.3.1-testing/xen/include/xen/sched.h
===================================================================
--- xen-3.3.1-testing.orig/xen/include/xen/sched.h
+++ xen-3.3.1-testing/xen/include/xen/sched.h
@@ -29,12 +29,11 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_in
extern struct domain *dom0;
#ifndef CONFIG_COMPAT
-#define MAX_EVTCHNS(d) NR_EVENT_CHANNELS
+#define BITS_PER_EVTCHN_WORD(d) BITS_PER_LONG
#else
-#define MAX_EVTCHNS(d) (!IS_COMPAT(d) ? \
- NR_EVENT_CHANNELS : \
- sizeof(unsigned int) * sizeof(unsigned int) * 64)
+#define BITS_PER_EVTCHN_WORD(d) (has_32bit_shinfo(d) ? 32 : BITS_PER_LONG)
#endif
+#define MAX_EVTCHNS(d) (BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d))
#define EVTCHNS_PER_BUCKET 128
#define NR_EVTCHN_BUCKETS (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET)
@@ -542,10 +541,6 @@ void vcpu_runstate_get(struct vcpu *v, s
#define IS_PRIV(_d) ((_d)->is_privileged)
#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target == (_t)))
-#ifndef IS_COMPAT
-#define IS_COMPAT(d) 0
-#endif
-
#define VM_ASSIST(_d,_t) (test_bit((_t), &(_d)->vm_assist))
#define is_hvm_domain(d) ((d)->is_hvm)