Re: [PATCH v4 21/33] driver core: Introduce a generic device trust level

From: Leon Romanovsky

Date: Thu Dec 03 2026 - 04:38:55 EST


On Tue, Dec 01, 2026 at 10:11:29PM +1100, Alexey Kardashevskiy wrote:
> On 24/11/26 20:43, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@xxxxxxxxxx>
> >
> > Attestation needs to hold devices before driver probing and DMA setup.
> > Authorization on individual buses does not provide a common policy that
> > drivers and infrastructure can use.
> >
> > Introduce a shared admission policy and operating trust level. Keep the
> > accepted level fixed for the device's lifetime because unbind or failed
> > setup does not necessarily undo hardware configuration. Retain active trust
> > through teardown so cleanup uses the same assumptions as setup. Preserve
> > existing behavior when no trust boot options are supplied.
> >
> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
>
>
> Reviewed-by: Alexey Kardashevskiy <aik@xxxxxxx>

Thanks

<...>

> > #define to_driver(obj) container_of(obj, struct driver_private, kobj)
> > +/**
> > + * enum device_trust_state - Device trust authorization and commitment
> > + * @DEVICE_TRUST_SELECTABLE: No authorization or commitment. When runtime
> > + * policy changes are enabled, any policy can be selected. Selecting
> > + * blocked enters %DEVICE_TRUST_WAITING.
> > + * @DEVICE_TRUST_WAITING: Blocked policy without commitment. Runtime
> > + * authorization requires adversarial or unrestricted and enters
> > + * %DEVICE_TRUST_AUTHORIZED; selecting default is rejected.
> > + * @DEVICE_TRUST_AUTHORIZED: Adversarial or unrestricted selected from
> > + * %DEVICE_TRUST_WAITING. Policy is fixed, but no operating level has
> > + * been committed.
> > + * @DEVICE_TRUST_COMMITTED: Policy and operating level accepted before
> > + * driver setup. Both remain fixed through setup failure and unbind.
>
>
> My AI says that binding a driver is possible in all of them except WAITING so it is quite exceptional but the name is not. Dunno, may be add the note about drivers binding in this comment.

I don't think so. This is internal state required by the trust_state logic
and its corresponding KUnit tests.

<...>

> > +/**
> > + * device_is_adversarial - Test whether a device is operated as an adversary
> > + * @dev: device to inspect
> > + *
> > + * Return: True when the active trust level is %DEVICE_TRUST_ADVERSARIAL.
> > + */
> > +bool device_is_adversarial(const struct device *dev)
> > +{
> > + return device_get_trust_level(dev) == DEVICE_TRUST_ADVERSARIAL;
> > +}
> > +EXPORT_SYMBOL_GPL(device_is_adversarial);
>
> Can be static inline.

This function is used later in the patch "iommu: Use device trust for
DMA restrictions".

>
> > +
> > +static const char * const device_trust_policy_names[] = {
> > + [DEVICE_TRUST_POLICY_DEFAULT] = "default",
>
> This "default" is a bus-specific default?

Yes. default means “don’t override” - each device keeps whatever its bus decides.

> I'd probably call it "bus":
>
> device_trust.default=bus

Sure, let's change.

>
>
> Seeing device_trust.default=default makes my brain explode :) Thanks,

Thanks