* [PATCH 04/12] crypto: atmel-ecc - simplify probe error handling
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
In-Reply-To: <20260517180639.9657-1-l.rubusch@gmail.com>
Replace early return in atmel_ecc_probe() with explicit error handling
using a goto-based cleanup path.
Add comments to clarify client list insertion and algorithm registration
steps.
No functional change intended.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/crypto/atmel-ecc.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 76fb1d0cf075..696ab1d51fc6 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -328,17 +328,20 @@ static int atmel_ecc_probe(struct i2c_client *client)
ret = crypto_register_kpp(&atmel_ecdh_nist_p256);
if (ret) {
- spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
- list_del(&i2c_priv->i2c_client_list_node);
- spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
-
dev_err(&client->dev, "%s alg registration failed\n",
atmel_ecdh_nist_p256.base.cra_driver_name);
+ goto err_list_del;
} else {
dev_info(&client->dev, "atmel ecc algorithms registered in /proc/crypto\n");
}
return ret;
+
+err_list_del:
+ spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
+ list_del(&i2c_priv->i2c_client_list_node);
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
+ return ret;
}
static void atmel_ecc_remove(struct i2c_client *client)
--
2.53.0
^ permalink raw reply related
* [PATCH 03/12] crypto: atmel - move i2c client management instance into core driver
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
In-Reply-To: <20260517180639.9657-1-l.rubusch@gmail.com>
Move the atmel_i2c client management instance from the ECC driver into the
atmel-i2c core driver.
This is a preparatory step for consolidating shared I2C client tracking
infrastructure in the core, allowing ECC and SHA204A drivers to operate on
a common management instance.
The symbol is exported via EXPORT_SYMBOL_GPL() and declared extern in the
shared header.
No functional change intended.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/crypto/atmel-ecc.c | 2 --
drivers/crypto/atmel-i2c.c | 6 ++++++
drivers/crypto/atmel-i2c.h | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 9feae468b7ff..76fb1d0cf075 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -23,8 +23,6 @@
#include <crypto/kpp.h>
#include "atmel-i2c.h"
-static struct atmel_i2c_client_mgmt atmel_i2c_mgmt;
-
/**
* struct atmel_ecdh_ctx - transformation context
* @client : pointer to i2c client device
diff --git a/drivers/crypto/atmel-i2c.c b/drivers/crypto/atmel-i2c.c
index 0e275dbdc8c5..db24f65ae90e 100644
--- a/drivers/crypto/atmel-i2c.c
+++ b/drivers/crypto/atmel-i2c.c
@@ -21,6 +21,12 @@
#include <linux/workqueue.h>
#include "atmel-i2c.h"
+struct atmel_i2c_client_mgmt atmel_i2c_mgmt = {
+ .i2c_list_lock = __SPIN_LOCK_UNLOCKED(atmel_i2c_mgmt.i2c_list_lock),
+ .i2c_client_list = LIST_HEAD_INIT(atmel_i2c_mgmt.i2c_client_list),
+};
+EXPORT_SYMBOL_GPL(atmel_i2c_mgmt);
+
static const struct {
u8 value;
const char *error_text;
diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h
index 98a79dcae2b6..a3385e8f0dc9 100644
--- a/drivers/crypto/atmel-i2c.h
+++ b/drivers/crypto/atmel-i2c.h
@@ -119,6 +119,7 @@ struct atmel_i2c_client_mgmt {
struct list_head i2c_client_list;
spinlock_t i2c_list_lock;
} ____cacheline_aligned;
+extern struct atmel_i2c_client_mgmt atmel_i2c_mgmt;
/**
* atmel_i2c_client_priv - i2c_client private data
--
2.53.0
^ permalink raw reply related
* [PATCH 02/12] crypto: atmel - rename atmel_ecc_driver_data to atmel_i2c_client_mgmt
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
In-Reply-To: <20260517180639.9657-1-l.rubusch@gmail.com>
Rename struct atmel_ecc_driver_data to atmel_i2c_client_mgmt to reflect its
generic role in shared I2C client tracking and locking.
A subsequent change will move the client management infrastructure into the
atmel-i2c core driver.
No functional changes intended.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/crypto/atmel-ecc.c | 2 +-
drivers/crypto/atmel-i2c.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index c9f798ebf44f..9feae468b7ff 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -23,7 +23,7 @@
#include <crypto/kpp.h>
#include "atmel-i2c.h"
-static struct atmel_ecc_driver_data atmel_i2c_mgmt;
+static struct atmel_i2c_client_mgmt atmel_i2c_mgmt;
/**
* struct atmel_ecdh_ctx - transformation context
diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h
index 72f04c15682f..98a79dcae2b6 100644
--- a/drivers/crypto/atmel-i2c.h
+++ b/drivers/crypto/atmel-i2c.h
@@ -115,7 +115,7 @@ struct atmel_i2c_cmd {
#define ECDH_PREFIX_MODE 0x00
/* Used for binding tfm objects to i2c clients. */
-struct atmel_ecc_driver_data {
+struct atmel_i2c_client_mgmt {
struct list_head i2c_client_list;
spinlock_t i2c_list_lock;
} ____cacheline_aligned;
--
2.53.0
^ permalink raw reply related
* [PATCH 01/12] crypto: atmel-ecc - rename driver_data before moving it into atmel-i2c
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
In-Reply-To: <20260517180639.9657-1-l.rubusch@gmail.com>
Rename the local driver_data instance to atmel_i2c_mgmt in
preparation for moving the shared I2C client management
infrastructure into the atmel-i2c core driver in a subsequent
change.
No functional changes intended.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/crypto/atmel-ecc.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 9660f6426a84..c9f798ebf44f 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -23,7 +23,7 @@
#include <crypto/kpp.h>
#include "atmel-i2c.h"
-static struct atmel_ecc_driver_data driver_data;
+static struct atmel_ecc_driver_data atmel_i2c_mgmt;
/**
* struct atmel_ecdh_ctx - transformation context
@@ -209,14 +209,14 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void)
int min_tfm_cnt = INT_MAX;
int tfm_cnt;
- spin_lock(&driver_data.i2c_list_lock);
+ spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
- if (list_empty(&driver_data.i2c_client_list)) {
- spin_unlock(&driver_data.i2c_list_lock);
+ if (list_empty(&atmel_i2c_mgmt.i2c_client_list)) {
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
return ERR_PTR(-ENODEV);
}
- list_for_each_entry(i2c_priv, &driver_data.i2c_client_list,
+ list_for_each_entry(i2c_priv, &atmel_i2c_mgmt.i2c_client_list,
i2c_client_list_node) {
tfm_cnt = atomic_read(&i2c_priv->tfm_count);
if (tfm_cnt < min_tfm_cnt) {
@@ -232,7 +232,7 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void)
client = min_i2c_priv->client;
}
- spin_unlock(&driver_data.i2c_list_lock);
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
return client;
}
@@ -323,16 +323,16 @@ static int atmel_ecc_probe(struct i2c_client *client)
i2c_priv = i2c_get_clientdata(client);
- spin_lock(&driver_data.i2c_list_lock);
+ spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
list_add_tail(&i2c_priv->i2c_client_list_node,
- &driver_data.i2c_client_list);
- spin_unlock(&driver_data.i2c_list_lock);
+ &atmel_i2c_mgmt.i2c_client_list);
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
ret = crypto_register_kpp(&atmel_ecdh_nist_p256);
if (ret) {
- spin_lock(&driver_data.i2c_list_lock);
+ spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
list_del(&i2c_priv->i2c_client_list_node);
- spin_unlock(&driver_data.i2c_list_lock);
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
dev_err(&client->dev, "%s alg registration failed\n",
atmel_ecdh_nist_p256.base.cra_driver_name);
@@ -363,9 +363,9 @@ static void atmel_ecc_remove(struct i2c_client *client)
crypto_unregister_kpp(&atmel_ecdh_nist_p256);
- spin_lock(&driver_data.i2c_list_lock);
+ spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
list_del(&i2c_priv->i2c_client_list_node);
- spin_unlock(&driver_data.i2c_list_lock);
+ spin_unlock(&atmel_i2c_mgmt.i2c_list_lock);
}
static const struct of_device_id atmel_ecc_dt_ids[] = {
@@ -394,8 +394,8 @@ static struct i2c_driver atmel_ecc_driver = {
static int __init atmel_ecc_init(void)
{
- spin_lock_init(&driver_data.i2c_list_lock);
- INIT_LIST_HEAD(&driver_data.i2c_client_list);
+ spin_lock_init(&atmel_i2c_mgmt.i2c_list_lock);
+ INIT_LIST_HEAD(&atmel_i2c_mgmt.i2c_client_list);
return i2c_add_driver(&atmel_ecc_driver);
}
--
2.53.0
^ permalink raw reply related
* [PATCH] crypto: atmel - add capability-based I2C client selection
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
In-Reply-To: <20260517180639.9657-1-l.rubusch@gmail.com>
Add capability filtering to the I2C client allocator to support
feature-aware selection of hardware clients.
Each client now exposes supported features via a capability mask. The
allocator selects only clients matching the requested capability and still
prefers the least-loaded device.
ECC marks ECDH support during probe and requests matching clients during
tfm setup. SHA204A exposes no capabilities for now.
This is preparatory work for upcoming features that will extend hardware
usage beyond a single algorithm type.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/crypto/atmel-ecc.c | 4 +++-
drivers/crypto/atmel-i2c.c | 5 ++++-
drivers/crypto/atmel-i2c.h | 8 +++++++-
drivers/crypto/atmel-sha204a.c | 2 ++
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index f877f236552f..0eeee9ae6c48 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -214,7 +214,7 @@ static int atmel_ecdh_init_tfm(struct crypto_kpp *tfm)
struct atmel_ecdh_ctx *ctx = kpp_tfm_ctx(tfm);
ctx->curve_id = ECC_CURVE_NIST_P256;
- ctx->client = atmel_i2c_client_alloc();
+ ctx->client = atmel_i2c_client_alloc(ATMEL_CAP_ECDH);
if (IS_ERR(ctx->client)) {
pr_err("tfm - i2c_client binding failed\n");
return PTR_ERR(ctx->client);
@@ -286,6 +286,8 @@ static int atmel_ecc_probe(struct i2c_client *client)
i2c_priv = i2c_get_clientdata(client);
+ i2c_priv->caps = BIT(ATMEL_CAP_ECDH);
+
spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
list_add_tail(&i2c_priv->i2c_client_list_node,
&atmel_i2c_mgmt.i2c_client_list);
diff --git a/drivers/crypto/atmel-i2c.c b/drivers/crypto/atmel-i2c.c
index 4beab68997c4..b7ee2ec37531 100644
--- a/drivers/crypto/atmel-i2c.c
+++ b/drivers/crypto/atmel-i2c.c
@@ -57,7 +57,7 @@ static void atmel_i2c_checksum(struct atmel_i2c_cmd *cmd)
*__crc16 = cpu_to_le16(bitrev16(crc16(0, data, len)));
}
-struct i2c_client *atmel_i2c_client_alloc(void)
+struct i2c_client *atmel_i2c_client_alloc(enum atmel_i2c_capability cap)
{
struct atmel_i2c_client_priv *i2c_priv, *min_i2c_priv = NULL;
struct i2c_client *client = ERR_PTR(-ENODEV);
@@ -73,6 +73,9 @@ struct i2c_client *atmel_i2c_client_alloc(void)
list_for_each_entry(i2c_priv, &atmel_i2c_mgmt.i2c_client_list,
i2c_client_list_node) {
+ if (!(i2c_priv->caps & BIT(cap)))
+ continue;
+
tfm_cnt = atomic_read(&i2c_priv->tfm_count);
if (tfm_cnt < min_tfm_cnt) {
min_tfm_cnt = tfm_cnt;
diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h
index ba5a860011c8..70579b438256 100644
--- a/drivers/crypto/atmel-i2c.h
+++ b/drivers/crypto/atmel-i2c.h
@@ -115,6 +115,10 @@ struct atmel_i2c_cmd {
#define ECDH_PREFIX_MODE 0x00
/* Used for binding tfm objects to i2c clients. */
+enum atmel_i2c_capability {
+ ATMEL_CAP_ECDH = 0,
+};
+
struct atmel_i2c_client_mgmt {
struct list_head i2c_client_list;
spinlock_t i2c_list_lock;
@@ -130,6 +134,7 @@ extern struct atmel_i2c_client_mgmt atmel_i2c_mgmt;
* @wake_token_sz : size in bytes of the wake_token
* @tfm_count : number of active crypto transformations on i2c client
* @hwrng : hold the hardware generated rng
+ * @caps : feature capability of the particular driver
*
* Reads and writes from/to the i2c client are sequential. The first byte
* transmitted to the device is treated as the byte size. Any attempt to send
@@ -146,6 +151,7 @@ struct atmel_i2c_client_priv {
size_t wake_token_sz;
atomic_t tfm_count ____cacheline_aligned;
struct hwrng hwrng;
+ u32 caps;
};
/**
@@ -190,7 +196,7 @@ void atmel_i2c_init_genkey_cmd(struct atmel_i2c_cmd *cmd, u16 keyid);
int atmel_i2c_init_ecdh_cmd(struct atmel_i2c_cmd *cmd,
struct scatterlist *pubkey);
-struct i2c_client *atmel_i2c_client_alloc(void);
+struct i2c_client *atmel_i2c_client_alloc(enum atmel_i2c_capability cap);
void atmel_i2c_unregister_client(struct atmel_i2c_client_priv *i2c_priv);
#endif /* __ATMEL_I2C_H__ */
diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index 923e462ff6b0..1a28c6434669 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -173,6 +173,8 @@ static int atmel_sha204a_probe(struct i2c_client *client)
i2c_priv = i2c_get_clientdata(client);
+ i2c_priv->caps = 0;
+
/* add to client list */
spin_lock(&atmel_i2c_mgmt.i2c_list_lock);
list_add_tail(&i2c_priv->i2c_client_list_node,
--
2.53.0
^ permalink raw reply related
* [PATCH 00/12] crypto: atmel - introduce shared i2c core client management and capability-based selection framework
From: Lothar Rubusch @ 2026-05-17 18:06 UTC (permalink / raw)
To: thorsten.blum, herbert, davem, nicolas.ferre, alexandre.belloni,
claudiu.beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel, l.rubusch
This patch series introduces a staged refactoring of the Atmel crypto I2C
drivers in preparation for a shared core-based architecture. The goal is to
consolidate I2C client management and selection logic into a common
atmel-i2c core driver while keeping ECC (ECDH) and SHA204A client drivers
functionally separate but interoperating through shared infrastructure.
The series moves existing ECC-specific client tracking into a shared
management structure, relocates allocation and selection logic, and
introduces capability-based filtering for hardware selection. This allows
individual crypto drivers to request hardware clients based on supported
features while still benefiting from a unified least-loaded selection
strategy.
Subsequent patches extend this base by:
- migrating client management fully into the core driver,
- introducing explicit capability advertisement by each hardware client,
- updating ECC and SHA204A drivers to participate in capability-aware allocation,
- and cleaning up probe/remove paths to ensure consistent lifecycle handling.
No functional behavioral changes are intended at this stage beyond internal
refactoring and preparation for future feature expansion. The series is
designed to preserve existing crypto functionality while gradually
centralizing shared logic in the atmel-i2c core layer, reducing duplication
and improving maintainability across all Atmel crypto drivers.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
Lothar Rubusch (12):
crypto: atmel-ecc - rename driver_data before moving it into atmel-i2c
crypto: atmel - rename atmel_ecc_driver_data to atmel_i2c_client_mgmt
crypto: atmel - move i2c client management instance into core driver
crypto: atmel-ecc - simplify probe error handling
crypto: atmel - factor out i2c client unregistration helper
crypto: atmel-sha204a - add i2c hw client list and improve probe error
handling
crypto: atmel-sha204a - switch to module_i2c_driver
crypto: atmel-ecc - switch to module_i2c_driver
crypto: atmel-ecc - simplify remove path and relax busy handling
crypto: atmel-sha204a - guard remove path against missing client data
crypto: atmel - move i2c client selection to core driver
crypto: atmel - add capability-based I2C client selection
drivers/crypto/atmel-ecc.c | 98 ++++++++--------------------------
drivers/crypto/atmel-i2c.c | 54 +++++++++++++++++++
drivers/crypto/atmel-i2c.h | 12 ++++-
drivers/crypto/atmel-sha204a.c | 44 +++++++++------
4 files changed, 115 insertions(+), 93 deletions(-)
base-commit: 6c9dddeb582fde005360f4fe02c760d45ca05fb5
--
2.53.0
^ permalink raw reply
* [PATCH] crypto: atmel-sha204a - fail on hwrng registration error in probe path
From: Thorsten Blum @ 2026-05-17 16:27 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, Lothar Rubusch
Cc: stable, linux-crypto, linux-arm-kernel, linux-kernel
Commit 13909a0c8897 ("crypto: atmel-sha204a - provide the otp content")
overwrote the hwrng registration return value when creating the sysfs
group, which allowed atmel_sha204a_probe() to succeed even if
devm_hwrng_register() failed.
Return immediately when devm_hwrng_register() fails, and report both
hwrng and sysfs registration errors with dev_err(). Adjust the sysfs
error log message for consistency.
Fixes: 13909a0c8897 ("crypto: atmel-sha204a - provide the otp content")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-sha204a.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index 37538b0fd7c2..12eb85b57380 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -183,12 +183,14 @@ static int atmel_sha204a_probe(struct i2c_client *client)
i2c_priv->hwrng.quality = *quality;
ret = devm_hwrng_register(&client->dev, &i2c_priv->hwrng);
- if (ret)
- dev_warn(&client->dev, "failed to register RNG (%d)\n", ret);
+ if (ret) {
+ dev_err(&client->dev, "failed to register RNG (%d)\n", ret);
+ return ret;
+ }
ret = sysfs_create_group(&client->dev.kobj, &atmel_sha204a_groups);
if (ret) {
- dev_err(&client->dev, "failed to register sysfs entry\n");
+ dev_err(&client->dev, "failed to create sysfs group (%d)\n", ret);
return ret;
}
^ permalink raw reply related
* [PATCH] crypto: atmel-sha204a - remove sysfs group before hwrng
From: Thorsten Blum @ 2026-05-17 12:37 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel
atmel_sha204a_probe() registers the hwrng before creating the sysfs
group. Mirror this order in atmel_sha204a_remove() by removing the sysfs
group before unregistering the hwrng.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-sha204a.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index 6e6ac4770416..37538b0fd7c2 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -199,11 +199,10 @@ static void atmel_sha204a_remove(struct i2c_client *client)
{
struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);
+ sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups);
devm_hwrng_unregister(&client->dev, &i2c_priv->hwrng);
atmel_i2c_flush_queue();
- sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups);
-
kfree((void *)i2c_priv->hwrng.priv);
}
^ permalink raw reply related
* [PATCH v8] crypto: qce - Add runtime PM and interconnect bandwidth scaling support
From: Udit Tiwari @ 2026-05-17 10:52 UTC (permalink / raw)
To: konrad.dybcio, herbert, thara.gopinath, davem
Cc: linux-crypto, linux-arm-msm, linux-kernel, quic_neersoni,
udit.tiwari
The Qualcomm Crypto Engine (QCE) driver currently lacks support for
runtime power management (PM) and interconnect bandwidth control.
As a result, the hardware remains fully powered and clocks stay
enabled even when the device is idle. Additionally, static
interconnect bandwidth votes are held indefinitely, preventing the
system from reclaiming unused bandwidth.
Address this by enabling runtime PM and dynamic interconnect
bandwidth scaling to allow the system to suspend the device when idle
and scale interconnect usage based on actual demand. Improve overall
system efficiency by reducing power usage and optimizing interconnect
resource allocation.
Signed-off-by: Udit Tiwari <udit.tiwari@oss.qualcomm.com>
---
Tested:
- Verify that ICC votes drop to zero after probe and upon request
completion.
- Confirm that runtime PM usage count increments during active
requests and decrements afterward.
- Observe that the device correctly enters the suspended state when
idle.
Changes in v8:
- Drop pm_clk framework (devm_pm_clk_create/pm_clk_add/pm_clk_suspend/
pm_clk_resume); use devm_clk_get_optional() and direct
clk_prepare_enable()/clk_disable_unprepare() in runtime PM callbacks.
This removes the CONFIG_PM_CLK dependency and the build error reported
by the kernel test robot.
- Replace icc_disable() with icc_set_bw(path, 0, 0) in runtime suspend
to avoid corrupting the internal 'enabled' flag, which would cause
subsequent icc_set_bw() calls in resume to be silently skipped during
aggregation.
- Fix ICC vote ordering: cast bandwidth vote before enabling clocks in
resume; disable clocks before dropping ICC vote in suspend.
- Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND()/PM_RUNTIME_ACQUIRE_ERR() wrapper
macros instead of raw ACQUIRE() in both qce_handle_queue() and probe.
- Drop __maybe_unused from runtime PM callbacks; use RUNTIME_PM_OPS /
SYSTEM_SLEEP_PM_OPS (non-SET_ prefix) and pm_ptr(&qce_crypto_pm_ops).
- Drop unnecessary ret = 0 initializations in qce_handle_queue() and
qce_runtime_resume().
- Extend probe comment to explain ICC + clock ordering rationale.
- Link to v7:
https://lore.kernel.org/lkml/20260220072818.2921517-1-quic_utiwari@quicinc.com/
Changes in v7:
- Use ACQUIRE guard in probe to simplify runtime PM management and error
paths.
- Drop redundant icc_enable() call in runtime resume path.
- Explicitly call pm_clk_suspend(dev) and pm_clk_resume(dev) within the
custom runtime PM callbacks. Since custom callbacks are provided to
handle interconnect scaling, the standard PM clock helpers must be
invoked manually to ensure clocks are gated/ungated.
- Link to v6:
https://lore.kernel.org/lkml/20260210061437.2293654-1-quic_utiwari@quicinc.com/
Changes in v6:
- Adopt ACQUIRE(pm_runtime_active_try, ...) for scoped runtime PM
management in qce_handle_queue(). This removes the need for manual
put calls and goto labels in the error paths, as suggested by Konrad.
- Link to v5:
https://lore.kernel.org/lkml/20251120062443.2016084-1-quic_utiwari@quicinc.com/
Changes in v5:
- Drop Reported-by and Closes tags for kernel test robot W=1 warnings,
as the issue was fixed within the same patch series.
- Fix a minor comment indentation/style issue.
- Link to v4:
https://lore.kernel.org/lkml/20251117062737.3946074-1-quic_utiwari@quicinc.com/
Changes in v4:
- Annotate runtime PM callbacks with __maybe_unused to silence W=1
warnings.
- Add Reported-by and Closes tags for kernel test robot warning.
- Link to v3:
https://lore.kernel.org/lkml/20251115084851.2750446-1-quic_utiwari@quicinc.com/
Changes in v3:
- Switch from manual clock management to PM clock helpers
(devm_pm_clk_create() + pm_clk_add()); no direct clk_* enable/disable
in runtime callbacks.
- Replace pm_runtime_get_sync() with pm_runtime_resume_and_get(); remove
pm_runtime_put_noidle() on error.
- Define PM ops using helper macros and reuse runtime callbacks for
system sleep via pm_runtime_force_suspend()/pm_runtime_force_resume().
- Link to v2:
https://lore.kernel.org/lkml/20250826110917.3383061-1-quic_utiwari@quicinc.com/
Changes in v2:
- Extend suspend/resume support to include runtime PM and ICC scaling.
- Register dev_pm_ops and implement runtime_suspend/resume callbacks.
- Link to v1:
https://lore.kernel.org/lkml/20250606105808.2119280-1-quic_utiwari@quicinc.com/
---
drivers/crypto/qce/core.c | 99 ++++++++++++++++++++++++++++++++++++---
1 file changed, 92 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
index b966f3365b7d..c43a0e5f56f5 100644
--- a/drivers/crypto/qce/core.c
+++ b/drivers/crypto/qce/core.c
@@ -12,6 +12,8 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
#include <linux/types.h>
#include <crypto/algapi.h>
#include <crypto/internal/hash.h>
@@ -88,7 +90,12 @@ static int qce_handle_queue(struct qce_device *qce,
struct crypto_async_request *req)
{
struct crypto_async_request *async_req, *backlog;
- int ret = 0, err;
+ int ret, err;
+
+ PM_RUNTIME_ACQUIRE_AUTOSUSPEND(qce->dev, pm);
+ ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
+ if (ret)
+ return ret;
scoped_guard(mutex, &qce->lock) {
if (req)
@@ -207,23 +214,33 @@ static int qce_crypto_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- qce->core = devm_clk_get_optional_enabled(qce->dev, "core");
+ qce->core = devm_clk_get_optional(qce->dev, "core");
if (IS_ERR(qce->core))
return PTR_ERR(qce->core);
- qce->iface = devm_clk_get_optional_enabled(qce->dev, "iface");
+ qce->iface = devm_clk_get_optional(qce->dev, "iface");
if (IS_ERR(qce->iface))
return PTR_ERR(qce->iface);
- qce->bus = devm_clk_get_optional_enabled(qce->dev, "bus");
+ qce->bus = devm_clk_get_optional(qce->dev, "bus");
if (IS_ERR(qce->bus))
return PTR_ERR(qce->bus);
- qce->mem_path = devm_of_icc_get(qce->dev, "memory");
+ qce->mem_path = devm_of_icc_get(dev, "memory");
if (IS_ERR(qce->mem_path))
return PTR_ERR(qce->mem_path);
- ret = icc_set_bw(qce->mem_path, QCE_DEFAULT_MEM_BANDWIDTH, QCE_DEFAULT_MEM_BANDWIDTH);
+ /*
+ * Enable runtime PM after clocks and ICC path are acquired so that
+ * the resume callback can enable clocks and apply the ICC bandwidth
+ * vote before any hardware access takes place.
+ */
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
+ PM_RUNTIME_ACQUIRE_AUTOSUSPEND(dev, pm);
+ ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
if (ret)
return ret;
@@ -245,9 +262,76 @@ static int qce_crypto_probe(struct platform_device *pdev)
qce->async_req_enqueue = qce_async_request_enqueue;
qce->async_req_done = qce_async_request_done;
- return devm_qce_register_algs(qce);
+ ret = devm_qce_register_algs(qce);
+ if (ret)
+ return ret;
+
+ /* Configure autosuspend after successful init */
+ pm_runtime_set_autosuspend_delay(dev, 100);
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_mark_last_busy(dev);
+
+ return 0;
+}
+
+static int qce_runtime_suspend(struct device *dev)
+{
+ struct qce_device *qce = dev_get_drvdata(dev);
+ int ret;
+
+ clk_disable_unprepare(qce->core);
+ clk_disable_unprepare(qce->iface);
+ clk_disable_unprepare(qce->bus);
+
+ ret = icc_set_bw(qce->mem_path, 0, 0);
+ if (ret) {
+ clk_prepare_enable(qce->bus);
+ clk_prepare_enable(qce->iface);
+ clk_prepare_enable(qce->core);
+ return ret;
+ }
+
+ return 0;
}
+static int qce_runtime_resume(struct device *dev)
+{
+ struct qce_device *qce = dev_get_drvdata(dev);
+ int ret;
+
+ ret = icc_set_bw(qce->mem_path, QCE_DEFAULT_MEM_BANDWIDTH,
+ QCE_DEFAULT_MEM_BANDWIDTH);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(qce->core);
+ if (ret)
+ goto err_core;
+
+ ret = clk_prepare_enable(qce->iface);
+ if (ret)
+ goto err_iface;
+
+ ret = clk_prepare_enable(qce->bus);
+ if (ret)
+ goto err_bus;
+
+ return 0;
+
+err_bus:
+ clk_disable_unprepare(qce->iface);
+err_iface:
+ clk_disable_unprepare(qce->core);
+err_core:
+ icc_set_bw(qce->mem_path, 0, 0);
+ return ret;
+}
+
+static const struct dev_pm_ops qce_crypto_pm_ops = {
+ RUNTIME_PM_OPS(qce_runtime_suspend, qce_runtime_resume, NULL)
+ SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+};
+
static const struct of_device_id qce_crypto_of_match[] = {
{ .compatible = "qcom,crypto-v5.1", },
{ .compatible = "qcom,crypto-v5.4", },
@@ -261,6 +345,7 @@ static struct platform_driver qce_crypto_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = qce_crypto_of_match,
+ .pm = pm_ptr(&qce_crypto_pm_ops),
},
};
module_platform_driver(qce_crypto_driver);
--
2.34.1
^ permalink raw reply related
* [PATCH 2/2] crypto: omap-des - drop of_match_ptr from OF match table
From: Thorsten Blum @ 2026-05-17 10:36 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
Drop of_match_ptr() because OF matching is stubbed out when CONFIG_OF=n.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/omap-des.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index 4eb45b2988c3..f38ed2d387c6 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -1111,7 +1111,7 @@ static struct platform_driver omap_des_driver = {
.driver = {
.name = "omap-des",
.pm = &omap_des_pm_ops,
- .of_match_table = of_match_ptr(omap_des_of_match),
+ .of_match_table = omap_des_of_match,
},
};
^ permalink raw reply related
* [PATCH 1/2] crypto: omap-des - add COMPILE_TEST and fix CONFIG_OF=n build
From: Thorsten Blum @ 2026-05-17 10:34 UTC (permalink / raw)
To: Herbert Xu, David S. Miller; +Cc: Thorsten Blum, linux-crypto, linux-kernel
CRYPTO_DEV_OMAP_DES only depends on ARCH_OMAP2PLUS, which is ARM-only
and selects OF via ARM's USE_OF, making any non-OF code unreachable.
Add COMPILE_TEST so the driver can be built with CONFIG_OF=n, making the
non-OF code reachable.
Fix the resulting non-OF build failures:
- omap_des_irq() was defined inside a CONFIG_OF block, but is referenced
unconditionally from omap_des_probe(). Move the CONFIG_OF guard so it
only covers omap_des_get_of().
- The non-OF omap_des_get_of() stub took a struct device *, while
omap_des_probe() passes a struct platform_device *. Make the stub
prototype match the OF implementation and the caller.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/Kconfig | 4 ++--
drivers/crypto/omap-des.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index d23b58b81ca3..3449b3c9c6ad 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -316,7 +316,7 @@ config HW_RANDOM_PPC4XX
config CRYPTO_DEV_OMAP
tristate "Support for OMAP crypto HW accelerators"
- depends on ARCH_OMAP2PLUS
+ depends on ARCH_OMAP2PLUS || COMPILE_TEST
help
OMAP processors have various crypto HW accelerators. Select this if
you want to use the OMAP modules for any of the crypto algorithms.
@@ -352,7 +352,7 @@ config CRYPTO_DEV_OMAP_AES
config CRYPTO_DEV_OMAP_DES
tristate "Support for OMAP DES/3DES hw engine"
- depends on ARCH_OMAP2PLUS
+ depends on ARCH_OMAP2PLUS || COMPILE_TEST
select CRYPTO_LIB_DES
select CRYPTO_SKCIPHER
select CRYPTO_ENGINE
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index 149ebd77710b..4eb45b2988c3 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -800,7 +800,6 @@ static struct omap_des_algs_info omap_des_algs_info_ecb_cbc[] = {
},
};
-#ifdef CONFIG_OF
static const struct omap_des_pdata omap_des_pdata_omap4 = {
.algs_info = omap_des_algs_info_ecb_cbc,
.algs_info_size = ARRAY_SIZE(omap_des_algs_info_ecb_cbc),
@@ -909,6 +908,7 @@ static const struct of_device_id omap_des_of_match[] = {
};
MODULE_DEVICE_TABLE(of, omap_des_of_match);
+#ifdef CONFIG_OF
static int omap_des_get_of(struct omap_des_dev *dd,
struct platform_device *pdev)
{
@@ -923,7 +923,7 @@ static int omap_des_get_of(struct omap_des_dev *dd,
}
#else
static int omap_des_get_of(struct omap_des_dev *dd,
- struct device *dev)
+ struct platform_device *pdev)
{
return -EINVAL;
}
^ permalink raw reply related
* Re: [PATCH RFC 01/17] lib/crc: add crc32c_flip_range() for incremental CRC update
From: Baokun Li @ 2026-05-17 4:18 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-ext4, linux-crypto, ardb, tytso, adilger.kernel, jack,
yi.zhang, ojaswin, ritesh.list
In-Reply-To: <20260514035248.GA2816@sol>
Hi Eric,
Thanks for the feedback!
在 2026/5/14 11:52, Eric Biggers 写道:
> On Fri, May 08, 2026 at 08:15:23PM +0800, Baokun Li wrote:
>> When a contiguous range of bits in a buffer is flipped, the CRC32c
>> checksum can be updated incrementally without re-scanning the entire
>> buffer, by exploiting the linearity of CRCs over GF(2):
>>
>> New_CRC = Old_CRC ^ CRC(flip_mask << trailing_bits)
>>
>> Introduce crc32c_flip_range() which computes this delta using
>> precomputed GF(2) shift matrices and nibble-indexed lookup tables.
>> The implementation decomposes nbits and trailing_bits into
>> power-of-2 components and combines them via the CRC concatenation
>> property:
>>
>> CRC(A || B) = shift(CRC(A), len(B)) ^ CRC(B)
>>
>> This gives O(log N) complexity with only ~9.8KB of static tables
>> (fits in L1 cache). The current maximum supported buffer size is
>> 64KB (INCR_MAX_ORDER = 19, i.e. 2^19 bits = 524288 bits = 64KB).
> It will be a little while before I can do a full review of this, but
> just a high-level comment: "only ~9.8KB of static tables (fits in L1
> cache)" isn't ideal. Large tables tend to microbenchmark well, then
> have worse real-world performance due to lots of other things contending
> for the L1 cache.
You're right, and that's exactly the trap I fell into when picking
the initial size. I went with the variant that had the best kunit
microbenchmark while still fitting in a typical L1 -- the
nibble-indexed (4-bit) tables. I've now re-measured all three
candidate table sizes:
=== crc32c_flip_range benchmark (ns, speedup vs full) ===
bitmap full 1bit(2.5KB) 2bit(4.9KB) 4bit(9.8KB)
1024 46 165 (0.3x) 82 (0.6x) 48 (1.0x)
2048 88 180 (0.5x) 88 (1.0x) 53 (1.7x)
4096 181 194 (0.9x) 98 (1.8x) 58 (3.1x)
8192 358 207 (1.7x) 104 (3.4x) 63 (5.7x)
16384 707 222 (3.2x) 112 (6.3x) 68 (10.4x)
32768 1424 234 (6.1x) 121 (11.8x) 73 (19.5x)
65536 2846 248 (11.5x) 129 (22.1x) 79 (36.0x)
One thing worth mentioning: the upcoming crc32c_splice() API reuses
the same GF(2) shift tables for byte-granular CRC updates (extent
blocks, dir blocks, etc.). It's being posted as a separate series
because the ext4 integration is more involved, but roughly:
u32 crc32c_splice(const void *buf, u32 buflen, u32 old_crc,
u32 old_region_crc, u32 offset, u32 len)
{
u32 new_region_crc, delta, trail_bits;
[...]
new_region_crc = crc32c(0, (const u8 *)buf + offset, len);
delta = old_region_crc ^ new_region_crc;
if (!delta)
return old_crc;
trail_bits = (buflen - offset - len) * 8;
delta = gf2_shift_crc(delta, trail_bits);
return old_crc ^ delta;
}
The splice kunit numbers, for completeness:
=== crc32c_splice benchmark (ns, speedup vs full) ===
blk_regio full splice(1bit) splice(2bit) splice(4bit)
1024_12 46 8 (5.8x) 9 (5.1x) 9 (5.1x)
1024_32 46 15 (3.1x) 14 (3.3x) 15 (3.1x)
1024_64 46 20 (2.3x) 19 (2.4x) 20 (2.3x)
1024_128 46 30 (1.5x) 31 (1.5x) 30 (1.5x)
1024_264 46 53 (0.9x) 53 (0.9x) 53 (0.9x)
2048_12 88 8 (11.0x) 8 (11.0x) 8 (11.0x)
2048_32 88 15 (5.9x) 13 (6.8x) 15 (5.9x)
2048_64 89 20 (4.5x) 20 (4.5x) 20 (4.5x)
2048_128 89 31 (2.9x) 30 (3.0x) 30 (3.0x)
2048_264 88 53 (1.7x) 53 (1.7x) 53 (1.7x)
4096_12 181 9 (20.1x) 7 (25.9x) 9 (20.1x)
4096_32 181 14 (12.9x) 15 (12.1x) 15 (12.1x)
4096_64 181 20 (9.1x) 20 (9.1x) 19 (9.5x)
4096_128 181 31 (5.8x) 31 (5.8x) 30 (6.0x)
4096_264 182 54 (3.4x) 53 (3.4x) 54 (3.4x)
8192_12 358 9 (39.8x) 8 (44.8x) 10 (35.8x)
8192_32 358 15 (23.9x) 15 (23.9x) 15 (23.9x)
8192_64 358 21 (17.0x) 20 (17.9x) 21 (17.0x)
8192_128 358 32 (11.2x) 31 (11.5x) 31 (11.5x)
8192_264 358 54 (6.6x) 53 (6.8x) 53 (6.8x)
16384_12 707 10 (70.7x) 8 (88.4x) 8 (88.4x)
16384_32 706 15 (47.1x) 15 (47.1x) 15 (47.1x)
16384_64 706 21 (33.6x) 19 (37.2x) 19 (37.2x)
16384_128 707 30 (23.6x) 31 (22.8x) 30 (23.6x)
16384_264 707 54 (13.1x) 53 (13.3x) 53 (13.3x)
32768_12 1422 10 (142.2x) 9 (158.0x) 9 (158.0x)
32768_32 1422 15 (94.8x) 15 (94.8x) 15 (94.8x)
32768_64 1422 20 (71.1x) 19 (74.8x) 20 (71.1x)
32768_128 1422 31 (45.9x) 31 (45.9x) 31 (45.9x)
32768_264 1422 53 (26.8x) 53 (26.8x) 54 (26.3x)
65536_12 2841 10 (284.1x) 9 (315.7x) 8 (355.1x)
65536_32 2840 14 (202.9x) 15 (189.3x) 14 (202.9x)
65536_64 2840 21 (135.2x) 19 (149.5x) 20 (142.0x)
65536_128 2845 30 (94.8x) 31 (91.8x) 31 (91.8x)
65536_264 2841 53 (53.6x) 53 (53.6x) 53 (53.6x)
But, as you point out, what really matters is the real-world impact
once the tables are competing for L1 with everything else. I tested
all three table sizes on an ext4 fio workload (single-process
sequential fallocate of 64K extents) across a range of filesystem
block sizes. Results below, with both +flip_range alone and
+flip_range+splice applied:
=== default mkfs, single-process (GB/s) ===
config base raw-bit-flip raw-bit-splice 2-bit-flip 2-bit-splice
4-bit-flip 4-bit-splice
S_1k 15.4 15.3(-0.6%) 15.3(-0.6%) 15.1(-1.9%) 15.8(+2.6%)
15.0(-2.6%) 15.5(+0.6%)
S_2k 17.6 17.7(+0.6%) 17.9(+1.7%) 17.6(+0.0%) 18.3(+4.0%)
17.2(-2.3%) 18.6(+5.7%)
S_4k 16.9 17.0(+0.6%) 18.6(+10.1%) 17.4(+3.0%) 18.4(+8.9%)
17.3(+2.4%) 18.7(+10.7%)
S_8k 15.8 16.3(+3.2%) 18.1(+14.6%) 16.6(+5.1%) 18.3(+15.8%)
16.4(+3.8%) 17.8(+12.7%)
S_16k 12.5 13.1(+4.8%) 15.4(+23.2%) 13.0(+4.0%) 15.5(+24.0%)
12.9(+3.2%) 15.6(+24.8%)
S_32k 8.93 9.37(+4.9%) 12.5(+40.0%) 9.10(+1.9%) 13.1(+46.7%)
9.07(+1.6%) 12.5(+40.0%)
S_64k 8.17 8.43(+3.2%) 14.3(+75.0%) 8.64(+5.8%) 14.6(+78.7%)
8.39(+2.7%) 14.8(+81.2%)
So the larger tables do measure a bit faster, but the gain over 2-bit
is about 3% while the .rodata footprint doubles. All three variants
land within run-to-run noise on the real workload, which matches your
prediction exactly.
Based on this I'd lean toward the 2-bit (4.9 KB) variant for v2 as
the better trade-off. Would you prefer that, or the smaller 1-bit
(2.5 KB) version? The ext4 numbers say either is fine; 2-bit just
keeps a little more headroom on the microbench in case other
consumers show up later.
> Another consideration is that basically every Linux kernel has
> CONFIG_CRC32 enabled, regardless of whether they would actually find
> this new functionality useful.
Agreed. As large-block hardware becomes more common I expect other
filesystems beyond ext4 to hit the same large-buffer CRC overhead, so
I deliberately put this in lib/crc as a general-purpose API rather
than burying it inside ext4. But you're right that it shouldn't be
unconditionally compiled in. For v2 I'll add CONFIG_CRC32_INCR,
selected by consumers (initially just ext4), so kernels that don't
need it pay zero .text/.rodata cost.
> I'm not necessarily saying this should be its own option, especially if
> it's useful for ext4 even in the non-LBS case. But I do think it would
> be nice if it could be a bit smaller and more memory-optimized.
The non-LBS case does see some benefit, but it's modest -- the
incremental update mostly matters once group-descriptor-size CRCs
become large. The good news is that the regression on small-block
configs is essentially zero (see the S_1k / S_2k rows above), so I
left it unconditionally enabled in the current series to keep things
simple.
If there's concern about that, I'm happy to either gate it on a
sysfs/mount-option knob, or restrict it to LBS-only paths in ext4.
>
> Anyway, I'll look into the algorithm more when I have time.
>
Thanks again for taking the time on this -- the current series is
still rough around the edges and I'd appreciate any further feedback
once you get to a deeper review.
Cheers,
Baokun
^ permalink raw reply
* [PATCH] MIPS: Remove unused arch/mips/crypto directory
From: Ethan Nelson-Moore @ 2026-05-17 3:20 UTC (permalink / raw)
To: linux-mips, linux-crypto
Cc: Ethan Nelson-Moore, Thomas Bogendoerfer, Herbert Xu,
David S. Miller
The last MIPS crypto code was moved to lib/crypto/mips in
commit c9e5ac0ab9d1 ("lib/crypto: mips/md5: Migrate optimized code into
library"). However, arch/mips/crypto still contains stub Kconfig,
Makefile, and .gitignore files. Remove these unnecessary files.
Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
arch/mips/Makefile | 2 --
arch/mips/crypto/.gitignore | 2 --
arch/mips/crypto/Kconfig | 5 -----
arch/mips/crypto/Makefile | 5 -----
crypto/Kconfig | 3 ---
5 files changed, 17 deletions(-)
delete mode 100644 arch/mips/crypto/.gitignore
delete mode 100644 arch/mips/crypto/Kconfig
delete mode 100644 arch/mips/crypto/Makefile
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 6705fa5d9211..cff1a9a43b89 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -350,8 +350,6 @@ OBJCOPYFLAGS += --remove-section=.reginfo
libs-y += arch/mips/lib/
libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/
-drivers-y += arch/mips/crypto/
-
# suspend and hibernation support
drivers-$(CONFIG_PM) += arch/mips/power/
diff --git a/arch/mips/crypto/.gitignore b/arch/mips/crypto/.gitignore
deleted file mode 100644
index 0d47d4f21c6d..000000000000
--- a/arch/mips/crypto/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-poly1305-core.S
diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig
deleted file mode 100644
index 6a5bd5074867..000000000000
--- a/arch/mips/crypto/Kconfig
+++ /dev/null
@@ -1,5 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-menu "Accelerated Cryptographic Algorithms for CPU (mips)"
-
-endmenu
diff --git a/arch/mips/crypto/Makefile b/arch/mips/crypto/Makefile
deleted file mode 100644
index 5adb631a69c1..000000000000
--- a/arch/mips/crypto/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for MIPS crypto files..
-#
-
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 62221507f2b9..5203aa8f06f3 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1361,9 +1361,6 @@ endif
if ARM64
source "arch/arm64/crypto/Kconfig"
endif
-if MIPS
-source "arch/mips/crypto/Kconfig"
-endif
if PPC
source "arch/powerpc/crypto/Kconfig"
endif
--
2.43.0
^ permalink raw reply related
* [PATCH] LoongArch: Remove unused arch/loongarch/crypto directory
From: Ethan Nelson-Moore @ 2026-05-17 3:14 UTC (permalink / raw)
To: loongarch, linux-crypto
Cc: Ethan Nelson-Moore, Huacai Chen, WANG Xuerui, Herbert Xu,
David S. Miller
All LoongArch crypto code was moved to arch/loongarch/lib in
commit 72f51a4f4b07 ("loongarch/crc32: expose CRC32 functions through
lib"). However, arch/loongarch/crypto still contains stub Kconfig and
Makefile files. Remove these unnecessary files.
Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
arch/loongarch/Makefile | 2 --
arch/loongarch/crypto/Kconfig | 5 -----
arch/loongarch/crypto/Makefile | 4 ----
crypto/Kconfig | 3 ---
4 files changed, 14 deletions(-)
delete mode 100644 arch/loongarch/crypto/Kconfig
delete mode 100644 arch/loongarch/crypto/Makefile
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 54fcfa1eac1f..4b22f95aaafb 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -197,8 +197,6 @@ endif
libs-y += arch/loongarch/lib/
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
-drivers-y += arch/loongarch/crypto/
-
# suspend and hibernation support
drivers-$(CONFIG_PM) += arch/loongarch/power/
diff --git a/arch/loongarch/crypto/Kconfig b/arch/loongarch/crypto/Kconfig
deleted file mode 100644
index a0270b3e5b30..000000000000
--- a/arch/loongarch/crypto/Kconfig
+++ /dev/null
@@ -1,5 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-menu "Accelerated Cryptographic Algorithms for CPU (loongarch)"
-
-endmenu
diff --git a/arch/loongarch/crypto/Makefile b/arch/loongarch/crypto/Makefile
deleted file mode 100644
index ba83755dde2b..000000000000
--- a/arch/loongarch/crypto/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for LoongArch crypto files..
-#
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 103d1f58cb7c..62221507f2b9 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1361,9 +1361,6 @@ endif
if ARM64
source "arch/arm64/crypto/Kconfig"
endif
-if LOONGARCH
-source "arch/loongarch/crypto/Kconfig"
-endif
if MIPS
source "arch/mips/crypto/Kconfig"
endif
--
2.43.0
^ permalink raw reply related
* [PATCH] crypto: atmel-sha - use memcpy_and_pad to simplify hmac_setup
From: Thorsten Blum @ 2026-05-16 23:42 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea
Cc: Thorsten Blum, linux-crypto, linux-arm-kernel, linux-kernel
Use memcpy_and_pad() instead of memcpy() followed by memset() to
simplify atmel_sha_hmac_setup().
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-sha.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c
index 1f1341a16c42..f60c7c8cf912 100644
--- a/drivers/crypto/atmel-sha.c
+++ b/drivers/crypto/atmel-sha.c
@@ -1731,8 +1731,7 @@ static int atmel_sha_hmac_setup(struct atmel_sha_dev *dd,
return atmel_sha_hmac_prehash_key(dd, key, keylen);
/* Prepare ipad. */
- memcpy((u8 *)hmac->ipad, key, keylen);
- memset((u8 *)hmac->ipad + keylen, 0, bs - keylen);
+ memcpy_and_pad(hmac->ipad, bs, key, keylen, 0);
return atmel_sha_hmac_compute_ipad_hash(dd);
}
^ permalink raw reply related
* [PATCH v2] crypto: drivers - remove of_match_ptr from OF match tables
From: Thorsten Blum @ 2026-05-16 18:23 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Kees Cook
Cc: Thorsten Blum, linux-crypto, linux-kernel, linux-arm-msm
Drop of_match_ptr() because OF matching is stubbed out when CONFIG_OF=n.
Indent bcm_spu_pdriver.driver and its members while at it.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Drop omap-des.c because it doesn't compile with CONFIG=n and requires
other fixes first
- v1: https://lore.kernel.org/lkml/20260516114941.741140-2-thorsten.blum@linux.dev/
---
drivers/crypto/bcm/cipher.c | 6 +++---
drivers/crypto/qcom-rng.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index 2bce15dc0aa8..240b40ae9cd6 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -4698,9 +4698,9 @@ static void bcm_spu_remove(struct platform_device *pdev)
static struct platform_driver bcm_spu_pdriver = {
.driver = {
- .name = "brcm-spu-crypto",
- .of_match_table = of_match_ptr(bcm_spu_dt_ids),
- },
+ .name = "brcm-spu-crypto",
+ .of_match_table = bcm_spu_dt_ids,
+ },
.probe = bcm_spu_probe,
.remove = bcm_spu_remove,
};
diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index 0685ba122e8a..150e5802e351 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -265,7 +265,7 @@ static struct platform_driver qcom_rng_driver = {
.remove = qcom_rng_remove,
.driver = {
.name = KBUILD_MODNAME,
- .of_match_table = of_match_ptr(qcom_rng_of_match),
+ .of_match_table = qcom_rng_of_match,
.acpi_match_table = ACPI_PTR(qcom_rng_acpi_match),
}
};
^ permalink raw reply related
* [PATCH] crypto: eip93: - fix reset ring register definition
From: Aleksander Jan Bajkowski @ 2026-05-16 12:26 UTC (permalink / raw)
To: ansuelsmth, benjamin.larsson, atenart, herbert, davem, vschagen,
linux-crypto, linux-kernel
Cc: Aleksander Jan Bajkowski
This patch fixes a descriptor ring reset. This causes a hang in the
driver's unload/load sequence.
Fixes: 9739f5f93b78 ("crypto: eip93 - Add Inside Secure SafeXcel EIP-93 crypto engine support")
Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
---
drivers/crypto/inside-secure/eip93/eip93-regs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/inside-secure/eip93/eip93-regs.h b/drivers/crypto/inside-secure/eip93/eip93-regs.h
index 96285ca6fbbe..96d28c6651bd 100644
--- a/drivers/crypto/inside-secure/eip93/eip93-regs.h
+++ b/drivers/crypto/inside-secure/eip93/eip93-regs.h
@@ -103,7 +103,7 @@
#define EIP93_PE_TARGET_COMMAND_NO_RDR_MODE FIELD_PREP(EIP93_PE_CONFIG_PE_MODE, 0x2)
#define EIP93_PE_TARGET_COMMAND_WITH_RDR_MODE FIELD_PREP(EIP93_PE_CONFIG_PE_MODE, 0x1)
#define EIP93_PE_DIRECT_HOST_MODE FIELD_PREP(EIP93_PE_CONFIG_PE_MODE, 0x0)
-#define EIP93_PE_CONFIG_RST_RING BIT(2)
+#define EIP93_PE_CONFIG_RST_RING BIT(1)
#define EIP93_PE_CONFIG_RST_PE BIT(0)
#define EIP93_REG_PE_STATUS 0x104
#define EIP93_REG_PE_BUF_THRESH 0x10c
--
2.53.0
^ permalink raw reply related
* [PATCH] crypto: drivers - remove of_match_ptr from OF match tables
From: Thorsten Blum @ 2026-05-16 11:49 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Kees Cook
Cc: Thorsten Blum, linux-crypto, linux-kernel, linux-arm-msm
Drop of_match_ptr() because OF matching is stubbed out when CONFIG_OF=n.
Indent bcm_spu_pdriver.driver and its members while at it.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/bcm/cipher.c | 6 +++---
drivers/crypto/omap-des.c | 2 +-
drivers/crypto/qcom-rng.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index 2bce15dc0aa8..240b40ae9cd6 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -4698,9 +4698,9 @@ static void bcm_spu_remove(struct platform_device *pdev)
static struct platform_driver bcm_spu_pdriver = {
.driver = {
- .name = "brcm-spu-crypto",
- .of_match_table = of_match_ptr(bcm_spu_dt_ids),
- },
+ .name = "brcm-spu-crypto",
+ .of_match_table = bcm_spu_dt_ids,
+ },
.probe = bcm_spu_probe,
.remove = bcm_spu_remove,
};
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index 149ebd77710b..43768323de75 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -1111,7 +1111,7 @@ static struct platform_driver omap_des_driver = {
.driver = {
.name = "omap-des",
.pm = &omap_des_pm_ops,
- .of_match_table = of_match_ptr(omap_des_of_match),
+ .of_match_table = omap_des_of_match,
},
};
diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index 0685ba122e8a..150e5802e351 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -265,7 +265,7 @@ static struct platform_driver qcom_rng_driver = {
.remove = qcom_rng_remove,
.driver = {
.name = KBUILD_MODNAME,
- .of_match_table = of_match_ptr(qcom_rng_of_match),
+ .of_match_table = qcom_rng_of_match,
.acpi_match_table = ACPI_PTR(qcom_rng_acpi_match),
}
};
^ permalink raw reply related
* Re: [PATCH v16 01/38] tpm: Initial step to reorganize TPM public headers
From: Jarkko Sakkinen @ 2026-05-15 23:51 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Ross Philipson, linux-kernel, x86, linux-integrity, linux-doc,
linux-crypto, kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp,
hpa, dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <20260515230553.GO7702@ziepe.ca>
On Fri, May 15, 2026 at 08:05:53PM -0300, Jason Gunthorpe wrote:
> On Sat, May 16, 2026 at 02:03:59AM +0300, Jarkko Sakkinen wrote:
>
> > LGTM
> >
> > I'll hold on from actual tags up until there is some consensus with the
> > patch set.
>
> This patch set is huge, and I know there is alot of interest now in
> DRTM.
>
> Can we please split out and progress the TPM reorg mini-series at the
> front?
I'm not usually for "non-functional" series but in the case of D-RTM
that could stil bel a good idea.
I.e. let's iterate it through faster than the main series and get it to
the mainline before next merge window, and then switch gears back to
the "main series".
>
> Jason
BR, Jarkko
^ permalink raw reply
* Re: [PATCH v16 04/38] tpm: Move TPM common base definitions to the command header
From: Jarkko Sakkinen @ 2026-05-15 23:22 UTC (permalink / raw)
To: Ross Philipson
Cc: linux-kernel, x86, linux-integrity, linux-doc, linux-crypto,
kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp, hpa,
dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, jgg, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <20260515211410.31440-5-ross.philipson@gmail.com>
On Fri, May 15, 2026 at 02:13:36PM -0700, Ross Philipson wrote:
> These are top level definitions shared by both TPM 1 and 2
> family chips. This includes core definitions like TPM localities,
> common crypto algorithm IDs, and the base TPM command header.
>
> Co-developed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Co-developed-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Ross Philipson <ross.philipson@gmail.com>
> ---
> include/linux/tpm.h | 50 +--------------------
> include/linux/tpm_command.h | 89 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 90 insertions(+), 49 deletions(-)
>
> diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> index 8551b24c2bff..3630b2ea6aef 100644
> --- a/include/linux/tpm.h
> +++ b/include/linux/tpm.h
> @@ -27,49 +27,12 @@
>
> #include <linux/tpm_command.h>
>
> -#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */
> -
> -#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
> -#define TPM2_MAX_PCR_BANKS 8
> -
> struct tpm_chip;
> struct trusted_key_payload;
> struct trusted_key_options;
> /* opaque structure, holds auth session parameters like the session key */
> struct tpm2_auth;
>
> -/* if you add a new hash to this, increment TPM_MAX_HASHES below */
> -enum tpm_algorithms {
> - TPM_ALG_ERROR = 0x0000,
> - TPM_ALG_SHA1 = 0x0004,
> - TPM_ALG_AES = 0x0006,
> - TPM_ALG_KEYEDHASH = 0x0008,
> - TPM_ALG_SHA256 = 0x000B,
> - TPM_ALG_SHA384 = 0x000C,
> - TPM_ALG_SHA512 = 0x000D,
> - TPM_ALG_NULL = 0x0010,
> - TPM_ALG_SM3_256 = 0x0012,
> - TPM_ALG_ECC = 0x0023,
> - TPM_ALG_CFB = 0x0043,
> -};
> -
> -/*
> - * maximum number of hashing algorithms a TPM can have. This is
> - * basically a count of every hash in tpm_algorithms above
> - */
> -#define TPM_MAX_HASHES 5
> -
> -struct tpm_digest {
> - u16 alg_id;
> - u8 digest[TPM2_MAX_DIGEST_SIZE];
> -} __packed;
> -
> -struct tpm_bank_info {
> - u16 alg_id;
> - u16 digest_size;
> - u16 crypto_id;
> -};
> -
> enum TPM_OPS_FLAGS {
> TPM_OPS_AUTO_STARTUP = BIT(0),
> };
> @@ -127,7 +90,7 @@ struct tpm_chip_seqops {
> const struct seq_operations *seqops;
> };
>
> -/* fixed define for the curve we use which is NIST_P256 */
> +/* Fixed define for the curve we use which is NIST_P256 */
> #define EC_PT_SZ 32
>
> /*
> @@ -209,8 +172,6 @@ struct tpm_chip {
> #endif
> };
>
> -#define TPM_HEADER_SIZE 10
> -
> static inline enum tpm2_mso_type tpm2_handle_mso(u32 handle)
> {
> return handle >> 24;
> @@ -239,15 +200,6 @@ enum tpm_chip_flags {
>
> #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
>
> -struct tpm_header {
> - __be16 tag;
> - __be32 length;
> - union {
> - __be32 ordinal;
> - __be32 return_code;
> - };
> -} __packed;
> -
> enum tpm_buf_flags {
> /* the capacity exceeded: */
> TPM_BUF_OVERFLOW = BIT(0),
> diff --git a/include/linux/tpm_command.h b/include/linux/tpm_command.h
> index 9dd903dd6b5c..96edebd9610f 100644
> --- a/include/linux/tpm_command.h
> +++ b/include/linux/tpm_command.h
> @@ -427,4 +427,93 @@ struct tpm2_context {
> __be16 blob_size;
> } __packed;
>
> +/*
> + * == TPM Common Defs ==
> + */
> +
> +#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */
> +#define TPM_BUFSIZE 4096
> +
> +/*
> + * SHA-512 is, as of today, the largest digest in the TCG algorithm repository.
> + */
> +#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
> +
> +/*
> + * A TPM name digest i.e., TPMT_HA, is a concatenation of TPM_ALG_ID of the
> + * name algorithm and hash of TPMT_PUBLIC.
> + */
> +#define TPM2_MAX_NAME_SIZE (TPM2_MAX_DIGEST_SIZE + 2)
> +
> +/*
> + * Fixed define for the size of a name. This is actually HASHALG size
> + * plus 2, so 32 for SHA256
> + */
> +#define TPM2_NULL_NAME_SIZE 34
> +
> +/*
> + * The maximum number of PCR banks.
> + */
> +#define TPM2_MAX_PCR_BANKS 8
> +
> +/* If you add a new hash to this, increment TPM_MAX_HASHES below */
> +enum tpm_algorithms {
> + TPM_ALG_ERROR = 0x0000,
> + TPM_ALG_SHA1 = 0x0004,
> + TPM_ALG_AES = 0x0006,
> + TPM_ALG_KEYEDHASH = 0x0008,
> + TPM_ALG_SHA256 = 0x000B,
> + TPM_ALG_SHA384 = 0x000C,
> + TPM_ALG_SHA512 = 0x000D,
> + TPM_ALG_NULL = 0x0010,
> + TPM_ALG_SM3_256 = 0x0012,
> + TPM_ALG_ECC = 0x0023,
> + TPM_ALG_CFB = 0x0043,
> +};
> +
> +/*
> + * The locality (0 - 4) for a TPM, as defined in section 3.2 of the
> + * Client Platform Profile Specification.
> + */
> +enum tpm_localities {
> + TPM_LOCALITY_0 = 0, /* Static RTM */
> + TPM_LOCALITY_1 = 1, /* Dynamic OS */
> + TPM_LOCALITY_2 = 2, /* DRTM Environment */
> + TPM_LOCALITY_3 = 3, /* Aux Components */
> + TPM_LOCALITY_4 = 4, /* CPU DRTM Establishment */
> + TPM_MAX_LOCALITY = TPM_LOCALITY_4
> +};
> +
> +/*
> + * Structure to represent active PCR algorithm banks usable by the
> + * TPM chip.
> + */
> +struct tpm_bank_info {
> + u16 alg_id;
> + u16 digest_size;
> + u16 crypto_id;
> +};
> +
> +/*
> + * Maximum number of hashing algorithms a TPM can have. This is
> + * basically a count of every hash in tpm_algorithms above
> + */
> +#define TPM_MAX_HASHES 5
> +
> +struct tpm_digest {
> + u16 alg_id;
> + u8 digest[TPM2_MAX_DIGEST_SIZE];
> +} __packed;
> +
> +#define TPM_HEADER_SIZE 10
> +
> +struct tpm_header {
> + __be16 tag;
> + __be32 length;
> + union {
> + __be32 ordinal;
> + __be32 return_code;
> + };
> +} __packed;
> +
> #endif
> --
> 2.47.3
>
LGTM
BR, Jarkko
^ permalink raw reply
* Re: [PATCH v1] include: Remove unused crypto-ux500.h
From: Linus Walleij @ 2026-05-15 23:21 UTC (permalink / raw)
To: Costa Shulyupin; +Cc: Linus Walleij, linux-kernel, linux-crypto
In-Reply-To: <20260515190220.1534187-1-costa.shul@redhat.com>
On Fri, May 15, 2026 at 9:02 PM Costa Shulyupin <costa.shul@redhat.com> wrote:
> The UX500 crypto drivers were removed in commit 453de3eb08c4
> ("crypto: ux500/cryp - delete driver") and commit dd7b7972cb89
> ("crypto: ux500/hash - delete driver"). No file includes
> this header.
>
> Assisted-by: Claude:claude-opus-4-6
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
Good catch!
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply
* Re: [PATCH v16 03/38] tpm: Move TPM2 specific definitions to the command header
From: Jarkko Sakkinen @ 2026-05-15 23:15 UTC (permalink / raw)
To: Ross Philipson
Cc: linux-kernel, x86, linux-integrity, linux-doc, linux-crypto,
kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp, hpa,
dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, jgg, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <20260515211410.31440-4-ross.philipson@gmail.com>
On Fri, May 15, 2026 at 02:13:35PM -0700, Ross Philipson wrote:
> Gather all the TPM2 definitions and structures in the internal header
> file drivers/char/tpm/tpm.h into the command header, including:
> - Command codes, return codes and definitions from the public and
> internal tpm.h files.
> - Structures defined in numerous TPM driver C modules.
>
> The definitions moved to these files correspond to the TCG specification
> for TPM 2 family:
>
> TPM 2.0 Library
> - https://trustedcomputinggroup.org/resource/tpm-library-specification/
>
> Co-developed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Co-developed-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Ross Philipson <ross.philipson@gmail.com>
> ---
> drivers/char/tpm/tpm.h | 77 ----------
> drivers/char/tpm/tpm2-cmd.c | 30 ----
> drivers/char/tpm/tpm2-space.c | 13 --
> include/linux/tpm.h | 145 ------------------
> include/linux/tpm_command.h | 271 ++++++++++++++++++++++++++++++++++
> 5 files changed, 271 insertions(+), 265 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 043d78a9617a..680f89d9c9f9 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -52,83 +52,6 @@ enum tpm_addr {
> TPM_ADDR = 0x4E,
> };
>
> -/* TPM2 specific constants. */
> -#define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
> -
> -enum tpm2_pt_props {
> - TPM2_PT_NONE = 0x00000000,
> - TPM2_PT_GROUP = 0x00000100,
> - TPM2_PT_FIXED = TPM2_PT_GROUP * 1,
> - TPM2_PT_FAMILY_INDICATOR = TPM2_PT_FIXED + 0,
> - TPM2_PT_LEVEL = TPM2_PT_FIXED + 1,
> - TPM2_PT_REVISION = TPM2_PT_FIXED + 2,
> - TPM2_PT_DAY_OF_YEAR = TPM2_PT_FIXED + 3,
> - TPM2_PT_YEAR = TPM2_PT_FIXED + 4,
> - TPM2_PT_MANUFACTURER = TPM2_PT_FIXED + 5,
> - TPM2_PT_VENDOR_STRING_1 = TPM2_PT_FIXED + 6,
> - TPM2_PT_VENDOR_STRING_2 = TPM2_PT_FIXED + 7,
> - TPM2_PT_VENDOR_STRING_3 = TPM2_PT_FIXED + 8,
> - TPM2_PT_VENDOR_STRING_4 = TPM2_PT_FIXED + 9,
> - TPM2_PT_VENDOR_TPM_TYPE = TPM2_PT_FIXED + 10,
> - TPM2_PT_FIRMWARE_VERSION_1 = TPM2_PT_FIXED + 11,
> - TPM2_PT_FIRMWARE_VERSION_2 = TPM2_PT_FIXED + 12,
> - TPM2_PT_INPUT_BUFFER = TPM2_PT_FIXED + 13,
> - TPM2_PT_HR_TRANSIENT_MIN = TPM2_PT_FIXED + 14,
> - TPM2_PT_HR_PERSISTENT_MIN = TPM2_PT_FIXED + 15,
> - TPM2_PT_HR_LOADED_MIN = TPM2_PT_FIXED + 16,
> - TPM2_PT_ACTIVE_SESSIONS_MAX = TPM2_PT_FIXED + 17,
> - TPM2_PT_PCR_COUNT = TPM2_PT_FIXED + 18,
> - TPM2_PT_PCR_SELECT_MIN = TPM2_PT_FIXED + 19,
> - TPM2_PT_CONTEXT_GAP_MAX = TPM2_PT_FIXED + 20,
> - TPM2_PT_NV_COUNTERS_MAX = TPM2_PT_FIXED + 22,
> - TPM2_PT_NV_INDEX_MAX = TPM2_PT_FIXED + 23,
> - TPM2_PT_MEMORY = TPM2_PT_FIXED + 24,
> - TPM2_PT_CLOCK_UPDATE = TPM2_PT_FIXED + 25,
> - TPM2_PT_CONTEXT_HASH = TPM2_PT_FIXED + 26,
> - TPM2_PT_CONTEXT_SYM = TPM2_PT_FIXED + 27,
> - TPM2_PT_CONTEXT_SYM_SIZE = TPM2_PT_FIXED + 28,
> - TPM2_PT_ORDERLY_COUNT = TPM2_PT_FIXED + 29,
> - TPM2_PT_MAX_COMMAND_SIZE = TPM2_PT_FIXED + 30,
> - TPM2_PT_MAX_RESPONSE_SIZE = TPM2_PT_FIXED + 31,
> - TPM2_PT_MAX_DIGEST = TPM2_PT_FIXED + 32,
> - TPM2_PT_MAX_OBJECT_CONTEXT = TPM2_PT_FIXED + 33,
> - TPM2_PT_MAX_SESSION_CONTEXT = TPM2_PT_FIXED + 34,
> - TPM2_PT_PS_FAMILY_INDICATOR = TPM2_PT_FIXED + 35,
> - TPM2_PT_PS_LEVEL = TPM2_PT_FIXED + 36,
> - TPM2_PT_PS_REVISION = TPM2_PT_FIXED + 37,
> - TPM2_PT_PS_DAY_OF_YEAR = TPM2_PT_FIXED + 38,
> - TPM2_PT_PS_YEAR = TPM2_PT_FIXED + 39,
> - TPM2_PT_SPLIT_MAX = TPM2_PT_FIXED + 40,
> - TPM2_PT_TOTAL_COMMANDS = TPM2_PT_FIXED + 41,
> - TPM2_PT_LIBRARY_COMMANDS = TPM2_PT_FIXED + 42,
> - TPM2_PT_VENDOR_COMMANDS = TPM2_PT_FIXED + 43,
> - TPM2_PT_NV_BUFFER_MAX = TPM2_PT_FIXED + 44,
> - TPM2_PT_MODES = TPM2_PT_FIXED + 45,
> - TPM2_PT_MAX_CAP_BUFFER = TPM2_PT_FIXED + 46,
> - TPM2_PT_VAR = TPM2_PT_GROUP * 2,
> - TPM2_PT_PERMANENT = TPM2_PT_VAR + 0,
> - TPM2_PT_STARTUP_CLEAR = TPM2_PT_VAR + 1,
> - TPM2_PT_HR_NV_INDEX = TPM2_PT_VAR + 2,
> - TPM2_PT_HR_LOADED = TPM2_PT_VAR + 3,
> - TPM2_PT_HR_LOADED_AVAIL = TPM2_PT_VAR + 4,
> - TPM2_PT_HR_ACTIVE = TPM2_PT_VAR + 5,
> - TPM2_PT_HR_ACTIVE_AVAIL = TPM2_PT_VAR + 6,
> - TPM2_PT_HR_TRANSIENT_AVAIL = TPM2_PT_VAR + 7,
> - TPM2_PT_HR_PERSISTENT = TPM2_PT_VAR + 8,
> - TPM2_PT_HR_PERSISTENT_AVAIL = TPM2_PT_VAR + 9,
> - TPM2_PT_NV_COUNTERS = TPM2_PT_VAR + 10,
> - TPM2_PT_NV_COUNTERS_AVAIL = TPM2_PT_VAR + 11,
> - TPM2_PT_ALGORITHM_SET = TPM2_PT_VAR + 12,
> - TPM2_PT_LOADED_CURVES = TPM2_PT_VAR + 13,
> - TPM2_PT_LOCKOUT_COUNTER = TPM2_PT_VAR + 14,
> - TPM2_PT_MAX_AUTH_FAIL = TPM2_PT_VAR + 15,
> - TPM2_PT_LOCKOUT_INTERVAL = TPM2_PT_VAR + 16,
> - TPM2_PT_LOCKOUT_RECOVERY = TPM2_PT_VAR + 17,
> - TPM2_PT_NV_WRITE_RECOVERY = TPM2_PT_VAR + 18,
> - TPM2_PT_AUDIT_COUNTER_0 = TPM2_PT_VAR + 19,
> - TPM2_PT_AUDIT_COUNTER_1 = TPM2_PT_VAR + 20,
> -};
> -
> extern const struct class tpm_class;
> extern const struct class tpmrm_class;
> extern dev_t tpm_devt;
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index 3a77be7ebf4a..1fa3e8a43c79 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -94,17 +94,6 @@ unsigned long tpm2_calc_ordinal_duration(u32 ordinal)
> return msecs_to_jiffies(TPM2_DURATION_DEFAULT);
> }
>
> -struct tpm2_pcr_read_out {
> - __be32 update_cnt;
> - __be32 pcr_selects_cnt;
> - __be16 hash_alg;
> - u8 pcr_select_size;
> - u8 pcr_select[TPM2_PCR_SELECT_MIN];
> - __be32 digests_cnt;
> - __be16 digest_size;
> - u8 digest[];
> -} __packed;
> -
> /**
> * tpm2_pcr_read() - read a PCR value
> * @chip: TPM chip to use.
> @@ -238,11 +227,6 @@ int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
> return rc;
> }
>
> -struct tpm2_get_random_out {
> - __be16 size;
> - u8 buffer[TPM_MAX_RNG_DATA];
> -} __packed;
> -
> /**
> * tpm2_get_random() - get random bytes from the TPM RNG
> *
> @@ -366,14 +350,6 @@ void tpm2_flush_context(struct tpm_chip *chip, u32 handle)
> }
> EXPORT_SYMBOL_GPL(tpm2_flush_context);
>
> -struct tpm2_get_cap_out {
> - u8 more_data;
> - __be32 subcap_id;
> - __be32 property_cnt;
> - __be32 property_id;
> - __be32 value;
> -} __packed;
> -
> /**
> * tpm2_get_tpm_pt() - get value of a TPM_CAP_TPM_PROPERTIES type property
> * @chip: a &tpm_chip instance
> @@ -541,12 +517,6 @@ static int tpm2_init_bank_info(struct tpm_chip *chip, u32 bank_index)
> return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size);
> }
>
> -struct tpm2_pcr_selection {
> - __be16 hash_alg;
> - u8 size_of_select;
> - u8 pcr_select[3];
> -} __packed;
> -
> ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
> {
> struct tpm2_pcr_selection pcr_selection;
> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> index 60354cd53b5c..7c1c0a174a2b 100644
> --- a/drivers/char/tpm/tpm2-space.c
> +++ b/drivers/char/tpm/tpm2-space.c
> @@ -15,19 +15,6 @@
> #include <linux/unaligned.h>
> #include "tpm.h"
>
> -enum tpm2_handle_types {
> - TPM2_HT_HMAC_SESSION = 0x02000000,
> - TPM2_HT_POLICY_SESSION = 0x03000000,
> - TPM2_HT_TRANSIENT = 0x80000000,
> -};
> -
> -struct tpm2_context {
> - __be64 sequence;
> - __be32 saved_handle;
> - __be32 hierarchy;
> - __be16 blob_size;
> -} __packed;
> -
> static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space)
> {
> int i;
> diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> index 1846d5485a2c..8551b24c2bff 100644
> --- a/include/linux/tpm.h
> +++ b/include/linux/tpm.h
> @@ -38,12 +38,6 @@ struct trusted_key_options;
> /* opaque structure, holds auth session parameters like the session key */
> struct tpm2_auth;
>
> -enum tpm2_session_types {
> - TPM2_SE_HMAC = 0x00,
> - TPM2_SE_POLICY = 0x01,
> - TPM2_SE_TRIAL = 0x02,
> -};
> -
> /* if you add a new hash to this, increment TPM_MAX_HASHES below */
> enum tpm_algorithms {
> TPM_ALG_ERROR = 0x0000,
> @@ -65,11 +59,6 @@ enum tpm_algorithms {
> */
> #define TPM_MAX_HASHES 5
>
> -enum tpm2_curves {
> - TPM2_ECC_NONE = 0x0000,
> - TPM2_ECC_NIST_P256 = 0x0003,
> -};
> -
> struct tpm_digest {
> u16 alg_id;
> u8 digest[TPM2_MAX_DIGEST_SIZE];
> @@ -222,122 +211,11 @@ struct tpm_chip {
>
> #define TPM_HEADER_SIZE 10
>
> -enum tpm2_const {
> - TPM2_PLATFORM_PCR = 24,
> - TPM2_PCR_SELECT_MIN = ((TPM2_PLATFORM_PCR + 7) / 8),
> -};
> -
> -enum tpm2_timeouts {
> - TPM2_TIMEOUT_A = 750,
> - TPM2_TIMEOUT_B = 4000,
> - TPM2_TIMEOUT_C = 200,
> - TPM2_TIMEOUT_D = 30,
> -};
> -
> -enum tpm2_durations {
> - TPM2_DURATION_SHORT = 20,
> - TPM2_DURATION_LONG = 2000,
> - TPM2_DURATION_DEFAULT = 120000,
> -};
> -
> -enum tpm2_structures {
> - TPM2_ST_NO_SESSIONS = 0x8001,
> - TPM2_ST_SESSIONS = 0x8002,
> - TPM2_ST_CREATION = 0x8021,
> -};
> -
> -/* Indicates from what layer of the software stack the error comes from */
> -#define TSS2_RC_LAYER_SHIFT 16
> -#define TSS2_RESMGR_TPM_RC_LAYER (11 << TSS2_RC_LAYER_SHIFT)
> -
> -enum tpm2_return_codes {
> - TPM2_RC_SUCCESS = 0x0000,
> - TPM2_RC_HASH = 0x0083, /* RC_FMT1 */
> - TPM2_RC_HANDLE = 0x008B,
> - TPM2_RC_INTEGRITY = 0x009F,
> - TPM2_RC_INITIALIZE = 0x0100, /* RC_VER1 */
> - TPM2_RC_FAILURE = 0x0101,
> - TPM2_RC_DISABLED = 0x0120,
> - TPM2_RC_UPGRADE = 0x012D,
> - TPM2_RC_COMMAND_CODE = 0x0143,
> - TPM2_RC_TESTING = 0x090A, /* RC_WARN */
> - TPM2_RC_REFERENCE_H0 = 0x0910,
> - TPM2_RC_RETRY = 0x0922,
> - TPM2_RC_SESSION_MEMORY = 0x0903,
> -};
> -
> -enum tpm2_command_codes {
> - TPM2_CC_FIRST = 0x011F,
> - TPM2_CC_HIERARCHY_CONTROL = 0x0121,
> - TPM2_CC_HIERARCHY_CHANGE_AUTH = 0x0129,
> - TPM2_CC_CREATE_PRIMARY = 0x0131,
> - TPM2_CC_SEQUENCE_COMPLETE = 0x013E,
> - TPM2_CC_SELF_TEST = 0x0143,
> - TPM2_CC_STARTUP = 0x0144,
> - TPM2_CC_SHUTDOWN = 0x0145,
> - TPM2_CC_NV_READ = 0x014E,
> - TPM2_CC_CREATE = 0x0153,
> - TPM2_CC_LOAD = 0x0157,
> - TPM2_CC_SEQUENCE_UPDATE = 0x015C,
> - TPM2_CC_UNSEAL = 0x015E,
> - TPM2_CC_CONTEXT_LOAD = 0x0161,
> - TPM2_CC_CONTEXT_SAVE = 0x0162,
> - TPM2_CC_FLUSH_CONTEXT = 0x0165,
> - TPM2_CC_READ_PUBLIC = 0x0173,
> - TPM2_CC_START_AUTH_SESS = 0x0176,
> - TPM2_CC_VERIFY_SIGNATURE = 0x0177,
> - TPM2_CC_GET_CAPABILITY = 0x017A,
> - TPM2_CC_GET_RANDOM = 0x017B,
> - TPM2_CC_PCR_READ = 0x017E,
> - TPM2_CC_PCR_EXTEND = 0x0182,
> - TPM2_CC_EVENT_SEQUENCE_COMPLETE = 0x0185,
> - TPM2_CC_HASH_SEQUENCE_START = 0x0186,
> - TPM2_CC_CREATE_LOADED = 0x0191,
> - TPM2_CC_LAST = 0x0193, /* Spec 1.36 */
> -};
> -
> -enum tpm2_permanent_handles {
> - TPM2_RH_NULL = 0x40000007,
> - TPM2_RS_PW = 0x40000009,
> -};
> -
> -/* Most Significant Octet for key types */
> -enum tpm2_mso_type {
> - TPM2_MSO_NVRAM = 0x01,
> - TPM2_MSO_SESSION = 0x02,
> - TPM2_MSO_POLICY = 0x03,
> - TPM2_MSO_PERMANENT = 0x40,
> - TPM2_MSO_VOLATILE = 0x80,
> - TPM2_MSO_PERSISTENT = 0x81,
> -};
> -
> static inline enum tpm2_mso_type tpm2_handle_mso(u32 handle)
> {
> return handle >> 24;
> }
>
> -enum tpm2_capabilities {
> - TPM2_CAP_HANDLES = 1,
> - TPM2_CAP_COMMANDS = 2,
> - TPM2_CAP_PCRS = 5,
> - TPM2_CAP_TPM_PROPERTIES = 6,
> -};
> -
> -enum tpm2_properties {
> - TPM_PT_TOTAL_COMMANDS = 0x0129,
> -};
> -
> -enum tpm2_startup_types {
> - TPM2_SU_CLEAR = 0x0000,
> - TPM2_SU_STATE = 0x0001,
> -};
> -
> -enum tpm2_cc_attrs {
> - TPM2_CC_ATTR_CHANDLES = 25,
> - TPM2_CC_ATTR_RHANDLE = 28,
> - TPM2_CC_ATTR_VENDOR = 29,
> -};
> -
> #define TPM_VID_INTEL 0x8086
> #define TPM_VID_WINBOND 0x1050
> #define TPM_VID_STM 0x104A
> @@ -389,29 +267,6 @@ struct tpm_buf {
> u8 handles;
> };
>
> -enum tpm2_object_attributes {
> - TPM2_OA_FIXED_TPM = BIT(1),
> - TPM2_OA_ST_CLEAR = BIT(2),
> - TPM2_OA_FIXED_PARENT = BIT(4),
> - TPM2_OA_SENSITIVE_DATA_ORIGIN = BIT(5),
> - TPM2_OA_USER_WITH_AUTH = BIT(6),
> - TPM2_OA_ADMIN_WITH_POLICY = BIT(7),
> - TPM2_OA_NO_DA = BIT(10),
> - TPM2_OA_ENCRYPTED_DUPLICATION = BIT(11),
> - TPM2_OA_RESTRICTED = BIT(16),
> - TPM2_OA_DECRYPT = BIT(17),
> - TPM2_OA_SIGN = BIT(18),
> -};
> -
> -enum tpm2_session_attributes {
> - TPM2_SA_CONTINUE_SESSION = BIT(0),
> - TPM2_SA_AUDIT_EXCLUSIVE = BIT(1),
> - TPM2_SA_AUDIT_RESET = BIT(3),
> - TPM2_SA_DECRYPT = BIT(5),
> - TPM2_SA_ENCRYPT = BIT(6),
> - TPM2_SA_AUDIT = BIT(7),
> -};
> -
> struct tpm2_hash {
> unsigned int crypto_id;
> unsigned int tpm_id;
> diff --git a/include/linux/tpm_command.h b/include/linux/tpm_command.h
> index 30d01953a6f8..9dd903dd6b5c 100644
> --- a/include/linux/tpm_command.h
> +++ b/include/linux/tpm_command.h
> @@ -156,4 +156,275 @@ struct tpm1_get_random_out {
> #define TPM_NONCE_SIZE 20
> #define TPM_ST_CLEAR 1
>
> +/*
> + * == TPM 2 Family Chips ==
> + *
> + * TPM 2.0 Library
> + * https://trustedcomputinggroup.org/resource/tpm-library-specification/
> + */
> +
> +/* TPM2 specific constants. */
> +#define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
> +
> +enum tpm2_session_types {
> + TPM2_SE_HMAC = 0x00,
> + TPM2_SE_POLICY = 0x01,
> + TPM2_SE_TRIAL = 0x02,
> +};
> +
> +enum tpm2_timeouts {
> + TPM2_TIMEOUT_A = 750,
> + TPM2_TIMEOUT_B = 4000,
> + TPM2_TIMEOUT_C = 200,
> + TPM2_TIMEOUT_D = 30,
> + TPM2_DURATION_SHORT = 20,
> + TPM2_DURATION_MEDIUM = 750,
> + TPM2_DURATION_LONG = 2000,
> + TPM2_DURATION_LONG_LONG = 300000,
> + TPM2_DURATION_DEFAULT = 120000,
> +};
> +
> +enum tpm2_structures {
> + TPM2_ST_NO_SESSIONS = 0x8001,
> + TPM2_ST_SESSIONS = 0x8002,
> + TPM2_ST_CREATION = 0x8021,
> +};
> +
> +/* Indicates from what layer of the software stack the error comes from */
> +#define TSS2_RC_LAYER_SHIFT 16
> +#define TSS2_RESMGR_TPM_RC_LAYER (11 << TSS2_RC_LAYER_SHIFT)
> +
> +enum tpm2_return_codes {
> + TPM2_RC_SUCCESS = 0x0000,
> + TPM2_RC_HASH = 0x0083, /* RC_FMT1 */
> + TPM2_RC_HANDLE = 0x008B,
> + TPM2_RC_INTEGRITY = 0x009F,
> + TPM2_RC_INITIALIZE = 0x0100, /* RC_VER1 */
> + TPM2_RC_FAILURE = 0x0101,
> + TPM2_RC_DISABLED = 0x0120,
> + TPM2_RC_UPGRADE = 0x012D,
> + TPM2_RC_COMMAND_CODE = 0x0143,
> + TPM2_RC_TESTING = 0x090A, /* RC_WARN */
> + TPM2_RC_REFERENCE_H0 = 0x0910,
> + TPM2_RC_RETRY = 0x0922,
> + TPM2_RC_SESSION_MEMORY = 0x0903,
> +};
> +
> +enum tpm2_command_codes {
> + TPM2_CC_FIRST = 0x011F,
> + TPM2_CC_HIERARCHY_CONTROL = 0x0121,
> + TPM2_CC_HIERARCHY_CHANGE_AUTH = 0x0129,
> + TPM2_CC_CREATE_PRIMARY = 0x0131,
> + TPM2_CC_SEQUENCE_COMPLETE = 0x013E,
> + TPM2_CC_SELF_TEST = 0x0143,
> + TPM2_CC_STARTUP = 0x0144,
> + TPM2_CC_SHUTDOWN = 0x0145,
> + TPM2_CC_NV_READ = 0x014E,
> + TPM2_CC_CREATE = 0x0153,
> + TPM2_CC_LOAD = 0x0157,
> + TPM2_CC_SEQUENCE_UPDATE = 0x015C,
> + TPM2_CC_UNSEAL = 0x015E,
> + TPM2_CC_CONTEXT_LOAD = 0x0161,
> + TPM2_CC_CONTEXT_SAVE = 0x0162,
> + TPM2_CC_FLUSH_CONTEXT = 0x0165,
> + TPM2_CC_READ_PUBLIC = 0x0173,
> + TPM2_CC_START_AUTH_SESS = 0x0176,
> + TPM2_CC_VERIFY_SIGNATURE = 0x0177,
> + TPM2_CC_GET_CAPABILITY = 0x017A,
> + TPM2_CC_GET_RANDOM = 0x017B,
> + TPM2_CC_PCR_READ = 0x017E,
> + TPM2_CC_PCR_EXTEND = 0x0182,
> + TPM2_CC_EVENT_SEQUENCE_COMPLETE = 0x0185,
> + TPM2_CC_HASH_SEQUENCE_START = 0x0186,
> + TPM2_CC_CREATE_LOADED = 0x0191,
> + TPM2_CC_LAST = 0x0193, /* Spec 1.36 */
> +};
> +
> +enum tpm2_capabilities {
> + TPM2_CAP_HANDLES = 1,
> + TPM2_CAP_COMMANDS = 2,
> + TPM2_CAP_PCRS = 5,
> + TPM2_CAP_TPM_PROPERTIES = 6,
> +};
> +
> +enum tpm2_properties {
> + TPM_PT_TOTAL_COMMANDS = 0x0129,
> +};
> +
> +enum tpm2_startup_types {
> + TPM2_SU_CLEAR = 0x0000,
> + TPM2_SU_STATE = 0x0001,
> +};
> +
> +enum tpm2_cc_attrs {
> + TPM2_CC_ATTR_CHANDLES = 25,
> + TPM2_CC_ATTR_RHANDLE = 28,
> + TPM2_CC_ATTR_VENDOR = 29,
> +};
> +
> +enum tpm2_permanent_handles {
> + TPM2_RH_NULL = 0x40000007,
> + TPM2_RS_PW = 0x40000009,
> +};
> +
> +/* Most Significant Octet for key types */
> +enum tpm2_mso_type {
> + TPM2_MSO_NVRAM = 0x01,
> + TPM2_MSO_SESSION = 0x02,
> + TPM2_MSO_POLICY = 0x03,
> + TPM2_MSO_PERMANENT = 0x40,
> + TPM2_MSO_VOLATILE = 0x80,
> + TPM2_MSO_PERSISTENT = 0x81,
> +};
> +
> +enum tpm2_curves {
> + TPM2_ECC_NONE = 0x0000,
> + TPM2_ECC_NIST_P256 = 0x0003,
> +};
> +
> +enum tpm2_object_attributes {
> + TPM2_OA_FIXED_TPM = BIT(1),
> + TPM2_OA_ST_CLEAR = BIT(2),
> + TPM2_OA_FIXED_PARENT = BIT(4),
> + TPM2_OA_SENSITIVE_DATA_ORIGIN = BIT(5),
> + TPM2_OA_USER_WITH_AUTH = BIT(6),
> + TPM2_OA_ADMIN_WITH_POLICY = BIT(7),
> + TPM2_OA_NO_DA = BIT(10),
> + TPM2_OA_ENCRYPTED_DUPLICATION = BIT(11),
> + TPM2_OA_RESTRICTED = BIT(16),
> + TPM2_OA_DECRYPT = BIT(17),
> + TPM2_OA_SIGN = BIT(18),
> +};
> +
> +enum tpm2_session_attributes {
> + TPM2_SA_CONTINUE_SESSION = BIT(0),
> + TPM2_SA_AUDIT_EXCLUSIVE = BIT(1),
> + TPM2_SA_AUDIT_RESET = BIT(3),
> + TPM2_SA_DECRYPT = BIT(5),
> + TPM2_SA_ENCRYPT = BIT(6),
> + TPM2_SA_AUDIT = BIT(7),
> +};
> +
> +enum tpm2_pcr_select {
> + TPM2_PLATFORM_PCR = 24,
> + TPM2_PCR_SELECT_MIN = ((TPM2_PLATFORM_PCR + 7) / 8),
> +};
> +
> +enum tpm2_handle_types {
> + TPM2_HT_HMAC_SESSION = 0x02000000,
> + TPM2_HT_POLICY_SESSION = 0x03000000,
> + TPM2_HT_TRANSIENT = 0x80000000,
> +};
> +
> +enum tpm2_pt_props {
> + TPM2_PT_NONE = 0x00000000,
> + TPM2_PT_GROUP = 0x00000100,
> + TPM2_PT_FIXED = TPM2_PT_GROUP * 1,
> + TPM2_PT_FAMILY_INDICATOR = TPM2_PT_FIXED + 0,
> + TPM2_PT_LEVEL = TPM2_PT_FIXED + 1,
> + TPM2_PT_REVISION = TPM2_PT_FIXED + 2,
> + TPM2_PT_DAY_OF_YEAR = TPM2_PT_FIXED + 3,
> + TPM2_PT_YEAR = TPM2_PT_FIXED + 4,
> + TPM2_PT_MANUFACTURER = TPM2_PT_FIXED + 5,
> + TPM2_PT_VENDOR_STRING_1 = TPM2_PT_FIXED + 6,
> + TPM2_PT_VENDOR_STRING_2 = TPM2_PT_FIXED + 7,
> + TPM2_PT_VENDOR_STRING_3 = TPM2_PT_FIXED + 8,
> + TPM2_PT_VENDOR_STRING_4 = TPM2_PT_FIXED + 9,
> + TPM2_PT_VENDOR_TPM_TYPE = TPM2_PT_FIXED + 10,
> + TPM2_PT_FIRMWARE_VERSION_1 = TPM2_PT_FIXED + 11,
> + TPM2_PT_FIRMWARE_VERSION_2 = TPM2_PT_FIXED + 12,
> + TPM2_PT_INPUT_BUFFER = TPM2_PT_FIXED + 13,
> + TPM2_PT_HR_TRANSIENT_MIN = TPM2_PT_FIXED + 14,
> + TPM2_PT_HR_PERSISTENT_MIN = TPM2_PT_FIXED + 15,
> + TPM2_PT_HR_LOADED_MIN = TPM2_PT_FIXED + 16,
> + TPM2_PT_ACTIVE_SESSIONS_MAX = TPM2_PT_FIXED + 17,
> + TPM2_PT_PCR_COUNT = TPM2_PT_FIXED + 18,
> + TPM2_PT_PCR_SELECT_MIN = TPM2_PT_FIXED + 19,
> + TPM2_PT_CONTEXT_GAP_MAX = TPM2_PT_FIXED + 20,
> + TPM2_PT_NV_COUNTERS_MAX = TPM2_PT_FIXED + 22,
> + TPM2_PT_NV_INDEX_MAX = TPM2_PT_FIXED + 23,
> + TPM2_PT_MEMORY = TPM2_PT_FIXED + 24,
> + TPM2_PT_CLOCK_UPDATE = TPM2_PT_FIXED + 25,
> + TPM2_PT_CONTEXT_HASH = TPM2_PT_FIXED + 26,
> + TPM2_PT_CONTEXT_SYM = TPM2_PT_FIXED + 27,
> + TPM2_PT_CONTEXT_SYM_SIZE = TPM2_PT_FIXED + 28,
> + TPM2_PT_ORDERLY_COUNT = TPM2_PT_FIXED + 29,
> + TPM2_PT_MAX_COMMAND_SIZE = TPM2_PT_FIXED + 30,
> + TPM2_PT_MAX_RESPONSE_SIZE = TPM2_PT_FIXED + 31,
> + TPM2_PT_MAX_DIGEST = TPM2_PT_FIXED + 32,
> + TPM2_PT_MAX_OBJECT_CONTEXT = TPM2_PT_FIXED + 33,
> + TPM2_PT_MAX_SESSION_CONTEXT = TPM2_PT_FIXED + 34,
> + TPM2_PT_PS_FAMILY_INDICATOR = TPM2_PT_FIXED + 35,
> + TPM2_PT_PS_LEVEL = TPM2_PT_FIXED + 36,
> + TPM2_PT_PS_REVISION = TPM2_PT_FIXED + 37,
> + TPM2_PT_PS_DAY_OF_YEAR = TPM2_PT_FIXED + 38,
> + TPM2_PT_PS_YEAR = TPM2_PT_FIXED + 39,
> + TPM2_PT_SPLIT_MAX = TPM2_PT_FIXED + 40,
> + TPM2_PT_TOTAL_COMMANDS = TPM2_PT_FIXED + 41,
> + TPM2_PT_LIBRARY_COMMANDS = TPM2_PT_FIXED + 42,
> + TPM2_PT_VENDOR_COMMANDS = TPM2_PT_FIXED + 43,
> + TPM2_PT_NV_BUFFER_MAX = TPM2_PT_FIXED + 44,
> + TPM2_PT_MODES = TPM2_PT_FIXED + 45,
> + TPM2_PT_MAX_CAP_BUFFER = TPM2_PT_FIXED + 46,
> + TPM2_PT_VAR = TPM2_PT_GROUP * 2,
> + TPM2_PT_PERMANENT = TPM2_PT_VAR + 0,
> + TPM2_PT_STARTUP_CLEAR = TPM2_PT_VAR + 1,
> + TPM2_PT_HR_NV_INDEX = TPM2_PT_VAR + 2,
> + TPM2_PT_HR_LOADED = TPM2_PT_VAR + 3,
> + TPM2_PT_HR_LOADED_AVAIL = TPM2_PT_VAR + 4,
> + TPM2_PT_HR_ACTIVE = TPM2_PT_VAR + 5,
> + TPM2_PT_HR_ACTIVE_AVAIL = TPM2_PT_VAR + 6,
> + TPM2_PT_HR_TRANSIENT_AVAIL = TPM2_PT_VAR + 7,
> + TPM2_PT_HR_PERSISTENT = TPM2_PT_VAR + 8,
> + TPM2_PT_HR_PERSISTENT_AVAIL = TPM2_PT_VAR + 9,
> + TPM2_PT_NV_COUNTERS = TPM2_PT_VAR + 10,
> + TPM2_PT_NV_COUNTERS_AVAIL = TPM2_PT_VAR + 11,
> + TPM2_PT_ALGORITHM_SET = TPM2_PT_VAR + 12,
> + TPM2_PT_LOADED_CURVES = TPM2_PT_VAR + 13,
> + TPM2_PT_LOCKOUT_COUNTER = TPM2_PT_VAR + 14,
> + TPM2_PT_MAX_AUTH_FAIL = TPM2_PT_VAR + 15,
> + TPM2_PT_LOCKOUT_INTERVAL = TPM2_PT_VAR + 16,
> + TPM2_PT_LOCKOUT_RECOVERY = TPM2_PT_VAR + 17,
> + TPM2_PT_NV_WRITE_RECOVERY = TPM2_PT_VAR + 18,
> + TPM2_PT_AUDIT_COUNTER_0 = TPM2_PT_VAR + 19,
> + TPM2_PT_AUDIT_COUNTER_1 = TPM2_PT_VAR + 20,
> +};
> +
> +struct tpm2_pcr_read_out {
> + __be32 update_cnt;
> + __be32 pcr_selects_cnt;
> + __be16 hash_alg;
> + u8 pcr_select_size;
> + u8 pcr_select[TPM2_PCR_SELECT_MIN];
> + __be32 digests_cnt;
> + __be16 digest_size;
> + u8 digest[];
> +} __packed;
> +
> +struct tpm2_get_random_out {
> + __be16 size;
> + u8 buffer[TPM_MAX_RNG_DATA];
> +} __packed;
> +
> +struct tpm2_get_cap_out {
> + u8 more_data;
> + __be32 subcap_id;
> + __be32 property_cnt;
> + __be32 property_id;
> + __be32 value;
> +} __packed;
> +
> +struct tpm2_pcr_selection {
> + __be16 hash_alg;
> + u8 size_of_select;
> + u8 pcr_select[3];
> +} __packed;
> +
> +struct tpm2_context {
> + __be64 sequence;
> + __be32 saved_handle;
> + __be32 hierarchy;
> + __be16 blob_size;
> +} __packed;
> +
> #endif
> --
> 2.47.3
>
LGTM
BR, Jarkko
^ permalink raw reply
* Re: [PATCH v16 02/38] tpm: Move TPM1 specific definitions to the command header
From: Jarkko Sakkinen @ 2026-05-15 23:14 UTC (permalink / raw)
To: Ross Philipson
Cc: linux-kernel, x86, linux-integrity, linux-doc, linux-crypto,
kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp, hpa,
dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, jgg, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <20260515211410.31440-3-ross.philipson@gmail.com>
On Fri, May 15, 2026 at 02:13:34PM -0700, Ross Philipson wrote:
> Gather all the TPM1 definitions and structures in the internal header
> file drivers/char/tpm/tpm.h into the command header. In addition, bring
> in the single RNG structure from tpm-interface.c.
>
> The definitions moved to these files correspond to the TCG specification
> for TPM 1 family:
>
> TPM 1.2 Main Specification
> - https://trustedcomputinggroup.org/resource/tpm-main-specification/
>
> Co-developed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Co-developed-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
> Signed-off-by: Ross Philipson <ross.philipson@gmail.com>
> ---
> drivers/char/tpm/tpm.h | 102 --------------------------------
> drivers/char/tpm/tpm1-cmd.c | 5 --
> include/linux/tpm_command.h | 115 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 115 insertions(+), 107 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 87d68ddf270a..043d78a9617a 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -52,105 +52,9 @@ enum tpm_addr {
> TPM_ADDR = 0x4E,
> };
>
> -#define TPM_WARN_RETRY 0x800
> -#define TPM_WARN_DOING_SELFTEST 0x802
> -#define TPM_ERR_DEACTIVATED 0x6
> -#define TPM_ERR_DISABLED 0x7
> -#define TPM_ERR_FAILEDSELFTEST 0x1C
> -#define TPM_ERR_INVALID_POSTINIT 38
> -
> -#define TPM_TAG_RQU_COMMAND 193
> -
> /* TPM2 specific constants. */
> #define TPM2_SPACE_BUFFER_SIZE 16384 /* 16 kB */
>
> -struct stclear_flags_t {
> - __be16 tag;
> - u8 deactivated;
> - u8 disableForceClear;
> - u8 physicalPresence;
> - u8 physicalPresenceLock;
> - u8 bGlobalLock;
> -} __packed;
> -
> -struct tpm1_version {
> - u8 major;
> - u8 minor;
> - u8 rev_major;
> - u8 rev_minor;
> -} __packed;
> -
> -struct tpm1_version2 {
> - __be16 tag;
> - struct tpm1_version version;
> -} __packed;
> -
> -struct timeout_t {
> - __be32 a;
> - __be32 b;
> - __be32 c;
> - __be32 d;
> -} __packed;
> -
> -struct duration_t {
> - __be32 tpm_short;
> - __be32 tpm_medium;
> - __be32 tpm_long;
> -} __packed;
> -
> -struct permanent_flags_t {
> - __be16 tag;
> - u8 disable;
> - u8 ownership;
> - u8 deactivated;
> - u8 readPubek;
> - u8 disableOwnerClear;
> - u8 allowMaintenance;
> - u8 physicalPresenceLifetimeLock;
> - u8 physicalPresenceHWEnable;
> - u8 physicalPresenceCMDEnable;
> - u8 CEKPUsed;
> - u8 TPMpost;
> - u8 TPMpostLock;
> - u8 FIPS;
> - u8 operator;
> - u8 enableRevokeEK;
> - u8 nvLocked;
> - u8 readSRKPub;
> - u8 tpmEstablished;
> - u8 maintenanceDone;
> - u8 disableFullDALogicInfo;
> -} __packed;
> -
> -typedef union {
> - struct permanent_flags_t perm_flags;
> - struct stclear_flags_t stclear_flags;
> - __u8 owned;
> - __be32 num_pcrs;
> - struct tpm1_version version1;
> - struct tpm1_version2 version2;
> - __be32 manufacturer_id;
> - struct timeout_t timeout;
> - struct duration_t duration;
> -} cap_t;
> -
> -enum tpm_capabilities {
> - TPM_CAP_FLAG = 4,
> - TPM_CAP_PROP = 5,
> - TPM_CAP_VERSION_1_1 = 0x06,
> - TPM_CAP_VERSION_1_2 = 0x1A,
> -};
> -
> -enum tpm_sub_capabilities {
> - TPM_CAP_PROP_PCR = 0x101,
> - TPM_CAP_PROP_MANUFACTURER = 0x103,
> - TPM_CAP_FLAG_PERM = 0x108,
> - TPM_CAP_FLAG_VOL = 0x109,
> - TPM_CAP_PROP_OWNER = 0x111,
> - TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
> - TPM_CAP_PROP_TIS_DURATION = 0x120,
> -};
> -
> enum tpm2_pt_props {
> TPM2_PT_NONE = 0x00000000,
> TPM2_PT_GROUP = 0x00000100,
> @@ -225,12 +129,6 @@ enum tpm2_pt_props {
> TPM2_PT_AUDIT_COUNTER_1 = TPM2_PT_VAR + 20,
> };
>
> -/* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
> - * bytes, but 128 is still a relatively large number of random bytes and
> - * anything much bigger causes users of struct tpm_cmd_t to start getting
> - * compiler warnings about stack frame size. */
> -#define TPM_MAX_RNG_DATA 128
> -
> extern const struct class tpm_class;
> extern const struct class tpmrm_class;
> extern dev_t tpm_devt;
> diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c
> index 664ca1fff2e8..96f189b5fd6f 100644
> --- a/drivers/char/tpm/tpm1-cmd.c
> +++ b/drivers/char/tpm/tpm1-cmd.c
> @@ -504,11 +504,6 @@ ssize_t tpm1_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
> }
> EXPORT_SYMBOL_GPL(tpm1_getcap);
>
> -struct tpm1_get_random_out {
> - __be32 rng_data_len;
> - u8 rng_data[TPM_MAX_RNG_DATA];
> -} __packed;
> -
> /**
> * tpm1_get_random() - get random bytes from the TPM's RNG
> * @chip: a &struct tpm_chip instance
> diff --git a/include/linux/tpm_command.h b/include/linux/tpm_command.h
> index 174b043d8bbc..30d01953a6f8 100644
> --- a/include/linux/tpm_command.h
> +++ b/include/linux/tpm_command.h
> @@ -36,6 +36,121 @@ enum tpm_command_ordinals {
> TPM_ORD_UNSEAL = 24,
> };
>
> +enum tpm_capabilities {
> + TPM_CAP_FLAG = 4,
> + TPM_CAP_PROP = 5,
> + TPM_CAP_VERSION_1_1 = 0x06,
> + TPM_CAP_VERSION_1_2 = 0x1A,
> +};
> +
> +enum tpm_sub_capabilities {
> + TPM_CAP_PROP_PCR = 0x101,
> + TPM_CAP_PROP_MANUFACTURER = 0x103,
> + TPM_CAP_FLAG_PERM = 0x108,
> + TPM_CAP_FLAG_VOL = 0x109,
> + TPM_CAP_PROP_OWNER = 0x111,
> + TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
> + TPM_CAP_PROP_TIS_DURATION = 0x120,
> +};
> +
> +/* Return Codes */
> +enum tpm_return_codes {
> + TPM_BASE_MASK = 0,
> + TPM_NON_FATAL_MASK = 0x00000800,
> + TPM_SUCCESS = TPM_BASE_MASK + 0,
> + TPM_ERR_DEACTIVATED = TPM_BASE_MASK + 6,
> + TPM_ERR_DISABLED = TPM_BASE_MASK + 7,
> + TPM_ERR_FAIL = TPM_BASE_MASK + 9,
> + TPM_ERR_FAILEDSELFTEST = TPM_BASE_MASK + 28,
> + TPM_ERR_INVALID_POSTINIT = TPM_BASE_MASK + 38,
> + TPM_ERR_INVALID_FAMILY = TPM_BASE_MASK + 55,
> + TPM_WARN_RETRY = TPM_BASE_MASK + TPM_NON_FATAL_MASK + 0,
> + TPM_WARN_DOING_SELFTEST = TPM_BASE_MASK + TPM_NON_FATAL_MASK + 2,
> +};
> +
> +struct stclear_flags_t {
> + __be16 tag;
> + u8 deactivated;
> + u8 disableForceClear;
> + u8 physicalPresence;
> + u8 physicalPresenceLock;
> + u8 bGlobalLock;
> +} __packed;
> +
> +struct tpm1_version {
> + u8 major;
> + u8 minor;
> + u8 rev_major;
> + u8 rev_minor;
> +} __packed;
> +
> +struct tpm1_version2 {
> + __be16 tag;
> + struct tpm1_version version;
> +} __packed;
> +
> +struct timeout_t {
> + __be32 a;
> + __be32 b;
> + __be32 c;
> + __be32 d;
> +} __packed;
> +
> +struct duration_t {
> + __be32 tpm_short;
> + __be32 tpm_medium;
> + __be32 tpm_long;
> +} __packed;
> +
> +struct permanent_flags_t {
> + __be16 tag;
> + u8 disable;
> + u8 ownership;
> + u8 deactivated;
> + u8 readPubek;
> + u8 disableOwnerClear;
> + u8 allowMaintenance;
> + u8 physicalPresenceLifetimeLock;
> + u8 physicalPresenceHWEnable;
> + u8 physicalPresenceCMDEnable;
> + u8 CEKPUsed;
> + u8 TPMpost;
> + u8 TPMpostLock;
> + u8 FIPS;
> + u8 operator;
> + u8 enableRevokeEK;
> + u8 nvLocked;
> + u8 readSRKPub;
> + u8 tpmEstablished;
> + u8 maintenanceDone;
> + u8 disableFullDALogicInfo;
> +} __packed;
> +
> +typedef union {
> + struct permanent_flags_t perm_flags;
> + struct stclear_flags_t stclear_flags;
> + __u8 owned;
> + __be32 num_pcrs;
> + struct tpm1_version version1;
> + struct tpm1_version2 version2;
> + __be32 manufacturer_id;
> + struct timeout_t timeout;
> + struct duration_t duration;
> +} cap_t;
> +
> +/*
> + * 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
> + * bytes, but 128 is still a relatively large number of random bytes and
> + * anything much bigger causes users of struct tpm_cmd_t to start getting
> + * compiler warnings about stack frame size.
> + */
> +#define TPM_MAX_RNG_DATA 128
> +
> +struct tpm1_get_random_out {
> + __be32 rng_data_len;
> + u8 rng_data[TPM_MAX_RNG_DATA];
> +} __packed;
> +
> /* Other constants */
> #define SRKHANDLE 0x40000000
> #define TPM_NONCE_SIZE 20
> --
> 2.47.3
>
LGTM
BR, Jarkko
^ permalink raw reply
* Re: [PATCH v16 01/38] tpm: Initial step to reorganize TPM public headers
From: Dave Hansen @ 2026-05-15 23:10 UTC (permalink / raw)
To: Jason Gunthorpe, Jarkko Sakkinen
Cc: Ross Philipson, linux-kernel, x86, linux-integrity, linux-doc,
linux-crypto, kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp,
hpa, dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <20260515230553.GO7702@ziepe.ca>
On 5/15/26 16:05, Jason Gunthorpe wrote:
> Can we please split out and progress the TPM reorg mini-series at the
> front?
Yes, please.
Any way to break this down and merge in more bite-size pieces would be
better for everyone involved.
^ permalink raw reply
* Re: [PATCH v16 01/38] tpm: Initial step to reorganize TPM public headers
From: Jason Gunthorpe @ 2026-05-15 23:05 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Ross Philipson, linux-kernel, x86, linux-integrity, linux-doc,
linux-crypto, kexec, linux-efi, iommu, dpsmith, tglx, mingo, bp,
hpa, dave.hansen, ardb, mjg59, James.Bottomley, peterhuewe, luto,
nivedita, herbert, davem, corbet, ebiederm, dwmw2, baolu.lu,
kanth.ghatraju, daniel.kiper, andrew.cooper3, trenchboot-devel
In-Reply-To: <agemXwxVb9jvAbYM@kernel.org>
On Sat, May 16, 2026 at 02:03:59AM +0300, Jarkko Sakkinen wrote:
> LGTM
>
> I'll hold on from actual tags up until there is some consensus with the
> patch set.
This patch set is huge, and I know there is alot of interest now in
DRTM.
Can we please split out and progress the TPM reorg mini-series at the
front?
Jason
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox