qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Ninad Palsule" <ninad@linux.ibm.com>,
	qemu-devel@nongnu.org
Cc: joel@jms.id.au, andrew@aj.id.au
Subject: Re: [PATCH v3 3/3] New I2C: Add support for TPM devices over I2C bus
Date: Fri, 24 Mar 2023 09:43:28 -0400	[thread overview]
Message-ID: <0b2e37e7-1c0a-84b7-f717-e309d278023d@linux.ibm.com> (raw)
In-Reply-To: <90d1dcd4-c5b8-566d-325b-5a550e25a1cc@kaod.org>



On 3/24/23 04:24, Cédric Le Goater wrote:
> Hello Ninad,
> 

>> +
>> +/*
>> + * Convert little endian byte stream into local formated
>> + * unsigned integer
>> + */
>> +static inline uint32_t tpm_i2c_le_bytes_to_uint(TPMStateI2C *i2cst)
>> +{
>> +    uint32_t data = 0;
>> +    int      i;
>> +
>> +    assert(i2cst->offset <= 5);  /* Including 0th register value */
>> +
>> +    if (tpm_i2c_is_little_endian()) {
>> +        for (i = 1; i < i2cst->offset; i++) {
>> +            data |= (((uint32_t)i2cst->data[i]) << (8 * (i - 1)));
>> +        }
>> +    } else {
>> +        for (i = 1; i < i2cst->offset; i++) {
>> +            data <<= 8;
>> +            data |= i2cst->data[i];
>> +        }
>> +    }
>> +
>> +    return data;
>> +}
> 
> Why is this endianess test  needed ? Something looks wrong.
> 
> Could you please explain the endianess used by the various devices and
> the endianness of the MMIO ops ?
> 
> If you want to test on a BE host, simply install a debian PPC64 VM/LPAR
> on a POWER9/10 box. I suppose you have access to one in IBM.

I found it's not that simple anymore since all distros moved to little endian. I have been using Fedora 28 for big endian tests for swtpm but I have never tried it with QEMU...

    Stefan


  reply	other threads:[~2023-03-24 15:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  3:02 [PATCH v3 0/3] Add support for TPM devices over I2C bus Ninad Palsule
2023-03-24  3:02 ` [PATCH v3 1/3] docs: " Ninad Palsule
2023-03-24  3:02 ` [PATCH v3 2/3] TPM TIS: " Ninad Palsule
2023-03-24 14:26   ` Stefan Berger
2023-03-24 14:36     ` Ninad Palsule
2023-03-24  3:02 ` [PATCH v3 3/3] New I2C: " Ninad Palsule
2023-03-24  8:24   ` Cédric Le Goater
2023-03-24 13:43     ` Stefan Berger [this message]
2023-03-24 19:42       ` Stefan Berger
2023-03-24 18:22     ` Ninad Palsule
2023-03-24 14:19   ` Stefan Berger
2023-03-24 18:17     ` Ninad Palsule

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=0b2e37e7-1c0a-84b7-f717-e309d278023d@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=ninad@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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).