ia64/xen-unstable

changeset 17446:9e4c5b7e5aa6

hvm: Add HVM_PARAM_DM_DOMAIN to let ioreq events go to a stub domain
instead of dom0.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 11 17:19:07 2008 +0100 (2008-04-11)
parents d2010614d9f1
children a464af87c9db
files tools/ioemu/hw/xen_machine_fv.c xen/arch/ia64/vmx/vmx_hypercall.c xen/arch/x86/hvm/hvm.c xen/common/event_channel.c xen/include/public/hvm/params.h
line diff
     1.1 --- a/tools/ioemu/hw/xen_machine_fv.c	Fri Apr 11 15:55:42 2008 +0100
     1.2 +++ b/tools/ioemu/hw/xen_machine_fv.c	Fri Apr 11 17:19:07 2008 +0100
     1.3 @@ -205,6 +205,7 @@ static void xen_init_fv(uint64_t ram_siz
     1.4      }
     1.5  #endif
     1.6  
     1.7 +    xc_set_hvm_param(xc_handle, domid, HVM_PARAM_DM_DOMAIN, DOMID_SELF);
     1.8      xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
     1.9      fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn);
    1.10      shared_page = xc_map_foreign_range(xc_handle, domid, XC_PAGE_SIZE,
     2.1 --- a/xen/arch/ia64/vmx/vmx_hypercall.c	Fri Apr 11 15:55:42 2008 +0100
     2.2 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c	Fri Apr 11 17:19:07 2008 +0100
     2.3 @@ -165,6 +165,11 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
     2.4                  iorp = &d->arch.hvm_domain.buf_pioreq;
     2.5                  rc = vmx_set_ioreq_page(d, iorp, a.value);
     2.6                  break;
     2.7 +            case HVM_PARAM_DM_DOMAIN:
     2.8 +                if (a.value == DOMID_SELF)
     2.9 +                    a.value = current->domain->domain_id;
    2.10 +                rc = a.value ? -EINVAL : 0; /* no stub domain support */
    2.11 +                break;
    2.12              default:
    2.13                  /* nothing */
    2.14                  break;
     3.1 --- a/xen/arch/x86/hvm/hvm.c	Fri Apr 11 15:55:42 2008 +0100
     3.2 +++ b/xen/arch/x86/hvm/hvm.c	Fri Apr 11 17:19:07 2008 +0100
     3.3 @@ -2187,13 +2187,16 @@ long do_hvm_op(unsigned long op, XEN_GUE
     3.4  
     3.5          if ( op == HVMOP_set_param )
     3.6          {
     3.7 +            rc = 0;
     3.8 +
     3.9              switch ( a.index )
    3.10              {
    3.11              case HVM_PARAM_IOREQ_PFN:
    3.12                  iorp = &d->arch.hvm_domain.ioreq;
    3.13 -                rc = hvm_set_ioreq_page(d, iorp, a.value);
    3.14 +                if ( (rc = hvm_set_ioreq_page(d, iorp, a.value)) != 0 )
    3.15 +                    break;
    3.16                  spin_lock(&iorp->lock);
    3.17 -                if ( (rc == 0) && (iorp->va != NULL) )
    3.18 +                if ( iorp->va != NULL )
    3.19                      /* Initialise evtchn port info if VCPUs already created. */
    3.20                      for_each_vcpu ( d, v )
    3.21                          get_ioreq(v)->vp_eport = v->arch.hvm_vcpu.xen_port;
    3.22 @@ -2208,19 +2211,19 @@ long do_hvm_op(unsigned long op, XEN_GUE
    3.23                  hvm_latch_shinfo_size(d);
    3.24                  break;
    3.25              case HVM_PARAM_TIMER_MODE:
    3.26 -                rc = -EINVAL;
    3.27                  if ( a.value > HVMPTM_one_missed_tick_pending )
    3.28 -                    goto param_fail;
    3.29 +                    rc = -EINVAL;
    3.30                  break;
    3.31              case HVM_PARAM_IDENT_PT:
    3.32                  rc = -EPERM;
    3.33 -                if ( current->domain->domain_id != 0 )
    3.34 -                    goto param_fail;
    3.35 +                if ( !IS_PRIV(current->domain) )
    3.36 +                    break;
    3.37  
    3.38                  rc = -EINVAL;
    3.39                  if ( d->arch.hvm_domain.params[a.index] != 0 )
    3.40 -                    goto param_fail;
    3.41 +                    break;
    3.42  
    3.43 +                rc = 0;
    3.44                  if ( !paging_mode_hap(d) )
    3.45                      break;
    3.46  
    3.47 @@ -2239,9 +2242,41 @@ long do_hvm_op(unsigned long op, XEN_GUE
    3.48  
    3.49                  domain_unpause(d);
    3.50                  break;
    3.51 +            case HVM_PARAM_DM_DOMAIN:
    3.52 +                /* Privileged domains only, as we must domain_pause(d). */
    3.53 +                rc = -EPERM;
    3.54 +                if ( !IS_PRIV_FOR(current->domain, d) )
    3.55 +                    break;
    3.56 +
    3.57 +                if ( a.value == DOMID_SELF )
    3.58 +                    a.value = current->domain->domain_id;
    3.59 +
    3.60 +                rc = 0;
    3.61 +                domain_pause(d); /* safe to change per-vcpu xen_port */
    3.62 +                iorp = &d->arch.hvm_domain.ioreq;
    3.63 +                for_each_vcpu ( d, v )
    3.64 +                {
    3.65 +                    int old_port, new_port;
    3.66 +                    new_port = alloc_unbound_xen_event_channel(v, a.value);
    3.67 +                    if ( new_port < 0 )
    3.68 +                    {
    3.69 +                        rc = new_port;
    3.70 +                        break;
    3.71 +                    }
    3.72 +                    /* xchg() ensures that only we free_xen_event_channel() */
    3.73 +                    old_port = xchg(&v->arch.hvm_vcpu.xen_port, new_port);
    3.74 +                    free_xen_event_channel(v, old_port);
    3.75 +                    spin_lock(&iorp->lock);
    3.76 +                    if ( iorp->va != NULL )
    3.77 +                        get_ioreq(v)->vp_eport = v->arch.hvm_vcpu.xen_port;
    3.78 +                    spin_unlock(&iorp->lock);
    3.79 +                }
    3.80 +                domain_unpause(d);
    3.81 +                break;
    3.82              }
    3.83 -            d->arch.hvm_domain.params[a.index] = a.value;
    3.84 -            rc = 0;
    3.85 +
    3.86 +            if ( rc == 0 )
    3.87 +                d->arch.hvm_domain.params[a.index] = a.value;
    3.88          }
    3.89          else
    3.90          {
     4.1 --- a/xen/common/event_channel.c	Fri Apr 11 15:55:42 2008 +0100
     4.2 +++ b/xen/common/event_channel.c	Fri Apr 11 17:19:07 2008 +0100
     4.3 @@ -109,9 +109,7 @@ static int get_free_port(struct domain *
     4.4          if ( xsm_alloc_security_evtchn(&chn[i]) )
     4.5          {
     4.6              for ( j = 0; j < i; j++ )
     4.7 -            {
     4.8                  xsm_free_security_evtchn(&chn[j]);
     4.9 -            }        
    4.10              xfree(chn);
    4.11              return -ENOMEM;
    4.12          }
    4.13 @@ -971,9 +969,18 @@ void free_xen_event_channel(
    4.14      struct domain *d = local_vcpu->domain;
    4.15  
    4.16      spin_lock(&d->evtchn_lock);
    4.17 +
    4.18 +    if ( unlikely(d->is_dying) )
    4.19 +    {
    4.20 +        spin_unlock(&d->evtchn_lock);
    4.21 +        return;
    4.22 +    }
    4.23 +
    4.24 +    BUG_ON(!port_is_valid(d, port));
    4.25      chn = evtchn_from_port(d, port);
    4.26      BUG_ON(!chn->consumer_is_xen);
    4.27      chn->consumer_is_xen = 0;
    4.28 +
    4.29      spin_unlock(&d->evtchn_lock);
    4.30  
    4.31      (void)__evtchn_close(d, port);
    4.32 @@ -1035,6 +1042,7 @@ void evtchn_destroy(struct domain *d)
    4.33      {
    4.34          xsm_free_security_evtchn(d->evtchn[i]);
    4.35          xfree(d->evtchn[i]);
    4.36 +        d->evtchn[i] = NULL;
    4.37      }
    4.38      spin_unlock(&d->evtchn_lock);
    4.39  }
     5.1 --- a/xen/include/public/hvm/params.h	Fri Apr 11 15:55:42 2008 +0100
     5.2 +++ b/xen/include/public/hvm/params.h	Fri Apr 11 17:19:07 2008 +0100
     5.3 @@ -83,8 +83,13 @@
     5.4  
     5.5  /* Boolean: Enable virtual HPET (high-precision event timer)? (x86-only) */
     5.6  #define HVM_PARAM_HPET_ENABLED 11
     5.7 +
     5.8 +/* Identity-map page directory used by Intel EPT when CR0.PG=0. */
     5.9  #define HVM_PARAM_IDENT_PT     12
    5.10  
    5.11 -#define HVM_NR_PARAMS          13
    5.12 +/* Device Model domain, defaults to 0. */
    5.13 +#define HVM_PARAM_DM_DOMAIN    13
    5.14 +
    5.15 +#define HVM_NR_PARAMS          14
    5.16  
    5.17  #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */