Message ID | 1424477484.26401.17.camel@oc8377654763.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Looks good Joy. Thanks for testing it on both BE OS and LE OS. Reviewed-by: Ashley Lai <ashley@ahsleylai.com> --Ashley On Fri, 20 Feb 2015, Joy M. Latten wrote: > Hi, > > Problem: When IMA and VTPM are both enabled in kernel config, > kernel hangs during bootup on LE OS. > > Why?: IMA calls tpm_pcr_read() which results in tpm_ibmvtpm_send > and tpm_ibmtpm_recv getting called. A trace showed that > tpm_ibmtpm_recv was hanging. > > Resolution: tpm_ibmtpm_recv was hanging because tpm_ibmvtpm_send > was sending CRQ message that probably did not make much sense > to phype because of Endianess. The fix below sends correctly > converted CRQ for LE. This was not caught before because it > seems IMA is not enabled by default in kernel config and > IMA exercises this particular code path in vtpm. > > Tested with IMA and VTPM enabled in kernel config and VTPM > enabled on both a BE OS and a LE OS ppc64 lpar. This exercised > CRQ and TPM command code paths in vtpm. > Patch is against Peter's tpmdd tree on github which included > Vicky's previous vtpm le patches. > > Please let me know if this looks ok. Thanks. > > regards, > Joy > > Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com> > > diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c > index b1e53e3..11fde84 100644 > --- a/drivers/char/tpm/tpm_ibmvtpm.c > +++ b/drivers/char/tpm/tpm_ibmvtpm.c > @@ -124,7 +124,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) > { > struct ibmvtpm_dev *ibmvtpm; > struct ibmvtpm_crq crq; > - u64 *word = (u64 *) &crq; > + __be64 *word = (__be64 *) &crq; > int rc; > > ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip); > @@ -145,11 +145,11 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) > memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); > crq.valid = (u8)IBMVTPM_VALID_CMD; > crq.msg = (u8)VTPM_TPM_COMMAND; > - crq.len = (u16)count; > - crq.data = ibmvtpm->rtce_dma_handle; > + crq.len = cpu_to_be16(count); > + crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle); > > - rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]), > - cpu_to_be64(word[1])); > + rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]), > + be64_to_cpu(word[1])); > if (rc != H_SUCCESS) { > dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); > rc = 0; > diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h > index f595f14..6af9289 100644 > --- a/drivers/char/tpm/tpm_ibmvtpm.h > +++ b/drivers/char/tpm/tpm_ibmvtpm.h > @@ -22,9 +22,9 @@ > struct ibmvtpm_crq { > u8 valid; > u8 msg; > - u16 len; > - u32 data; > - u64 reserved; > + __be16 len; > + __be32 data; > + __be64 reserved; > } __attribute__((packed, aligned(8))); > > struct ibmvtpm_crq_queue { > > > ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/
Hi Joy,
> > Please let me know if this looks ok. Thanks.
thanks for your patch!
I staged it and will send out the pull request shortly.
Only thing that was a bit funny is that patchwork did not filter the
advertisements from the sourceforge mailing list correctly.
https://patchwork.ozlabs.org/patch/442168/
Maybe next time try git-send-email :)
Thanks,
Peter
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c index b1e53e3..11fde84 100644 --- a/drivers/char/tpm/tpm_ibmvtpm.c +++ b/drivers/char/tpm/tpm_ibmvtpm.c @@ -124,7 +124,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) { struct ibmvtpm_dev *ibmvtpm; struct ibmvtpm_crq crq; - u64 *word = (u64 *) &crq; + __be64 *word = (__be64 *) &crq; int rc; ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip); @@ -145,11 +145,11 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); crq.valid = (u8)IBMVTPM_VALID_CMD; crq.msg = (u8)VTPM_TPM_COMMAND; - crq.len = (u16)count; - crq.data = ibmvtpm->rtce_dma_handle; + crq.len = cpu_to_be16(count); + crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle); - rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]), - cpu_to_be64(word[1])); + rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]), + be64_to_cpu(word[1])); if (rc != H_SUCCESS) { dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); rc = 0; diff --git a/drivers/char/tpm/tpm_ibmvtpm.h b/drivers/char/tpm/tpm_ibmvtpm.h index f595f14..6af9289 100644 --- a/drivers/char/tpm/tpm_ibmvtpm.h +++ b/drivers/char/tpm/tpm_ibmvtpm.h @@ -22,9 +22,9 @@ struct ibmvtpm_crq { u8 valid; u8 msg; - u16 len; - u32 data; - u64 reserved; + __be16 len; + __be32 data; + __be64 reserved; } __attribute__((packed, aligned(8))); struct ibmvtpm_crq_queue {
Hi, Problem: When IMA and VTPM are both enabled in kernel config, kernel hangs during bootup on LE OS. Why?: IMA calls tpm_pcr_read() which results in tpm_ibmvtpm_send and tpm_ibmtpm_recv getting called. A trace showed that tpm_ibmtpm_recv was hanging. Resolution: tpm_ibmtpm_recv was hanging because tpm_ibmvtpm_send was sending CRQ message that probably did not make much sense to phype because of Endianess. The fix below sends correctly converted CRQ for LE. This was not caught before because it seems IMA is not enabled by default in kernel config and IMA exercises this particular code path in vtpm. Tested with IMA and VTPM enabled in kernel config and VTPM enabled on both a BE OS and a LE OS ppc64 lpar. This exercised CRQ and TPM command code paths in vtpm. Patch is against Peter's tpmdd tree on github which included Vicky's previous vtpm le patches. Please let me know if this looks ok. Thanks. regards, Joy Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com> ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk