Skip to contentSkip to conversation

firmware: imx: NXP Secure-Enclave FW Driver

PATCH Superseded Pankaj Gupta 5 participants 21 messages Sep 27, 2023 – Oct 27, 2023

Subsystems (3)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover firmware: imx: NXP Secure-Enclave FW Driver

V6 Changes:

- 1/11 (New): Kernel doc: "Documentation/driver-api/firmware/other_interfaces.rst" is added.

- 2/11 DT Binding: Disposed off comments from .yaml
-- replaced the "sram-pool" property, with standard property "fsl,sram". -- removed the additional details from the description.

- 3,4,5,6/11: DTSI changes:

	-- Validated using the following commands:
		--- make dt_binding_check DT_SCHEMA_FILES=freescale
        --- make CHECK_DTBS=y freescale/imx8ulp-evk.dtb;
		    make CHECK_DTBS=y freescale/imx93-11x11-evk.dtb

- 7/11 firmware: imx: add driver for NXP EdgeLock Enclave:
-- Removed:

-- pr_info is removed.
-- macro "devctx_info", "devctx_dbg" & "devctx_err" is removed.
-- Updated ABI:
--- Users: user-space SE-LIB, crypto-api, imx-ocotp-ele driver , smw
--- IOCTLS: Updated the ioctl
--- read/write:
-- Correct message header validation.
--- segregated handling of the error, while msg header parsing.
-- removed TX and RX messages static allocation in state container. -- ran coccicheck: make C=1 CHECK=scripts/coccicheck drivers/firmware/imx/*.* W=1
--- ran on all the patches.
- 8/11 firmware: imx: init-fw api exchange on imx93
-- removed TX and RX messages static allocation in state container. -- moved the header file ele_fw_api.h, to driver/firmware/imx/
-- segregated handling of the error, while msg header parsing.

- 9/11 firmware: imx: enable trng
-- macro "devctx_info", "devctx_dbg" & "devctx_err" is removed.
-- will remove this patch, will send this patch later, including RNG and crypto-maintainers.

- 10/11 firmware: imx: enclave-fw: add handling for save/restore IMEM region -- Linux comment style fixed.

- 10/11(old)(Removed) firmware: imx: enclave api to read-common-fuses
-- This API will be used by imx-ocotp-ele.c.
-- This patch can be sent later, when the changes to imx-ocotp-ele.c will be sent. -- "Documentation/driver-api/firmware/other_interfaces.rst" will be update for the exported symbols:
- read_common_fuses()
- get_se_dev()

v5 Changes:
- 1/7 DT Binding: Disposed off comments from .yaml
-- to use "-", instead of "_".
-- to use generic name, concatinated with soc-id.
-- removed mu-did.
-- renamed the ele-mu to se-fw
-- moved the file from .../arm/freescale/ to .../firmware/
- 2/7 Changed the .dtsi, as per the comments.
-- removed mu-did
-- renamed the ele_mu to se-fw.
-- updated the compatible string.
-- tested the DTB.
- 4/7 Changed the .dtsi, as per the comments.
-- removed mu-did
-- renamed the ele_mu to se-fw.
-- updated the compatible string.
-- tested the DTB.
- 6/7 Changes in driver code:
-- replace pr_err with dev_err
-- removed export symbols, except one, which will be used in other driver. -- Each API, send-recived based on device reference.
-- Divided the commits into smaller commits.
- Base Driver
-- Added ABI file.
- 7/11 (new) firmware: imx: init-fw api exchange on imx93
- 8/11 (new) firmware: imx: enable trng
- 9/11 (new) firmware: imx: enclave-fw: add handling for save/restore IMEM region
- 10/11 (new) firmware: imx: enclave api to read-common-fuses

v4 Changes:
- Post internal review, changed the name from "ele-mu" to "se-fw".
- Disposed-off comments in the dt-binding file.
- Removed the non-hw related dt-bindings from the driver code.
- Corrected the File MAINTAINERS for correct name of yaml file.

v3 Changes:
- update the commit message for documentation.
- Fixed dt-binding checking error for file- fsl,ele_mu.yaml
- Coverity fixes in the ele_mu.c

v2 Changes:
- Fixed Kernel Test Bot issues.
- Removed ".../devicetree/bindings/mailbox/fsl,muap.txt"

The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like
- HSM
- SHE
- V2X

Communicates via message unit with linux kernel. This driver is enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware.

Driver configures multiple misc-device on the MU, for multiple user-space applications can communicate on single MU.

It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc.

Pankaj Gupta (11):
Documentation/firmware: added imx/se-fw to other_interfaces
dt-bindings: arm: fsl: add imx-se-fw binding doc
arm64: dts: imx8ulp-evk: added nxp secure enclave firmware
arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw
dma-range
arm64: dts: imx93-11x11-evk: added nxp secure enclave fw
arm64: dts: imx93-11x11-evk: reserved mem-ranges
firmware: imx: add driver for NXP EdgeLock Enclave
firmware: imx: init-fw api exchange on imx93
firmware: imx: enable trng
firmware: imx: enclave-fw: add handling for save/restore IMEM region
MAINTAINERS: Added maintainer details

 Documentation/ABI/testing/se-cdev             |   41 +
 .../bindings/firmware/fsl,imx-se-fw.yaml      |   73 +
 .../driver-api/firmware/other_interfaces.rst  |   67 +
 MAINTAINERS                                   |   10 +
 arch/arm64/boot/dts/freescale/imx8ulp-evk.dts |   15 +
 arch/arm64/boot/dts/freescale/imx8ulp.dtsi    |   12 +-
 .../boot/dts/freescale/imx93-11x11-evk.dts    |   15 +
 arch/arm64/boot/dts/freescale/imx93.dtsi      |   10 +-
 drivers/firmware/imx/Kconfig                  |   21 +
 drivers/firmware/imx/Makefile                 |    3 +
 drivers/firmware/imx/ele_base_msg.c           |  271 ++++
 drivers/firmware/imx/ele_common.c             |  294 ++++
 drivers/firmware/imx/ele_common.h             |   40 +
 drivers/firmware/imx/ele_fw_api.c             |  118 ++
 drivers/firmware/imx/ele_fw_api.h             |   26 +
 drivers/firmware/imx/ele_trng.c               |   47 +
 drivers/firmware/imx/se_fw.c                  | 1372 +++++++++++++++++
 drivers/firmware/imx/se_fw.h                  |  152 ++
 include/linux/firmware/imx/ele_base_msg.h     |   67 +
 include/linux/firmware/imx/ele_mu_ioctl.h     |   73 +
 20 files changed, 2725 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/testing/se-cdev
 create mode 100644 Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml
 create mode 100644 drivers/firmware/imx/ele_base_msg.c
 create mode 100644 drivers/firmware/imx/ele_common.c
 create mode 100644 drivers/firmware/imx/ele_common.h
 create mode 100644 drivers/firmware/imx/ele_fw_api.c
 create mode 100644 drivers/firmware/imx/ele_fw_api.h
 create mode 100644 drivers/firmware/imx/ele_trng.c
 create mode 100644 drivers/firmware/imx/se_fw.c
 create mode 100644 drivers/firmware/imx/se_fw.h
 create mode 100644 include/linux/firmware/imx/ele_base_msg.h
 create mode 100644 include/linux/firmware/imx/ele_mu_ioctl.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v6 1/11 Documentation/firmware: added imx/se-fw to other_interfaces

Documented i.MX SoC's Service layer and C_DEV driver for SoC(s) enabled with hardware IP for secure-enclaves like:
- edgelock enclave on i.MX93 & i.MX8ULP

---
 .../driver-api/firmware/other_interfaces.rst  | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
Documentation/driver-api/firmware/other_interfaces.rst +67 -0
index 06ac89adaafb..1d21b88ef20e 100644
@@ -49,3 +49,70 @@ of the requests on to a secure monitor (EL3).
 
 .. kernel-doc:: drivers/firmware/stratix10-svc.c
    :export:
+
+NXP i.MX Secure Enclave Enabled SoC Service layer and C_DEV driver
+------------------------------------------------------------------
+The NXP's i.MX HW IP like EdgeLock-Enclave, creating an embedded secure
+enclave within the SoC boundary to enable features like
+ - HSM
+ - SHE
+ - V2X
+
+SoC enabled with the NXP i.MX secure enclave IP(s) like EdgeLock-Enclave(ELE),
+are: i.MX93, i.MX8ULP.
+
+This driver exposes two interfaces:
+- service layer: This layer takes the two mutex locks:
+  "mu_cmd_lock" is taken to ensure one service is processed at a time. This
+  lock is not unlocked, till one service processing is complete. Multiple
+  messages can be exchanged with FW as part of one service processing.
+  "mu_lock" is taken to ensure one message is sent over MU at a time. This
+  lock is unlocked, post sending the message.
+
+- c_dev:
+  This driver configures multiple misc-devices on the MU, to exchange
+  messages from User-space application and NXP's Edgelocke Enclave firmware.
+  The driver ensures that the messages must follow the following protocol
+  defined.
+
+                                Non-Secure               +   Secure
+                                                         |
+                                                         |
+                  +---------+      +-------------+       |
+                  | se_fw.c +<---->+imx-mailbox.c|       |
+                  |         |      |  mailbox.c  +<-->+------+    +------+
+                  +---+-----+      +-------------+    | MU X +<-->+ ELE |
+                      |                               +------+    +------+
+                      +----------------+                 |
+                      |                |                 |
+                      v                v                 |
+                  logical           logical              |
+                  receiver          waiter               |
+                     +                 +                 |
+                     |                 |                 |
+                     |                 |                 |
+                     |            +----+------+          |
+                     |            |           |          |
+                     |            |           |          |
+              device_ctx     device_ctx     device_ctx   |
+                                                         |
+                User 0        User 1       User Y        |
+                +------+      +------+     +------+      |
+                |misc.c|      |misc.c|     |misc.c|      |
+ kernel space   +------+      +------+     +------+      |
+                                                         |
+ +------------------------------------------------------ |
+                    |             |           |          |
+ userspace     /dev/ele_muXch0    |           |          |
+                          /dev/ele_muXch1     |          |
+                                        /dev/ele_muXchY  |
+                                                         |
+
+When a user sends a command to the firmware, it registers its device_ctx
+as waiter of a response from firmware.
+
+Enclave's Firmware owns the storage management, over linux filesystem.
+For this c_dev provisions a dedicated slave device called "receiver".
+
+.. kernel-doc:: drivers/firmware/imx/se_fw.c
+   :export:
Signature · 1 line
2.34.1
#2 lore raw

PATCH v6 2/11 dt-bindings: arm: fsl: add imx-se-fw binding doc

In reply to Pankaj Gupta

The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like
- HSM
- SHE
- V2X

Communicates via message unit with linux kernel. This driver is enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware.

Driver configures multiple misc-device on the MU, for multiple user-space applications can communicate on single MU.

It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc.

---
 .../bindings/firmware/fsl,imx-se-fw.yaml      | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +73 -0
new file mode 100644
index 000000000000..d250794432b3
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/firmware/fsl,imx-se-fw.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP i.MX EdgeLock Enclave Firmware (ELEFW)
+
+maintainers:
+  - Pankaj Gupta <[email protected]>
+
+description:
+  The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded
+  secure enclave within the SoC boundary to enable features like
+  - HSM
+  - SHE
+  - V2X
+
+  It uses message unit to communicate and coordinate to pass messages
+  (e.g., data,  status and control) through its interfaces.
+
+properties:
+  compatible:
+    enum:
+      - fsl,imx8ulp-se-fw
+      - fsl,imx93-se-fw
+
+  mboxes:
+    description:
+      All MU channels must be within the same MU instance. Cross instances are
+      not allowed. Users need to ensure that used MU instance does not conflict
+      with other execution environments.
+    items:
+      - description: TX0 MU channel
+      - description: RX0 MU channel
+
+  mbox-names:
+    items:
+      - const: tx
+      - const: rx
+
+  fsl,mu-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Identifier to the message-unit among the multiple message-unit that exists on SoC.
+      Per message-unit, multiple misc-devices are created, that are  used by userspace
+      application as logical-waiter and logical-receiver.
+
+  memory-region:
+    items:
+      - description: Reserved memory region that can be accessed by firmware. Used for
+          exchanging the buffers between driver and firmware.
+
+  fsl,sram:
+    description: Phandle to the device SRAM
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - mboxes
+  - mbox-names
+  - fsl,mu-id
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {
+      compatible = "fsl,imx8ulp-se-fw";
+      mbox-names = "tx", "rx";
+      mboxes = <&s4muap 0 0>, <&s4muap 1 0>;
+      fsl,mu-id = <2>;
+    };
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Quoted 29 lines · Pankaj Gupta

The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like
- HSM
- SHE
- V2X

Communicates via message unit with linux kernel. This driver is enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware.

Driver configures multiple misc-device on the MU, for multiple user-space applications can communicate on single MU.

It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc.

---
 .../bindings/firmware/fsl,imx-se-fw.yaml      | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +2 -0
new file mode 100644
index 000000000000..d250794432b3
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 12

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/firmware/fsl,imx-se-fw.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP i.MX EdgeLock Enclave Firmware (ELEFW)
+
+maintainers:
+  - Pankaj Gupta <[email protected]>
+
+description:

Need '|' to preserve formatting.

Quoted 4 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +4 -0
+  The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded
+  secure enclave within the SoC boundary to enable features like
+  - HSM
+  - SHE

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+  - V2X
+
+  It uses message unit to communicate and coordinate to pass messages
+  (e.g., data,  status and control) through its interfaces.
+
+properties:
+  compatible:
+    enum:
+      - fsl,imx8ulp-se-fw
+      - fsl,imx93-se-fw

The firmware is not compatible across chips?

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+
+  mboxes:
+    description:
+      All MU channels must be within the same MU instance. Cross instances are
+      not allowed. Users need to ensure that used MU instance does not conflict
+      with other execution environments.
+    items:
+      - description: TX0 MU channel
+      - description: RX0 MU channel
+

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 46

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+  mbox-names:
+    items:
+      - const: tx
+      - const: rx
+
+  fsl,mu-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Identifier to the message-unit among the multiple message-unit that exists on SoC.
+      Per message-unit, multiple misc-devices are created, that are  used by userspace

Extra space in there.

Wrap lines at 80 unless there's a benefit to going to 100.

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 54

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +8 -0
+      application as logical-waiter and logical-receiver.
+
+  memory-region:
+    items:
+      - description: Reserved memory region that can be accessed by firmware. Used for
+          exchanging the buffers between driver and firmware.
+
+  fsl,sram:

Just the common 'sram' property.

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 55

Quoted 1 line
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +1 -0
+    description: Phandle to the device SRAM

Used for what?

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 62

Quoted 7 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +7 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - mboxes
+  - mbox-names
+  - fsl,mu-id

How is memory-region optional?

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 6 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +5 -0
+      compatible = "fsl,imx8ulp-se-fw";
+      mbox-names = "tx", "rx";
+      mboxes = <&s4muap 0 0>, <&s4muap 1 0>;
+      fsl,mu-id = <2>;
+    };
Signature · 1 line
2.34.1
#4 lore raw

RE: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Quoted 89 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, September 29, 2023 12:22 AM
To: Pankaj Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <linux- [email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Gaurav Jain <[email protected]>; [email protected]; Varun Sethi <[email protected]>
Subject: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 31 lines · Pankaj Gupta

The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like
- HSM
- SHE
- V2X

Communicates via message unit with linux kernel. This driver is enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware.

Driver configures multiple misc-device on the MU, for multiple user-space applications can communicate on single MU.

It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc.

---
 .../bindings/firmware/fsl,imx-se-fw.yaml      | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml

diff --git a/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml b/Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file mode 100644
index 000000000000..d250794432b3

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 3

Quoted 3 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +3 -0
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 4

Quoted 1 line
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +1 -0
+cetree.org%2Fschemas%2Ffirmware%2Ffsl%2Cimx-se-

fw.yaml%23&data=05%7C0

Quoted 1 line

+1%7Cpankaj.gupta%40nxp.com%7C5ec9b97100834814d30608dbc054010a%7 C686ea

Quoted 1 line

+1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638315239256248220%7CUnk nown%7C

Quoted 1 line

+TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi LCJXV

Quoted 1 line

+CI6Mn0%3D%7C3000%7C%7C%7C&sdata=5%2BuUxUzFCRHsi17vX83tGcJijp HsNAxd5Fu

Quoted 3 lines

+Ws4qT9Lw%3D&reserved=0
+$schema:

+https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevi

Quoted 1 line

+cetree.org%2Fmeta-

schemas%2Fcore.yaml%23&data=05%7C01%7Cpankaj.gupta%

Quoted 1 line

+40nxp.com%7C5ec9b97100834814d30608dbc054010a%7C686ea1d3bc2b4c6f a92cd9

Quoted 1 line

+9c5c301635%7C0%7C0%7C638315239256248220%7CUnknown%7CTWFpbGZ sb3d8eyJWI

Quoted 1 line

+joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7 C3000%

Quoted 1 line

+7C%7C%7C&sdata=o1LjAT7gJVTb66L21HyhfY9dGh8uKIFNHWKg%2FLNBMO 8%3D&reser

Quoted 10 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 12

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +8 -0
+ved=0
+
+title: NXP i.MX EdgeLock Enclave Firmware (ELEFW)
+
+maintainers:
+  - Pankaj Gupta <[email protected]>
+
+description:

Need '|' to preserve formatting.

Accepted.

Quoted 17 lines
Quoted 5 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +4 -0
+  The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded
+ secure enclave within the SoC boundary to enable features like
+  - HSM
+  - SHE

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+  - V2X
+
+  It uses message unit to communicate and coordinate to pass messages
+ (e.g., data,  status and control) through its interfaces.
+
+properties:
+  compatible:
+    enum:
+      - fsl,imx8ulp-se-fw
+      - fsl,imx93-se-fw

The firmware is not compatible across chips?

The secure-enclave hardware varies from one SoC to another. Hence, FW varies too, from one SoC, to other.

Quoted 23 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml

Quoted 5 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +4 -0
+
+  mboxes:
+    description:
+      All MU channels must be within the same MU instance. Cross instances

are

Quoted 1 line

+ not allowed. Users need to ensure that used MU instance does not

conflict

Quoted 4 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +4 -0
+      with other execution environments.
+    items:
+      - description: TX0 MU channel
+      - description: RX0 MU channel

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml

Quoted 10 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +10 -0
+
+  mbox-names:
+    items:
+      - const: tx
+      - const: rx
+
+  fsl,mu-id:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Identifier to the message-unit among the multiple message-unit that

exists on SoC.

Quoted 4 lines
Quoted 2 lines

+ Per message-unit, multiple misc-devices are created, that are
+ used by userspace

Extra space in there.

Accepted.

Quoted 3 lines

Wrap lines at 80 unless there's a benefit to going to 100.

Accepted.

Quoted 11 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml

Quoted 5 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +5 -0
+      application as logical-waiter and logical-receiver.
+
+  memory-region:
+    items:
+      - description: Reserved memory region that can be accessed by

firmware. Used for

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 54

Quoted 3 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +3 -0
+          exchanging the buffers between driver and firmware.
+
+  fsl,sram:

Just the common 'sram' property.

Ok

Quoted 4 lines
Quoted 2 lines

+ description: Phandle to the device SRAM

Used for what?

Accepted and will add the details on the usage.

Quoted 10 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 62

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +7 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - mboxes
+  - mbox-names
+  - fsl,mu-id

How is memory-region optional?

Depending on the type of enclave IP and the FW, memory-region is configured optionally. For i.MX8ULP and i.MX93, it is required. For i.MX8DXL, it is not required.

Quoted 9 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 7 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

I am sorry, if I am not able to understand your point here. But, all the below labels are getting used.
I can remove the fsl,mu-id. Will do it in V7.

Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +5 -1
+      compatible = "fsl,imx8ulp-se-fw";
+      mbox-names = "tx", "rx";
+      mboxes = <&s4muap 0 0>, <&s4muap 1 0>;
+      fsl,mu-id = <2>;
+    };
--

2.34.1

#5 lore raw

Re: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Quoted 10 lines · Pankaj Gupta
Quoted 10 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 62

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +7 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - mboxes
+  - mbox-names
+  - fsl,mu-id

How is memory-region optional?

Quoted 2 lines

Depending on the type of enclave IP and the FW, memory-region is configured optionally. For i.MX8ULP and i.MX93, it is required. For i.MX8DXL, it is not required.

Then write it in the bindings in allOf:if:then:.

Quoted 9 lines
Quoted 9 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 7 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

Quoted 3 lines

I am sorry, if I am not able to understand your point here. But, all the below labels are getting used.
I can remove the fsl,mu-id. Will do it in V7.

Comment was about labels, not properties.

Best regards,
Krzysztof

#6 lore raw

RE: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Quoted 33 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Wednesday, October 4, 2023 12:06 PM
To: Pankaj Gupta <[email protected]>; Rob Herring <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <linux- [email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Gaurav Jain <[email protected]>; [email protected]; Varun Sethi <[email protected]>
Subject: Re: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 10 lines · Pankaj Gupta
Quoted 10 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 62

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +7 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+required:
+  - compatible
+  - mboxes
+  - mbox-names
+  - fsl,mu-id

How is memory-region optional?

Quoted 5 lines
Quoted 1 line

Depending on the type of enclave IP and the FW, memory-region is

configured optionally.

Quoted 1 line

For i.MX8ULP and i.MX93, it is required. For i.MX8DXL, it is not required.

Then write it in the bindings in allOf:if:then:.

Accepted.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 8 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

Quoted 5 lines
Quoted 3 lines

I am sorry, if I am not able to understand your point here. But, all the below labels are getting used.
I can remove the fsl,mu-id. Will do it in V7.

Comment was about labels, not properties.

The label "ele_fw", is needed to be placed in different DTSI file.

For instance, node is added in i.mx93.dtsi.
Using label, the memory-region property dependent on size of DDR on the platform, is placed in:

- imx93-11x11-evk.dts

Quoted 3 lines

Best regards,
Krzysztof

#7 lore raw

Re: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 9 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 7 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

I am sorry, if I am not able to understand your point here. But, all the below labels are getting used.
I can remove the fsl,mu-id. Will do it in V7.

Quoted 7 lines
Quoted 1 line

Comment was about labels, not properties.

The label "ele_fw", is needed to be placed in different DTSI file.

For instance, node is added in i.mx93.dtsi.
Using label, the memory-region property dependent on size of DDR on the platform, is placed in:

- imx93-11x11-evk.dts

This is a standalone example, whether or not you need a label in the dts/dtsi is not relevant to this example.

#8 lore raw

Re: [EXT] Re: [PATCH v6 02/11] dt-bindings: arm: fsl: add imx-se-fw binding doc

In reply to Pankaj Gupta
Quoted 11 lines · Pankaj Gupta
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines

Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml line 68

Quoted 5 lines
Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml new file +5 -0
+additionalProperties: false
+
+examples:
+  - |
+    ele_fw: se-fw {

Drop unused labels.

I am sorry, if I am not able to understand your point here. But, all the below labels are getting used.
I can remove the fsl,mu-id. Will do it in V7.

Quoted 7 lines
Quoted 1 line

Comment was about labels, not properties.

The label "ele_fw", is needed to be placed in different DTSI file.

For instance, node is added in i.mx93.dtsi.
Using label, the memory-region property dependent on size of DDR on the platform, is placed in:

- imx93-11x11-evk.dts

And how is this related to this patch?

Best regards,
Krzysztof

#9 lore raw

PATCH v6 3/11 arm64: dts: imx8ulp-evk: added nxp secure enclave firmware

In reply to Pankaj Gupta

Added support for NXP secure enclave called EdgeLock Enclave firmware (se-fw) for imx8ulp-evk.

---
 arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8ulp.dtsi +11 -1
index 946f2b68d16f..0724a2524ac2 100644
@@ -152,7 +152,7 @@ sosc: clock-sosc {
 		#clock-cells = <0>;
 	};
 
-	sram@2201f000 {
+	sram0: sram@2201f000 {
 		compatible = "mmio-sram";
 		reg = <0x0 0x2201f000 0x0 0x1000>;
 
@@ -578,4 +578,14 @@ gpiod: gpio@2e200080 {
 			gpio-ranges = <&iomuxc1 0 0 24>;
 		};
 	};
+
+	ele_fw2: se-fw2 {
+		 compatible = "fsl,imx8ulp-se-fw";
+		 mbox-names = "tx", "rx";
+		 mboxes = <&s4muap 0 0>,
+			<&s4muap 1 0>;
+		 fsl,mu-id = <2>;
+		 fsl,sram = <&sram0>;
+	 };
+
 };
Signature · 1 line
2.34.1
#10 lore raw

PATCH v6 4/11 arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw dma-range

In reply to Pankaj Gupta

EdgeLock Enclave are has a hardware limitation of restricted access to the DDR memory range:
- 0x90000000 - 0xAFFFFFFF

ELE-FW driver requireis 1MB of memory. In this patch the we are reserving 1MB of ddr memory region from the lower 32-bit range.

---
 arch/arm64/boot/dts/freescale/imx8ulp-evk.dts | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/freescale/imx8ulp-evk.dts +15 -0
index 69dd8e31027c..d5cdce62a760 100644
@@ -19,6 +19,17 @@ memory@80000000 {
 		device_type = "memory";
 		reg = <0x0 0x80000000 0 0x80000000>;
 	};
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		ele_reserved: ele-reserved@90000000 {
+			compatible = "shared-dma-pool";
+			reg = <0 0x90000000 0 0x100000>;
+			no-map;
+		};
+	};
 
 	reserved-memory {
 		#address-cells = <2>;
@@ -146,6 +157,10 @@ &usdhc0 {
 	status = "okay";
 };
 
+&ele_fw2 {
+	memory-region = <&ele_reserved>;
+};
+
 &fec {
 	pinctrl-names = "default", "sleep";
 	pinctrl-0 = <&pinctrl_enet>;
Signature · 1 line
2.34.1
#11 lore raw

PATCH v6 5/11 arm64: dts: imx93-11x11-evk: added nxp secure enclave fw

In reply to Pankaj Gupta

Added support for NXP secure enclave called EdgeLock Enclave firmware (se-fw) for imx93-11x11-evk.

---
 arch/arm64/boot/dts/freescale/imx93.dtsi | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx93.dtsi +9 -1
index 6f85a05ee7e1..04c9af059461 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Copyright 2022 NXP
+ * Copyright 2022-2023 NXP
  */
 
 #include <dt-bindings/clock/imx93-clock.h>
@@ -923,4 +923,12 @@ ddr-pmu@4e300dc0 {
 			interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
 		};
 	};
+
+	ele_fw2: se-fw2 {
+		compatible = "fsl,imx93-se-fw";
+		mbox-names = "tx", "rx";
+		mboxes = <&s4muap 0 0>,
+			<&s4muap 1 0>;
+		fsl,mu-id = <2>;
+	};
 };
Signature · 1 line
2.34.1
#12 lore raw

PATCH v6 6/11 arm64: dts: imx93-11x11-evk: reserved mem-ranges

In reply to Pankaj Gupta

EdgeLock Enclave are has a hardware limitation of restricted access to the DDR memory range:
- 0x80000000 0x9FFFFFFF

ELE-MU driver requireis 1MB of memory. In this patch, reserving 1MB of ddr memory region from the lower 32-bit range.

---
 arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts +15 -0
index cafd39130eb8..bcb4ae931c64 100644
@@ -7,6 +7,10 @@
 
 #include "imx93.dtsi"
 
+&ele_fw2 {
+	memory-region = <&ele_reserved>;
+};
+
 / {
 	model = "NXP i.MX93 11X11 EVK board";
 	compatible = "fsl,imx93-11x11-evk", "fsl,imx93";
@@ -68,6 +72,17 @@ reg_vref_1v8: regulator-adc-vref {
 		regulator-max-microvolt = <1800000>;
 	};
 
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+		ele_reserved: ele-reserved@a4120000 {
+			compatible = "shared-dma-pool";
+			reg = <0 0xa4120000 0 0x100000>;
+			no-map;
+		};
+	};
+
 	reg_usdhc2_vmmc: regulator-usdhc2 {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
Signature · 1 line
2.34.1
#13 lore raw

PATCH v6 7/11 firmware: imx: add driver for NXP EdgeLock Enclave

In reply to Pankaj Gupta

The Edgelock Enclave , is the secure enclave embedded in the SoC to support the features like HSM, SHE & V2X, using message based communication channel.

ELE FW communicates on a dedicated MU with application core where kernel is running. It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93.

---
 Documentation/ABI/testing/se-cdev         |   41 +
 drivers/firmware/imx/Kconfig              |   12 +
 drivers/firmware/imx/Makefile             |    2 +
 drivers/firmware/imx/ele_base_msg.c       |  101 ++
 drivers/firmware/imx/ele_common.c         |  139 +++
 drivers/firmware/imx/ele_common.h         |   30 +
 drivers/firmware/imx/se_fw.c              | 1300 +++++++++++++++++++++
 drivers/firmware/imx/se_fw.h              |  144 +++
 include/linux/firmware/imx/ele_base_msg.h |   40 +
 include/linux/firmware/imx/ele_mu_ioctl.h |   73 ++
 10 files changed, 1882 insertions(+)
 create mode 100644 Documentation/ABI/testing/se-cdev
 create mode 100644 drivers/firmware/imx/ele_base_msg.c
 create mode 100644 drivers/firmware/imx/ele_common.c
 create mode 100644 drivers/firmware/imx/ele_common.h
 create mode 100644 drivers/firmware/imx/se_fw.c
 create mode 100644 drivers/firmware/imx/se_fw.h
 create mode 100644 include/linux/firmware/imx/ele_base_msg.h
 create mode 100644 include/linux/firmware/imx/ele_mu_ioctl.h
Documentation/ABI/testing/se-cdev new file +41 -0
new file mode 100644
index 000000000000..14a7143fcaf3
@@ -0,0 +1,41 @@
+What:		/dev/<se>_mu[0-9]+_ch[0-9]+
+Date:		August 2023
+KernelVersion:	6.6
+Contact:	[email protected], [email protected]
+Description:
+		NXP offers multiple hardware IP(s) for  secure-enclaves like EdgeLock-
+		Enclave(ELE), SECO. The character device file-descriptors
+		/dev/<se>_mu*_ch* are the interface between user-space NXP's secure-
+		enclave shared-library and the kernel driver.
+
+		The ioctl(2)-based ABI is defined and documented in
+		[include]<linux/firmware/imx/ele_mu_ioctl.h>
+		 ioctl(s) are used primarily for:
+			- shared memory management
+			- allocation of I/O buffers
+			- get mu info
+			- setting a dev-ctx as receiver that is slave to fw
+
+		The following file operations are supported:
+
+		open(2)
+		  Currently the only useful flags are O_RDWR.
+
+		read(2)
+		  Every read() from the opened character device context is waiting on
+		  wakeup_intruptible, that gets set by the registered mailbox callback
+		  function; indicating a message received from the firmware on message-
+		  unit.
+
+		write(2)
+		  Every write() to the opened character device context needs to acquire
+		  mailbox_lock, before sending message on to the message unit.
+
+		close(2)
+		  Stops and free up the I/O contexts that was associated
+		  with the file descriptor.
+
+Users:		https://github.com/nxp-imx/imx-secure-enclave.git,
+		https://github.com/nxp-imx/imx-smw.git
+		crypto/skcipher,
+		drivers/nvmem/imx-ocotp-ele.c
drivers/firmware/imx/Kconfig +12 -0
index c027d99f2a59..2822e5d4b24c 100644
@@ -28,3 +28,15 @@ config IMX_SCU_PD
 	depends on IMX_SCU
 	help
 	  The System Controller Firmware (SCFW) based power domain driver.
+
+config IMX_SEC_ENCLAVE
+	tristate "i.MX Embedded Secure Enclave - EdgeLock Enclave Firmware driver."
+	depends on IMX_MBOX && ARCH_MXC && ARM64
+	default m if ARCH_MXC
+
+	help
+	  It is possible to use APIs exposed by the iMX Secure Enclave HW IP called:
+          - EdgeLock Enclave Firmware (for i.MX8ULP, i.MX93),
+          like base, HSM, V2X & SHE using the SAB protocol via the shared Messaging
+          Unit. This driver exposes these interfaces via a set of file descriptors
+          allowing to configure shared memory, send and receive messages.
drivers/firmware/imx/Makefile +2 -0
index 8f9f04a513a8..77ec0f922788 100644
@@ -1,3 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IMX_DSP)		+= imx-dsp.o
 obj-$(CONFIG_IMX_SCU)		+= imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o
+sec_enclave-objs		= se_fw.o ele_common.o ele_base_msg.o
+obj-${CONFIG_IMX_SEC_ENCLAVE}	+= sec_enclave.o
drivers/firmware/imx/ele_base_msg.c new file +101 -0

101 lines not on this page · raw message

drivers/firmware/imx/ele_common.c new file +139 -0

139 lines not on this page · raw message

drivers/firmware/imx/ele_common.h new file +30 -0
new file mode 100644
index 000000000000..284b7f66d8e3
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2023 NXP
+ */
+
+
+#ifndef __ELE_COMMON_H__
+#define __ELE_COMMON_H__
+
+#include "se_fw.h"
+
+int imx_ele_msg_send_rcv(struct ele_mu_priv *priv);
+void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv);
+int imx_se_alloc_tx_rx_buf(struct ele_mu_priv *priv);
+int validate_rsp_hdr(struct ele_mu_priv *priv, unsigned int header,
+		     uint8_t msg_id, uint8_t sz, bool is_base_api);
+int plat_fill_cmd_msg_hdr(struct ele_mu_priv *priv,
+			  struct mu_hdr *hdr,
+			  uint8_t cmd,
+			  uint32_t len,
+			  bool is_base_api);
+#ifdef CONFIG_IMX_ELE_TRNG
+int ele_trng_init(struct device *dev);
+#else
+static inline int ele_trng_init(struct device *dev)
+{
+	return 0;
+}
+#endif
+#endif
drivers/firmware/imx/se_fw.c new file +1300 -0

1,300 lines not on this page · raw message

drivers/firmware/imx/se_fw.h new file +144 -0

144 lines not on this page · raw message

include/linux/firmware/imx/ele_base_msg.h new file +40 -0
new file mode 100644
index 000000000000..49e3619372be
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021-2023 NXP
+ *
+ * Header file for the ELE Base API(s).
+ */
+
+#ifndef ELE_BASE_MSG_H
+#define ELE_BASE_MSG_H
+
+#include <linux/types.h>
+
+#define WORD_SZ				4
+#define ELE_NONE_VAL			0x0
+
+#define ELE_SUCCESS_IND			0xD6
+
+#define ELE_GET_INFO_REQ		0xDA
+#define ELE_GET_INFO_REQ_MSG_SZ		0x10
+#define ELE_GET_INFO_RSP_MSG_SZ		0x08
+
+#define ELE_GET_INFO_BUFF_SZ		0x100
+#define ELE_GET_INFO_READ_SZ		0xA0
+#define DEVICE_GET_INFO_SZ		0x100
+
+#define GET_INFO_SOC_INFO_WORD_OFFSET	1
+#define GET_INFO_UUID_WORD_OFFSET	3
+#define GET_INFO_SL_NUM_MSB_WORD_OFF \
+	(GET_INFO_UUID_WORD_OFFSET + 3)
+#define GET_INFO_SL_NUM_LSB_WORD_OFF \
+	(GET_INFO_UUID_WORD_OFFSET + 0)
+
+#define ELE_PING_REQ			0x01
+#define ELE_PING_REQ_SZ			0x04
+#define ELE_PING_RSP_SZ			0x08
+
+int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size);
+int ele_ping(struct device *dev);
+
+#endif
include/linux/firmware/imx/ele_mu_ioctl.h new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
2.34.1
#14 lore raw

Re: [PATCH v6 07/11] firmware: imx: add driver for NXP EdgeLock Enclave

Quoted 9 lines · Pankaj Gupta

The Edgelock Enclave , is the secure enclave embedded in the SoC to support the features like HSM, SHE & V2X, using message based communication channel.

ELE FW communicates on a dedicated MU with application core where kernel is running. It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93.

Where is the user-space tool? Please include it in the commit msg. We talked about this already.

Quoted 3 lines
---
 Documentation/ABI/testing/se-cdev         |   41 +
 drivers/firmware/imx/Kconfig              |   12 +

...

Quoted 6 lines
drivers/firmware/imx/se_fw.c new file +6 -0
+
+	ret = ele_mu_request_channel(dev, &priv->rx_chan,
+				     &priv->ele_mb_cl, info->mbox_rx_name);
+	if (ret) {
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to request rx channel\n");

drivers/firmware/imx/se_fw.c line 1155

Quoted 10 lines
drivers/firmware/imx/se_fw.c new file +10 -0
+
+		goto exit;
+	}
+
+	priv->ctxs = devm_kzalloc(dev, sizeof(dev_ctx) * priv->max_dev_ctx,
+				  GFP_KERNEL);
+
+	if (!priv->ctxs) {
+		ret = -ENOMEM;
+		dev_err(dev, "Fail allocate mem for private dev-ctxs.\n");

So you ignored the feedback... I assume you ignored it all, so:

NAK

Please go back and implement the feedback.

Best regards,
Krzysztof

#15 lore raw

RE: [EXT] Re: [PATCH v6 07/11] firmware: imx: add driver for NXP EdgeLock Enclave

Quoted 26 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Wednesday, October 4, 2023 12:11 PM
To: Pankaj Gupta <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl- linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; linux- [email protected]; Gaurav Jain <[email protected]>; [email protected]; Varun Sethi <[email protected]>
Subject: [EXT] Re: [PATCH v6 07/11] firmware: imx: add driver for NXP EdgeLock Enclave

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 4 lines · Pankaj Gupta

The Edgelock Enclave , is the secure enclave embedded in the SoC to support the features like HSM, SHE & V2X, using message based communication channel.

Quoted 9 lines
Quoted 5 lines

ELE FW communicates on a dedicated MU with application core where kernel is running. It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93.

Where is the user-space tool? Please include it in the commit msg. We talked about this already.

It is included as part of "Documentation/ABI/testing/se-cdev". I will add it in the commit message too.

Quoted 27 lines
Quoted 3 lines
---
 Documentation/ABI/testing/se-cdev         |   41 +
 drivers/firmware/imx/Kconfig              |   12 +

...

Quoted 7 lines
drivers/firmware/imx/se_fw.c new file +7 -0
+
+     ret = ele_mu_request_channel(dev, &priv->rx_chan,
+                                  &priv->ele_mb_cl, info->mbox_rx_name);
+     if (ret) {
+             if (ret != -EPROBE_DEFER)
+                     dev_err(dev, "Failed to request rx channel\n");
+

drivers/firmware/imx/se_fw.c

Quoted 10 lines
drivers/firmware/imx/se_fw.c new file +10 -0
+             goto exit;
+     }
+
+     priv->ctxs = devm_kzalloc(dev, sizeof(dev_ctx) * priv->max_dev_ctx,
+                               GFP_KERNEL);
+
+     if (!priv->ctxs) {
+             ret = -ENOMEM;
+             dev_err(dev, "Fail allocate mem for private
+ dev-ctxs.\n");

So you ignored the feedback... I assume you ignored it all, so:

Quoted 3 lines

NAK

Please go back and implement the feedback.

I will remove the dev_err prints for memory allocations. If still needed, will convert the dev_err to dev_dbg.

Quoted 3 lines

Best regards,
Krzysztof

#16 lore raw

PATCH v6 8/11 firmware: imx: init-fw api exchange on imx93

In reply to Pankaj Gupta

On imx93 platforms, exchange init-fw message with enclave's firmware is to be done.

---
 drivers/firmware/imx/Makefile     |  2 +-
 drivers/firmware/imx/ele_fw_api.c | 51 +++++++++++++++++++++++++++++++
 drivers/firmware/imx/ele_fw_api.h | 20 ++++++++++++
 drivers/firmware/imx/se_fw.c      | 13 +++++++-
 4 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/imx/ele_fw_api.c
 create mode 100644 drivers/firmware/imx/ele_fw_api.h
drivers/firmware/imx/Makefile +1 -1
index 77ec0f922788..d61f06a8050a 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IMX_DSP)		+= imx-dsp.o
 obj-$(CONFIG_IMX_SCU)		+= imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o
-sec_enclave-objs		= se_fw.o ele_common.o ele_base_msg.o
+sec_enclave-objs		= se_fw.o ele_common.o ele_base_msg.o ele_fw_api.o
 obj-${CONFIG_IMX_SEC_ENCLAVE}	+= sec_enclave.o
drivers/firmware/imx/ele_fw_api.c new file +51 -0

51 lines not on this page · raw message

drivers/firmware/imx/ele_fw_api.h new file +20 -0
new file mode 100644
index 000000000000..21bb35b4041f
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2023 NXP
+ */
+
+#ifndef ELE_FW_API_H
+#define ELE_FW_API_H
+
+#include <linux/hw_random.h>
+
+#define MESSAGING_VERSION_7		0x7
+
+#define ELE_INIT_FW_REQ                 0x17
+#define ELE_INIT_FW_REQ_SZ              0x04
+#define ELE_INIT_FW_RSP_SZ              0x08
+
+
+int ele_init_fw(struct device *dev);
+
+#endif /* ELE_FW_API_H */
drivers/firmware/imx/se_fw.c +12 -1
index e47ad4b6ba54..c225cdc016be 100644
@@ -24,6 +24,7 @@
 #include <linux/sys_soc.h>
 
 #include "se_fw.h"
+#include "ele_fw_api.h"
 
 #define SOC_ID_OF_IMX8ULP		0x084D
 #define SOC_ID_OF_IMX93			0x9300
@@ -46,6 +47,7 @@ struct imx_info {
 	uint8_t *mbox_rx_name;
 	uint8_t *pool_name;
 	bool reserved_dma_ranges;
+	bool init_fw;
 };
 
 struct imx_info_list {
@@ -73,6 +75,7 @@ static const struct imx_info_list imx8ulp_info = {
 				.mbox_rx_name = "rx",
 				.pool_name = "fsl,sram",
 				.reserved_dma_ranges = true,
+				.init_fw = false,
 			},
 	},
 };
@@ -95,8 +98,9 @@ static const struct imx_info_list imx93_info = {
 				.mbox_rx_name = "rx",
 				.pool_name = NULL,
 				.reserved_dma_ranges = true,
+				.init_fw = true,
 			},
-		},
+	},
 };
 
 static const struct of_device_id se_fw_match[] = {
@@ -1228,6 +1232,13 @@ static int se_fw_probe(struct platform_device *pdev)
 		priv->flags |= RESERVED_DMA_POOL;
 	}
 
+	if (info->init_fw) {
+		/* start initializing ele fw */
+		ret = ele_init_fw(dev);
+		if (ret)
+			dev_err(dev, "Failed to initialize ele fw.\n");
+	}
+
 	if (info->socdev) {
 		ret = imx_soc_device_register(dev, info);
 		if (ret) {
Signature · 1 line
2.34.1
#17 lore raw

PATCH v6 9/11 firmware: imx: enable trng

In reply to Pankaj Gupta

Enabled trng on imx93 platform through enclave fw.

---
 drivers/firmware/imx/Kconfig              |   9 ++
 drivers/firmware/imx/Makefile             |   1 +
 drivers/firmware/imx/ele_base_msg.c       | 117 ++++++++++++++++++++++
 drivers/firmware/imx/ele_common.c         |  40 ++++++++
 drivers/firmware/imx/ele_common.h         |   2 +
 drivers/firmware/imx/ele_fw_api.c         |  67 +++++++++++++
 drivers/firmware/imx/ele_fw_api.h         |   6 ++
 drivers/firmware/imx/ele_trng.c           |  47 +++++++++
 drivers/firmware/imx/se_fw.c              |  23 ++++-
 include/linux/firmware/imx/ele_base_msg.h |  13 +++
 10 files changed, 324 insertions(+), 1 deletion(-)
 create mode 100644 drivers/firmware/imx/ele_trng.c
drivers/firmware/imx/Kconfig +9 -0
index 2822e5d4b24c..ffc02593293c 100644
@@ -40,3 +40,12 @@ config IMX_SEC_ENCLAVE
           like base, HSM, V2X & SHE using the SAB protocol via the shared Messaging
           Unit. This driver exposes these interfaces via a set of file descriptors
           allowing to configure shared memory, send and receive messages.
+
+config IMX_ELE_TRNG
+	tristate "i.MX ELE True Random Number Generator"
+	default y
+	select CRYPTO_RNG
+	select HW_RANDOM
+	help
+	  This driver provides kernel-side support for the Random Number generation,
+          through NXP hardware IP for secure-enclave called EdgeLock Enclave.
drivers/firmware/imx/Makefile +1 -0
index d61f06a8050a..9018f7824f36 100644
@@ -3,3 +3,4 @@ obj-$(CONFIG_IMX_DSP)		+= imx-dsp.o
 obj-$(CONFIG_IMX_SCU)		+= imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o
 sec_enclave-objs		= se_fw.o ele_common.o ele_base_msg.o ele_fw_api.o
 obj-${CONFIG_IMX_SEC_ENCLAVE}	+= sec_enclave.o
+sec_enclave-${CONFIG_IMX_ELE_TRNG} += ele_trng.o
drivers/firmware/imx/ele_base_msg.c +117 -0

120 lines not on this page · raw message

drivers/firmware/imx/ele_common.c +40 -0
index 4410245a19ec..d4b829c19133 100644
@@ -3,6 +3,10 @@
  * Copyright 2023 NXP
  */
 
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/firmware/imx/ele_base_msg.h>
+
 #include "ele_common.h"
 #include "se_fw.h"
 
@@ -137,3 +141,39 @@ int validate_rsp_hdr(struct ele_mu_priv *priv, unsigned int header,
 
 	return ret;
 }
+
+int ele_do_start_rng(struct device *dev)
+{
+	int ret;
+	int count = ELE_GET_TRNG_STATE_RETRY_COUNT;
+
+	ret = ele_get_trng_state(dev);
+	if (ret < 0) {
+		dev_err(dev, "Failed to get trng state\n");
+		return ret;
+	} else if (ret != ELE_TRNG_STATE_OK) {
+		/* call start rng */
+		ret = ele_start_rng(dev);
+		if (ret) {
+			dev_err(dev, "Failed to start rng\n");
+			return ret;
+		}
+
+		/* poll get trng state API, ELE_GET_TRNG_STATE_RETRY_COUNT times
+		 * or while trng state != 0x203
+		 */
+		do {
+			msleep(10);
+			ret = ele_get_trng_state(dev);
+			if (ret < 0) {
+				dev_err(dev, "Failed to get trng state\n");
+				return ret;
+			}
+			count--;
+		} while ((ret != ELE_TRNG_STATE_OK) && count);
+		if (ret != ELE_TRNG_STATE_OK)
+			return -EIO;
+	}
+
+	return 0;
+}
drivers/firmware/imx/ele_common.h +2 -0
index 284b7f66d8e3..f9e1d949dc6a 100644
@@ -27,4 +27,6 @@ static inline int ele_trng_init(struct device *dev)
 	return 0;
 }
 #endif
+
+int ele_do_start_rng(struct device *dev);
 #endif
drivers/firmware/imx/ele_fw_api.c +67 -0

70 lines not on this page · raw message

drivers/firmware/imx/ele_fw_api.h +6 -0
index 21bb35b4041f..70cd8cf5074b 100644
@@ -14,7 +14,13 @@
 #define ELE_INIT_FW_REQ_SZ              0x04
 #define ELE_INIT_FW_RSP_SZ              0x08
 
+#define ELE_GET_RANDOM_REQ		0xCD
+#define ELE_GET_RANDOM_REQ_SZ		0x10
+#define ELE_GET_RANDOM_RSP_SZ		0x08
+
 
 int ele_init_fw(struct device *dev);
+int ele_get_random(struct device *dev, void *data, size_t len);
+int ele_get_hwrng(struct hwrng *rng, void *data, size_t len, bool wait);
 
 #endif /* ELE_FW_API_H */
drivers/firmware/imx/ele_trng.c new file +47 -0

47 lines not on this page · raw message

drivers/firmware/imx/se_fw.c +22 -1
index c225cdc016be..b2ac00b3ac7d 100644
@@ -20,10 +20,10 @@
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-#include <linux/delay.h>
 #include <linux/sys_soc.h>
 
 #include "se_fw.h"
+#include "ele_common.h"
 #include "ele_fw_api.h"
 
 #define SOC_ID_OF_IMX8ULP		0x084D
@@ -48,6 +48,9 @@ struct imx_info {
 	uint8_t *pool_name;
 	bool reserved_dma_ranges;
 	bool init_fw;
+	/* platform specific flag to enable/disable the ELE True RNG */
+	bool start_rng;
+	bool enable_ele_trng;
 };
 
 struct imx_info_list {
@@ -76,6 +79,8 @@ static const struct imx_info_list imx8ulp_info = {
 				.pool_name = "fsl,sram",
 				.reserved_dma_ranges = true,
 				.init_fw = false,
+				.start_rng = true,
+				.enable_ele_trng = false,
 			},
 	},
 };
@@ -99,6 +104,8 @@ static const struct imx_info_list imx93_info = {
 				.pool_name = NULL,
 				.reserved_dma_ranges = true,
 				.init_fw = true,
+				.start_rng = true,
+				.enable_ele_trng = true,
 			},
 	},
 };
@@ -1252,9 +1259,23 @@ static int se_fw_probe(struct platform_device *pdev)
 	if (ret)
 		dev_err(dev, "Failed[%d] to ping the fw.\n", ret);
 
+	/* start ele rng */
+	if (info->start_rng) {
+		ret = ele_do_start_rng(dev);
+		if (ret)
+			dev_err(dev, "Failed to start ele rng\n");
+	}
+
+	if (!ret && info->enable_ele_trng) {
+		ret = ele_trng_init(dev);
+		if (ret)
+			dev_err(dev, "Failed to init ele-trng\n");
+	}
+
 	dev_info(dev, "i.MX secure-enclave: %s's mu#%d interface to firmware, configured.\n",
 		info->se_name,
 		priv->ele_mu_id);
+
 	return devm_of_platform_populate(dev);
 
 exit:
include/linux/firmware/imx/ele_base_msg.h +13 -0
index 49e3619372be..3ca4b47e4c4e 100644
@@ -34,7 +34,20 @@
 #define ELE_PING_REQ_SZ			0x04
 #define ELE_PING_RSP_SZ			0x08
 
+#define ELE_START_RNG_REQ		0xA3
+#define ELE_START_RNG_REQ_MSG_SZ	0x04
+#define ELE_START_RNG_RSP_MSG_SZ	0x08
+
+#define ELE_GET_TRNG_STATE_REQ		0xA4
+#define ELE_GET_TRNG_STATE_REQ_MSG_SZ	0x04
+#define ELE_GET_TRNG_STATE_RSP_MSG_SZ	0x0C
+#define ELE_TRNG_STATE_OK		0x203
+#define ELE_GET_TRNG_STATE_RETRY_COUNT	0x5
+#define CSAL_TRNG_STATE_MASK		0x0000ffff
+
 int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size);
 int ele_ping(struct device *dev);
+int ele_start_rng(struct device *dev);
+int ele_get_trng_state(struct device *dev);
 
 #endif
Signature · 1 line
2.34.1
#18 lore raw

Re: [PATCH v6 09/11] firmware: imx: enable trng

kernel test robot noticed the following build errors:

Hi Pankaj,

kernel test robot noticed the following build errors:

[auto build test ERROR on shawnguo/for-next]
[also build test ERROR on robh/for-next linus/master v6.6-rc3] [cannot apply to next-20230929]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pankaj-Gupta/Documentation-firmware-added-imx-se-fw-to-other_interfaces/20230927-202918
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next
patch link:    https://lore.kernel.org/r/20230927175401.1962733-10-pankaj.gupta%40nxp.com
patch subject: [PATCH v6 09/11] firmware: imx: enable trng
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20231001/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231001/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/firmware/imx/ele_trng.c:16:5: error: redefinition of 'ele_trng_init'

16 | int ele_trng_init(struct device *dev)
| ^~~~~~~~~~~~~
In file included from drivers/firmware/imx/ele_trng.c:8:
drivers/firmware/imx/ele_common.h:25:19: note: previous definition of 'ele_trng_init' with type 'int(struct device *)'
25 | static inline int ele_trng_init(struct device *dev)
| ^~~~~~~~~~~~~

vim +/ele_trng_init +16 drivers/firmware/imx/ele_trng.c

    15	
  > 16	int ele_trng_init(struct device *dev)
    17	{
    18		struct ele_trng *trng;
    19		int ret;
    20	
    21		trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL);
    22		if (!trng)
    23			return -ENOMEM;
    24	
    25		trng->dev         = dev;
    26		trng->rng.name    = "ele-trng";
    27		trng->rng.read    = ele_get_hwrng;
    28		trng->rng.priv    = (unsigned long)trng;
    29		trng->rng.quality = 1024;
    30	
    31		dev_dbg(dev, "registering ele-trng\n");
    32	
    33		ret = devm_hwrng_register(dev, &trng->rng);
    34		if (ret)
    35			return ret;
    36	
    37		dev_info(dev, "Successfully registered ele-trng\n");
    38		return 0;
    39	}
    40	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#19 lore raw

PATCH v6 10/11 firmware: imx: enclave-fw: add handling for save/restore IMEM region

In reply to Pankaj Gupta

Some IMEM region is lost during kernel power down. Due to this, firmware's functionaity cannot work correctly.

Saving encrypted IMEM region in kernel memory during power down, and restore IMEM region on resume.

---
 drivers/firmware/imx/ele_base_msg.c       |  53 ++++++++++
 drivers/firmware/imx/ele_common.c         | 115 ++++++++++++++++++++++
 drivers/firmware/imx/ele_common.h         |   8 ++
 drivers/firmware/imx/se_fw.c              |  44 ++++++++-
 drivers/firmware/imx/se_fw.h              |   8 ++
 include/linux/firmware/imx/ele_base_msg.h |  14 +++
 6 files changed, 240 insertions(+), 2 deletions(-)
drivers/firmware/imx/ele_base_msg.c +53 -0
index 3a3af2321f67..473388357dea 100644
@@ -216,3 +216,56 @@ int ele_start_rng(struct device *dev)
 
 	return ret;
 }
+
+int ele_service_swap(struct device *dev,
+		     phys_addr_t addr,
+		     u32 addr_size, u16 flag)
+{
+	struct ele_mu_priv *priv = dev_get_drvdata(dev);
+	int ret;
+	unsigned int status;
+
+	ret = imx_se_alloc_tx_rx_buf(priv);
+	if (ret)
+		return ret;
+
+	ret = plat_fill_cmd_msg_hdr(priv,
+				    (struct mu_hdr *)&priv->tx_msg->header,
+				    ELE_SERVICE_SWAP_REQ,
+				    ELE_SERVICE_SWAP_REQ_MSG_SZ,
+				    true);
+	if (ret)
+		return ret;
+
+	priv->tx_msg->data[0] = flag;
+	priv->tx_msg->data[1] = addr_size;
+	priv->tx_msg->data[2] = ELE_NONE_VAL;
+	priv->tx_msg->data[3] = lower_32_bits(addr);
+	priv->tx_msg->data[4] = plat_add_msg_crc((uint32_t *)&priv->tx_msg,
+						 ELE_SERVICE_SWAP_REQ_MSG_SZ);
+	ret = imx_ele_msg_send_rcv(priv);
+	if (ret < 0)
+		return ret;
+
+	ret  = validate_rsp_hdr(priv,
+				priv->rx_msg->header,
+				ELE_SERVICE_SWAP_REQ,
+				ELE_SERVICE_SWAP_RSP_MSG_SZ,
+				true);
+	if (ret)
+		return ret;
+
+	status = RES_STATUS(priv->rx_msg->data[0]);
+	if (status != priv->success_tag) {
+		dev_err(dev, "Command Id[%d], Response Failure = 0x%x",
+			ELE_SERVICE_SWAP_REQ, status);
+		ret = -1;
+	} else {
+		if (flag == ELE_IMEM_EXPORT)
+			ret = priv->rx_msg->data[1];
+		else
+			ret = 0;
+	}
+
+	return ret;
+}
drivers/firmware/imx/ele_common.c +115 -0

124 lines not on this page · raw message

drivers/firmware/imx/ele_common.h +8 -0
index f9e1d949dc6a..e1979b555b58 100644
@@ -9,6 +9,7 @@
 
 #include "se_fw.h"
 
+uint32_t plat_add_msg_crc(uint32_t *msg, uint32_t msg_len);
 int imx_ele_msg_send_rcv(struct ele_mu_priv *priv);
 void imx_se_free_tx_rx_buf(struct ele_mu_priv *priv);
 int imx_se_alloc_tx_rx_buf(struct ele_mu_priv *priv);
@@ -29,4 +30,11 @@ static inline int ele_trng_init(struct device *dev)
 #endif
 
 int ele_do_start_rng(struct device *dev);
+
+#ifdef CONFIG_PM_SLEEP
+int save_imem(struct device *dev);
+int restore_imem(struct device *dev,
+		 uint8_t *pool_name);
 #endif
+
+#endif /*__ELE_COMMON_H__ */
drivers/firmware/imx/se_fw.c +42 -2

103 lines not on this page · raw message

drivers/firmware/imx/se_fw.h +8 -0
index 25906f40daef..c7123c9233ca 100644
@@ -141,4 +141,12 @@ struct ele_mu_priv {
 	struct ele_imem_buf imem;
 };
 
+phys_addr_t get_phy_buf_mem_pool(struct device *dev,
+				 char *mem_pool_name,
+				 u32 **buf,
+				 uint32_t size);
+void free_phybuf_mem_pool(struct device *dev,
+			  char *mem_pool_name,
+			  u32 *buf,
+			  uint32_t size);
 #endif
include/linux/firmware/imx/ele_base_msg.h +14 -0
index 3ca4b47e4c4e..a7de50fdf8f4 100644
@@ -45,9 +45,23 @@
 #define ELE_GET_TRNG_STATE_RETRY_COUNT	0x5
 #define CSAL_TRNG_STATE_MASK		0x0000ffff
 
+#define ELE_SERVICE_SWAP_REQ		0xDF
+#define ELE_SERVICE_SWAP_REQ_MSG_SZ	0x24
+#define ELE_SERVICE_SWAP_RSP_MSG_SZ	0x0C
+#define ELE_IMEM_SIZE			0x10000
+#define ELE_IMEM_STATE_OK		0xCA
+#define ELE_IMEM_STATE_BAD		0xFE
+#define ELE_IMEM_STATE_WORD		0x27
+#define ELE_IMEM_STATE_MASK		0x00ff0000
+#define ELE_IMEM_EXPORT			0x1
+#define ELE_IMEM_IMPORT			0x2
+
 int ele_get_info(struct device *dev, phys_addr_t addr, u32 data_size);
 int ele_ping(struct device *dev);
 int ele_start_rng(struct device *dev);
 int ele_get_trng_state(struct device *dev);
+int ele_service_swap(struct device *dev,
+		     phys_addr_t addr,
+		     u32 addr_size, u16 flag);
 
 #endif
Signature · 1 line
2.34.1
#20 lore raw

PATCH v6 11/11 MAINTAINERS: Added maintainer details

In reply to Pankaj Gupta

MAINTAINERS: Added maintainer details for se-fw driver.

---
 MAINTAINERS | 10 ++++++++++
 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
index b19995690904..61e69dc247ad 100644
@@ -13758,6 +13758,16 @@ F:	mm/
 F:	tools/mm/
 F:	tools/testing/selftests/mm/
 
+NXP EDGELOCK(SECURE) ENCLAVE FIRMWARE DRIVER
+M:	Pankaj Gupta <[email protected]>
+R:	NXP Linux Team <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/arm/freescale/fsl,se-fw.yaml
+F:	drivers/firmware/imx/ele*.*
+F:	drivers/firmware/imx/se*.*
+F:	include/linux/firmware/imx/ele*.*
+
 MEMORY TECHNOLOGY DEVICES (MTD)
 M:	Miquel Raynal <[email protected]>
 M:	Richard Weinberger <[email protected]>
Signature · 1 line
2.34.1