* [PATCH 0/2] tpm: Fix MMIO TIS reg size parsing and absent-device detection
@ 2026-12-03 2:20 Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 1/2] tpm: tpm2_tis_mmio: Read reg size via dev_read_addr_size_index() Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 2/2] tpm: tpm2_tis_core: Reject 0xff TPM_ACCESS and invalid DID/VID Dan Holmes-Mitra
0 siblings, 2 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03 2:20 UTC (permalink / raw)
To: u-boot; +Cc: Ilias Apalodimas, Tom Rini
Two small fixes for the TPM 2.0 TIS MMIO probe path:
1. tpm2_tis_mmio: Use dev_read_addr_size_index(dev, 0, &sz) instead of
dev_read_u64(dev, "reg", &sz), which read the base address as the
region size or failed on 32-bit #address-cells/#size-cells DT nodes.
2. tpm2_tis_core: Require status != 0xff in tpm_tis_wait_init() so
unpopulated MMIO reads (all-ones, which has TPM_ACCESS_VALID set) do
not falsely pass init, and reject 0xffffffff / 0x00000000 TPM_DID_VID
values with -ENODEV after releasing locality.
Tested:
- Built qemu_arm64_defconfig with CONFIG_TPM_V2=y, CONFIG_TPM2_TIS_MMIO=y.
- Checked with scripts/checkpatch.pl --strict --u-boot (0 errors, 0 warnings).
Dan Holmes-Mitra (2):
tpm: tpm2_tis_mmio: Read reg size via dev_read_addr_size_index()
tpm: tpm2_tis_core: Reject 0xff TPM_ACCESS and invalid DID/VID
drivers/tpm/tpm2_tis_core.c | 6 +++++-
drivers/tpm/tpm2_tis_mmio.c | 10 +++-------
2 files changed, 8 insertions(+), 8 deletions(-)
base-commit: d1caced3a435607435cb7969e34499051a4ac1e6
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] tpm: tpm2_tis_mmio: Read reg size via dev_read_addr_size_index()
2026-12-03 2:20 [PATCH 0/2] tpm: Fix MMIO TIS reg size parsing and absent-device detection Dan Holmes-Mitra
@ 2026-12-03 2:20 ` Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 2/2] tpm: tpm2_tis_core: Reject 0xff TPM_ACCESS and invalid DID/VID Dan Holmes-Mitra
1 sibling, 0 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03 2:20 UTC (permalink / raw)
To: u-boot; +Cc: Ilias Apalodimas, Tom Rini
tpm_tis_probe() previously called dev_read_u64(dev, "reg", &sz), which
reads the first 64 bits of the reg property (the base address rather
than the size) or fails outright on 32-bit #address-cells/#size-cells
device-tree nodes.
Use dev_read_addr_size_index(dev, 0, &sz) so both base address and
region size are parsed according to the parent bus cell widths, and
reject zero-sized regions.
Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
drivers/tpm/tpm2_tis_mmio.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/tpm/tpm2_tis_mmio.c b/drivers/tpm/tpm2_tis_mmio.c
index fc62dcda9e..5c53f33b03 100644
--- a/drivers/tpm/tpm2_tis_mmio.c
+++ b/drivers/tpm/tpm2_tis_mmio.c
@@ -83,16 +83,12 @@ static int tpm_tis_probe(struct udevice *dev)
struct tpm_chip_priv *priv = dev_get_uclass_priv(dev);
int ret = 0;
fdt_addr_t ioaddr;
- u64 sz;
+ fdt_size_t sz;
- ioaddr = dev_read_addr(dev);
- if (ioaddr == FDT_ADDR_T_NONE)
+ ioaddr = dev_read_addr_size_index(dev, 0, &sz);
+ if (ioaddr == FDT_ADDR_T_NONE || !sz)
return log_msg_ret("ioaddr", -EINVAL);
- ret = dev_read_u64(dev, "reg", &sz);
- if (ret)
- return -EINVAL;
-
drv_data->iobase = ioremap(ioaddr, sz);
tpm_tis_ops_register(dev, &phy_ops);
ret = tpm_tis_init(dev);
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] tpm: tpm2_tis_core: Reject 0xff TPM_ACCESS and invalid DID/VID
2026-12-03 2:20 [PATCH 0/2] tpm: Fix MMIO TIS reg size parsing and absent-device detection Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 1/2] tpm: tpm2_tis_mmio: Read reg size via dev_read_addr_size_index() Dan Holmes-Mitra
@ 2026-12-03 2:20 ` Dan Holmes-Mitra
1 sibling, 0 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03 2:20 UTC (permalink / raw)
To: u-boot; +Cc: Ilias Apalodimas, Tom Rini
When an MMIO TIS TPM is absent, unpopulated reads return 0xff, which has
bit 7 (TPM_ACCESS_VALID) set and caused tpm_tis_wait_init() to falsely
report success. Requiring status != 0xff in tpm_tis_wait_init() avoids
false positives on floating MMIO buses while still polling cold-boot SPI
TPMs until ready.
Also reject all-ones or all-zeroes TPM_DID_VID readings in
tpm_tis_init() with -ENODEV after releasing the locality.
Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
drivers/tpm/tpm2_tis_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tpm/tpm2_tis_core.c b/drivers/tpm/tpm2_tis_core.c
index 1fdf8cfa31..f37ed0cdee 100644
--- a/drivers/tpm/tpm2_tis_core.c
+++ b/drivers/tpm/tpm2_tis_core.c
@@ -434,7 +434,7 @@ static int tpm_tis_wait_init(struct udevice *dev, int loc)
if (ret)
break;
- if (status & TPM_ACCESS_VALID)
+ if (status != 0xff && (status & TPM_ACCESS_VALID))
return 0;
} while (get_timer(start) < stop);
@@ -477,6 +477,10 @@ int tpm_tis_init(struct udevice *dev)
phy_ops->read_bytes(dev, TPM_RID(chip->locality), 1, &chip->rid);
phy_ops->read32(dev, TPM_DID_VID(chip->locality), &chip->vend_dev);
+ if (chip->vend_dev == 0xffffffffU || chip->vend_dev == 0x00000000U) {
+ tpm_tis_release_locality(dev, chip->locality);
+ return -ENODEV;
+ }
return tpm_tis_release_locality(dev, chip->locality);
}
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 5:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 2:20 [PATCH 0/2] tpm: Fix MMIO TIS reg size parsing and absent-device detection Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 1/2] tpm: tpm2_tis_mmio: Read reg size via dev_read_addr_size_index() Dan Holmes-Mitra
2026-12-03 2:20 ` [PATCH 2/2] tpm: tpm2_tis_core: Reject 0xff TPM_ACCESS and invalid DID/VID Dan Holmes-Mitra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.