[PATCH v2 15/19] driver core: Expose committed device trust level

From: Leon Romanovsky

Date: Mon Nov 09 2026 - 02:46:44 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

IOMMU state can outlive a functional driver, including after failed setup
and unbind. The active trust level becomes disabled in those states, so
infrastructure needs access to the retained authorization.

Export device_get_committed_trust_level() to expose the existing lifetime
commitment independently of the active binding.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
drivers/base/trust.c | 13 +++++++++++++
include/linux/device/trust.h | 1 +
2 files changed, 14 insertions(+)

diff --git a/drivers/base/trust.c b/drivers/base/trust.c
index 2bec6825ef31e..f79762e201178 100644
--- a/drivers/base/trust.c
+++ b/drivers/base/trust.c
@@ -93,6 +93,19 @@ enum device_trust_level device_get_trust_level(const struct device *dev)
}
EXPORT_SYMBOL_GPL(device_get_trust_level);

+/**
+ * device_get_committed_trust_level - Return the lifetime trust commitment
+ * @dev: device to inspect
+ *
+ * Return: %DEVICE_TRUST_DISABLED before admission, otherwise the level fixed
+ * before driver setup. The commitment survives setup failure and unbind.
+ */
+enum device_trust_level device_get_committed_trust_level(const struct device *dev)
+{
+ return READ_ONCE(dev->trust_committed_level);
+}
+EXPORT_SYMBOL_GPL(device_get_committed_trust_level);
+
/**
* device_is_adversarial - Test whether a device is operated as an adversary
* @dev: device to inspect
diff --git a/include/linux/device/trust.h b/include/linux/device/trust.h
index 9d6d387d01203..decf5aaf2d46d 100644
--- a/include/linux/device/trust.h
+++ b/include/linux/device/trust.h
@@ -41,6 +41,7 @@ enum device_trust_policy {
void device_trust_init(struct device *dev);
int device_trust_set_policy(struct device *dev, enum device_trust_policy policy);
enum device_trust_level device_get_trust_level(const struct device *dev);
+enum device_trust_level device_get_committed_trust_level(const struct device *dev);
bool device_is_adversarial(const struct device *dev);

#endif /* _DEVICE_TRUST_H_ */

--
2.56.0