[PATCH v4 25/33] driver core: Expose committed device trust level

From: Leon Romanovsky

Date: Tue Nov 24 2026 - 04:48:52 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

After probe failure or unbind, active trust returns to blocked while the
accepted operating level remains committed. IOMMU state and other
infrastructure can outlive the driver, so active trust alone cannot tell
them which operating level was accepted.

Expose the retained commitment separately. This lets infrastructure honor
the original level after probe failure or unbind without mistaking inactive
driver state for a new authorization opportunity.

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 b968bfc937346..ddd570773a070 100644
--- a/drivers/base/trust.c
+++ b/drivers/base/trust.c
@@ -155,6 +155,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_BLOCKED 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 a3a583eeb484c..1ac9cb5b3ceb3 100644
--- a/include/linux/device/trust.h
+++ b/include/linux/device/trust.h
@@ -48,6 +48,7 @@ int device_trust_set_policy_locked(struct device *dev,
enum device_trust_policy policy);
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.1