diff -r 61c96456a3e1 drivers/char/tpm/tpm_vtpm.c --- a/drivers/char/tpm/tpm_vtpm.c Thu Dec 20 16:58:14 2007 +0000 +++ b/drivers/char/tpm/tpm_vtpm.c Wed Jan 02 14:19:04 2008 -0500 @@ -307,6 +307,7 @@ static int vtpm_send(struct tpm_chip *ch rc = vtpm_vd_send(vtpms->tpm_private, buf, count, + 0, t); /* * The generic TPM driver will call @@ -368,6 +369,7 @@ static int _vtpm_send_queued(struct tpm_ rc = vtpm_vd_send(vtpms->tpm_private, qt->request, qt->request_len, + 0, qt); if (rc < 0) { diff -r 61c96456a3e1 drivers/char/tpm/tpm_vtpm.h --- a/drivers/char/tpm/tpm_vtpm.h Thu Dec 20 16:58:14 2007 +0000 +++ b/drivers/char/tpm/tpm_vtpm.h Wed Jan 02 14:19:04 2008 -0500 @@ -35,7 +35,7 @@ enum vdev_status { /* this function is called from tpm_vtpm.c */ int vtpm_vd_send(struct tpm_private * tp, - const u8 * buf, size_t count, void *ptr); + const u8 * buf, size_t count, u8 locality, void *ptr); /* these functions are offered by tpm_vtpm.c */ struct tpm_chip *init_vtpm(struct device *, diff -r 61c96456a3e1 drivers/char/tpm/tpm_xen.c --- a/drivers/char/tpm/tpm_xen.c Thu Dec 20 16:58:14 2007 +0000 +++ b/drivers/char/tpm/tpm_xen.c Wed Jan 02 14:19:04 2008 -0500 @@ -98,7 +98,7 @@ static void tpmif_set_connected_state(st u8 newstate); static int tpm_xmit(struct tpm_private *tp, const u8 * buf, size_t count, int userbuffer, - void *remember); + u8 locality, void *remember); static void destroy_tpmring(struct tpm_private *tp); void __exit tpmif_exit(void); @@ -211,12 +211,12 @@ static DEFINE_MUTEX(suspend_lock); * Send data via this module by calling this function */ int vtpm_vd_send(struct tpm_private *tp, - const u8 * buf, size_t count, void *ptr) + const u8 * buf, size_t count, u8 locality, void *ptr) { int sent; mutex_lock(&suspend_lock); - sent = tpm_xmit(tp, buf, count, 0, ptr); + sent = tpm_xmit(tp, buf, count, 0, locality, ptr); mutex_unlock(&suspend_lock); return sent; @@ -239,6 +239,7 @@ static int setup_tpmring(struct xenbus_d xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring"); return -ENOMEM; } + memset(sring, 0, PAGE_SIZE); tp->tx = sring; err = xenbus_grant_ring(dev, virt_to_mfn(tp->tx)); @@ -573,7 +574,7 @@ static irqreturn_t tpmif_int(int irq, vo static int tpm_xmit(struct tpm_private *tp, const u8 * buf, size_t count, int isuserbuffer, - void *remember) + u8 locality, void *remember) { tpmif_tx_request_t *tx; TPMIF_RING_IDX i; @@ -617,6 +618,8 @@ static int tpm_xmit(struct tpm_private * tx = &tp->tx->ring[i].req; tx->addr = virt_to_machine(txb->data); tx->size = txb->len; + tx->version = 1; + tx->locality = locality; DPRINTK("First 4 characters sent by TPM-FE are " "0x%02x 0x%02x 0x%02x 0x%02x\n", diff -r 61c96456a3e1 drivers/xen/tpmback/tpmback.c --- a/drivers/xen/tpmback/tpmback.c Thu Dec 20 16:58:14 2007 +0000 +++ b/drivers/xen/tpmback/tpmback.c Wed Jan 02 14:19:04 2008 -0500 @@ -298,6 +298,18 @@ int _packet_write(struct packet *pak, return rc; } + +static u8 get_locty_ring(tpmif_t *tpmif) +{ + tpmif_tx_request_t *tx = &tpmif->tx->ring[0].req; + + if (tx->version == 1) + return tx->locality; + + return 0; +} + + /* * Read data from the shared memory and copy it directly into the * provided buffer. Advance the read_last indicator which tells @@ -319,9 +331,11 @@ static int packet_read(struct packet *pa if (pak->last_read < 4) { /* - * copy the instance number into the buffer + * copy the instance number into the buffer along + * with locality information. */ - u32 instance_no = htonl(pak->tpm_instance); + u32 instance_no = htonl(pak->tpm_instance | + get_locty_ring(pak->tpmif) << 29); u32 last_read = pak->last_read; to_copy = min_t(size_t, 4 - last_read, numbytes); diff -r 61c96456a3e1 include/xen/interface/io/tpmif.h --- a/include/xen/interface/io/tpmif.h Thu Dec 20 16:58:14 2007 +0000 +++ b/include/xen/interface/io/tpmif.h Wed Jan 02 14:19:04 2008 -0500 @@ -39,7 +39,8 @@ struct tpmif_tx_request { struct tpmif_tx_request { unsigned long addr; /* Machine address of packet. */ grant_ref_t ref; /* grant table access reference */ - uint16_t unused; + uint8_t version; /* version of block */ + uint8_t locality; /* locality for command */ uint16_t size; /* Packet size in bytes. */ }; typedef struct tpmif_tx_request tpmif_tx_request_t;