Skip to contentSkip to conversation

Driver for Open Profile for DICE

PATCH Superseded David Brazdil 4 participants 11 messages Dec 13, 2021 – Dec 21, 2021

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Driver for Open Profile for DICE

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_v3

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

#1 lore raw

PATCH v3 1/2 dt-bindings: firmware: Add Open Profile for DICE

Add DeviceTree bindings for Open Profile for DICE, an open protocol for measured boot. Firmware uses DICE to measure the hardware/software combination and generates Compound Device Identifier (CDI) certificates. These are stored in memory and the buffer is described in the DT as a reserved memory region referenced by a compatible device node.

---
 .../bindings/firmware/google,open-dice.yaml   | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/google,open-dice.yaml
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +51 -0
new file mode 100644
index 000000000000..1aa69f381b8c
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/google,open-dice.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Open Profile for DICE Device Tree Bindings
+
+description: |
+  This binding represents a reserved memory region containing data
+  generated by the Open Profile for DICE protocol.
+
+  See https://pigweed.googlesource.com/open-dice/
+
+maintainers:
+  - David Brazdil <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - google,open-dice
+
+  memory-region:
+    maxItems: 1
+    description: |
+      phandle to the reserved memory node to be associated with the device
+      The reserved memory node should be defined as per the bindings,
+      Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml
+
+required:
+  - compatible
+  - memory-region
+
+additionalProperties: false
+
+examples:
+  - |
+    reserved-memory {
+        #address-cells = <2>;
+        #size-cells = <1>;
+
+        dice_reserved: dice@12340000 {
+            reg = <0x00 0x12340000 0x2000>;
+            no-map;
+        };
+    };
+
+    dice {
+        compatible = "google,open-dice";
+        memory-region = <&dice_reserved>;
+    };
Signature · 1 line
2.34.1.173.g76aa8bc2d0-goog
#6 lore raw

PATCH v3 2/2 misc: open-dice: Add driver to expose DICE data to userspace

In reply to David Brazdil

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 hardware/software combination measured by DICE, and can be used for remote attestation and sealing.

Add a driver that exposes reserved memory regions populated by firmware with DICE CDIs and exposes them to userspace via a character device.

Userspace obtains the memory region's size from read() and calls mmap() to create a mapping of the memory region in its address space. The mapping is not allowed to be write+shared, giving userspace a guarantee that the data were not overwritten by another process.

Userspace can also call write(), which triggers a wipe of the DICE data by the driver. Because both the kernel and userspace mappings use write-combine semantics, all clients observe the memory as zeroed after the syscall has returned.

Cc Andrew Scull <[email protected]>
Cc Will Deacon <[email protected]>
---
 drivers/misc/Kconfig     |  12 +++
 drivers/misc/Makefile    |   1 +
 drivers/misc/open-dice.c | 197 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 drivers/misc/open-dice.c
drivers/misc/Kconfig +12 -0
index 0f5a49fc7c9e..4d996485f5a7 100644
@@ -470,6 +470,18 @@ config HISI_HIKEY_USB
 	  switching between the dual-role USB-C port and the USB-A host ports
 	  using only one USB controller.
 
+config OPEN_DICE
+	tristate "Open Profile for DICE driver"
+	depends on OF_RESERVED_MEM
+	help
+	  This driver exposes a DICE reserved memory region to userspace via
+	  a character device. The memory region contains Compound Device
+	  Identifiers (CDIs) generated by firmware as an output of DICE
+	  measured boot flow. Userspace can uses CDIs for remote attestation
+	  and sealing.
+
+	  If unsure, say N.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index a086197af544..70e800e9127f 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
 obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
 obj-$(CONFIG_HI6421V600_IRQ)	+= hi6421v600-irq.o
+obj-$(CONFIG_OPEN_DICE)		+= open-dice.o
drivers/misc/open-dice.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
2.34.1.173.g76aa8bc2d0-goog
#7 lore raw

Re: [PATCH v3 2/2] misc: open-dice: Add driver to expose DICE data to userspace

Thank you for the patch! Perhaps something to improve:

Hi David,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on char-misc/char-misc-testing soc/for-next v5.16-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-Brazdil/Driver-for-Open-Profile-for-DICE/20211214-040051
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20211214/202112141128.lBBmmIuE-lkp(a)intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6fb8e9472d98abcc2dfabd43e95fc4ec5819ecd0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-Brazdil/Driver-for-Open-Profile-for-DICE/20211214-040051 git checkout 6fb8e9472d98abcc2dfabd43e95fc4ec5819ecd0
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/misc/open-dice.c:74: warning: Function parameter or member 'filp' not described in 'open_dice_read' drivers/misc/open-dice.c:74: warning: Function parameter or member 'ptr' not described in 'open_dice_read' drivers/misc/open-dice.c:74: warning: Function parameter or member 'len' not described in 'open_dice_read' drivers/misc/open-dice.c:74: warning: Function parameter or member 'off' not described in 'open_dice_read'

>> drivers/misc/open-dice.c:74: warning: expecting prototype for Returns the size of the reserved memory region. The user(). Prototype was for open_dice_read() instead
   drivers/misc/open-dice.c:84: warning: Function parameter or member 'filp' not described in 'open_dice_write'
   drivers/misc/open-dice.c:84: warning: Function parameter or member 'ptr' not described in 'open_dice_write'
   drivers/misc/open-dice.c:84: warning: Function parameter or member 'len' not described in 'open_dice_write'
   drivers/misc/open-dice.c:84: warning: Function parameter or member 'off' not described in 'open_dice_write'
>> drivers/misc/open-dice.c:84: warning: expecting prototype for Triggers a wipe of the reserved memory region. The user(). Prototype was for open_dice_write() instead
>> drivers/misc/open-dice.c:89: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

* Creates a mapping of the reserved memory region in a user address space.

vim +74 drivers/misc/open-dice.c

    67	
    68	/**
    69	 * Returns the size of the reserved memory region. The user-provided pointer is
    70	 * never dereferenced.
    71	 */
    72	static ssize_t open_dice_read(struct file *filp, char __user *ptr, size_t len,
    73				      loff_t *off)
  > 74	{
    75		return open_dice_size(to_open_dice_drvdata(filp));
    76	}
    77	
    78	/**
    79	 * Triggers a wipe of the reserved memory region. The user-provided pointer is
    80	 * never dereferenced.
    81	 */
    82	static ssize_t open_dice_write(struct file *filp, const char __user *ptr,
    83				       size_t len, loff_t *off)
  > 84	{
    85		return open_dice_wipe(to_open_dice_drvdata(filp));
    86	}
    87	
    88	/**
  > 89	 * Creates a mapping of the reserved memory region in a user address space.
    90	 */
    91	static int open_dice_mmap(struct file *filp, struct vm_area_struct *vma)
    92	{
    93		struct open_dice_drvdata *drvdata = to_open_dice_drvdata(filp);
    94	
    95		/* Do not allow userspace to modify the underlying data. */
    96		if ((vma->vm_flags & VM_WRITE) && (vma->vm_flags & VM_SHARED))
    97			return -EPERM;
    98	
    99		/* Create write-combine mapping so all clients observe a wipe. */

100 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
101 vma->vm_flags |= VM_DONTCOPY | VM_DONTDUMP;
102 return vm_iomap_memory(vma, drvdata->rmem->base, drvdata->rmem->size);
103 }
104

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw

Re: [PATCH v3 2/2] misc: open-dice: Add driver to expose DICE data to userspace

In reply to David Brazdil
Thank you for the patch! Perhaps something to improve:

Hi David,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on char-misc/char-misc-testing soc/for-next v5.16-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/David-Brazdil/Driver-for-Open-Profile-for-DICE/20211214-040051
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20211214/202112141150.Hh48OleF-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/6fb8e9472d98abcc2dfabd43e95fc4ec5819ecd0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review David-Brazdil/Driver-for-Open-Profile-for-DICE/20211214-040051 git checkout 6fb8e9472d98abcc2dfabd43e95fc4ec5819ecd0
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/misc/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/misc/open-dice.c: In function 'open_dice_probe':

>> drivers/misc/open-dice.c:30:21: warning: format '%d' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
      30 | #define DRIVER_NAME "open-dice"
         |                     ^~~~~~~~~~~
   drivers/misc/open-dice.c:160:49: note: in expansion of macro 'DRIVER_NAME'
     160 |  snprintf(drvdata->name, sizeof(drvdata->name), DRIVER_NAME"%d", dev_idx++);
         |                                                 ^~~~~~~~~~~
   drivers/misc/open-dice.c:160:62: note: format string is defined here
     160 |  snprintf(drvdata->name, sizeof(drvdata->name), DRIVER_NAME"%d", dev_idx++);
         |                                                             ~^
         |                                                              |
         |                                                              int
         |                                                             %ld

vim +30 drivers/misc/open-dice.c

    29	
  > 30	#define DRIVER_NAME "open-dice"
    31	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#9 lore raw

Re: [PATCH v3 2/2] misc: open-dice: Add driver to expose DICE data to userspace

In reply to David Brazdil
Quoted 74 lines · David Brazdil

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 hardware/software combination measured by DICE, and can be used for remote attestation and sealing.

Add a driver that exposes reserved memory regions populated by firmware with DICE CDIs and exposes them to userspace via a character device.

Userspace obtains the memory region's size from read() and calls mmap() to create a mapping of the memory region in its address space. The mapping is not allowed to be write+shared, giving userspace a guarantee that the data were not overwritten by another process.

Userspace can also call write(), which triggers a wipe of the DICE data by the driver. Because both the kernel and userspace mappings use write-combine semantics, all clients observe the memory as zeroed after the syscall has returned.

Cc Andrew Scull <[email protected]>
Cc Will Deacon <[email protected]>
---
 drivers/misc/Kconfig     |  12 +++
 drivers/misc/Makefile    |   1 +
 drivers/misc/open-dice.c | 197 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 drivers/misc/open-dice.c
drivers/misc/Kconfig +12 -0
index 0f5a49fc7c9e..4d996485f5a7 100644
@@ -470,6 +470,18 @@ config HISI_HIKEY_USB
 	  switching between the dual-role USB-C port and the USB-A host ports
 	  using only one USB controller.
 
+config OPEN_DICE
+	tristate "Open Profile for DICE driver"
+	depends on OF_RESERVED_MEM
+	help
+	  This driver exposes a DICE reserved memory region to userspace via
+	  a character device. The memory region contains Compound Device
+	  Identifiers (CDIs) generated by firmware as an output of DICE
+	  measured boot flow. Userspace can uses CDIs for remote attestation
+	  and sealing.
+
+	  If unsure, say N.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index a086197af544..70e800e9127f 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
 obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
 obj-$(CONFIG_HI6421V600_IRQ)	+= hi6421v600-irq.o
+obj-$(CONFIG_OPEN_DICE)		+= open-dice.o
drivers/misc/open-dice.c new file +7 -0
new file mode 100644
index 000000000000..ea7b1a8d49ac
@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2021 - Google LLC
+ * Author: David Brazdil <[email protected]>
+ *
+ * Driver for Open Profile for DICE.
+ *

drivers/misc/open-dice.c line 17

Quoted 10 lines
drivers/misc/open-dice.c new file +10 -0
+ * This driver takes ownership of a reserved memory region containing secrets
+ * derived following the Open Profile for DICE. The contents of the memory
+ * region are not interpreted by the kernel but can be mapped into a userspace
+ * process via a misc device. The memory region can also be wiped, removing
+ * the secrets from memory.
+ *
+ * Userspace can access the data by (w/o error handling):
+ *
+ *     fd = open("/dev/open-dice0", O_RDWR);
+ *     size = read(fd, NULL, 0);

I was thinking you would return the value as a string in the buffer provided to the read call, not as the return value itself. That is odd and probably breaks something. What would happen if you ran 'cat' on the device node?

thanks,

greg k-h

#10 lore raw

Re: [PATCH v3 2/2] misc: open-dice: Add driver to expose DICE data to userspace

Quoted 82 lines · Greg Kroah-Hartman
Quoted 81 lines · David Brazdil

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 hardware/software combination measured by DICE, and can be used for remote attestation and sealing.

Add a driver that exposes reserved memory regions populated by firmware with DICE CDIs and exposes them to userspace via a character device.

Userspace obtains the memory region's size from read() and calls mmap() to create a mapping of the memory region in its address space. The mapping is not allowed to be write+shared, giving userspace a guarantee that the data were not overwritten by another process.

Userspace can also call write(), which triggers a wipe of the DICE data by the driver. Because both the kernel and userspace mappings use write-combine semantics, all clients observe the memory as zeroed after the syscall has returned.

Cc Andrew Scull <[email protected]>
Cc Will Deacon <[email protected]>
---
 drivers/misc/Kconfig     |  12 +++
 drivers/misc/Makefile    |   1 +
 drivers/misc/open-dice.c | 197 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 drivers/misc/open-dice.c
drivers/misc/Kconfig +12 -0
index 0f5a49fc7c9e..4d996485f5a7 100644
@@ -470,6 +470,18 @@ config HISI_HIKEY_USB
 	  switching between the dual-role USB-C port and the USB-A host ports
 	  using only one USB controller.
 
+config OPEN_DICE
+	tristate "Open Profile for DICE driver"
+	depends on OF_RESERVED_MEM
+	help
+	  This driver exposes a DICE reserved memory region to userspace via
+	  a character device. The memory region contains Compound Device
+	  Identifiers (CDIs) generated by firmware as an output of DICE
+	  measured boot flow. Userspace can uses CDIs for remote attestation
+	  and sealing.
+
+	  If unsure, say N.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index a086197af544..70e800e9127f 100644
@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE)		+= uacce/
 obj-$(CONFIG_XILINX_SDFEC)	+= xilinx_sdfec.o
 obj-$(CONFIG_HISI_HIKEY_USB)	+= hisi_hikey_usb.o
 obj-$(CONFIG_HI6421V600_IRQ)	+= hi6421v600-irq.o
+obj-$(CONFIG_OPEN_DICE)		+= open-dice.o
drivers/misc/open-dice.c new file +14 -0
new file mode 100644
index 000000000000..ea7b1a8d49ac
@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2021 - Google LLC
+ * Author: David Brazdil <[email protected]>
+ *
+ * Driver for Open Profile for DICE.
+ *
+ * This driver takes ownership of a reserved memory region containing secrets
+ * derived following the Open Profile for DICE. The contents of the memory
+ * region are not interpreted by the kernel but can be mapped into a userspace
+ * process via a misc device. The memory region can also be wiped, removing
+ * the secrets from memory.
+ *
+ * Userspace can access the data by (w/o error handling):
Quoted 8 lines

drivers/misc/open-dice.c line 17

Quoted 3 lines
drivers/misc/open-dice.c new file +3 -0
+ *
+ *     fd = open("/dev/open-dice0", O_RDWR);
+ *     size = read(fd, NULL, 0);

I was thinking you would return the value as a string in the buffer provided to the read call, not as the return value itself. That is odd and probably breaks something. What would happen if you ran 'cat' on the device node?

Ah, I misunderstood. Yeah, running cat will endlessly print garbage. I'll do a quick respin and also change write() to appear to consume the buffer because 'echo 1 > /dev/open-dice0' currently blocks.

David

maintainer
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: firmware: Add Open Profile for DICE

In reply to David Brazdil
Quoted 58 lines · David Brazdil

Add DeviceTree bindings for Open Profile for DICE, an open protocol for measured boot. Firmware uses DICE to measure the hardware/software combination and generates Compound Device Identifier (CDI) certificates. These are stored in memory and the buffer is described in the DT as a reserved memory region referenced by a compatible device node.

---
 .../bindings/firmware/google,open-dice.yaml   | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/google,open-dice.yaml
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +40 -0
new file mode 100644
index 000000000000..1aa69f381b8c
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/google,open-dice.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Open Profile for DICE Device Tree Bindings
+
+description: |
+  This binding represents a reserved memory region containing data
+  generated by the Open Profile for DICE protocol.
+
+  See https://pigweed.googlesource.com/open-dice/
+
+maintainers:
+  - David Brazdil <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - google,open-dice
+
+  memory-region:
+    maxItems: 1
+    description: |
+      phandle to the reserved memory node to be associated with the device
+      The reserved memory node should be defined as per the bindings,
+      Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml
+
+required:
+  - compatible
+  - memory-region
+
+additionalProperties: false
+
+examples:
+  - |
+    reserved-memory {
+        #address-cells = <2>;
+        #size-cells = <1>;

Documentation/devicetree/bindings/firmware/google,open-dice.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +10 -0
+
+        dice_reserved: dice@12340000 {
+            reg = <0x00 0x12340000 0x2000>;
+            no-map;
+        };
+    };
+
+    dice {
+        compatible = "google,open-dice";
+        memory-region = <&dice_reserved>;

There's no need for this indirection. Just add the compatible to the dice@12340000 node. You can bind drivers to /reserved-memory nodes.

Rob

#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: firmware: Add Open Profile for DICE

Hi Rob,

Quoted 10 lines

Documentation/devicetree/bindings/firmware/google,open-dice.yaml line 50

Quoted 9 lines
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +9 -0
+        dice_reserved: dice@12340000 {
+            reg = <0x00 0x12340000 0x2000>;
+            no-map;
+        };
+    };
+
+    dice {
+        compatible = "google,open-dice";
+        memory-region = <&dice_reserved>;
Quoted 2 lines

There's no need for this indirection. Just add the compatible to the dice@12340000 node. You can bind drivers to /reserved-memory nodes.

I have not found a way to make that work for kernel modules. Built-in drivers can bind with RESERVEDMEM_OF_DECLARE, which puts an entry in __reservedmem_of_table and __reserved_mem_init_node() iterates find it there. A good case study might be CONFIG_TEGRA210_EMC, where the driver itself can be a module but the rmem parsing is always built-in under CONFIG_TEGRA210_EMC_TABLE. I don't think that's worth the trouble with this driver.

David

maintainer
#4 lore raw

Re: [PATCH v3 1/2] dt-bindings: firmware: Add Open Profile for DICE

Quoted 16 lines · David Brazdil

Hi Rob,

Quoted 10 lines

Documentation/devicetree/bindings/firmware/google,open-dice.yaml line 50

Quoted 9 lines
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +9 -0
+        dice_reserved: dice@12340000 {
+            reg = <0x00 0x12340000 0x2000>;
+            no-map;
+        };
+    };
+
+    dice {
+        compatible = "google,open-dice";
+        memory-region = <&dice_reserved>;
Quoted 2 lines

There's no need for this indirection. Just add the compatible to the dice@12340000 node. You can bind drivers to /reserved-memory nodes.

Quoted 7 lines

I have not found a way to make that work for kernel modules. Built-in drivers can bind with RESERVEDMEM_OF_DECLARE, which puts an entry in __reservedmem_of_table and __reserved_mem_init_node() iterates find it there. A good case study might be CONFIG_TEGRA210_EMC, where the driver itself can be a module but the rmem parsing is always built-in under CONFIG_TEGRA210_EMC_TABLE. I don't think that's worth the trouble with this driver.

I forgot you have to add the compatible to reserved_mem_matches in drivers/of/platform.c.

Rob

#5 lore raw

Re: [PATCH v3 1/2] dt-bindings: firmware: Add Open Profile for DICE

Quoted 25 lines · Rob Herring
Quoted 16 lines · David Brazdil

Hi Rob,

Quoted 10 lines

Documentation/devicetree/bindings/firmware/google,open-dice.yaml line 50

Quoted 9 lines
Documentation/devicetree/bindings/firmware/google,open-dice.yaml new file +9 -0
+        dice_reserved: dice@12340000 {
+            reg = <0x00 0x12340000 0x2000>;
+            no-map;
+        };
+    };
+
+    dice {
+        compatible = "google,open-dice";
+        memory-region = <&dice_reserved>;
Quoted 2 lines

There's no need for this indirection. Just add the compatible to the dice@12340000 node. You can bind drivers to /reserved-memory nodes.

Quoted 7 lines

I have not found a way to make that work for kernel modules. Built-in drivers can bind with RESERVEDMEM_OF_DECLARE, which puts an entry in __reservedmem_of_table and __reserved_mem_init_node() iterates find it there. A good case study might be CONFIG_TEGRA210_EMC, where the driver itself can be a module but the rmem parsing is always built-in under CONFIG_TEGRA210_EMC_TABLE. I don't think that's worth the trouble with this driver.

Quoted 2 lines

I forgot you have to add the compatible to reserved_mem_matches in drivers/of/platform.c.

Oh nice! Exactly what I was looking for, thanks. I'll respin shortly.

David