firmware: imx: secvio: Add secvio support
Subsystems (2)
v3 cover firmware: imx: secvio: Add secvio support
The tampers are security feature available on i.MX products and managed by SNVS block.The tamper goal is to detect the variation of hardware or physical parameters, which can indicate an attack.
The SNVS, which provides secure non-volatile storage, allows to detect some hardware attacks against the SoC.They are connected to the security-violation ports, which send an alert when an out-of-range value is detected.
This detection is done by:
-Analog tampers: measure analogic values
- External clock frequency.
- Temperature.
- Voltage.
- Digital tampers:
- External tamper
- Other detectors:
- Secure real-time counter rollover tamper.
- Monotonic counter rollover tamper.
- Power supply glitch tamper.
The on-chip sensors for voltage, temperature, and clock frequency indicate if tamper scenarios may be present. These sensors generate an out-of-range signal that causes a security violation to clear the authentication and storage keys and to block access to sensitive information.
Add linux module secvio driver to handle security violation interrupt.
The "imx-secvio-sc" module is designed to report security violations and tamper triggering to the user.
The functionalities of the module are accessible via the "debugfs" kernel.The folder containing the interface files for the module is "<kernel_debugfs>/secvio/".
Get status
Reading from the "info" file will return the status of security:
- Fuse related to security tampers.
- SNVS readable registers.
- DGO registers.
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Dong Aisheng <[email protected]>
To: Shawn Guo <[email protected]>
To: Sascha Hauer <[email protected]>
To: Pengutronix Kernel Team <[email protected]>
To: Fabio Estevam <[email protected]>
Changes in v3:
- Dropped [PATCH 1/4] dt-bindings: firmware: secvio: Add device tree bindings.
- Reuse SCU node to prove secvio driver asynchronously.
- Dropped [PATCH 4/4] arm64: dts: imx8q: Add node for Security Violation.
- Removed explicit secvio sub-node within SCU node.
- Create seperate secvio platform devices.
- secvio driver probe asynchronously.
- SCU driver keep going and finish the probe first.
- added new function imx_scu_secvio_init() called within imx_scu_probe()
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- used b4 to add the devicetree list.
- Added all necessary to/cc list.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Vabhav Sharma (4):
dt-bindings: firmware: imx: add nvmem phandle
arm64: dts: imx8qxp: add node for nvmem property
firmware: imx: Add SC APIs required for secvio module
firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW
.../devicetree/bindings/firmware/fsl,scu.yaml | 3 + arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 1 + drivers/firmware/imx/Kconfig | 11 + drivers/firmware/imx/Makefile | 4 +- drivers/firmware/imx/imx-scu-secvio-debugfs.c | 274 +++++++++ drivers/firmware/imx/imx-scu-secvio.c | 618 +++++++++++++++++++++ drivers/firmware/imx/imx-scu.c | 8 +- drivers/firmware/imx/seco.c | 216 +++++++ include/linux/firmware/imx/ipc.h | 1 + include/linux/firmware/imx/sci.h | 9 + include/linux/firmware/imx/svc/imx-secvio-sc.h | 216 +++++++ include/linux/firmware/imx/svc/seco.h | 69 +++ 12 files changed, 1428 insertions(+), 2 deletions(-)
---
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
change-id: 20240508-secvio-8acfa2838385
Best regards,
Signature · 1 line
Vabhav Sharma <[email protected]>
PATCH v3 1/4 dt-bindings: firmware: imx: add nvmem phandle
nvmem phandle is required by secvio driver to
read fuse.
--- Documentation/devicetree/bindings/firmware/fsl,scu.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/firmware/fsl,scu.yaml +3 -0
@@ -112,6 +112,9 @@ properties: - const: rx2 - const: rx3 - const: gip3 + nvmem: + description: + phandle of NVMEM driver provided by the SCU pinctrl: description:
Signature · 1 line
2.25.1
Re: [PATCH v3 1/4] dt-bindings: firmware: imx: add nvmem phandle
Quoted 13 lines · Vabhav Sharma
nvmem phandle is required by secvio driver to
read fuse.Signed-off-by Vabhav Sharma <[email protected]>--- Documentation/devicetree/bindings/firmware/fsl,scu.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/firmware/fsl,scu.yaml +0
-0
Documentation/devicetree/bindings/firmware/fsl,scu.yaml properties: · line 114
Quoted 3 lines
Documentation/devicetree/bindings/firmware/fsl,scu.yaml +0
-0@@ -112,6 +112,9 @@ properties: - const: rx2 - const: rx3 - const: gip3
Missing blank line
Documentation/devicetree/bindings/firmware/fsl,scu.yaml properties: · line 117
Quoted 3 lines
Documentation/devicetree/bindings/firmware/fsl,scu.yaml +3
-0+ nvmem: + description: + phandle of NVMEM driver provided by the SCU
driver? Please describe hardware, not driver. I think I gave you such comment last time.
Best regards,
Krzysztof
PATCH v3 2/4 arm64: dts: imx8qxp: add node for nvmem property
In reply to Vabhav SharmaAdd nvmem property to be used by secvio driver.
--- arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/freescale/imx8qxp.dtsi +1 -0
@@ -210,6 +210,7 @@ system-controller { mboxes = <&lsio_mu1 0 0 &lsio_mu1 1 0 &lsio_mu1 3 3>; + nvmem = <&ocotp>; pd: power-controller { compatible = "fsl,imx8qxp-scu-pd", "fsl,scu-pd";
Signature · 1 line
2.25.1
PATCH v3 3/4 firmware: imx: Add SC APIs required for secvio module
In reply to Vabhav SharmaThe Security Violation module requires below System Controller Security controller API to interact with SNVS block via SCFW
- imx_sc_seco_build_info
- imx_sc_seco_secvio_enable
- imx_sc_seco_secvio_config
- imx_sc_seco_secvio_dgo_config
--- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/imx-scu.c | 4 +- drivers/firmware/imx/seco.c | 216 ++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/ipc.h | 1 + include/linux/firmware/imx/sci.h | 4 + include/linux/firmware/imx/svc/seco.h | 69 +++++++++++ 6 files changed, 294 insertions(+), 2 deletions(-)
drivers/firmware/imx/Makefile +1 -1
@@ -1,4 +1,4 @@ # 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 +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o seco.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o
drivers/firmware/imx/imx-scu.c +3 -1
@@ -242,9 +242,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp)* APIs are defined as void function in SCU firmware, so they * should be treated as return success always. */ -if ((saved_svc ==IMX_SC_RPC_SVC_MISC ) && +if (((saved_svc ==IMX_SC_RPC_SVC_MISC ) && (saved_func ==IMX_SC_MISC_FUNC_UNIQUE_ID || saved_func ==IMX_SC_MISC_FUNC_GET_BUTTON_STATUS )) + || (saved_svc ==IMX_SC_RPC_SVC_SECO && + saved_func ==IMX_SC_SECO_FUNC_BUILD_INFO )) ret =0 ; }
drivers/firmware/imx/seco.c new file +216 -0
216 lines not on this page · raw message
include/linux/firmware/imx/ipc.h +1 -0
@@ -25,6 +25,7 @@ enum imx_sc_rpc_svc {IMX_SC_RPC_SVC_PAD =6 ,IMX_SC_RPC_SVC_MISC =7 ,IMX_SC_RPC_SVC_IRQ =8 , + IMX_SC_RPC_SVC_SECO = 9, }; struct imx_sc_rpc_msg {
include/linux/firmware/imx/sci.h +4 -0
@@ -15,6 +15,10 @@#include <linux/firmware/imx/svc/misc.h> #include <linux/firmware/imx/svc/pm.h> #include <linux/firmware/imx/svc/rm.h> +#include <linux/firmware/imx/svc/seco.h> + +#define IMX_SC_IRQ_SECVIO BIT(6)/* Security violation */ +#define IMX_SC_IRQ_GROUP_WAKE 3/* Wakeup interrupts */ #if IS_ENABLED (CONFIG_IMX_SCU )int imx_scu_enable_general_irq_channel (struct device *dev);
include/linux/firmware/imx/svc/seco.h new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 4/4 firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW
In reply to Vabhav SharmaThe i.MX8QXP SoC contains the Secure Non-Volatile Storage (SNVS) block. This block can detect specific hardware attacks.This block can only be accessible using the SCFW API.
This module interact with the SCU which relay request to/from the SNVS block to detect if security violation occurred.
The driver register an IRQ handle to SCU for security violation interrupt.
When an interruption is fired, the driver inform the user.
--- drivers/firmware/imx/Kconfig | 11 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/imx-scu-secvio-debugfs.c | 274 +++++++++++ drivers/firmware/imx/imx-scu-secvio.c | 618 +++++++++++++++++++++++++ drivers/firmware/imx/imx-scu.c | 4 + include/linux/firmware/imx/sci.h | 5 + include/linux/firmware/imx/svc/imx-secvio-sc.h | 216 +++++++++ 7 files changed, 1130 insertions(+)
drivers/firmware/imx/Kconfig +11 -0
@@ -33,3 +33,14 @@ config IMX_SCMI_MISC_DRV core that could provide misc functions such as board control. This driver can also be built as a module. + +config SECVIO_SC + tristate "NXP SC secvio support" + depends on IMX_SCU + default y + help + If you say yes here you get support for the NXP SNVS security + violation module. It includes the possibility to read information + related to security violations and tampers. It also gives the + possibility to register user callbacks when a security violation + occurs.
drivers/firmware/imx/Makefile +2 -0
@@ -2,3 +2,5 @@ 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 seco.o obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o +obj-$(CONFIG_SECVIO_SC) += imx-scu-secvio.o +obj-$(CONFIG_DEBUG_FS) += imx-scu-secvio-debugfs.o
drivers/firmware/imx/imx-scu-secvio-debugfs.c new file +274 -0
274 lines not on this page · raw message
drivers/firmware/imx/imx-scu-secvio.c new file +618 -0
618 lines not on this page · raw message
drivers/firmware/imx/imx-scu.c +4 -0
@@ -339,6 +339,10 @@ static int imx_scu_probe(struct platform_device *pdev)dev_warn (dev,"failed to enable general irq channel: %d\n" , ret); + ret =imx_scu_secvio_init (dev); +if (ret) +dev_warn (dev,"failed to initialize secvio: %d\n" , ret); +dev_info (dev,"NXP i.MX SCU Initialized\n" );return devm_of_platform_populate (dev);
include/linux/firmware/imx/sci.h +5 -0
@@ -27,7 +27,12 @@ int imx_scu_irq_unregister_notifier(struct notifier_block *nb);int imx_scu_irq_group_enable (u8 group,u32 mask,u8 enable);int imx_scu_irq_get_status (u8 group,u32 *irq_status);int imx_scu_soc_init (struct device *dev); +int imx_scu_secvio_init (struct device *dev);#else +static inline int imx_scu_secvio_init (struct device *dev) +{ +return -EOPNOTSUPP ; +}static inline int imx_scu_soc_init (struct device *dev) {return -EOPNOTSUPP ;
include/linux/firmware/imx/svc/imx-secvio-sc.h new file +216 -0
216 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v3 4/4] firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW
kernel test robot noticed the following build warnings:
Hi Vabhav,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 9852d85ec9d492ebef56dc5f229416c925758edc]
url: https://github.com/intel-lab-lkp/linux/commits/Vabhav-Sharma/dt-bindings-firmware-imx-add-nvmem-phandle/20241107-134504 base: 9852d85ec9d492ebef56dc5f229416c925758edc patch link: https://lore.kernel.org/r/20241107-secvio-v3-4-ea27f1e9ced4%40nxp.com patch subject: [PATCH v3 4/4] firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW config: nios2-randconfig-r131-20241107 (https://download.01.org/0day-ci/archive/20241108/[email protected]/config) compiler: nios2-linux-gcc (GCC) 14.2.0 reproduce: (https://download.01.org/0day-ci/archive/20241108/[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]/
sparse warnings: (new ones prefixed by >>)
>> drivers/firmware/imx/imx-scu-secvio.c:59:15: sparse: sparse: symbol 'scdev' was not declared. Should it be static? >> drivers/firmware/imx/imx-scu-secvio.c:387:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got void * @@ drivers/firmware/imx/imx-scu-secvio.c:387:37: sparse: expected void [noderef] __user *to drivers/firmware/imx/imx-scu-secvio.c:387:37: sparse: got void * >> drivers/firmware/imx/imx-scu-secvio.c:399:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got void * @@
drivers/firmware/imx/imx-scu-secvio.c:399:46: sparse: expected void const [noderef] __user *from
drivers/firmware/imx/imx-scu-secvio.c:399:46: sparse: got void *
vim +/scdev +59 drivers/firmware/imx/imx-scu-secvio.c
56
57 static struct platform_driver imx_secvio_sc_driver;
> 58 struct platform_device *pdev;
> 59 struct device *scdev;
60 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 4/4] firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW
In reply to Vabhav Sharmakernel test robot noticed the following build errors:
Hi Vabhav,
kernel test robot noticed the following build errors:
[auto build test ERROR on 9852d85ec9d492ebef56dc5f229416c925758edc]
url: https://github.com/intel-lab-lkp/linux/commits/Vabhav-Sharma/dt-bindings-firmware-imx-add-nvmem-phandle/20241107-134504 base: 9852d85ec9d492ebef56dc5f229416c925758edc patch link: https://lore.kernel.org/r/20241107-secvio-v3-4-ea27f1e9ced4%40nxp.com patch subject: [PATCH v3 4/4] firmware: imx: secvio: Add support for SNVS secvio and tamper via SCFW config: csky-randconfig-001-20241108 (https://download.01.org/0day-ci/archive/20241108/[email protected]/config) compiler: csky-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241108/[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 >>):
csky-linux-ld: drivers/firmware/imx/imx-scu.o: in function `imx_scu_probe':
>> imx-scu.c:(.text+0x3dc): undefined reference to `imx_scu_secvio_init' >> csky-linux-ld: imx-scu.c:(.text+0x460): undefined reference to `imx_scu_secvio_init'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki