From: Leon Romanovsky 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 --- 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 8ed414d6eb0e..9f7478bd7a6d 100644 --- a/drivers/base/trust.c +++ b/drivers/base/trust.c @@ -157,6 +157,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 f39523df03ae..250cf4004193 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