devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ashley Lai <ashley@ashleylai.com>
To: honclo <honclo@imap.linux.ibm.com>
Cc: tpmdd-devel@lists.sourceforge.net, ashley@ashleylai.com,
	PeterHuewe@gmx.de, jmlatten@linux.vnet.ibm.com,
	devicetree@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [tpmdd-devel] [PATCH] Added Little Endian support to vtpm module
Date: Fri, 13 Feb 2015 16:25:30 -0600 (CST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1502131620280.7574@ant> (raw)
In-Reply-To: <525b5ba04c7d86f483ac11404cf15572@imap.linux.ibm.com>

Looks good to me.

Reviewed-by: Ashley Lai <ashley@ahsleylai.com>

Thanks,
--Ashley

On Thu, 12 Feb 2015, honclo wrote:

> The tpm_ibmvtpm module is affected by an unaligned access problem.
> ibmvtpm_crq_get_version failed with rc=-4 during boot when vTPM is
> enabled in Power partition, which supports both little endian and
> big endian modes.
>
> We added little endian support to fix this problem:
> 1) added cpu_to_be64 calls to ensure BE data is sent from an LE OS.
> 2) added be16_to_cpu and be32_to_cpu calls to make sure data received
>   is in LE format on a LE OS.
>
> Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
> Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
> ---
>  drivers/char/tpm/tpm_ibmvtpm.c |   20 ++++++++++++--------
>  1 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_ibmvtpm.c
> b/drivers/char/tpm/tpm_ibmvtpm.c
> index af74c57..1632242 100644
> --- a/drivers/char/tpm/tpm_ibmvtpm.c
> +++ b/drivers/char/tpm/tpm_ibmvtpm.c
> @@ -148,7 +148,8 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip,
> u8 *buf, size_t count)
>  	crq.len = (u16)count;
>  	crq.data = ibmvtpm->rtce_dma_handle;
>
> -	rc = ibmvtpm_send_crq(ibmvtpm->vdev, word[0], word[1]);
> +	rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]),
> +			      cpu_to_be64(word[1]));
>  	if (rc != H_SUCCESS) {
>  		dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc);
>  		rc = 0;
> @@ -186,7 +187,8 @@ static int ibmvtpm_crq_get_rtce_size(struct
> ibmvtpm_dev *ibmvtpm)
>  	crq.valid = (u8)IBMVTPM_VALID_CMD;
>  	crq.msg = (u8)VTPM_GET_RTCE_BUFFER_SIZE;
>
> -	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
> +	rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
> +			      cpu_to_be64(buf[1]));
>  	if (rc != H_SUCCESS)
>  		dev_err(ibmvtpm->dev,
>  			"ibmvtpm_crq_get_rtce_size failed rc=%d\n", rc);
> @@ -212,7 +214,8 @@ static int ibmvtpm_crq_get_version(struct
> ibmvtpm_dev *ibmvtpm)
>  	crq.valid = (u8)IBMVTPM_VALID_CMD;
>  	crq.msg = (u8)VTPM_GET_VERSION;
>
> -	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
> +	rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
> +			      cpu_to_be64(buf[1]));
>  	if (rc != H_SUCCESS)
>  		dev_err(ibmvtpm->dev,
>  			"ibmvtpm_crq_get_version failed rc=%d\n", rc);
> @@ -327,7 +330,8 @@ static int tpm_ibmvtpm_suspend(struct device *dev)
>  	crq.valid = (u8)IBMVTPM_VALID_CMD;
>  	crq.msg = (u8)VTPM_PREPARE_TO_SUSPEND;
>
> -	rc = ibmvtpm_send_crq(ibmvtpm->vdev, buf[0], buf[1]);
> +	rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(buf[0]),
> +			      cpu_to_be64(buf[1]));
>  	if (rc != H_SUCCESS)
>  		dev_err(ibmvtpm->dev,
>  			"tpm_ibmvtpm_suspend failed rc=%d\n", rc);
> @@ -472,11 +476,11 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq
> *crq,
>  	case IBMVTPM_VALID_CMD:
>  		switch (crq->msg) {
>  		case VTPM_GET_RTCE_BUFFER_SIZE_RES:
> -			if (crq->len <= 0) {
> +			if (be16_to_cpu(crq->len) <= 0) {
>  				dev_err(ibmvtpm->dev, "Invalid rtce size\n");
>  				return;
>  			}
> -			ibmvtpm->rtce_size = crq->len;
> +			ibmvtpm->rtce_size = be16_to_cpu(crq->len);
>  			ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size,
>  						    GFP_KERNEL);
>  			if (!ibmvtpm->rtce_buf) {
> @@ -497,11 +501,11 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq
> *crq,
>
>  			return;
>  		case VTPM_GET_VERSION_RES:
> -			ibmvtpm->vtpm_version = crq->data;
> +			ibmvtpm->vtpm_version = be32_to_cpu(crq->data);
>  			return;
>  		case VTPM_TPM_COMMAND_RES:
>  			/* len of the data in rtce buffer */
> -			ibmvtpm->res_len = crq->len;
> +			ibmvtpm->res_len = be16_to_cpu(crq->len);
>  			wake_up_interruptible(&ibmvtpm->wq);
>  			return;
>  		default:
> -- 
> 1.7.1
>
>
> ------------------------------------------------------------------------------
> 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/
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
>

       reply	other threads:[~2015-02-13 22:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <525b5ba04c7d86f483ac11404cf15572@imap.linux.ibm.com>
2015-02-13 22:25 ` Ashley Lai [this message]
     [not found] <b5cb25ed725511cbb675c2dfb5da00f6@imap.linux.ibm.com>
2015-02-12 16:00 ` [tpmdd-devel] [PATCH] Added Little Endian support to vtpm module Ashley Lai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.10.1502131620280.7574@ant \
    --to=ashley@ashleylai.com \
    --cc=PeterHuewe@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=honclo@imap.linux.ibm.com \
    --cc=jmlatten@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).