ia64/xen-unstable

changeset 19268:71af89e70fee

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>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 03 13:17:05 2009 +0000 (2009-03-03)
parents 7d55cc23493b
children 7f573cb76db4
files xen/arch/x86/domain.c xen/arch/x86/domctl.c xen/arch/x86/irq.c xen/arch/x86/traps.c xen/common/domctl.c xen/common/event_channel.c xen/common/keyhandler.c xen/common/trace.c xen/common/xenoprof.c xen/include/asm-x86/domain.h xen/include/xen/compat.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Tue Mar 03 12:48:16 2009 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Tue Mar 03 13:17:05 2009 +0000
     1.3 @@ -840,7 +840,7 @@ map_vcpu_info(struct vcpu *v, unsigned l
     1.4       * lost.  The domain will get a spurious event, but it can cope.
     1.5       */
     1.6      vcpu_info(v, evtchn_upcall_pending) = 1;
     1.7 -    for ( i = 0; i < BITS_PER_GUEST_LONG(d); i++ )
     1.8 +    for ( i = 0; i < BITS_PER_EVTCHN_WORD(d); i++ )
     1.9          set_bit(i, &vcpu_info(v, evtchn_pending_sel));
    1.10  
    1.11      return 0;
     2.1 --- a/xen/arch/x86/domctl.c	Tue Mar 03 12:48:16 2009 +0000
     2.2 +++ b/xen/arch/x86/domctl.c	Tue Mar 03 13:17:05 2009 +0000
     2.3 @@ -494,7 +494,8 @@ long arch_do_domctl(
     2.4              break;
     2.5          }
     2.6  
     2.7 -        domctl->u.address_size.size = BITS_PER_GUEST_LONG(d);
     2.8 +        domctl->u.address_size.size =
     2.9 +            is_pv_32on64_domain(d) ? 32 : BITS_PER_LONG;
    2.10  
    2.11          ret = 0;
    2.12          rcu_unlock_domain(d);
     3.1 --- a/xen/arch/x86/irq.c	Tue Mar 03 12:48:16 2009 +0000
     3.2 +++ b/xen/arch/x86/irq.c	Tue Mar 03 13:17:05 2009 +0000
     3.3 @@ -1104,7 +1104,8 @@ static void dump_irqs(unsigned char key)
     3.4                         (test_bit(d->pirq_to_evtchn[irq],
     3.5                                   &shared_info(d, evtchn_pending)) ?
     3.6                          'P' : '-'),
     3.7 -                       (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_GUEST_LONG(d),
     3.8 +                       (test_bit(d->pirq_to_evtchn[irq] /
     3.9 +                                 BITS_PER_EVTCHN_WORD(d),
    3.10                                   &vcpu_info(d->vcpu[0], evtchn_pending_sel)) ?
    3.11                          'S' : '-'),
    3.12                         (test_bit(d->pirq_to_evtchn[irq],
     4.1 --- a/xen/arch/x86/traps.c	Tue Mar 03 12:48:16 2009 +0000
     4.2 +++ b/xen/arch/x86/traps.c	Tue Mar 03 13:17:05 2009 +0000
     4.3 @@ -3095,7 +3095,8 @@ long register_guest_nmi_callback(unsigne
     4.4  
     4.5      t->vector  = TRAP_nmi;
     4.6      t->flags   = 0;
     4.7 -    t->cs      = !IS_COMPAT(d) ? FLAT_KERNEL_CS : FLAT_COMPAT_KERNEL_CS;
     4.8 +    t->cs      = (is_pv_32on64_domain(d) ?
     4.9 +                  FLAT_COMPAT_KERNEL_CS : FLAT_KERNEL_CS);
    4.10      t->address = address;
    4.11      TI_SET_IF(t, 1);
    4.12  
     5.1 --- a/xen/common/domctl.c	Tue Mar 03 12:48:16 2009 +0000
     5.2 +++ b/xen/common/domctl.c	Tue Mar 03 13:17:05 2009 +0000
     5.3 @@ -242,13 +242,15 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
     5.4          if ( (c.nat = xmalloc(struct vcpu_guest_context)) == NULL )
     5.5              goto svc_out;
     5.6  
     5.7 -        if ( !IS_COMPAT(v->domain) )
     5.8 +#ifdef CONFIG_COMPAT
     5.9 +        if ( !is_pv_32on64_vcpu(v) )
    5.10              ret = copy_from_guest(c.nat, op->u.vcpucontext.ctxt, 1);
    5.11 -#ifdef CONFIG_COMPAT
    5.12          else
    5.13              ret = copy_from_guest(c.cmp,
    5.14                                    guest_handle_cast(op->u.vcpucontext.ctxt,
    5.15                                                      void), 1);
    5.16 +#else
    5.17 +        ret = copy_from_guest(c.nat, op->u.vcpucontext.ctxt, 1);
    5.18  #endif
    5.19          ret = ret ? -EFAULT : 0;
    5.20  
    5.21 @@ -596,12 +598,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
    5.22          if ( v != current )
    5.23              vcpu_unpause(v);
    5.24  
    5.25 -        if ( !IS_COMPAT(v->domain) )
    5.26 +#ifdef CONFIG_COMPAT
    5.27 +        if ( !is_pv_32on64_vcpu(v) )
    5.28              ret = copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1);
    5.29 -#ifdef CONFIG_COMPAT
    5.30          else
    5.31              ret = copy_to_guest(guest_handle_cast(op->u.vcpucontext.ctxt,
    5.32                                                    void), c.cmp, 1);
    5.33 +#else
    5.34 +        ret = copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1);
    5.35  #endif
    5.36  
    5.37          if ( copy_to_guest(u_domctl, op, 1) || ret )
     6.1 --- a/xen/common/event_channel.c	Tue Mar 03 12:48:16 2009 +0000
     6.2 +++ b/xen/common/event_channel.c	Tue Mar 03 13:17:05 2009 +0000
     6.3 @@ -548,7 +548,7 @@ static int evtchn_set_pending(struct vcp
     6.4          return 1;
     6.5  
     6.6      if ( !test_bit        (port, &shared_info(d, evtchn_mask)) &&
     6.7 -         !test_and_set_bit(port / BITS_PER_GUEST_LONG(d),
     6.8 +         !test_and_set_bit(port / BITS_PER_EVTCHN_WORD(d),
     6.9                             &vcpu_info(v, evtchn_pending_sel)) )
    6.10      {
    6.11          vcpu_mark_events_pending(v);
    6.12 @@ -783,7 +783,7 @@ int evtchn_unmask(unsigned int port)
    6.13       */
    6.14      if ( test_and_clear_bit(port, &shared_info(d, evtchn_mask)) &&
    6.15           test_bit          (port, &shared_info(d, evtchn_pending)) &&
    6.16 -         !test_and_set_bit (port / BITS_PER_GUEST_LONG(d),
    6.17 +         !test_and_set_bit (port / BITS_PER_EVTCHN_WORD(d),
    6.18                              &vcpu_info(v, evtchn_pending_sel)) )
    6.19      {
    6.20          vcpu_mark_events_pending(v);
     7.1 --- a/xen/common/keyhandler.c	Tue Mar 03 12:48:16 2009 +0000
     7.2 +++ b/xen/common/keyhandler.c	Tue Mar 03 13:17:05 2009 +0000
     7.3 @@ -225,7 +225,7 @@ static void dump_domains(unsigned char k
     7.4                     test_bit(v->virq_to_evtchn[VIRQ_DEBUG], 
     7.5                              &shared_info(d, evtchn_mask)),
     7.6                     test_bit(v->virq_to_evtchn[VIRQ_DEBUG] /
     7.7 -                            BITS_PER_GUEST_LONG(d),
     7.8 +                            BITS_PER_EVTCHN_WORD(d),
     7.9                              &vcpu_info(v, evtchn_pending_sel)));
    7.10              send_guest_vcpu_virq(v, VIRQ_DEBUG);
    7.11          }
     8.1 --- a/xen/common/trace.c	Tue Mar 03 12:48:16 2009 +0000
     8.2 +++ b/xen/common/trace.c	Tue Mar 03 13:17:05 2009 +0000
     8.3 @@ -37,10 +37,8 @@
     8.4  #define xen_t_buf t_buf
     8.5  CHECK_t_buf;
     8.6  #undef xen_t_buf
     8.7 -#define TB_COMPAT IS_COMPAT(dom0)
     8.8  #else
     8.9  #define compat_t_rec t_rec
    8.10 -#define TB_COMPAT 0
    8.11  #endif
    8.12  
    8.13  /* opt_tbuf_size: trace buffer size (in pages) */
     9.1 --- a/xen/common/xenoprof.c	Tue Mar 03 12:48:16 2009 +0000
     9.2 +++ b/xen/common/xenoprof.c	Tue Mar 03 13:17:05 2009 +0000
     9.3 @@ -208,7 +208,7 @@ static int alloc_xenoprof_struct(
     9.4      bufsize = sizeof(struct xenoprof_buf);
     9.5      i = sizeof(struct event_log);
     9.6  #ifdef CONFIG_COMPAT
     9.7 -    d->xenoprof->is_compat = IS_COMPAT(is_passive ? dom0 : d);
     9.8 +    d->xenoprof->is_compat = is_pv_32on64_domain(is_passive ? dom0 : d);
     9.9      if ( XENOPROF_COMPAT(d->xenoprof) )
    9.10      {
    9.11          bufsize = sizeof(struct compat_oprof_buf);
    10.1 --- a/xen/include/asm-x86/domain.h	Tue Mar 03 12:48:16 2009 +0000
    10.2 +++ b/xen/include/asm-x86/domain.h	Tue Mar 03 13:17:05 2009 +0000
    10.3 @@ -16,7 +16,6 @@
    10.4  #define is_pv_32on64_domain(d) (0)
    10.5  #endif
    10.6  #define is_pv_32on64_vcpu(v)   (is_pv_32on64_domain((v)->domain))
    10.7 -#define IS_COMPAT(d)           (is_pv_32on64_domain(d))
    10.8  
    10.9  struct trap_bounce {
   10.10      uint32_t      error_code;
    11.1 --- a/xen/include/xen/compat.h	Tue Mar 03 12:48:16 2009 +0000
    11.2 +++ b/xen/include/xen/compat.h	Tue Mar 03 13:17:05 2009 +0000
    11.3 @@ -178,15 +178,10 @@ void xlat_vcpu_runstate_info(struct vcpu
    11.4  int switch_compat(struct domain *);
    11.5  int switch_native(struct domain *);
    11.6  
    11.7 -#define BITS_PER_GUEST_LONG(d) \
    11.8 -    (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG)
    11.9 -
   11.10  #else
   11.11  
   11.12  #define compat_handle_is_null(hnd) 0
   11.13  
   11.14 -#define BITS_PER_GUEST_LONG(d) BITS_PER_LONG
   11.15 -
   11.16  #endif
   11.17  
   11.18  #endif /* __XEN_COMPAT_H__ */
    12.1 --- a/xen/include/xen/sched.h	Tue Mar 03 12:48:16 2009 +0000
    12.2 +++ b/xen/include/xen/sched.h	Tue Mar 03 13:17:05 2009 +0000
    12.3 @@ -30,12 +30,11 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_in
    12.4  extern struct domain *dom0;
    12.5  
    12.6  #ifndef CONFIG_COMPAT
    12.7 -#define MAX_EVTCHNS(d)     NR_EVENT_CHANNELS
    12.8 +#define BITS_PER_EVTCHN_WORD(d) BITS_PER_LONG
    12.9  #else
   12.10 -#define MAX_EVTCHNS(d)     (!IS_COMPAT(d) ? \
   12.11 -                            NR_EVENT_CHANNELS : \
   12.12 -                            sizeof(unsigned int) * sizeof(unsigned int) * 64)
   12.13 +#define BITS_PER_EVTCHN_WORD(d) (has_32bit_shinfo(d) ? 32 : BITS_PER_LONG)
   12.14  #endif
   12.15 +#define MAX_EVTCHNS(d) (BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d) * 64)
   12.16  #define EVTCHNS_PER_BUCKET 128
   12.17  #define NR_EVTCHN_BUCKETS  (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET)
   12.18  
   12.19 @@ -542,10 +541,6 @@ uint64_t get_cpu_idle_time(unsigned int 
   12.20  #define IS_PRIV(_d) ((_d)->is_privileged)
   12.21  #define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target == (_t)))
   12.22  
   12.23 -#ifndef IS_COMPAT
   12.24 -#define IS_COMPAT(d) 0
   12.25 -#endif
   12.26 -
   12.27  #define VM_ASSIST(_d,_t) (test_bit((_t), &(_d)->vm_assist))
   12.28  
   12.29  #define is_hvm_domain(d) ((d)->is_hvm)