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
     1.1 --- a/Makefile	Fri Jul 08 12:22:18 2005 +0000
     1.2 +++ b/Makefile	Fri Jul 08 12:24:58 2005 +0000
     1.3 @@ -177,10 +177,10 @@ uninstall:
     1.4  
     1.5  # Legacy targets for compatibility
     1.6  linux24:
     1.7 -	$(MAKE) 'KERNELS=linux-2.4*' dist
     1.8 +	$(MAKE) 'KERNELS=linux-2.4*' kernels
     1.9  
    1.10  linux26:
    1.11 -	$(MAKE) 'KERNELS=linux-2.6*' dist
    1.12 +	$(MAKE) 'KERNELS=linux-2.6*' kernels
    1.13  
    1.14  netbsd20:
    1.15  	$(MAKE) netbsd-2.0-xenU-build
     2.1 --- a/tools/libxc/xc.h	Fri Jul 08 12:22:18 2005 +0000
     2.2 +++ b/tools/libxc/xc.h	Fri Jul 08 12:24:58 2005 +0000
     2.3 @@ -192,6 +192,24 @@ int xc_domain_getinfo(int xc_handle,
     2.4                        xc_dominfo_t *info);
     2.5  
     2.6  /**
     2.7 + * This function will return information about one or more domains, using a
     2.8 + * single hypercall.  The domain information will be stored into the supplied
     2.9 + * array of xc_domaininfo_t structures.
    2.10 + *
    2.11 + * @parm xc_handle a handle to an open hypervisor interface
    2.12 + * @parm first_domain the first domain to enumerate information from.
    2.13 + *                    Domains are currently enumerate in order of creation.
    2.14 + * @parm max_domains the number of elements in info
    2.15 + * @parm info an array of max_doms size that will contain the information for
    2.16 + *            the enumerated domains.
    2.17 + * @return the number of domains enumerated or -1 on error
    2.18 + */
    2.19 +int xc_domain_getinfolist(int xc_handle,
    2.20 +                          u32 first_domain,
    2.21 +                          unsigned int max_domains,
    2.22 +                          xc_domaininfo_t *info);
    2.23 +
    2.24 +/**
    2.25   * This function returns information about one domain.  This information is
    2.26   * more detailed than the information from xc_domain_getinfo().
    2.27   *
     3.1 --- a/tools/libxc/xc_domain.c	Fri Jul 08 12:22:18 2005 +0000
     3.2 +++ b/tools/libxc/xc_domain.c	Fri Jul 08 12:24:58 2005 +0000
     3.3 @@ -125,6 +125,33 @@ int xc_domain_getinfo(int xc_handle,
     3.4      return nr_doms;
     3.5  }
     3.6  
     3.7 +int xc_domain_getinfolist(int xc_handle,
     3.8 +                          u32 first_domain,
     3.9 +                          unsigned int max_domains,
    3.10 +                          xc_domaininfo_t *info)
    3.11 +{
    3.12 +    int ret = 0;
    3.13 +    dom0_op_t op;
    3.14 +
    3.15 +    if(mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
    3.16 +        return -1;
    3.17 +    
    3.18 +    op.cmd = DOM0_GETDOMAININFOLIST;
    3.19 +    op.u.getdomaininfolist.first_domain = first_domain;
    3.20 +    op.u.getdomaininfolist.max_domains  = max_domains;
    3.21 +    op.u.getdomaininfolist.buffer       = info;
    3.22 +
    3.23 +    if(xc_dom0_op(xc_handle, &op) < 0)
    3.24 +        ret = -1;
    3.25 +    else
    3.26 +        ret = op.u.getdomaininfolist.num_domains;
    3.27 +    
    3.28 +    if(munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
    3.29 +        ret = -1;
    3.30 +    
    3.31 +    return ret;
    3.32 +}
    3.33 +
    3.34  int xc_domain_get_vcpu_context(int xc_handle,
    3.35                                 u32 domid,
    3.36                                 u32 vcpu,
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 08 12:22:18 2005 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jul 08 12:24:58 2005 +0000
     4.3 @@ -688,7 +688,7 @@ static PyObject *pyxc_physinfo(PyObject 
     4.4      if ( xc_physinfo(xc->xc_handle, &info) != 0 )
     4.5          return PyErr_SetFromErrno(xc_error);
     4.6  
     4.7 -    return Py_BuildValue("{s:i,s:i,s:l,s:l,s:l}",
     4.8 +    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i}",
     4.9                           "threads_per_core", info.threads_per_core,
    4.10                           "cores_per_socket", info.cores_per_socket,
    4.11                           "sockets_per_node", info.sockets_per_node,
     5.1 --- a/xen/arch/x86/traps.c	Fri Jul 08 12:22:18 2005 +0000
     5.2 +++ b/xen/arch/x86/traps.c	Fri Jul 08 12:24:58 2005 +0000
     5.3 @@ -94,6 +94,9 @@ DECLARE_TRAP_HANDLER(alignment_check);
     5.4  DECLARE_TRAP_HANDLER(spurious_interrupt_bug);
     5.5  DECLARE_TRAP_HANDLER(machine_check);
     5.6  
     5.7 +long do_set_debugreg(int reg, unsigned long value);
     5.8 +unsigned long do_get_debugreg(int reg);
     5.9 +
    5.10  static int debug_stack_lines = 20;
    5.11  integer_param("debug_stack_lines", debug_stack_lines);
    5.12  
    5.13 @@ -568,8 +571,8 @@ static inline int admin_io_okay(
    5.14  static int emulate_privileged_op(struct cpu_user_regs *regs)
    5.15  {
    5.16      struct vcpu *v = current;
    5.17 -    unsigned long *reg, eip = regs->eip;
    5.18 -    u8 opcode, modrm_reg = 0, rep_prefix = 0;
    5.19 +    unsigned long *reg, eip = regs->eip, res;
    5.20 +    u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0;
    5.21      unsigned int port, i, op_bytes = 4, data;
    5.22  
    5.23      /* Legacy prefixes. */
    5.24 @@ -604,7 +607,9 @@ static int emulate_privileged_op(struct 
    5.25      if ( (opcode & 0xf0) == 0x40 )
    5.26      {
    5.27          modrm_reg = (opcode & 4) << 1;  /* REX.R */
    5.28 -        /* REX.W, REX.B and REX.X do not need to be decoded. */
    5.29 +        modrm_rm  = (opcode & 1) << 3;  /* REX.B */
    5.30 +
    5.31 +        /* REX.W and REX.X do not need to be decoded. */
    5.32          opcode = insn_fetch(u8, 1, eip);
    5.33      }
    5.34  #endif
    5.35 @@ -782,11 +787,10 @@ static int emulate_privileged_op(struct 
    5.36  
    5.37      case 0x20: /* MOV CR?,<reg> */
    5.38          opcode = insn_fetch(u8, 1, eip);
    5.39 -        if ( (opcode & 0xc0) != 0xc0 )
    5.40 -            goto fail;
    5.41 -        modrm_reg |= opcode & 7;
    5.42 -        reg = decode_register(modrm_reg, regs, 0);
    5.43 -        switch ( (opcode >> 3) & 7 )
    5.44 +        modrm_reg |= (opcode >> 3) & 7;
    5.45 +        modrm_rm  |= (opcode >> 0) & 7;
    5.46 +        reg = decode_register(modrm_rm, regs, 0);
    5.47 +        switch ( modrm_reg )
    5.48          {
    5.49          case 0: /* Read CR0 */
    5.50              *reg = v->arch.guest_context.ctrlreg[0];
    5.51 @@ -805,13 +809,22 @@ static int emulate_privileged_op(struct 
    5.52          }
    5.53          break;
    5.54  
    5.55 +    case 0x21: /* MOV DR?,<reg> */
    5.56 +        opcode = insn_fetch(u8, 1, eip);
    5.57 +        modrm_reg |= (opcode >> 3) & 7;
    5.58 +        modrm_rm  |= (opcode >> 0) & 7;
    5.59 +        reg = decode_register(modrm_rm, regs, 0);
    5.60 +        if ( (res = do_get_debugreg(modrm_reg)) > (unsigned long)-256 )
    5.61 +            goto fail;
    5.62 +        *reg = res;
    5.63 +        break;
    5.64 +
    5.65      case 0x22: /* MOV <reg>,CR? */
    5.66          opcode = insn_fetch(u8, 1, eip);
    5.67 -        if ( (opcode & 0xc0) != 0xc0 )
    5.68 -            goto fail;
    5.69 -        modrm_reg |= opcode & 7;
    5.70 -        reg = decode_register(modrm_reg, regs, 0);
    5.71 -        switch ( (opcode >> 3) & 7 )
    5.72 +        modrm_reg |= (opcode >> 3) & 7;
    5.73 +        modrm_rm  |= (opcode >> 0) & 7;
    5.74 +        reg = decode_register(modrm_rm, regs, 0);
    5.75 +        switch ( modrm_reg )
    5.76          {
    5.77          case 0: /* Write CR0 */
    5.78              (void)do_fpu_taskswitch(!!(*reg & X86_CR0_TS));
    5.79 @@ -827,6 +840,15 @@ static int emulate_privileged_op(struct 
    5.80              UNLOCK_BIGLOCK(v->domain);
    5.81              break;
    5.82  
    5.83 +    case 0x23: /* MOV <reg>,DR? */
    5.84 +        opcode = insn_fetch(u8, 1, eip);
    5.85 +        modrm_reg |= (opcode >> 3) & 7;
    5.86 +        modrm_rm  |= (opcode >> 0) & 7;
    5.87 +        reg = decode_register(modrm_rm, regs, 0);
    5.88 +        if ( do_set_debugreg(modrm_reg, *reg) != 0 )
    5.89 +            goto fail;
    5.90 +        break;
    5.91 +
    5.92          default:
    5.93              goto fail;
    5.94          }
     6.1 --- a/xen/common/dom0_ops.c	Fri Jul 08 12:22:18 2005 +0000
     6.2 +++ b/xen/common/dom0_ops.c	Fri Jul 08 12:24:58 2005 +0000
     6.3 @@ -88,6 +88,60 @@ static int allocate_domid(domid_t *pdom)
     6.4      return err;
     6.5  }
     6.6  
     6.7 +static void getdomaininfo(struct domain *d, dom0_getdomaininfo_t *info)
     6.8 +{
     6.9 +    struct vcpu   *v;
    6.10 +    u64 cpu_time = 0;
    6.11 +    int vcpu_count = 0;
    6.12 +    int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
    6.13 +    
    6.14 +    info->domain = d->domain_id;
    6.15 +    
    6.16 +    memset(&info->vcpu_to_cpu, -1, sizeof(info->vcpu_to_cpu));
    6.17 +    memset(&info->cpumap, 0, sizeof(info->cpumap));
    6.18 +    
    6.19 +    /* 
    6.20 +     * - domain is marked as paused or blocked only if all its vcpus 
    6.21 +     *   are paused or blocked 
    6.22 +     * - domain is marked as running if any of its vcpus is running
    6.23 +     * - only map vcpus that aren't down.  Note, at some point we may
    6.24 +     *   wish to demux the -1 value to indicate down vs. not-ever-booted
    6.25 +     *   
    6.26 +     */
    6.27 +    for_each_vcpu ( d, v ) {
    6.28 +        /* only map vcpus that are up */
    6.29 +        if ( !(test_bit(_VCPUF_down, &v->vcpu_flags)) )
    6.30 +            info->vcpu_to_cpu[v->vcpu_id] = v->processor;
    6.31 +        info->cpumap[v->vcpu_id] = v->cpumap;
    6.32 +        if ( !(v->vcpu_flags & VCPUF_ctrl_pause) )
    6.33 +            flags &= ~DOMFLAGS_PAUSED;
    6.34 +        if ( !(v->vcpu_flags & VCPUF_blocked) )
    6.35 +            flags &= ~DOMFLAGS_BLOCKED;
    6.36 +        if ( v->vcpu_flags & VCPUF_running )
    6.37 +            flags |= DOMFLAGS_RUNNING;
    6.38 +        if ( v->cpu_time > cpu_time )
    6.39 +            cpu_time += v->cpu_time;
    6.40 +        vcpu_count++;
    6.41 +    }
    6.42 +    
    6.43 +    info->cpu_time = cpu_time;
    6.44 +    info->n_vcpu = vcpu_count;
    6.45 +    
    6.46 +    info->flags = flags |
    6.47 +        ((d->domain_flags & DOMF_dying)    ? DOMFLAGS_DYING    : 0) |
    6.48 +        ((d->domain_flags & DOMF_shutdown) ? DOMFLAGS_SHUTDOWN : 0) |
    6.49 +        d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
    6.50 +
    6.51 +    if (d->ssid != NULL)
    6.52 +        info->ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
    6.53 +    else    
    6.54 +        info->ssidref = ACM_DEFAULT_SSID;
    6.55 +    
    6.56 +    info->tot_pages         = d->tot_pages;
    6.57 +    info->max_pages         = d->max_pages;
    6.58 +    info->shared_info_frame = __pa(d->shared_info) >> PAGE_SHIFT;
    6.59 +}
    6.60 +
    6.61  long do_dom0_op(dom0_op_t *u_dom0_op)
    6.62  {
    6.63      long ret = 0;
    6.64 @@ -306,10 +360,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    6.65      case DOM0_GETDOMAININFO:
    6.66      { 
    6.67          struct domain *d;
    6.68 -        struct vcpu   *v;
    6.69 -        u64 cpu_time = 0;
    6.70 -        int vcpu_count = 0;
    6.71 -        int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
    6.72  
    6.73          read_lock(&domlist_lock);
    6.74  
    6.75 @@ -328,54 +378,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    6.76  
    6.77          read_unlock(&domlist_lock);
    6.78  
    6.79 -        op->u.getdomaininfo.domain = d->domain_id;
    6.80 -
    6.81 -        memset(&op->u.getdomaininfo.vcpu_to_cpu, -1,
    6.82 -               sizeof(op->u.getdomaininfo.vcpu_to_cpu));
    6.83 -        memset(&op->u.getdomaininfo.cpumap, 0,
    6.84 -               sizeof(op->u.getdomaininfo.cpumap));
    6.85 -
    6.86 -        /* 
    6.87 -         * - domain is marked as paused or blocked only if all its vcpus 
    6.88 -         *   are paused or blocked 
    6.89 -         * - domain is marked as running if any of its vcpus is running
    6.90 -         * - only map vcpus that aren't down.  Note, at some point we may
    6.91 -         *   wish to demux the -1 value to indicate down vs. not-ever-booted
    6.92 -         *   
    6.93 -         */
    6.94 -        for_each_vcpu ( d, v ) {
    6.95 -            /* only map vcpus that are up */
    6.96 -            if ( !(test_bit(_VCPUF_down, &v->vcpu_flags)) )
    6.97 -                op->u.getdomaininfo.vcpu_to_cpu[v->vcpu_id] = v->processor;
    6.98 -            op->u.getdomaininfo.cpumap[v->vcpu_id]      = v->cpumap;
    6.99 -            if ( !(v->vcpu_flags & VCPUF_ctrl_pause) )
   6.100 -                flags &= ~DOMFLAGS_PAUSED;
   6.101 -            if ( !(v->vcpu_flags & VCPUF_blocked) )
   6.102 -                flags &= ~DOMFLAGS_BLOCKED;
   6.103 -            if ( v->vcpu_flags & VCPUF_running )
   6.104 -                flags |= DOMFLAGS_RUNNING;
   6.105 -            if ( v->cpu_time > cpu_time )
   6.106 -                cpu_time += v->cpu_time;
   6.107 -            vcpu_count++;
   6.108 -        }
   6.109 -
   6.110 -        op->u.getdomaininfo.cpu_time = cpu_time;
   6.111 -        op->u.getdomaininfo.n_vcpu = vcpu_count;
   6.112 -
   6.113 -        op->u.getdomaininfo.flags = flags |
   6.114 -            ((d->domain_flags & DOMF_dying)    ? DOMFLAGS_DYING    : 0) |
   6.115 -            ((d->domain_flags & DOMF_shutdown) ? DOMFLAGS_SHUTDOWN : 0) |
   6.116 -            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
   6.117 -
   6.118 -        if (d->ssid != NULL)
   6.119 -            op->u.getdomaininfo.ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
   6.120 -        else    
   6.121 -            op->u.getdomaininfo.ssidref = ACM_DEFAULT_SSID;
   6.122 -
   6.123 -        op->u.getdomaininfo.tot_pages   = d->tot_pages;
   6.124 -        op->u.getdomaininfo.max_pages   = d->max_pages;
   6.125 -        op->u.getdomaininfo.shared_info_frame = 
   6.126 -            __pa(d->shared_info) >> PAGE_SHIFT;
   6.127 +        getdomaininfo(d, &op->u.getdomaininfo);
   6.128  
   6.129          if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
   6.130              ret = -EINVAL;
   6.131 @@ -384,6 +387,53 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   6.132      }
   6.133      break;
   6.134  
   6.135 +    case DOM0_GETDOMAININFOLIST:
   6.136 +    { 
   6.137 +        struct domain *d;
   6.138 +        dom0_getdomaininfo_t info;
   6.139 +        dom0_getdomaininfo_t *buffer = op->u.getdomaininfolist.buffer;
   6.140 +        u32 num_domains = 0;
   6.141 +
   6.142 +        read_lock(&domlist_lock);
   6.143 +
   6.144 +        for_each_domain ( d )
   6.145 +        {
   6.146 +            if ( d->domain_id < op->u.getdomaininfolist.first_domain )
   6.147 +                continue;
   6.148 +            if ( num_domains == op->u.getdomaininfolist.max_domains )
   6.149 +                break;
   6.150 +            if ( (d == NULL) || !get_domain(d) )
   6.151 +            {
   6.152 +                ret = -ESRCH;
   6.153 +                break;
   6.154 +            }
   6.155 +
   6.156 +            getdomaininfo(d, &info);
   6.157 +
   6.158 +            put_domain(d);
   6.159 +
   6.160 +            if ( copy_to_user(buffer, &info, sizeof(dom0_getdomaininfo_t)) )
   6.161 +            {
   6.162 +                ret = -EINVAL;
   6.163 +                break;
   6.164 +            }
   6.165 +            
   6.166 +            buffer++;
   6.167 +            num_domains++;
   6.168 +        }
   6.169 +        
   6.170 +        read_unlock(&domlist_lock);
   6.171 +        
   6.172 +        if ( ret != 0 )
   6.173 +            break;
   6.174 +        
   6.175 +        op->u.getdomaininfolist.num_domains = num_domains;
   6.176 +
   6.177 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
   6.178 +            ret = -EINVAL;
   6.179 +    }
   6.180 +    break;
   6.181 +
   6.182      case DOM0_GETVCPUCONTEXT:
   6.183      { 
   6.184          struct vcpu_guest_context *c;
     7.1 --- a/xen/include/acm/acm_core.h	Fri Jul 08 12:22:18 2005 +0000
     7.2 +++ b/xen/include/acm/acm_core.h	Fri Jul 08 12:24:58 2005 +0000
     7.3 @@ -20,6 +20,7 @@
     7.4  
     7.5  #include <xen/spinlock.h>
     7.6  #include <public/acm.h>
     7.7 +#include <xen/acm_policy.h>
     7.8  #include <public/policy_ops.h>
     7.9  
    7.10  /* Xen-internal representation of the binary policy */
     8.1 --- a/xen/include/public/dom0_ops.h	Fri Jul 08 12:22:18 2005 +0000
     8.2 +++ b/xen/include/public/dom0_ops.h	Fri Jul 08 12:24:58 2005 +0000
     8.3 @@ -19,7 +19,7 @@
     8.4   * This makes sure that old versions of dom0 tools will stop working in a
     8.5   * well-defined way (rather than crashing the machine, for instance).
     8.6   */
     8.7 -#define DOM0_INTERFACE_VERSION   0xAAAA100C
     8.8 +#define DOM0_INTERFACE_VERSION   0xAAAA100D
     8.9  
    8.10  /************************************************************************/
    8.11  
    8.12 @@ -357,6 +357,16 @@ typedef struct {
    8.13      u64     cpu_time;                 
    8.14  } dom0_getvcpucontext_t;
    8.15  
    8.16 +#define DOM0_GETDOMAININFOLIST    38
    8.17 +typedef struct {
    8.18 +    /* IN variables. */
    8.19 +    domid_t               first_domain;
    8.20 +    memory_t              max_domains;
    8.21 +    dom0_getdomaininfo_t *buffer;
    8.22 +    /* OUT variables. */
    8.23 +    memory_t              num_domains;
    8.24 +} dom0_getdomaininfolist_t;
    8.25 +
    8.26  typedef struct {
    8.27      u32 cmd;
    8.28      u32 interface_version; /* DOM0_INTERFACE_VERSION */
    8.29 @@ -389,6 +399,7 @@ typedef struct {
    8.30          dom0_microcode_t         microcode;
    8.31          dom0_ioport_permission_t ioport_permission;
    8.32          dom0_getvcpucontext_t    getvcpucontext;
    8.33 +        dom0_getdomaininfolist_t getdomaininfolist;
    8.34      } u;
    8.35  } dom0_op_t;
    8.36