vtpm Mini-Os domain: linux tpmbk bugfixes
PATCH 7/7 vtpm Mini-Os domain: linux tpmbk bugfixes
Signed-off-by Matthew Fioravante <[email protected]>
This patch is for the xen linux kernel. It was made against 2.6.18 but is fairly simple and should apply cleanly to all of the xen kernels out there.
This patch fixes a couple of race conditions in the linux tpmbk driver. One of them is during startup and will cause the vtpm domains to fail to start correctly. The other race condition happens during shutdown and causes the vtpm tpmfrontend to release a shared page before the backend driver has unmapped it.
drivers/xen/tpmback/xenbus.c +17 -8
@@ -52,6 +52,18 @@return res; } +static void tpmback_disconnect (struct xenbus_device *dev) { +struct backend_info *be = dev->dev.driver_data; + +if (be->tpmif) { + be->tpmif->bi =NULL ; +vtpm_release_packets (be->tpmif,0 ); +tpmif_put (be->tpmif); + be->tpmif =NULL ; + } +return ; +} +static int tpmback_remove (struct xenbus_device *dev) {struct backend_info *be = dev->dev.driver_data;
@@ -63,12 +75,7 @@kfree (be->backend_watch.node); 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 ; - } +tpmback_disconnect (dev);kfree (be); dev->dev.driver_data =NULL ;return 0 ;
@@ -162,6 +169,7 @@case XenbusStateUnknown:/* keep it here */ case XenbusStateClosed: +tpmback_disconnect (dev);/*Unmap shared pages first */ xenbus_switch_state (dev, XenbusStateClosed);device_unregister (&be->dev->dev);tpmback_remove (dev);
@@ -213,9 +221,10 @@if (err)xenbus_dev_fatal (be->dev, err,"end of transaction" ); + be->tpmif->status =CONNECTED ; err =xenbus_switch_state (dev, XenbusStateConnected); -if (!err) - be->tpmif->status =CONNECTED ; +if (err) + be->tpmif->status =DISCONNECTED ;return ; abort:xenbus_transaction_end (xbt,1 );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel