ia64/xen-unstable

changeset 5702:579d1e771025

Merge.
author sos22@douglas.cl.cam.ac.uk
date Fri Jul 08 12:24:58 2005 +0000 (2005-07-08)
parents 707fcf42a5ae eef23f57f20e
children 1d375ce8e0e0 49a00af50777
files .hgignore Makefile buildconfigs/mk.linux-2.6-xen docs/misc/hg-cheatsheet.txt extras/mini-os/Makefile extras/mini-os/events.c extras/mini-os/hypervisor.c extras/mini-os/include/events.h extras/mini-os/include/hypervisor.h extras/mini-os/include/lib.h extras/mini-os/include/mm.h extras/mini-os/include/os.h extras/mini-os/include/time.h extras/mini-os/include/traps.h extras/mini-os/include/types.h extras/mini-os/kernel.c extras/mini-os/time.c extras/mini-os/traps.c extras/mini-os/x86_32.S linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/configs/xen_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/configs/xen_defconfig_x86_64 linux-2.6.11-xen-sparse/arch/xen/i386/kernel/irq.c linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c linux-2.6.11-xen-sparse/arch/xen/kernel/evtchn.c linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c patches/linux-2.6.11/smp-alts.patch tools/Rules.mk tools/firmware/vmxassist/Makefile tools/libxc/xc.h tools/libxc/xc_domain.c tools/libxc/xc_linux_build.c tools/misc/cpuperf/Makefile tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/main.py tools/xenstore/Makefile xen/Makefile xen/arch/x86/traps.c xen/common/dom0_ops.c xen/common/event_channel.c xen/common/schedule.c xen/include/acm/acm_core.h xen/include/public/dom0_ops.h xen/include/public/event_channel.h
line diff
     2.1 --- a/Makefile	Fri Jul 08 12:22:18 2005 +0000
     2.2 +++ b/Makefile	Fri Jul 08 12:24:58 2005 +0000
     2.3 @@ -177,10 +177,10 @@ uninstall:
     2.4  
     2.5  # Legacy targets for compatibility
     2.6  linux24:
     2.7 -	$(MAKE) 'KERNELS=linux-2.4*' dist
     2.8 +	$(MAKE) 'KERNELS=linux-2.4*' kernels
     2.9  
    2.10  linux26:
    2.11 -	$(MAKE) 'KERNELS=linux-2.6*' dist
    2.12 +	$(MAKE) 'KERNELS=linux-2.6*' kernels
    2.13  
    2.14  netbsd20:
    2.15  	$(MAKE) netbsd-2.0-xenU-build
    31.1 --- a/tools/libxc/xc.h	Fri Jul 08 12:22:18 2005 +0000
    31.2 +++ b/tools/libxc/xc.h	Fri Jul 08 12:24:58 2005 +0000
    31.3 @@ -192,6 +192,24 @@ int xc_domain_getinfo(int xc_handle,
    31.4                        xc_dominfo_t *info);
    31.5  
    31.6  /**
    31.7 + * This function will return information about one or more domains, using a
    31.8 + * single hypercall.  The domain information will be stored into the supplied
    31.9 + * array of xc_domaininfo_t structures.
   31.10 + *
   31.11 + * @parm xc_handle a handle to an open hypervisor interface
   31.12 + * @parm first_domain the first domain to enumerate information from.
   31.13 + *                    Domains are currently enumerate in order of creation.
   31.14 + * @parm max_domains the number of elements in info
   31.15 + * @parm info an array of max_doms size that will contain the information for
   31.16 + *            the enumerated domains.
   31.17 + * @return the number of domains enumerated or -1 on error
   31.18 + */
   31.19 +int xc_domain_getinfolist(int xc_handle,
   31.20 +                          u32 first_domain,
   31.21 +                          unsigned int max_domains,
   31.22 +                          xc_domaininfo_t *info);
   31.23 +
   31.24 +/**
   31.25   * This function returns information about one domain.  This information is
   31.26   * more detailed than the information from xc_domain_getinfo().
   31.27   *
    32.1 --- a/tools/libxc/xc_domain.c	Fri Jul 08 12:22:18 2005 +0000
    32.2 +++ b/tools/libxc/xc_domain.c	Fri Jul 08 12:24:58 2005 +0000
    32.3 @@ -125,6 +125,33 @@ int xc_domain_getinfo(int xc_handle,
    32.4      return nr_doms;
    32.5  }
    32.6  
    32.7 +int xc_domain_getinfolist(int xc_handle,
    32.8 +                          u32 first_domain,
    32.9 +                          unsigned int max_domains,
   32.10 +                          xc_domaininfo_t *info)
   32.11 +{
   32.12 +    int ret = 0;
   32.13 +    dom0_op_t op;
   32.14 +
   32.15 +    if(mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
   32.16 +        return -1;
   32.17 +    
   32.18 +    op.cmd = DOM0_GETDOMAININFOLIST;
   32.19 +    op.u.getdomaininfolist.first_domain = first_domain;
   32.20 +    op.u.getdomaininfolist.max_domains  = max_domains;
   32.21 +    op.u.getdomaininfolist.buffer       = info;
   32.22 +
   32.23 +    if(xc_dom0_op(xc_handle, &op) < 0)
   32.24 +        ret = -1;
   32.25 +    else
   32.26 +        ret = op.u.getdomaininfolist.num_domains;
   32.27 +    
   32.28 +    if(munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
   32.29 +        ret = -1;
   32.30 +    
   32.31 +    return ret;
   32.32 +}
   32.33 +
   32.34  int xc_domain_get_vcpu_context(int xc_handle,
   32.35                                 u32 domid,
   32.36                                 u32 vcpu,
    35.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 08 12:22:18 2005 +0000
    35.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 08 12:24:58 2005 +0000
    35.3 @@ -688,7 +688,7 @@ static PyObject *pyxc_physinfo(PyObject 
    35.4      if ( xc_physinfo(xc->xc_handle, &info) != 0 )
    35.5          return PyErr_SetFromErrno(xc_error);
    35.6  
    35.7 -    return Py_BuildValue("{s:i,s:i,s:l,s:l,s:l}",
    35.8 +    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i}",
    35.9                           "threads_per_core", info.threads_per_core,
   35.10                           "cores_per_socket", info.cores_per_socket,
   35.11                           "sockets_per_node", info.sockets_per_node,
    40.1 --- a/xen/arch/x86/traps.c	Fri Jul 08 12:22:18 2005 +0000
    40.2 +++ b/xen/arch/x86/traps.c	Fri Jul 08 12:24:58 2005 +0000
    40.3 @@ -94,6 +94,9 @@ DECLARE_TRAP_HANDLER(alignment_check);
    40.4  DECLARE_TRAP_HANDLER(spurious_interrupt_bug);
    40.5  DECLARE_TRAP_HANDLER(machine_check);
    40.6  
    40.7 +long do_set_debugreg(int reg, unsigned long value);
    40.8 +unsigned long do_get_debugreg(int reg);
    40.9 +
   40.10  static int debug_stack_lines = 20;
   40.11  integer_param("debug_stack_lines", debug_stack_lines);
   40.12  
   40.13 @@ -568,8 +571,8 @@ static inline int admin_io_okay(
   40.14  static int emulate_privileged_op(struct cpu_user_regs *regs)
   40.15  {
   40.16      struct vcpu *v = current;
   40.17 -    unsigned long *reg, eip = regs->eip;
   40.18 -    u8 opcode, modrm_reg = 0, rep_prefix = 0;
   40.19 +    unsigned long *reg, eip = regs->eip, res;
   40.20 +    u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0;
   40.21      unsigned int port, i, op_bytes = 4, data;
   40.22  
   40.23      /* Legacy prefixes. */
   40.24 @@ -604,7 +607,9 @@ static int emulate_privileged_op(struct 
   40.25      if ( (opcode & 0xf0) == 0x40 )
   40.26      {
   40.27          modrm_reg = (opcode & 4) << 1;  /* REX.R */
   40.28 -        /* REX.W, REX.B and REX.X do not need to be decoded. */
   40.29 +        modrm_rm  = (opcode & 1) << 3;  /* REX.B */
   40.30 +
   40.31 +        /* REX.W and REX.X do not need to be decoded. */
   40.32          opcode = insn_fetch(u8, 1, eip);
   40.33      }
   40.34  #endif
   40.35 @@ -782,11 +787,10 @@ static int emulate_privileged_op(struct 
   40.36  
   40.37      case 0x20: /* MOV CR?,<reg> */
   40.38          opcode = insn_fetch(u8, 1, eip);
   40.39 -        if ( (opcode & 0xc0) != 0xc0 )
   40.40 -            goto fail;
   40.41 -        modrm_reg |= opcode & 7;
   40.42 -        reg = decode_register(modrm_reg, regs, 0);
   40.43 -        switch ( (opcode >> 3) & 7 )
   40.44 +        modrm_reg |= (opcode >> 3) & 7;
   40.45 +        modrm_rm  |= (opcode >> 0) & 7;
   40.46 +        reg = decode_register(modrm_rm, regs, 0);
   40.47 +        switch ( modrm_reg )
   40.48          {
   40.49          case 0: /* Read CR0 */
   40.50              *reg = v->arch.guest_context.ctrlreg[0];
   40.51 @@ -805,13 +809,22 @@ static int emulate_privileged_op(struct 
   40.52          }
   40.53          break;
   40.54  
   40.55 +    case 0x21: /* MOV DR?,<reg> */
   40.56 +        opcode = insn_fetch(u8, 1, eip);
   40.57 +        modrm_reg |= (opcode >> 3) & 7;
   40.58 +        modrm_rm  |= (opcode >> 0) & 7;
   40.59 +        reg = decode_register(modrm_rm, regs, 0);
   40.60 +        if ( (res = do_get_debugreg(modrm_reg)) > (unsigned long)-256 )
   40.61 +            goto fail;
   40.62 +        *reg = res;
   40.63 +        break;
   40.64 +
   40.65      case 0x22: /* MOV <reg>,CR? */
   40.66          opcode = insn_fetch(u8, 1, eip);
   40.67 -        if ( (opcode & 0xc0) != 0xc0 )
   40.68 -            goto fail;
   40.69 -        modrm_reg |= opcode & 7;
   40.70 -        reg = decode_register(modrm_reg, regs, 0);
   40.71 -        switch ( (opcode >> 3) & 7 )
   40.72 +        modrm_reg |= (opcode >> 3) & 7;
   40.73 +        modrm_rm  |= (opcode >> 0) & 7;
   40.74 +        reg = decode_register(modrm_rm, regs, 0);
   40.75 +        switch ( modrm_reg )
   40.76          {
   40.77          case 0: /* Write CR0 */
   40.78              (void)do_fpu_taskswitch(!!(*reg & X86_CR0_TS));
   40.79 @@ -827,6 +840,15 @@ static int emulate_privileged_op(struct 
   40.80              UNLOCK_BIGLOCK(v->domain);
   40.81              break;
   40.82  
   40.83 +    case 0x23: /* MOV <reg>,DR? */
   40.84 +        opcode = insn_fetch(u8, 1, eip);
   40.85 +        modrm_reg |= (opcode >> 3) & 7;
   40.86 +        modrm_rm  |= (opcode >> 0) & 7;
   40.87 +        reg = decode_register(modrm_rm, regs, 0);
   40.88 +        if ( do_set_debugreg(modrm_reg, *reg) != 0 )
   40.89 +            goto fail;
   40.90 +        break;
   40.91 +
   40.92          default:
   40.93              goto fail;
   40.94          }
    41.1 --- a/xen/common/dom0_ops.c	Fri Jul 08 12:22:18 2005 +0000
    41.2 +++ b/xen/common/dom0_ops.c	Fri Jul 08 12:24:58 2005 +0000
    41.3 @@ -88,6 +88,60 @@ static int allocate_domid(domid_t *pdom)
    41.4      return err;
    41.5  }
    41.6  
    41.7 +static void getdomaininfo(struct domain *d, dom0_getdomaininfo_t *info)
    41.8 +{
    41.9 +    struct vcpu   *v;
   41.10 +    u64 cpu_time = 0;
   41.11 +    int vcpu_count = 0;
   41.12 +    int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
   41.13 +    
   41.14 +    info->domain = d->domain_id;
   41.15 +    
   41.16 +    memset(&info->vcpu_to_cpu, -1, sizeof(info->vcpu_to_cpu));
   41.17 +    memset(&info->cpumap, 0, sizeof(info->cpumap));
   41.18 +    
   41.19 +    /* 
   41.20 +     * - domain is marked as paused or blocked only if all its vcpus 
   41.21 +     *   are paused or blocked 
   41.22 +     * - domain is marked as running if any of its vcpus is running
   41.23 +     * - only map vcpus that aren't down.  Note, at some point we may
   41.24 +     *   wish to demux the -1 value to indicate down vs. not-ever-booted
   41.25 +     *   
   41.26 +     */
   41.27 +    for_each_vcpu ( d, v ) {
   41.28 +        /* only map vcpus that are up */
   41.29 +        if ( !(test_bit(_VCPUF_down, &v->vcpu_flags)) )
   41.30 +            info->vcpu_to_cpu[v->vcpu_id] = v->processor;
   41.31 +        info->cpumap[v->vcpu_id] = v->cpumap;
   41.32 +        if ( !(v->vcpu_flags & VCPUF_ctrl_pause) )
   41.33 +            flags &= ~DOMFLAGS_PAUSED;
   41.34 +        if ( !(v->vcpu_flags & VCPUF_blocked) )
   41.35 +            flags &= ~DOMFLAGS_BLOCKED;
   41.36 +        if ( v->vcpu_flags & VCPUF_running )
   41.37 +            flags |= DOMFLAGS_RUNNING;
   41.38 +        if ( v->cpu_time > cpu_time )
   41.39 +            cpu_time += v->cpu_time;
   41.40 +        vcpu_count++;
   41.41 +    }
   41.42 +    
   41.43 +    info->cpu_time = cpu_time;
   41.44 +    info->n_vcpu = vcpu_count;
   41.45 +    
   41.46 +    info->flags = flags |
   41.47 +        ((d->domain_flags & DOMF_dying)    ? DOMFLAGS_DYING    : 0) |
   41.48 +        ((d->domain_flags & DOMF_shutdown) ? DOMFLAGS_SHUTDOWN : 0) |
   41.49 +        d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
   41.50 +
   41.51 +    if (d->ssid != NULL)
   41.52 +        info->ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
   41.53 +    else    
   41.54 +        info->ssidref = ACM_DEFAULT_SSID;
   41.55 +    
   41.56 +    info->tot_pages         = d->tot_pages;
   41.57 +    info->max_pages         = d->max_pages;
   41.58 +    info->shared_info_frame = __pa(d->shared_info) >> PAGE_SHIFT;
   41.59 +}
   41.60 +
   41.61  long do_dom0_op(dom0_op_t *u_dom0_op)
   41.62  {
   41.63      long ret = 0;
   41.64 @@ -306,10 +360,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   41.65      case DOM0_GETDOMAININFO:
   41.66      { 
   41.67          struct domain *d;
   41.68 -        struct vcpu   *v;
   41.69 -        u64 cpu_time = 0;
   41.70 -        int vcpu_count = 0;
   41.71 -        int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
   41.72  
   41.73          read_lock(&domlist_lock);
   41.74  
   41.75 @@ -328,54 +378,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   41.76  
   41.77          read_unlock(&domlist_lock);
   41.78  
   41.79 -        op->u.getdomaininfo.domain = d->domain_id;
   41.80 -
   41.81 -        memset(&op->u.getdomaininfo.vcpu_to_cpu, -1,
   41.82 -               sizeof(op->u.getdomaininfo.vcpu_to_cpu));
   41.83 -        memset(&op->u.getdomaininfo.cpumap, 0,
   41.84 -               sizeof(op->u.getdomaininfo.cpumap));
   41.85 -
   41.86 -        /* 
   41.87 -         * - domain is marked as paused or blocked only if all its vcpus 
   41.88 -         *   are paused or blocked 
   41.89 -         * - domain is marked as running if any of its vcpus is running
   41.90 -         * - only map vcpus that aren't down.  Note, at some point we may
   41.91 -         *   wish to demux the -1 value to indicate down vs. not-ever-booted
   41.92 -         *   
   41.93 -         */
   41.94 -        for_each_vcpu ( d, v ) {
   41.95 -            /* only map vcpus that are up */
   41.96 -            if ( !(test_bit(_VCPUF_down, &v->vcpu_flags)) )
   41.97 -                op->u.getdomaininfo.vcpu_to_cpu[v->vcpu_id] = v->processor;
   41.98 -            op->u.getdomaininfo.cpumap[v->vcpu_id]      = v->cpumap;
   41.99 -            if ( !(v->vcpu_flags & VCPUF_ctrl_pause) )
  41.100 -                flags &= ~DOMFLAGS_PAUSED;
  41.101 -            if ( !(v->vcpu_flags & VCPUF_blocked) )
  41.102 -                flags &= ~DOMFLAGS_BLOCKED;
  41.103 -            if ( v->vcpu_flags & VCPUF_running )
  41.104 -                flags |= DOMFLAGS_RUNNING;
  41.105 -            if ( v->cpu_time > cpu_time )
  41.106 -                cpu_time += v->cpu_time;
  41.107 -            vcpu_count++;
  41.108 -        }
  41.109 -
  41.110 -        op->u.getdomaininfo.cpu_time = cpu_time;
  41.111 -        op->u.getdomaininfo.n_vcpu = vcpu_count;
  41.112 -
  41.113 -        op->u.getdomaininfo.flags = flags |
  41.114 -            ((d->domain_flags & DOMF_dying)    ? DOMFLAGS_DYING    : 0) |
  41.115 -            ((d->domain_flags & DOMF_shutdown) ? DOMFLAGS_SHUTDOWN : 0) |
  41.116 -            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
  41.117 -
  41.118 -        if (d->ssid != NULL)
  41.119 -            op->u.getdomaininfo.ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
  41.120 -        else    
  41.121 -            op->u.getdomaininfo.ssidref = ACM_DEFAULT_SSID;
  41.122 -
  41.123 -        op->u.getdomaininfo.tot_pages   = d->tot_pages;
  41.124 -        op->u.getdomaininfo.max_pages   = d->max_pages;
  41.125 -        op->u.getdomaininfo.shared_info_frame = 
  41.126 -            __pa(d->shared_info) >> PAGE_SHIFT;
  41.127 +        getdomaininfo(d, &op->u.getdomaininfo);
  41.128  
  41.129          if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
  41.130              ret = -EINVAL;
  41.131 @@ -384,6 +387,53 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
  41.132      }
  41.133      break;
  41.134  
  41.135 +    case DOM0_GETDOMAININFOLIST:
  41.136 +    { 
  41.137 +        struct domain *d;
  41.138 +        dom0_getdomaininfo_t info;
  41.139 +        dom0_getdomaininfo_t *buffer = op->u.getdomaininfolist.buffer;
  41.140 +        u32 num_domains = 0;
  41.141 +
  41.142 +        read_lock(&domlist_lock);
  41.143 +
  41.144 +        for_each_domain ( d )
  41.145 +        {
  41.146 +            if ( d->domain_id < op->u.getdomaininfolist.first_domain )
  41.147 +                continue;
  41.148 +            if ( num_domains == op->u.getdomaininfolist.max_domains )
  41.149 +                break;
  41.150 +            if ( (d == NULL) || !get_domain(d) )
  41.151 +            {
  41.152 +                ret = -ESRCH;
  41.153 +                break;
  41.154 +            }
  41.155 +
  41.156 +            getdomaininfo(d, &info);
  41.157 +
  41.158 +            put_domain(d);
  41.159 +
  41.160 +            if ( copy_to_user(buffer, &info, sizeof(dom0_getdomaininfo_t)) )
  41.161 +            {
  41.162 +                ret = -EINVAL;
  41.163 +                break;
  41.164 +            }
  41.165 +            
  41.166 +            buffer++;
  41.167 +            num_domains++;
  41.168 +        }
  41.169 +        
  41.170 +        read_unlock(&domlist_lock);
  41.171 +        
  41.172 +        if ( ret != 0 )
  41.173 +            break;
  41.174 +        
  41.175 +        op->u.getdomaininfolist.num_domains = num_domains;
  41.176 +
  41.177 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
  41.178 +            ret = -EINVAL;
  41.179 +    }
  41.180 +    break;
  41.181 +
  41.182      case DOM0_GETVCPUCONTEXT:
  41.183      { 
  41.184          struct vcpu_guest_context *c;
    44.1 --- a/xen/include/acm/acm_core.h	Fri Jul 08 12:22:18 2005 +0000
    44.2 +++ b/xen/include/acm/acm_core.h	Fri Jul 08 12:24:58 2005 +0000
    44.3 @@ -20,6 +20,7 @@
    44.4  
    44.5  #include <xen/spinlock.h>
    44.6  #include <public/acm.h>
    44.7 +#include <xen/acm_policy.h>
    44.8  #include <public/policy_ops.h>
    44.9  
   44.10  /* Xen-internal representation of the binary policy */
    45.1 --- a/xen/include/public/dom0_ops.h	Fri Jul 08 12:22:18 2005 +0000
    45.2 +++ b/xen/include/public/dom0_ops.h	Fri Jul 08 12:24:58 2005 +0000
    45.3 @@ -19,7 +19,7 @@
    45.4   * This makes sure that old versions of dom0 tools will stop working in a
    45.5   * well-defined way (rather than crashing the machine, for instance).
    45.6   */
    45.7 -#define DOM0_INTERFACE_VERSION   0xAAAA100C
    45.8 +#define DOM0_INTERFACE_VERSION   0xAAAA100D
    45.9  
   45.10  /************************************************************************/
   45.11  
   45.12 @@ -357,6 +357,16 @@ typedef struct {
   45.13      u64     cpu_time;                 
   45.14  } dom0_getvcpucontext_t;
   45.15  
   45.16 +#define DOM0_GETDOMAININFOLIST    38
   45.17 +typedef struct {
   45.18 +    /* IN variables. */
   45.19 +    domid_t               first_domain;
   45.20 +    memory_t              max_domains;
   45.21 +    dom0_getdomaininfo_t *buffer;
   45.22 +    /* OUT variables. */
   45.23 +    memory_t              num_domains;
   45.24 +} dom0_getdomaininfolist_t;
   45.25 +
   45.26  typedef struct {
   45.27      u32 cmd;
   45.28      u32 interface_version; /* DOM0_INTERFACE_VERSION */
   45.29 @@ -389,6 +399,7 @@ typedef struct {
   45.30          dom0_microcode_t         microcode;
   45.31          dom0_ioport_permission_t ioport_permission;
   45.32          dom0_getvcpucontext_t    getvcpucontext;
   45.33 +        dom0_getdomaininfolist_t getdomaininfolist;
   45.34      } u;
   45.35  } dom0_op_t;
   45.36