mbox series

[v4,0/2] Driver for Open Profile for DICE

Message ID 20211215150410.1707849-1-dbrazdil@google.com
Headers show
Series Driver for Open Profile for DICE | expand

Message

David Brazdil Dec. 15, 2021, 3:04 p.m. UTC
Open Profile for DICE is an open protocol for measured boot compatible
with the Trusted Computing Group's Device Identifier Composition
Engine (DICE) specification. The generated Compound Device Identifier
(CDI) certificates represent the measured hardware/software combination
and can be used by userspace for remote attestation and sealing.

This patchset adds DeviceTree bindings for the DICE device referencing
a reserved memory region containing the CDIs, and a driver that exposes
the memory region to userspace via a misc device.

See https://pigweed.googlesource.com/open-dice for more details.

The patches are based on top of v5.16-rc5 and can also be found here:
  https://android-kvm.googlesource.com/linux topic/dice_v4

Changes since v3:
  * align with semantics of read/write
  * fix kerneldoc warnings
  * fix printf format warnings

Changes since v2:
  * renamed from 'dice' to 'open-dice'
  * replaced ioctls with read/write
  * replaced memzero_explicit with memset
  * allowed multiple instances
  * expanded Kconfig description

Changes since v1:
  * converted to miscdevice
  * all mappings now write-combine to simplify semantics
  * removed atomic state, any attempt at exclusive access
  * simplified wipe, applied on ioctl, not on release
  * fixed ioctl return value

David Brazdil (2):
  dt-bindings: firmware: Add Open Profile for DICE
  misc: open-dice: Add driver to expose DICE data to userspace

 .../bindings/firmware/google,open-dice.yaml   |  51 +++++
 drivers/misc/Kconfig                          |  12 ++
 drivers/misc/Makefile                         |   1 +
 drivers/misc/open-dice.c                      | 197 ++++++++++++++++++
 4 files changed, 261 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/google,open-dice.yaml
 create mode 100644 drivers/misc/open-dice.c

--
2.34.1.173.g76aa8bc2d0-goog

Comments

Greg Kroah-Hartman Dec. 15, 2021, 3:19 p.m. UTC | #1
On Wed, Dec 15, 2021 at 03:04:10PM +0000, David Brazdil wrote:
> +	drvdata = devm_kmalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> +	if (!drvdata)
> +		return -ENOMEM;
> +
> +	*drvdata = (struct open_dice_drvdata){
> +		.lock = __SPIN_LOCK_UNLOCKED(drvdata->lock),
> +		.rmem = rmem,
> +		.misc = (struct miscdevice){
> +			.parent	= dev,
> +			.name	= drvdata->name,
> +			.minor	= MISC_DYNAMIC_MINOR,
> +			.fops	= &open_dice_fops,
> +			.mode	= 0600,
> +		},
> +	};

That is a lovely abuse of an implicit memcpy(), took me a while to
realize what it was doing here...

Anyway, this all looks great to me, I'll wait for the DT maintainers to
review the dt change before being able to take this through my tree.
Thanks for the cleanups based on the review, the driver is now almost
1/3 smaller than your first version with more functionality!

thanks,

greg k-h
David Brazdil Dec. 15, 2021, 3:45 p.m. UTC | #2
On Wed, Dec 15, 2021 at 04:19:35PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Dec 15, 2021 at 03:04:10PM +0000, David Brazdil wrote:
> > +	drvdata = devm_kmalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> > +	if (!drvdata)
> > +		return -ENOMEM;
> > +
> > +	*drvdata = (struct open_dice_drvdata){
> > +		.lock = __SPIN_LOCK_UNLOCKED(drvdata->lock),
> > +		.rmem = rmem,
> > +		.misc = (struct miscdevice){
> > +			.parent	= dev,
> > +			.name	= drvdata->name,
> > +			.minor	= MISC_DYNAMIC_MINOR,
> > +			.fops	= &open_dice_fops,
> > +			.mode	= 0600,
> > +		},
> > +	};
> 
> That is a lovely abuse of an implicit memcpy(), took me a while to
> realize what it was doing here...
> 
> Anyway, this all looks great to me, I'll wait for the DT maintainers to
> review the dt change before being able to take this through my tree.
> Thanks for the cleanups based on the review, the driver is now almost
> 1/3 smaller than your first version with more functionality!

Thanks, and thank your for your help!

David