Skip to contentSkip to conversation

spi: intel: Add protected and locked attributes

PATCH New Mika Westerberg 1 participant 1 message Apr 8, 2024 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: intel: Add protected and locked attributes

From: Tamar Mashiah <[email protected]>

The manufacturing access to the PCH/SoC SPI device is traditionally performed via userspace driver accessing registers via /dev/mem but due to security concerns /dev/mem access is being much restricted, hence the reason for utilizing dedicated Intel PCH/SoC SPI controller driver, which is already implemented in the Linux kernel.

Intel PCH/SoC SPI controller protects the flash storage via two mechanisms one is the via region protection registers and second via BIOS lock. The BIOS locks only the BIOS regions usually 0 and/or 6.

The device always boots with BIOS lock set, but during manufacturing the BIOS lock has to be lifted in order to enable the write access. This can be done by passing "writeable=1" in the command line when the driver is loaded. This "locked" state is exposed through new sysfs attributes (intel_spi_locked, intel_spi_bios_locked).

Second, also the region protection status is exposed via sysfs attribute (intel_spi_protected) as the manufacturing will need the both files in order to validate that the device is properly sealed.

---
 .../ABI/testing/sysfs-driver-spi-intel        | 20 ++++++
 drivers/spi/spi-intel-pci.c                   |  1 +
 drivers/spi/spi-intel-platform.c              |  1 +
 drivers/spi/spi-intel.c                       | 64 +++++++++++++++++--
 drivers/spi/spi-intel.h                       |  2 +
 5 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-spi-intel
Documentation/ABI/testing/sysfs-driver-spi-intel new file +20 -0
new file mode 100644
index 000000000000..5b3e425f0e14
@@ -0,0 +1,20 @@
+What:		/sys/devices/.../intel_spi_protected
+Date:		July 2024
+KernelVersion:	6.10
+Contact:	Tomas Winkler <[email protected]>
+Description:	This attribute allows the userspace to check if the
+		Intel SPI flash controller is write protected from the host.
+
+What:		/sys/devices/.../intel_spi_locked
+Date:		July 2024
+KernelVersion:	6.10
+Contact:	Tomas Winkler <[email protected]>
+Description:	This attribute allows the user space to check if the
+		Intel SPI flash controller locks supported opcodes.
+
+What:		/sys/devices/.../intel_spi_bios_locked
+Date:		July 2024
+KernelVersion:	6.10
+Contact:	Tomas Winkler <[email protected]>
+Description:	This attribute allows the user space to check if the
+		Intel SPI flash controller BIOS region is locked for writes.
drivers/spi/spi-intel-pci.c +1 -0
index 4337ca51d7aa..c3b54928143d 100644
@@ -94,6 +94,7 @@ static struct pci_driver intel_spi_pci_driver = {
 	.name = "intel-spi",
 	.id_table = intel_spi_pci_ids,
 	.probe = intel_spi_pci_probe,
+	.dev_groups = intel_spi_groups,
 };
 
 module_pci_driver(intel_spi_pci_driver);
drivers/spi/spi-intel-platform.c +1 -0
index 2ef09fa35661..0974cca83a5d 100644
@@ -28,6 +28,7 @@ static struct platform_driver intel_spi_platform_driver = {
 	.probe = intel_spi_platform_probe,
 	.driver = {
 		.name = "intel-spi",
+		.dev_groups = intel_spi_groups,
 	},
 };
 
drivers/spi/spi-intel.c +59 -5

101 lines not on this page · raw message

drivers/spi/spi-intel.h +2 -0
index a4f0327a46ff..c5f35060dd63 100644
@@ -13,6 +13,8 @@
 
 struct resource;
 
+extern const struct attribute_group *intel_spi_groups[];
+
 int intel_spi_probe(struct device *dev, struct resource *mem,
 		    const struct intel_spi_boardinfo *info);
 
Signature · 1 line
2.43.0