From: Stefan Berger <stefanb@linux.ibm.com>
To: dan tan <dantan@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, stefanb@linux.vnet.ibm.com,
pbonzini@redhat.com, farosas@suse.de, lvivier@redhat.com,
clg@kaod.org, dantan@linux.ibm.com
Subject: Re: [PATCH v6 1/3] tpm/tpm_tis_spi: Support TPM for SPI (Serial Peripheral Interface)
Date: Fri, 8 Nov 2024 10:38:00 -0500 [thread overview]
Message-ID: <c54deb74-b5b4-44f2-bc6b-b514ac0a2356@linux.ibm.com> (raw)
In-Reply-To: <20241104171815.13853-2-dantan@linux.vnet.ibm.com>
On 11/4/24 12:18 PM, dan tan wrote:
> Implement support for TPM via SPI interface. The SPI bus master
> is provided by PowerNV SPI device which is an SSI peripheral.
> It can uses the tpm_emulator driver backend with the external
> swtpm.
>
> Signed-off-by: dan tan <dantan@linux.ibm.com>
> ---
>
> diff --git a/hw/tpm/tpm_tis_spi.c b/hw/tpm/tpm_tis_spi.c
> new file mode 100644
> index 0000000000..079972de03
> --- /dev/null
> +++ b/hw/tpm/tpm_tis_spi.c
> @@ -0,0 +1,357 @@
> +/*
> + * QEMU SPI TPM 2.0 model
> + *
> + * Copyright (c) 2024, IBM Corporation.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/log.h"
> +#include "hw/sysbus.h"
> +#include "hw/acpi/tpm.h"
> +#include "tpm_prop.h"
> +#include "qemu/log.h"
> +#include "trace.h"
> +#include "tpm_tis.h"
> +#include "hw/ssi/ssi.h"
> +#include "migration/vmstate.h"
> +
> +typedef struct TPMStateSPI {
> + /*< private >*/
> + SSIPeripheral parent_object;
> +
> + uint8_t byte_offset; /* byte offset in transfer */
> + uint8_t wait_state_cnt; /* wait state counter */
#define NUM_WAIT_STATES 1
Are 4 wait states actually needed? I ran the test with 1. More wait
states just have impact on performance and I don't think we need to be
emulating the real hardware entirely.
@@ -236,9 +237,9 @@ static uint32_t tpm_tis_spi_transfer(SSIPeripheral
*ss, uint32_t tx)
trace_tpm_tis_spi_transfer_addr("reg_addr", spist->reg_addr);
break;
default: /* data bytes */
- if (spist->wait_state_cnt < 4) {
+ if (spist->wait_state_cnt < NUM_WAIT_STATES) {
spist->wait_state_cnt++;
- if (spist->wait_state_cnt == 4) {
+ if (spist->wait_state_cnt == NUM_WAIT_STATES) {
trace_tpm_tis_spi_transfer_data("wait complete,
count",
spist->wait_state_cnt);
rx = rx | (0x01 << (24 - offset * 8));
@@ -274,7 +275,8 @@ static uint32_t tpm_tis_spi_transfer(SSIPeripheral
*ss, uint32_t tx)
}
break;
}
- if ((spist->wait_state_cnt == 0) || (spist->wait_state_cnt == 4)) {
+ if ((spist->wait_state_cnt == 0) ||
+ (spist->wait_state_cnt == NUM_WAIT_STATES)) {
offset++;
spist->byte_offset++;
} else {
next prev parent reply other threads:[~2024-11-08 15:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 17:18 [PATCH v6 0/3] TPM TIS SPI Support dan tan
2024-11-04 17:18 ` [PATCH v6 1/3] tpm/tpm_tis_spi: Support TPM for SPI (Serial Peripheral Interface) dan tan
2024-11-08 15:38 ` Stefan Berger [this message]
2024-11-08 15:47 ` dan tan
2024-11-04 17:18 ` [PATCH v6 2/3] tpm/tpm_tis_spi: activation for the PowerNV machines dan tan
2024-11-04 17:18 ` [PATCH v6 3/3] tests/qtest/tpm: add unit test to tis-spi dan tan
2024-11-04 19:29 ` [PATCH v6 0/3] TPM TIS SPI Support Stefan Berger
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=c54deb74-b5b4-44f2-bc6b-b514ac0a2356@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=clg@kaod.org \
--cc=dantan@linux.ibm.com \
--cc=dantan@linux.vnet.ibm.com \
--cc=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/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).