direct-io.hg

changeset 7234:bd37123974b2

Merged.
author emellor@ewan
date Thu Oct 06 11:12:55 2005 +0100 (2005-10-06)
parents 4ab4f023a6ce ba0bbf9d29ff
children cd228621e1fd
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Oct 06 11:11:16 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Oct 06 11:12:55 2005 +0100
     1.3 @@ -180,14 +180,13 @@ static int find_unbound_irq(void)
     1.4  
     1.5  int bind_virq_to_irq(int virq)
     1.6  {
     1.7 -	evtchn_op_t op;
     1.8 +	evtchn_op_t op = { .cmd = EVTCHNOP_bind_virq };
     1.9  	int evtchn, irq;
    1.10  	int cpu = smp_processor_id();
    1.11  
    1.12  	spin_lock(&irq_mapping_update_lock);
    1.13  
    1.14  	if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1) {
    1.15 -		op.cmd              = EVTCHNOP_bind_virq;
    1.16  		op.u.bind_virq.virq = virq;
    1.17  		op.u.bind_virq.vcpu = cpu;
    1.18  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.19 @@ -212,7 +211,7 @@ EXPORT_SYMBOL(bind_virq_to_irq);
    1.20  
    1.21  void unbind_virq_from_irq(int virq)
    1.22  {
    1.23 -	evtchn_op_t op;
    1.24 +	evtchn_op_t op = { .cmd = EVTCHNOP_close };
    1.25  	int cpu    = smp_processor_id();
    1.26  	int irq    = per_cpu(virq_to_irq, cpu)[virq];
    1.27  	int evtchn = irq_to_evtchn[irq];
    1.28 @@ -220,7 +219,6 @@ void unbind_virq_from_irq(int virq)
    1.29  	spin_lock(&irq_mapping_update_lock);
    1.30  
    1.31  	if (--irq_bindcount[irq] == 0) {
    1.32 -		op.cmd          = EVTCHNOP_close;
    1.33  		op.u.close.dom  = DOMID_SELF;
    1.34  		op.u.close.port = evtchn;
    1.35  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.36 @@ -245,14 +243,13 @@ EXPORT_SYMBOL(unbind_virq_from_irq);
    1.37  
    1.38  int bind_ipi_to_irq(int ipi)
    1.39  {
    1.40 -	evtchn_op_t op;
    1.41 +	evtchn_op_t op = { .cmd = EVTCHNOP_bind_ipi };
    1.42  	int evtchn, irq;
    1.43  	int cpu = smp_processor_id();
    1.44  
    1.45  	spin_lock(&irq_mapping_update_lock);
    1.46  
    1.47  	if ((evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi]) == -1) {
    1.48 -		op.cmd = EVTCHNOP_bind_ipi;
    1.49  		op.u.bind_ipi.vcpu = cpu;
    1.50  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.51  		evtchn = op.u.bind_ipi.port;
    1.52 @@ -278,7 +275,7 @@ EXPORT_SYMBOL(bind_ipi_to_irq);
    1.53  
    1.54  void unbind_ipi_from_irq(int ipi)
    1.55  {
    1.56 -	evtchn_op_t op;
    1.57 +	evtchn_op_t op = { .cmd = EVTCHNOP_close };
    1.58  	int cpu    = smp_processor_id();
    1.59  	int evtchn = per_cpu(ipi_to_evtchn, cpu)[ipi];
    1.60  	int irq    = evtchn_to_irq[evtchn];
    1.61 @@ -286,7 +283,6 @@ void unbind_ipi_from_irq(int ipi)
    1.62  	spin_lock(&irq_mapping_update_lock);
    1.63  
    1.64  	if (--irq_bindcount[irq] == 0) {
    1.65 -		op.cmd          = EVTCHNOP_close;
    1.66  		op.u.close.dom  = DOMID_SELF;
    1.67  		op.u.close.port = evtchn;
    1.68  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.69 @@ -324,13 +320,12 @@ EXPORT_SYMBOL(bind_evtchn_to_irq);
    1.70  
    1.71  void unbind_evtchn_from_irq(unsigned int irq)
    1.72  {
    1.73 -	evtchn_op_t op;
    1.74 +	evtchn_op_t op = { .cmd = EVTCHNOP_close };
    1.75  	int evtchn = irq_to_evtchn[irq];
    1.76  
    1.77  	spin_lock(&irq_mapping_update_lock);
    1.78  
    1.79  	if ((--irq_bindcount[irq] == 0) && (evtchn != -1)) {
    1.80 -		op.cmd          = EVTCHNOP_close;
    1.81  		op.u.close.dom  = DOMID_SELF;
    1.82  		op.u.close.port = evtchn;
    1.83  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
    1.84 @@ -378,7 +373,7 @@ static void do_nothing_function(void *ig
    1.85  /* Rebind an evtchn so that it gets delivered to a specific cpu */
    1.86  static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
    1.87  {
    1.88 -	evtchn_op_t op;
    1.89 +	evtchn_op_t op = { .cmd = EVTCHNOP_bind_vcpu };
    1.90  	int evtchn;
    1.91  
    1.92  	spin_lock(&irq_mapping_update_lock);
    1.93 @@ -389,7 +384,6 @@ static void rebind_irq_to_cpu(unsigned i
    1.94  	}
    1.95  
    1.96  	/* Send future instances of this interrupt to other vcpu. */
    1.97 -	op.cmd = EVTCHNOP_bind_vcpu;
    1.98  	op.u.bind_vcpu.port = evtchn;
    1.99  	op.u.bind_vcpu.vcpu = tcpu;
   1.100  
   1.101 @@ -518,10 +512,9 @@ static inline void pirq_query_unmask(int
   1.102  
   1.103  static unsigned int startup_pirq(unsigned int irq)
   1.104  {
   1.105 -	evtchn_op_t op;
   1.106 +	evtchn_op_t op = { .cmd = EVTCHNOP_bind_pirq };
   1.107  	int evtchn;
   1.108  
   1.109 -	op.cmd               = EVTCHNOP_bind_pirq;
   1.110  	op.u.bind_pirq.pirq  = irq;
   1.111  	/* NB. We are happy to share unless we are probing. */
   1.112  	op.u.bind_pirq.flags = probing_irq(irq) ? 0 : BIND_PIRQ__WILL_SHARE;
   1.113 @@ -547,7 +540,7 @@ static unsigned int startup_pirq(unsigne
   1.114  
   1.115  static void shutdown_pirq(unsigned int irq)
   1.116  {
   1.117 -	evtchn_op_t op;
   1.118 +	evtchn_op_t op = { .cmd = EVTCHNOP_close };
   1.119  	int evtchn = irq_to_evtchn[irq];
   1.120  
   1.121  	if (!VALID_EVTCHN(evtchn))
   1.122 @@ -555,7 +548,6 @@ static void shutdown_pirq(unsigned int i
   1.123  
   1.124  	mask_evtchn(evtchn);
   1.125  
   1.126 -	op.cmd          = EVTCHNOP_close;
   1.127  	op.u.close.dom  = DOMID_SELF;
   1.128  	op.u.close.port = evtchn;
   1.129  	BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
   1.130 @@ -666,6 +658,7 @@ void irq_resume(void)
   1.131  			continue;
   1.132  
   1.133  		/* Get a new binding from Xen. */
   1.134 +		memset(&op, 0, sizeof(op));
   1.135  		op.cmd              = EVTCHNOP_bind_virq;
   1.136  		op.u.bind_virq.virq = virq;
   1.137  		op.u.bind_virq.vcpu = 0;
   1.138 @@ -689,6 +682,7 @@ void irq_resume(void)
   1.139  		evtchn_to_irq[evtchn] = -1;
   1.140  
   1.141  		/* Get a new binding from Xen. */
   1.142 +		memset(&op, 0, sizeof(op));
   1.143  		op.cmd = EVTCHNOP_bind_ipi;
   1.144  		op.u.bind_ipi.vcpu = 0;
   1.145  		BUG_ON(HYPERVISOR_event_channel_op(&op) != 0);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Oct 06 11:11:16 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Oct 06 11:12:55 2005 +0100
     2.3 @@ -68,8 +68,13 @@ static void unmap_frontend_page(blkif_t 
     2.4  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
     2.5  {
     2.6  	blkif_sring_t *sring;
     2.7 -	evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
     2.8  	int err;
     2.9 +	evtchn_op_t op = {
    2.10 +		.cmd = EVTCHNOP_bind_interdomain,
    2.11 +		.u.bind_interdomain.dom1 = DOMID_SELF,
    2.12 +		.u.bind_interdomain.dom2 = blkif->domid,
    2.13 +		.u.bind_interdomain.port1 = 0,
    2.14 +		.u.bind_interdomain.port2 = evtchn };
    2.15  
    2.16  	if ( (blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL )
    2.17  		return -ENOMEM;
    2.18 @@ -80,10 +85,6 @@ int blkif_map(blkif_t *blkif, unsigned l
    2.19  		return err;
    2.20  	}
    2.21  
    2.22 -	op.u.bind_interdomain.dom1 = DOMID_SELF;
    2.23 -	op.u.bind_interdomain.dom2 = blkif->domid;
    2.24 -	op.u.bind_interdomain.port1 = 0;
    2.25 -	op.u.bind_interdomain.port2 = evtchn;
    2.26  	err = HYPERVISOR_event_channel_op(&op);
    2.27  	if (err) {
    2.28  		unmap_frontend_page(blkif);
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 06 11:11:16 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 06 11:12:55 2005 +0100
     3.3 @@ -485,8 +485,11 @@ static void watch_for_status(struct xenb
     3.4  static int setup_blkring(struct xenbus_device *dev, struct blkfront_info *info)
     3.5  {
     3.6  	blkif_sring_t *sring;
     3.7 -	evtchn_op_t op = { .cmd = EVTCHNOP_alloc_unbound };
     3.8  	int err;
     3.9 +	evtchn_op_t op = {
    3.10 +		.cmd = EVTCHNOP_alloc_unbound,
    3.11 +		.u.alloc_unbound.dom = DOMID_SELF,
    3.12 +		.u.alloc_unbound.remote_dom = info->backend_id };
    3.13  
    3.14  	info->ring_ref = GRANT_INVALID_REF;
    3.15  
    3.16 @@ -508,7 +511,6 @@ static int setup_blkring(struct xenbus_d
    3.17  	}
    3.18  	info->ring_ref = err;
    3.19  
    3.20 -	op.u.alloc_unbound.dom = info->backend_id;
    3.21  	err = HYPERVISOR_event_channel_op(&op);
    3.22  	if (err) {
    3.23  		gnttab_end_foreign_access(info->ring_ref, 0);
    3.24 @@ -518,7 +520,9 @@ static int setup_blkring(struct xenbus_d
    3.25  		xenbus_dev_error(dev, err, "allocating event channel");
    3.26  		return err;
    3.27  	}
    3.28 +
    3.29  	blkif_connect(info, op.u.alloc_unbound.port);
    3.30 +
    3.31  	return 0;
    3.32  }
    3.33  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Thu Oct 06 11:11:16 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Thu Oct 06 11:12:55 2005 +0100
     4.3 @@ -68,8 +68,13 @@ static void unmap_frontend_page(blkif_t 
     4.4  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
     4.5  {
     4.6  	blkif_sring_t *sring;
     4.7 -	evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
     4.8  	int err;
     4.9 +	evtchn_op_t op = {
    4.10 +		.cmd = EVTCHNOP_bind_interdomain,
    4.11 +		.u.bind_interdomain.dom1 = DOMID_SELF,
    4.12 +		.u.bind_interdomain.dom2 = blkif->domid,
    4.13 +		.u.bind_interdomain.port1 = 0,
    4.14 +		.u.bind_interdomain.port2 = evtchn };
    4.15  
    4.16  	if ((blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE)) == NULL)
    4.17  		return -ENOMEM;
    4.18 @@ -80,10 +85,6 @@ int blkif_map(blkif_t *blkif, unsigned l
    4.19  		return err;
    4.20  	}
    4.21  
    4.22 -	op.u.bind_interdomain.dom1 = DOMID_SELF;
    4.23 -	op.u.bind_interdomain.dom2 = blkif->domid;
    4.24 -	op.u.bind_interdomain.port1 = 0;
    4.25 -	op.u.bind_interdomain.port2 = evtchn;
    4.26  	err = HYPERVISOR_event_channel_op(&op);
    4.27  	if (err) {
    4.28  		unmap_frontend_page(blkif);
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Oct 06 11:11:16 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Oct 06 11:12:55 2005 +0100
     5.3 @@ -177,8 +177,13 @@ static void unmap_frontend_pages(netif_t
     5.4  int netif_map(netif_t *netif, unsigned long tx_ring_ref,
     5.5  	      unsigned long rx_ring_ref, unsigned int evtchn)
     5.6  {
     5.7 -	evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
     5.8  	int err;
     5.9 +	evtchn_op_t op = {
    5.10 +		.cmd = EVTCHNOP_bind_interdomain,
    5.11 +		.u.bind_interdomain.dom1 = DOMID_SELF,
    5.12 +		.u.bind_interdomain.dom2 = netif->domid,
    5.13 +		.u.bind_interdomain.port1 = 0,
    5.14 +		.u.bind_interdomain.port2 = evtchn };
    5.15  
    5.16  	netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
    5.17  	if (netif->comms_area == NULL)
    5.18 @@ -190,10 +195,6 @@ int netif_map(netif_t *netif, unsigned l
    5.19  		return err;
    5.20  	}
    5.21  
    5.22 -	op.u.bind_interdomain.dom1 = DOMID_SELF;
    5.23 -	op.u.bind_interdomain.dom2 = netif->domid;
    5.24 -	op.u.bind_interdomain.port1 = 0;
    5.25 -	op.u.bind_interdomain.port2 = evtchn;
    5.26  	err = HYPERVISOR_event_channel_op(&op);
    5.27  	if (err) {
    5.28  		unmap_frontend_pages(netif);
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 06 11:11:16 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Oct 06 11:12:55 2005 +0100
     6.3 @@ -972,8 +972,11 @@ static void watch_for_status(struct xenb
     6.4  
     6.5  static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
     6.6  {
     6.7 -	evtchn_op_t op = { .cmd = EVTCHNOP_alloc_unbound };
     6.8  	int err;
     6.9 +	evtchn_op_t op = {
    6.10 +		.cmd = EVTCHNOP_alloc_unbound,
    6.11 +		.u.alloc_unbound.dom = DOMID_SELF,
    6.12 +		.u.alloc_unbound.remote_dom = info->backend_id };
    6.13  
    6.14  	info->tx_ring_ref = GRANT_INVALID_REF;
    6.15  	info->rx_ring_ref = GRANT_INVALID_REF;
    6.16 @@ -1010,13 +1013,14 @@ static int setup_device(struct xenbus_de
    6.17  	}
    6.18  	info->rx_ring_ref = err;
    6.19  
    6.20 -	op.u.alloc_unbound.dom = info->backend_id;
    6.21  	err = HYPERVISOR_event_channel_op(&op);
    6.22  	if (err) {
    6.23  		xenbus_dev_error(dev, err, "allocating event channel");
    6.24  		goto out;
    6.25  	}
    6.26 +
    6.27  	connect_device(info, op.u.alloc_unbound.port);
    6.28 +
    6.29  	return 0;
    6.30  
    6.31   out:
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Thu Oct 06 11:11:16 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Thu Oct 06 11:12:55 2005 +0100
     7.3 @@ -117,8 +117,13 @@ unmap_frontend_page(tpmif_t *tpmif)
     7.4  int
     7.5  tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
     7.6  {
     7.7 -	evtchn_op_t op = {.cmd = EVTCHNOP_bind_interdomain };
     7.8  	int err;
     7.9 +	evtchn_op_t op = {
    7.10 +		.cmd = EVTCHNOP_bind_interdomain,
    7.11 +		.u.bind_interdomain.dom1 = DOMID_SELF,
    7.12 +		.u.bind_interdomain.dom2 = tpmif->domid,
    7.13 +		.u.bind_interdomain.port1 = 0,
    7.14 +		.u.bind_interdomain.port2 = evtchn };
    7.15  
    7.16  	if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
    7.17  		return -ENOMEM;
    7.18 @@ -129,10 +134,6 @@ tpmif_map(tpmif_t *tpmif, unsigned long 
    7.19  		return err;
    7.20  	}
    7.21  
    7.22 -	op.u.bind_interdomain.dom1 = DOMID_SELF;
    7.23 -	op.u.bind_interdomain.dom2 = tpmif->domid;
    7.24 -	op.u.bind_interdomain.port1 = 0;
    7.25 -	op.u.bind_interdomain.port2 = evtchn;
    7.26  	err = HYPERVISOR_event_channel_op(&op);
    7.27  	if (err) {
    7.28  		unmap_frontend_page(tpmif);
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Thu Oct 06 11:11:16 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Thu Oct 06 11:12:55 2005 +0100
     8.3 @@ -244,9 +244,11 @@ static int setup_tpmring(struct xenbus_d
     8.4  {
     8.5  	tpmif_tx_interface_t *sring;
     8.6  	struct tpm_private *tp = &my_private;
     8.7 -
     8.8 -	evtchn_op_t op = { .cmd = EVTCHNOP_alloc_unbound };
     8.9  	int err;
    8.10 +	evtchn_op_t op = {
    8.11 +		.cmd = EVTCHNOP_alloc_unbound,
    8.12 +		.u.alloc_unbound.dom = DOMID_SELF,
    8.13 +		.u.alloc_unbound.remote_dom = backend_id } ;
    8.14  
    8.15  	sring = (void *)__get_free_page(GFP_KERNEL);
    8.16  	if (!sring) {
    8.17 @@ -269,7 +271,6 @@ static int setup_tpmring(struct xenbus_d
    8.18  	}
    8.19  	info->ring_ref = err;
    8.20  
    8.21 -	op.u.alloc_unbound.dom = backend_id;
    8.22  	err = HYPERVISOR_event_channel_op(&op);
    8.23  	if (err) {
    8.24  		gnttab_end_foreign_access(info->ring_ref, 0);
    8.25 @@ -278,7 +279,9 @@ static int setup_tpmring(struct xenbus_d
    8.26  		xenbus_dev_error(dev, err, "allocating event channel");
    8.27  		return err;
    8.28  	}
    8.29 +
    8.30  	tpmif_connect(op.u.alloc_unbound.port, backend_id);
    8.31 +
    8.32  	return 0;
    8.33  }
    8.34  
    8.35 @@ -439,26 +442,32 @@ static int tpmfront_remove(struct xenbus
    8.36  	return 0;
    8.37  }
    8.38  
    8.39 -static int tpmfront_suspend(struct xenbus_device *dev)
    8.40 +static int
    8.41 +tpmfront_suspend(struct xenbus_device *dev)
    8.42  {
    8.43  	struct tpmfront_info *info = dev->data;
    8.44  	struct tpm_private *tp = &my_private;
    8.45 +	u32 ctr = 0;
    8.46  
    8.47 -	/* lock so no app can send */
    8.48 +	/* lock, so no app can send */
    8.49  	down(&suspend_lock);
    8.50  
    8.51 -	while (atomic_read(&tp->tx_busy)) {
    8.52 -		printk("---- TPMIF: Outstanding request.\n");
    8.53 -#if 0
    8.54 +	while (atomic_read(&tp->tx_busy) && ctr <= 25) {
    8.55 +	        if ((ctr % 10) == 0)
    8.56 +			printk("INFO: Waiting for outstanding request.\n");
    8.57  		/*
    8.58 -		 * Would like to wait until the outstanding request
    8.59 -		 * has come back, but this does not work properly, yet.
    8.60 +		 * Wait for a request to be responded to.
    8.61  		 */
    8.62 -		interruptible_sleep_on_timeout(&tp->wait_q,
    8.63 -		                               100);
    8.64 -#else
    8.65 -		break;
    8.66 -#endif
    8.67 +		interruptible_sleep_on_timeout(&tp->wait_q, 100);
    8.68 +		ctr++;
    8.69 +	}
    8.70 +
    8.71 +	if (atomic_read(&tp->tx_busy)) {
    8.72 +		/*
    8.73 +		 * A temporary work-around.
    8.74 +		 */
    8.75 +		printk("WARNING: Resetting busy flag.");
    8.76 +		atomic_set(&tp->tx_busy, 0);
    8.77  	}
    8.78  
    8.79  	unregister_xenbus_watch(&info->watch);
    8.80 @@ -466,44 +475,34 @@ static int tpmfront_suspend(struct xenbu
    8.81  	kfree(info->backend);
    8.82  	info->backend = NULL;
    8.83  
    8.84 -	destroy_tpmring(info, tp);
    8.85 -
    8.86 -	return 0;
    8.87 -}
    8.88 -
    8.89 -static int tpmif_recover(void)
    8.90 -{
    8.91  	return 0;
    8.92  }
    8.93  
    8.94 -static int tpmfront_resume(struct xenbus_device *dev)
    8.95 +static int
    8.96 +tpmfront_resume(struct xenbus_device *dev)
    8.97  {
    8.98  	struct tpmfront_info *info = dev->data;
    8.99 -	int err;
   8.100 +	int err = talk_to_backend(dev, info);
   8.101  
   8.102 -	err = talk_to_backend(dev, info);
   8.103 -	if (!err) {
   8.104 -		tpmif_recover();
   8.105 -	}
   8.106 -
   8.107 -	/* unlock so apps can resume */
   8.108 +	/* unlock, so apps can resume sending */
   8.109  	up(&suspend_lock);
   8.110  
   8.111  	return err;
   8.112  }
   8.113  
   8.114 -static void tpmif_connect(u16 evtchn, domid_t domid)
   8.115 +static void
   8.116 +tpmif_connect(u16 evtchn, domid_t domid)
   8.117  {
   8.118  	int err = 0;
   8.119  	struct tpm_private *tp = &my_private;
   8.120  
   8.121  	tp->evtchn = evtchn;
   8.122 -	tp->backend_id  = domid;
   8.123 +	tp->backend_id = domid;
   8.124  
   8.125 -	err = bind_evtchn_to_irqhandler(
   8.126 -		tp->evtchn,
   8.127 -		tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
   8.128 -	if ( err <= 0 ) {
   8.129 +	err = bind_evtchn_to_irqhandler(tp->evtchn,
   8.130 +					tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
   8.131 +					tp);
   8.132 +	if (err <= 0) {
   8.133  		WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
   8.134  		return;
   8.135  	}
   8.136 @@ -638,7 +637,7 @@ tpm_xmit(struct tpm_private *tp,
   8.137  
   8.138  		if (NULL == txb) {
   8.139  			DPRINTK("txb (i=%d) is NULL. buffers initilized?\n", i);
   8.140 -			DPRINTK("Not transmittin anything!\n");
   8.141 +			DPRINTK("Not transmitting anything!\n");
   8.142  			spin_unlock_irq(&tp->tx_lock);
   8.143  			return -EFAULT;
   8.144  		}
     9.1 --- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Oct 06 11:11:16 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h	Thu Oct 06 11:12:55 2005 +0100
     9.3 @@ -123,9 +123,9 @@ static inline void clear_evtchn(int port
     9.4  
     9.5  static inline void notify_remote_via_evtchn(int port)
     9.6  {
     9.7 -	evtchn_op_t op;
     9.8 -	op.cmd = EVTCHNOP_send;
     9.9 -	op.u.send.local_port = port;
    9.10 +	evtchn_op_t op = {
    9.11 +		.cmd = EVTCHNOP_send,
    9.12 +		.u.send.local_port = port };
    9.13  	(void)HYPERVISOR_event_channel_op(&op);
    9.14  }
    9.15  
    10.1 --- a/tools/examples/network-bridge	Thu Oct 06 11:11:16 2005 +0100
    10.2 +++ b/tools/examples/network-bridge	Thu Oct 06 11:12:55 2005 +0100
    10.3 @@ -39,6 +39,17 @@
    10.4  #
    10.5  #============================================================================
    10.6  
    10.7 +# Gentoo doesn't have ifup/ifdown: define appropriate alternatives
    10.8 +which ifup >& /dev/null
    10.9 +if [ "$?" != 0 -a -e /etc/conf.d/net ]; then
   10.10 +    ifup() {
   10.11 +        /etc/init.d/net.$1 start
   10.12 +    }
   10.13 +    ifdown() {
   10.14 +        /etc/init.d/net.$1 stop
   10.15 +    }
   10.16 +fi
   10.17 +
   10.18  # Exit if anything goes wrong.
   10.19  set -e 
   10.20  
   10.21 @@ -55,17 +66,6 @@ antispoof=${antispoof:-no}
   10.22  
   10.23  echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof" >&2
   10.24  
   10.25 -# Gentoo doesn't have ifup/ifdown: define appropriate alternatives
   10.26 -which ifup >& /dev/null
   10.27 -if [ "$?" != 0 -a -e /etc/conf.d/net ]; then
   10.28 -    ifup() {
   10.29 -        /etc/init.d/net.$1 start
   10.30 -    }
   10.31 -    ifdown() {
   10.32 -        /etc/init.d/net.$1 stop
   10.33 -    }
   10.34 -fi
   10.35 -
   10.36  # Usage: transfer_addrs src dst
   10.37  # Copy all IP addresses (including aliases) from device $src to device $dst.
   10.38  transfer_addrs () {
    11.1 --- a/tools/libxc/xc_evtchn.c	Thu Oct 06 11:11:16 2005 +0100
    11.2 +++ b/tools/libxc/xc_evtchn.c	Thu Oct 06 11:12:55 2005 +0100
    11.3 @@ -33,15 +33,16 @@ static int do_evtchn_op(int xc_handle, e
    11.4  
    11.5  
    11.6  int xc_evtchn_alloc_unbound(int xc_handle,
    11.7 +                            u32 remote_dom,
    11.8                              u32 dom,
    11.9                              int *port)
   11.10  {
   11.11 -    evtchn_op_t op;
   11.12      int         rc;
   11.13 -
   11.14 -    op.cmd = EVTCHNOP_alloc_unbound;
   11.15 -    op.u.alloc_unbound.dom  = (domid_t)dom;
   11.16 -    op.u.alloc_unbound.port = (port != NULL) ? *port : 0;
   11.17 +    evtchn_op_t op = {
   11.18 +        .cmd = EVTCHNOP_alloc_unbound,
   11.19 +        .u.alloc_unbound.remote_dom = (domid_t)remote_dom,
   11.20 +        .u.alloc_unbound.dom  = (domid_t)dom,
   11.21 +        .u.alloc_unbound.port = (port != NULL) ? *port : 0 };
   11.22  
   11.23      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
   11.24      {
   11.25 @@ -59,15 +60,13 @@ int xc_evtchn_bind_interdomain(int xc_ha
   11.26                                 int *port1,
   11.27                                 int *port2)
   11.28  {
   11.29 -    evtchn_op_t op;
   11.30      int         rc;
   11.31 -
   11.32 -    op.cmd = EVTCHNOP_bind_interdomain;
   11.33 -    op.u.bind_interdomain.dom1  = (domid_t)dom1;
   11.34 -    op.u.bind_interdomain.dom2  = (domid_t)dom2;
   11.35 -    op.u.bind_interdomain.port1 = (port1 != NULL) ? *port1 : 0;
   11.36 -    op.u.bind_interdomain.port2 = (port2 != NULL) ? *port2 : 0;
   11.37 -
   11.38 +    evtchn_op_t op = {
   11.39 +        .cmd = EVTCHNOP_bind_interdomain,
   11.40 +        .u.bind_interdomain.dom1  = (domid_t)dom1,
   11.41 +        .u.bind_interdomain.dom2  = (domid_t)dom2,
   11.42 +        .u.bind_interdomain.port1 = (port1 != NULL) ? *port1 : 0,
   11.43 +        .u.bind_interdomain.port2 = (port2 != NULL) ? *port2 : 0 };
   11.44  
   11.45      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
   11.46      {
   11.47 @@ -85,12 +84,11 @@ int xc_evtchn_bind_virq(int xc_handle,
   11.48                          int virq,
   11.49                          int *port)
   11.50  {
   11.51 -    evtchn_op_t op;
   11.52      int         rc;
   11.53 -
   11.54 -    op.cmd = EVTCHNOP_bind_virq;
   11.55 -    op.u.bind_virq.virq = (u32)virq;
   11.56 -    op.u.bind_virq.vcpu = 0;
   11.57 +    evtchn_op_t op = {
   11.58 +        .cmd = EVTCHNOP_bind_virq,
   11.59 +        .u.bind_virq.virq = (u32)virq,
   11.60 +        .u.bind_virq.vcpu = 0 };
   11.61  
   11.62      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
   11.63      {
   11.64 @@ -106,10 +104,10 @@ int xc_evtchn_close(int xc_handle,
   11.65                      u32 dom,
   11.66                      int port)
   11.67  {
   11.68 -    evtchn_op_t op;
   11.69 -    op.cmd = EVTCHNOP_close;
   11.70 -    op.u.close.dom  = (domid_t)dom;
   11.71 -    op.u.close.port = port;
   11.72 +    evtchn_op_t op = {
   11.73 +        .cmd          = EVTCHNOP_close,
   11.74 +        .u.close.dom  = (domid_t)dom,
   11.75 +        .u.close.port = port };
   11.76      return do_evtchn_op(xc_handle, &op);
   11.77  }
   11.78  
   11.79 @@ -117,9 +115,9 @@ int xc_evtchn_close(int xc_handle,
   11.80  int xc_evtchn_send(int xc_handle,
   11.81                     int local_port)
   11.82  {
   11.83 -    evtchn_op_t op;
   11.84 -    op.cmd = EVTCHNOP_send;
   11.85 -    op.u.send.local_port = local_port;
   11.86 +    evtchn_op_t op = {
   11.87 +        .cmd = EVTCHNOP_send,
   11.88 +        .u.send.local_port = local_port };
   11.89      return do_evtchn_op(xc_handle, &op);
   11.90  }
   11.91  
   11.92 @@ -129,13 +127,12 @@ int xc_evtchn_status(int xc_handle,
   11.93                       int port,
   11.94                       xc_evtchn_status_t *status)
   11.95  {
   11.96 -    evtchn_op_t op;
   11.97      int         rc;
   11.98 +    evtchn_op_t op = {
   11.99 +        .cmd           = EVTCHNOP_status,
  11.100 +        .u.status.dom  = (domid_t)dom,
  11.101 +        .u.status.port = port };
  11.102  
  11.103 -    op.cmd = EVTCHNOP_status;
  11.104 -    op.u.status.dom  = (domid_t)dom;
  11.105 -    op.u.status.port = port;
  11.106 -   
  11.107      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
  11.108          memcpy(status, &op.u.status, sizeof(*status));
  11.109      
    12.1 --- a/tools/libxc/xenctrl.h	Thu Oct 06 11:11:16 2005 +0100
    12.2 +++ b/tools/libxc/xenctrl.h	Thu Oct 06 11:12:55 2005 +0100
    12.3 @@ -306,13 +306,15 @@ typedef evtchn_status_t xc_evtchn_status
    12.4   * well-known port within a domain to receive events on.
    12.5   *
    12.6   * @parm xc_handle a handle to an open hypervisor interface
    12.7 - * @parm dom the ID of the domain.  This maybe DOMID_SELF
    12.8 + * @parm remote_dom the ID of the domain who will later bind
    12.9 + * @parm dom the ID of the local domain (the 'allocatee')
   12.10   * @parm port a pointer to a port.  This is an in/out parameter.  If *port is
   12.11   *            0, then a new port will be assigned, if port is > 0 then that
   12.12   *            port is allocated if the port is unallocated.
   12.13   * @return 0 on success, -1 on failure
   12.14   */
   12.15  int xc_evtchn_alloc_unbound(int xc_handle,
   12.16 +                            u32 remote_dom,
   12.17                              u32 dom,
   12.18                              int *port);
   12.19  
    13.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Oct 06 11:11:16 2005 +0100
    13.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Oct 06 11:12:55 2005 +0100
    13.3 @@ -432,16 +432,16 @@ static PyObject *pyxc_evtchn_alloc_unbou
    13.4  {
    13.5      XcObject *xc = (XcObject *)self;
    13.6  
    13.7 -    u32 dom;
    13.8 +    u32 dom = DOMID_SELF, remote_dom;
    13.9      int port = 0;
   13.10  
   13.11 -    static char *kwd_list[] = { "dom", "port", NULL };
   13.12 +    static char *kwd_list[] = { "remote_dom", "dom", "port", NULL };
   13.13  
   13.14 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
   13.15 -                                      &dom, &port) )
   13.16 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|ii", kwd_list,
   13.17 +                                      &remote_dom, &dom, &port) )
   13.18          return NULL;
   13.19  
   13.20 -    if ( xc_evtchn_alloc_unbound(xc->xc_handle, dom, &port) != 0 )
   13.21 +    if ( xc_evtchn_alloc_unbound(xc->xc_handle, remote_dom, dom, &port) != 0 )
   13.22          return PyErr_SetFromErrno(xc_error);
   13.23  
   13.24      return PyInt_FromLong(port);
    14.1 --- a/tools/python/xen/xend/server/tpmif.py	Thu Oct 06 11:11:16 2005 +0100
    14.2 +++ b/tools/python/xen/xend/server/tpmif.py	Thu Oct 06 11:12:55 2005 +0100
    14.3 @@ -39,9 +39,24 @@ class TPMifController(DevController):
    14.4          """@see DevController.getDeviceDetails"""
    14.5          
    14.6          devid = int(sxp.child_value(config, 'instance', '0'))
    14.7 -        log.debug("The domain has a TPM with instance %d." % devid)
    14.8 +        log.info("The domain has a TPM with instance %d." % devid)
    14.9  
   14.10          back  = { 'instance' : "%i" % devid }
   14.11          front = { 'handle' : "%i" % devid }
   14.12  
   14.13          return (devid, back, front)
   14.14 +
   14.15 +    def configuration(self, devid):
   14.16 +
   14.17 +        log.info("The configuration method is called.")
   14.18 +
   14.19 +        result = DevContoller.configuration(self, devid)
   14.20 +
   14.21 +        (instance) = self.readBackend(devif,
   14.22 +                                      'instance')
   14.23 +
   14.24 +        if instance:
   14.25 +            result.append(['instance', instance])
   14.26 +            log.info("configuration: instance=%d." % instance)
   14.27 +
   14.28 +        return result
    15.1 --- a/tools/python/xen/xm/main.py	Thu Oct 06 11:11:16 2005 +0100
    15.2 +++ b/tools/python/xen/xm/main.py	Thu Oct 06 11:12:55 2005 +0100
    15.3 @@ -86,8 +86,8 @@ xm full list of subcommands:
    15.4      shutdown [-w|-a] <DomId>  shutdown a domain
    15.5      sysrq   <DomId> <letter>  send a sysrq to a domain
    15.6      unpause <DomId>           unpause a paused domain
    15.7 -    vcpu-enable <DomId> <VCPU>        disable VCPU in a domain
    15.8 -    vcpu-disable <DomId> <VCPU>       enable VCPU in a domain
    15.9 +    vcpu-enable <DomId> <VCPU>        enable VCPU in a domain
   15.10 +    vcpu-disable <DomId> <VCPU>       disable VCPU in a domain
   15.11      vcpu-list <DomId>                 get the list of VCPUs for a domain
   15.12      vcpu-pin <DomId> <VCpu> <CPUS>    set which cpus a VCPU can use. 
   15.13  
    16.1 --- a/xen/arch/x86/x86_32/mm.c	Thu Oct 06 11:11:16 2005 +0100
    16.2 +++ b/xen/arch/x86/x86_32/mm.c	Thu Oct 06 11:12:55 2005 +0100
    16.3 @@ -156,6 +156,7 @@ void subarch_init_memory(struct domain *
    16.4       */
    16.5      if ( (offsetof(struct pfn_info, u.inuse._domain) != 
    16.6            (offsetof(struct pfn_info, count_info) + sizeof(u32))) ||
    16.7 +         ((offsetof(struct pfn_info, count_info) & 7) != 0) ||
    16.8           (sizeof(struct pfn_info) != 24) )
    16.9      {
   16.10          printk("Weird pfn_info layout (%ld,%ld,%d)\n",
    17.1 --- a/xen/arch/x86/x86_64/mm.c	Thu Oct 06 11:11:16 2005 +0100
    17.2 +++ b/xen/arch/x86/x86_64/mm.c	Thu Oct 06 11:12:55 2005 +0100
    17.3 @@ -137,8 +137,10 @@ void subarch_init_memory(struct domain *
    17.4       * count_info and domain fields must be adjacent, as we perform atomic
    17.5       * 64-bit operations on them.
    17.6       */
    17.7 -    if ( (offsetof(struct pfn_info, u.inuse._domain) != 
    17.8 -          (offsetof(struct pfn_info, count_info) + sizeof(u32))) )
    17.9 +    if ( ((offsetof(struct pfn_info, u.inuse._domain) != 
   17.10 +           (offsetof(struct pfn_info, count_info) + sizeof(u32)))) ||
   17.11 +         ((offsetof(struct pfn_info, count_info) & 7) != 0) ||
   17.12 +         (sizeof(struct pfn_info) != 40) )
   17.13      {
   17.14          printk("Weird pfn_info layout (%ld,%ld,%ld)\n",
   17.15                 offsetof(struct pfn_info, count_info),
    18.1 --- a/xen/common/event_channel.c	Thu Oct 06 11:11:16 2005 +0100
    18.2 +++ b/xen/common/event_channel.c	Thu Oct 06 11:12:55 2005 +0100
    18.3 @@ -63,10 +63,19 @@ static int get_free_port(struct domain *
    18.4  static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
    18.5  {
    18.6      struct evtchn *chn;
    18.7 -    struct domain *d = current->domain;
    18.8 +    struct domain *d;
    18.9      int            port = alloc->port;
   18.10 +    domid_t        dom = alloc->dom;
   18.11      long           rc = 0;
   18.12  
   18.13 +    if ( dom == DOMID_SELF )
   18.14 +        dom = current->domain->domain_id;
   18.15 +    else if ( !IS_PRIV(current->domain) )
   18.16 +        return -EPERM;
   18.17 +
   18.18 +    if ( (d = find_domain_by_id(dom)) == NULL )
   18.19 +        return -ESRCH;
   18.20 +
   18.21      spin_lock(&d->evtchn_lock);
   18.22  
   18.23      /* Obtain, or ensure that we already have, a valid <port>. */
   18.24 @@ -84,11 +93,11 @@ static long evtchn_alloc_unbound(evtchn_
   18.25      {
   18.26      case ECS_FREE:
   18.27          chn->state = ECS_UNBOUND;
   18.28 -        chn->u.unbound.remote_domid = alloc->dom;
   18.29 +        chn->u.unbound.remote_domid = alloc->remote_dom;
   18.30          break;
   18.31  
   18.32      case ECS_UNBOUND:
   18.33 -        if ( chn->u.unbound.remote_domid != alloc->dom )
   18.34 +        if ( chn->u.unbound.remote_domid != alloc->remote_dom )
   18.35              ERROR_EXIT(-EINVAL);
   18.36          break;
   18.37  
   18.38 @@ -99,7 +108,10 @@ static long evtchn_alloc_unbound(evtchn_
   18.39   out:
   18.40      spin_unlock(&d->evtchn_lock);
   18.41  
   18.42 +    put_domain(d);
   18.43 +
   18.44      alloc->port = port;
   18.45 +
   18.46      return rc;
   18.47  }
   18.48  
    19.1 --- a/xen/include/asm-x86/mm.h	Thu Oct 06 11:11:16 2005 +0100
    19.2 +++ b/xen/include/asm-x86/mm.h	Thu Oct 06 11:12:55 2005 +0100
    19.3 @@ -22,9 +22,6 @@ struct pfn_info
    19.4      /* Each frame can be threaded onto a doubly-linked list. */
    19.5      struct list_head list;
    19.6  
    19.7 -    /* Timestamp from 'TLB clock', used to reduce need for safety flushes. */
    19.8 -    u32 tlbflush_timestamp;
    19.9 -
   19.10      /* Reference count and various PGC_xxx flags and fields. */
   19.11      u32 count_info;
   19.12  
   19.13 @@ -37,17 +34,20 @@ struct pfn_info
   19.14              u32 _domain; /* pickled format */
   19.15              /* Type reference count and various PGT_xxx flags and fields. */
   19.16              unsigned long type_info;
   19.17 -        } inuse;
   19.18 +        } __attribute__ ((packed)) inuse;
   19.19  
   19.20          /* Page is on a free list: ((count_info & PGC_count_mask) == 0). */
   19.21          struct {
   19.22 +            /* Order-size of the free chunk this page is the head of. */
   19.23 +            u32 order;
   19.24              /* Mask of possibly-tainted TLBs. */
   19.25              cpumask_t cpumask;
   19.26 -            /* Order-size of the free chunk this page is the head of. */
   19.27 -            u8 order;
   19.28 -        } free;
   19.29 +        } __attribute__ ((packed)) free;
   19.30  
   19.31      } u;
   19.32 +
   19.33 +    /* Timestamp from 'TLB clock', used to reduce need for safety flushes. */
   19.34 +    u32 tlbflush_timestamp;
   19.35  };
   19.36  
   19.37   /* The following page types are MUTUALLY EXCLUSIVE. */
    20.1 --- a/xen/include/public/event_channel.h	Thu Oct 06 11:11:16 2005 +0100
    20.2 +++ b/xen/include/public/event_channel.h	Thu Oct 06 11:12:55 2005 +0100
    20.3 @@ -10,14 +10,16 @@
    20.4  #define __XEN_PUBLIC_EVENT_CHANNEL_H__
    20.5  
    20.6  /*
    20.7 - * EVTCHNOP_alloc_unbound: Prepare a local port for binding to <dom>.
    20.8 - * <port> may be wildcarded by setting to zero, in which case a fresh port
    20.9 - * will be allocated, and the field filled in on return.
   20.10 + * EVTCHNOP_alloc_unbound: Allocate a port in <dom> for later binding to
   20.11 + * <remote_dom>. <port> may be wildcarded by setting to zero, in which case a
   20.12 + * fresh port will be allocated, and the field filled in on return.
   20.13 + * NOTES:
   20.14 + *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
   20.15   */
   20.16  #define EVTCHNOP_alloc_unbound    6
   20.17  typedef struct evtchn_alloc_unbound {
   20.18      /* IN parameters */
   20.19 -    domid_t dom;
   20.20 +    domid_t dom, remote_dom;
   20.21      /* IN/OUT parameters */
   20.22      u32     port;
   20.23  } evtchn_alloc_unbound_t;