[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [TPM] Fix an occasional problem when doing local migration due to the xenstore's
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 23136423a76586c6b9f1f7a69fa39d377d526c9e # Parent 60d7d64eaff2cb6fa081b960237fa530f48cb9e8 [TPM] Fix an occasional problem when doing local migration due to the xenstore's 'instance' variable not being initialized at the time when it's driver counterpart is accessed. That variable's content was used to initialize the tpmif structure. Instead, now a pointer to the structure is passed whose 'instance' variable will be initialized before the domain is resumed. Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx> --- linux-2.6-xen-sparse/drivers/xen/tpmback/common.h | 9 +++++++-- linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c | 10 +++++----- linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c | 2 +- linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c | 14 +++++++++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff -r 60d7d64eaff2 -r 23136423a765 linux-2.6-xen-sparse/drivers/xen/tpmback/common.h --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Tue Jun 27 11:27:25 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Tue Jun 27 11:29:29 2006 +0100 @@ -21,6 +21,8 @@ pr_debug("(file=%s, line=%d) " _f, \ __FILE__ , __LINE__ , ## _a ) +struct backend_info; + typedef struct tpmif_st { struct list_head tpmif_list; /* Unique identifier for this interface. */ @@ -43,7 +45,7 @@ typedef struct tpmif_st { struct list_head list; /* scheduling list */ atomic_t refcnt; - long int tpm_instance; + struct backend_info *bi; unsigned long mmap_vstart; grant_handle_t shmem_handle; @@ -54,7 +56,7 @@ typedef struct tpmif_st { } tpmif_t; void tpmif_disconnect_complete(tpmif_t * tpmif); -tpmif_t *tpmif_find(domid_t domid, long int instance); +tpmif_t *tpmif_find(domid_t domid, struct backend_info *bi); void tpmif_interface_init(void); void tpmif_interface_exit(void); void tpmif_schedule_work(tpmif_t * tpmif); @@ -64,7 +66,10 @@ int tpmif_map(tpmif_t *tpmif, unsigned l int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn); irqreturn_t tpmif_be_int(int irq, void *dev_id, struct pt_regs *regs); +long int tpmback_get_instance(struct backend_info *bi); + int vtpm_release_packets(tpmif_t * tpmif, int send_msgs); + #define tpmif_get(_b) (atomic_inc(&(_b)->refcnt)) #define tpmif_put(_b) \ diff -r 60d7d64eaff2 -r 23136423a765 linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Tue Jun 27 11:27:25 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Tue Jun 27 11:29:29 2006 +0100 @@ -20,7 +20,7 @@ int num_frontends = 0; LIST_HEAD(tpmif_list); -static tpmif_t *alloc_tpmif(domid_t domid, long int instance) +static tpmif_t *alloc_tpmif(domid_t domid, struct backend_info *bi) { tpmif_t *tpmif; @@ -31,7 +31,7 @@ static tpmif_t *alloc_tpmif(domid_t domi memset(tpmif, 0, sizeof (*tpmif)); tpmif->domid = domid; tpmif->status = DISCONNECTED; - tpmif->tpm_instance = instance; + tpmif->bi = bi; snprintf(tpmif->devname, sizeof(tpmif->devname), "tpmif%d", domid); atomic_set(&tpmif->refcnt, 1); @@ -54,12 +54,12 @@ static void free_tpmif(tpmif_t * tpmif) kmem_cache_free(tpmif_cachep, tpmif); } -tpmif_t *tpmif_find(domid_t domid, long int instance) +tpmif_t *tpmif_find(domid_t domid, struct backend_info *bi) { tpmif_t *tpmif; list_for_each_entry(tpmif, &tpmif_list, tpmif_list) { - if (tpmif->tpm_instance == instance) { + if (tpmif->bi == bi) { if (tpmif->domid == domid) { tpmif_get(tpmif); return tpmif; @@ -69,7 +69,7 @@ tpmif_t *tpmif_find(domid_t domid, long } } - return alloc_tpmif(domid, instance); + return alloc_tpmif(domid, bi); } static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page) diff -r 60d7d64eaff2 -r 23136423a765 linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Tue Jun 27 11:27:25 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Tue Jun 27 11:29:29 2006 +0100 @@ -161,7 +161,7 @@ static struct packet *packet_alloc(tpmif if (NULL != pak) { if (tpmif) { pak->tpmif = tpmif; - pak->tpm_instance = tpmif->tpm_instance; + pak->tpm_instance = tpmback_get_instance(tpmif->bi); tpmif_get(tpmif); } pak->data_len = size; diff -r 60d7d64eaff2 -r 23136423a765 linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Tue Jun 27 11:27:25 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Tue Jun 27 11:29:29 2006 +0100 @@ -45,6 +45,14 @@ static void frontend_changed(struct xenb static void frontend_changed(struct xenbus_device *dev, enum xenbus_state frontend_state); +long int tpmback_get_instance(struct backend_info *bi) +{ + long int res = -1; + if (bi && bi->is_instance_set) + res = bi->instance; + return res; +} + static int tpmback_remove(struct xenbus_device *dev) { struct backend_info *be = dev->dev.driver_data; @@ -57,6 +65,7 @@ static int tpmback_remove(struct xenbus_ be->backend_watch.node = NULL; } if (be->tpmif) { + be->tpmif->bi = NULL; vtpm_release_packets(be->tpmif, 0); tpmif_put(be->tpmif); be->tpmif = NULL; @@ -150,7 +159,7 @@ static void frontend_changed(struct xenb break; case XenbusStateClosing: - be->tpmif->tpm_instance = -1; + be->instance = -1; break; case XenbusStateClosed: @@ -233,8 +242,7 @@ static int connect_ring(struct backend_i } if (!be->tpmif) { - be->tpmif = tpmif_find(dev->otherend_id, - be->instance); + be->tpmif = tpmif_find(dev->otherend_id, be); if (IS_ERR(be->tpmif)) { err = PTR_ERR(be->tpmif); be->tpmif = NULL; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |