ia64/xen-unstable

changeset 2254:1ec35141a882

bitkeeper revision 1.1159.32.3 (4120e70bXTpJy0O5vPdcj0GxE44yNw)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Mon Aug 16 16:55:39 2004 +0000 (2004-08-16)
parents 2a65e83681e6 6abde822c82f
children bb91ba552d34 b4498a444e43
files linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6.7-xen-sparse/include/asm-xen/hypervisor.h tools/libxc/xc_linux_restore.c tools/libxc/xc_linux_save.c tools/libxc/xc_private.h xen/common/dom_mem_ops.c
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c	Mon Aug 16 14:21:43 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c	Mon Aug 16 16:55:39 2004 +0000
     1.3 @@ -17,6 +17,7 @@
     1.4  #include <linux/etherdevice.h>
     1.5  #include <linux/skbuff.h>
     1.6  #include <linux/init.h>
     1.7 +#include <linux/bitops.h>
     1.8  #include <net/sock.h>
     1.9  #include <net/pkt_sched.h>
    1.10  #include <asm/io.h>
    1.11 @@ -427,9 +428,7 @@ static int netif_poll(struct net_device 
    1.12           */
    1.13          if ( unlikely(rx->status <= 0) )
    1.14          {
    1.15 -            /* Gate this error. We get a (valid) slew of them on suspend. */
    1.16 -            if ( np->user_state == UST_OPEN )
    1.17 -                printk(KERN_ALERT "bad buffer on RX ring!(%d)\n", rx->status);
    1.18 +	    printk(KERN_ALERT "bad buffer on RX ring!(%d)\n", rx->status);
    1.19              np->rx->ring[MASK_NETIF_RX_IDX(np->rx->req_prod)].req.id = rx->id;
    1.20              wmb();
    1.21              np->rx->req_prod++;
    1.22 @@ -470,6 +469,15 @@ static int netif_poll(struct net_device 
    1.23          mcl->args[2] = 0;
    1.24          mcl++;
    1.25          (void)HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
    1.26 +
    1.27 +#if 0 
    1.28 +	if (unlikely(rx_mcl[0].args[5] != 0))
    1.29 +	    printk(KERN_ALERT"Hypercall0 failed %u\n",np->rx->resp_prod);
    1.30 +
    1.31 +	if (unlikely(rx_mcl[1].args[5] != 0))
    1.32 +	    printk(KERN_ALERT"Hypercall1 failed %u\n",np->rx->resp_prod);
    1.33 +#endif
    1.34 +
    1.35      }
    1.36  
    1.37      while ( (skb = __skb_dequeue(&rxq)) != NULL )
    1.38 @@ -595,6 +603,7 @@ static void network_connect(struct net_d
    1.39  printk(KERN_ALERT"Netfront recovered tx=%d rxfree=%d\n",
    1.40         np->tx->req_prod,np->rx->req_prod);
    1.41  
    1.42 +
    1.43      /* Step 3: All public and private state should now be sane.  Get
    1.44       * ready to start sending and receiving packets and give the driver
    1.45       * domain a kick because we've probably just requeued some
    1.46 @@ -916,6 +925,8 @@ void netif_resume(void)
    1.47      struct net_private *np = NULL;
    1.48      int i;
    1.49  
    1.50 +
    1.51 +
    1.52  #if 1
    1.53      /* XXX THIS IS TEMPORARY */
    1.54  
    1.55 @@ -932,6 +943,9 @@ void netif_resume(void)
    1.56  
    1.57  	    // stop bad things from happening until we're back up
    1.58  	    np->backend_state = BEST_DISCONNECTED;
    1.59 +	    
    1.60 +	    memset(np->tx,0,PAGE_SIZE);
    1.61 +	    memset(np->rx,0,PAGE_SIZE);
    1.62  
    1.63  	    cmsg.type      = CMSG_NETIF_FE;
    1.64  	    cmsg.subtype   = CMSG_NETIF_FE_INTERFACE_CONNECT;
     2.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/hypervisor.h	Mon Aug 16 14:21:43 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/hypervisor.h	Mon Aug 16 16:55:39 2004 +0000
     2.3 @@ -374,7 +374,8 @@ static inline int HYPERVISOR_dom_mem_op(
     2.4      __asm__ __volatile__ (
     2.5          TRAP_INSTR
     2.6          : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
     2.7 -        "b" (op), "c" (extent_list), "d" (nr_extents), "S" (extent_order)
     2.8 +        "b" (op), "c" (extent_list), "d" (nr_extents), "S" (extent_order),
     2.9 +	"D" (DOMID_SELF)
    2.10          : "memory" );
    2.11  
    2.12      return ret;
     3.1 --- a/tools/libxc/xc_linux_restore.c	Mon Aug 16 14:21:43 2004 +0000
     3.2 +++ b/tools/libxc/xc_linux_restore.c	Mon Aug 16 16:55:39 2004 +0000
     3.3 @@ -504,6 +504,54 @@ printf("XXXXXXXXXXXXXXX pin L2\n");
     3.4  
     3.5      xcio_info(ioctxt, "\b\b\b\b100%%\nMemory reloaded.\n");
     3.6  
     3.7 +    /* Get the list of PFNs that are not in the psuedo-phys map */
     3.8 +    {
     3.9 +	unsigned int count, *pfntab;
    3.10 +	int rc;
    3.11 +	if ( xcio_read(ioctxt, &count, sizeof(count)) )
    3.12 +	{
    3.13 +	    xcio_error(ioctxt, "Error when reading from state file");
    3.14 +	    goto out;
    3.15 +	}
    3.16 +
    3.17 +	pfntab = malloc( sizeof(unsigned int) * count );
    3.18 +	if ( !pfntab )
    3.19 +	{
    3.20 +	    xcio_error(ioctxt, "Out of memory");
    3.21 +	    goto out;
    3.22 +	}
    3.23 +
    3.24 +	if ( xcio_read(ioctxt, pfntab, sizeof(unsigned int)*count) )
    3.25 +	{
    3.26 +	    xcio_error(ioctxt, "Error when reading pfntab from state file");
    3.27 +	    goto out;
    3.28 +	}
    3.29 +
    3.30 +	for(i=0;i<count;i++)
    3.31 +	{
    3.32 +	    unsigned long pfn = pfntab[i];
    3.33 +	    pfntab[i]=pfn_to_mfn_table[pfn];
    3.34 +	    pfn_to_mfn_table[pfn] = 0x80000001;  // not in pmap
    3.35 +	}
    3.36 +
    3.37 +	if ( count>0 )
    3.38 +	{
    3.39 +	    if ( (rc = do_dom_mem_op( xc_handle,
    3.40 +				       MEMOP_decrease_reservation,
    3.41 +				       pfntab, count, 0, dom )) <0 )
    3.42 +	    {
    3.43 +		xcio_error(ioctxt, "Could not decrease reservation : %d",rc);
    3.44 +		goto out;
    3.45 +	    }
    3.46 +	    else
    3.47 +	    {
    3.48 +		printf("Decreased reservation by %d pages\n", count);
    3.49 +	    }
    3.50 +	}
    3.51 +	
    3.52 +    }
    3.53 +
    3.54 +
    3.55  
    3.56      if ( xcio_read(ioctxt, &ctxt,       sizeof(ctxt)) ||
    3.57           xcio_read(ioctxt, shared_info, PAGE_SIZE) )
     4.1 --- a/tools/libxc/xc_linux_save.c	Mon Aug 16 14:21:43 2004 +0000
     4.2 +++ b/tools/libxc/xc_linux_save.c	Mon Aug 16 16:55:39 2004 +0000
     4.3 @@ -463,10 +463,6 @@ int xc_linux_save(int xc_handle, XcIOCon
     4.4  	    goto out;
     4.5  	}
     4.6  
     4.7 -	printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
     4.8 -	       op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
     4.9 -	       ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
    4.10 -
    4.11      }
    4.12  
    4.13      /* calculate the power of 2 order of nr_pfns, e.g.
    4.14 @@ -866,9 +862,41 @@ printf("type fail: page %i mfn %08lx\n",
    4.15          goto out;
    4.16      }
    4.17  
    4.18 -printf("SUSPPPPPPPP flags %08lx shinfo %08lx eip %08lx esi %08lx\n", 
    4.19 -       op.u.getdomaininfo.flags, op.u.getdomaininfo.shared_info_frame,
    4.20 -       ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
    4.21 +    /* Send through a list of all the PFNs that were not in map at the close */
    4.22 +    {
    4.23 +	unsigned int i,j;
    4.24 +	unsigned int pfntab[1024];
    4.25 +
    4.26 +	for ( i = 0, j = 0; i < nr_pfns; i++ )
    4.27 +	{
    4.28 +	    if ( live_pfn_to_mfn_table[i] >= 0x80000000UL )
    4.29 +		j++;
    4.30 +	}
    4.31 +
    4.32 +	if ( xcio_write(ioctxt, &j, sizeof(unsigned int)) )
    4.33 +	{
    4.34 +	    xcio_error(ioctxt, "Error when writing to state file (6a)");
    4.35 +	    goto out;
    4.36 +	}	
    4.37 +
    4.38 +	for ( i = 0, j = 0; i < nr_pfns; )
    4.39 +	{
    4.40 +	    if ( live_pfn_to_mfn_table[i] >= 0x80000000UL )
    4.41 +	    {
    4.42 +		pfntab[j++] = i;
    4.43 +	    }
    4.44 +	    i++;
    4.45 +	    if ( j == 1024 || i == nr_pfns )
    4.46 +	    {
    4.47 +		if ( xcio_write(ioctxt, &pfntab, sizeof(unsigned long)*j) )
    4.48 +		{
    4.49 +		    xcio_error(ioctxt, "Error when writing to state file (6b)");
    4.50 +		    goto out;
    4.51 +		}	
    4.52 +		j = 0;
    4.53 +	    }
    4.54 +	}
    4.55 +    }
    4.56  
    4.57      /* Map the suspend-record MFN to pin it. The page must be owned by 
    4.58         domid for this to succeed. */
     5.1 --- a/tools/libxc/xc_private.h	Mon Aug 16 14:21:43 2004 +0000
     5.2 +++ b/tools/libxc/xc_private.h	Mon Aug 16 16:55:39 2004 +0000
     5.3 @@ -127,6 +127,42 @@ static inline int do_multicall_op(int xc
     5.4   out1: return ret;
     5.5  }
     5.6  
     5.7 +
     5.8 +static inline int do_dom_mem_op(int            xc_handle,
     5.9 +				unsigned int   memop, 
    5.10 +				unsigned int *extent_list, 
    5.11 +				unsigned int  nr_extents,
    5.12 +				unsigned int   extent_order,
    5.13 +				domid_t        domid)
    5.14 +{
    5.15 +    privcmd_hypercall_t hypercall;
    5.16 +    long ret = -EINVAL;
    5.17 +	
    5.18 +    hypercall.op     = __HYPERVISOR_dom_mem_op;
    5.19 +    hypercall.arg[0] = (unsigned long)memop;
    5.20 +    hypercall.arg[1] = (unsigned long)extent_list;
    5.21 +    hypercall.arg[2] = (unsigned long)nr_extents;
    5.22 +    hypercall.arg[3] = (unsigned long)extent_order;
    5.23 +    hypercall.arg[4] = (unsigned long)domid;
    5.24 +
    5.25 +    if ( mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0 )
    5.26 +    {
    5.27 +        PERROR("Could not lock memory for Xen hypercall");
    5.28 +        goto out1;
    5.29 +    }
    5.30 +
    5.31 +    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
    5.32 +    {
    5.33 +	fprintf(stderr, "Dom_mem operation failed (rc=%ld errno=%d)-- need to"
    5.34 +                    " rebuild the user-space tool set?\n",ret,errno);
    5.35 +        goto out2;
    5.36 +    }
    5.37 +
    5.38 + out2: (void)munlock(extent_list, nr_extents*sizeof(unsigned long));
    5.39 + out1: return ret;
    5.40 +}    
    5.41 +
    5.42 +
    5.43  /*
    5.44   * PFN mapping.
    5.45   */
     6.1 --- a/xen/common/dom_mem_ops.c	Mon Aug 16 14:21:43 2004 +0000
     6.2 +++ b/xen/common/dom_mem_ops.c	Mon Aug 16 16:55:39 2004 +0000
     6.3 @@ -92,13 +92,32 @@ static long free_dom_mem(struct domain *
     6.4  long do_dom_mem_op(unsigned int   op, 
     6.5                     unsigned long *extent_list, 
     6.6                     unsigned long  nr_extents,
     6.7 -                   unsigned int   extent_order)
     6.8 +                   unsigned int   extent_order,
     6.9 +		   domid_t        domid)
    6.10  {
    6.11 -    if ( op == MEMOP_increase_reservation )
    6.12 -        return alloc_dom_mem(current, extent_list, nr_extents, extent_order);
    6.13 +    struct domain *d;
    6.14 +    long rc = -ENOSYS;
    6.15 +
    6.16 +    if (domid == DOMID_SELF)
    6.17 +	d = current;
    6.18 +    else
    6.19 +	d = find_domain_by_id(domid);
    6.20 +
    6.21 +    if (d==NULL)
    6.22 +	return -ESRCH;
    6.23  
    6.24 -    if ( op == MEMOP_decrease_reservation )
    6.25 -        return free_dom_mem(current, extent_list, nr_extents, extent_order);
    6.26 +    switch( op )
    6.27 +    {
    6.28 +    case MEMOP_increase_reservation:
    6.29 +        rc = alloc_dom_mem(d, extent_list, nr_extents, extent_order);
    6.30 +	break;
    6.31 +    case MEMOP_decrease_reservation:
    6.32 +        rc = free_dom_mem(d, extent_list, nr_extents, extent_order);
    6.33 +	break;
    6.34 +    }
    6.35  
    6.36 -    return -ENOSYS;
    6.37 +    if (domid!=DOMID_SELF)
    6.38 +	put_domain(d);
    6.39 +
    6.40 +    return rc;
    6.41  }