git: f613a43c3666 - main - tpm20: Correct 32-bit register helpers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 03 Sep 2026 04:03:05 UTC
The branch main has been updated by kbowling:
URL: https://cgit.FreeBSD.org/src/commit/?id=f613a43c366600e8c388c3200f74c6dd27f8a7a2
commit f613a43c366600e8c388c3200f74c6dd27f8a7a2
Author: Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-27 12:48:30 +0000
Commit: Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-03 04:02:41 +0000
tpm20: Correct 32-bit register helpers
OR4() reads only the low byte before writing the complete 32-bit
register. Preserve all register bits by using a matching 32-bit read.
Make BIT() produce an unsigned value so masks containing bit 31 do not
rely on a signed left shift into the sign bit. OpenBSD carries the
same change.
Reviewed by: kevans
MFC after: 2 weeks
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D59244
---
sys/dev/tpm/tpm20.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/dev/tpm/tpm20.h b/sys/dev/tpm/tpm20.h
index 36f41e6b9e0b..1d7a11265b02 100644
--- a/sys/dev/tpm/tpm20.h
+++ b/sys/dev/tpm/tpm20.h
@@ -62,7 +62,7 @@
#include "opt_tpm.h"
#include "tpm_if.h"
-#define BIT(x) (1 << (x))
+#define BIT(x) (1U << (x))
/* Timeouts in us */
#define TPM_TIMEOUT_A 750000
@@ -183,7 +183,7 @@ OR1(struct tpm_sc *sc, bus_size_t off, uint8_t val)
static inline void
OR4(struct tpm_sc *sc, bus_size_t off, uint32_t val)
{
- uint32_t v = TPM_READ_1(sc->dev, off);
+ uint32_t v = TPM_READ_4(sc->dev, off);
TPM_WRITE_4(sc->dev, off, v | val);
}