Skip to contentSkip to conversation

core: add support for secure boot

PATCH New Alexandre Courbot 1 participant 1 message Oct 26, 2015 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 core: add support for secure boot

On GM20x and later GPUs, firmware for some essential falcons (notably FECS) must be authenticated by a NVIDIA-produced signature and loaded by a high-secure falcon in order to access certain registers, in a process known as Secure Boot.

Secure Boot requires the building of a binary blob containing the firmwares and signatures of the falcons to be loaded. This blob is then given to a high-secure falcon running a signed loader firmware that copies the blob into a write-protected region, checks that the signatures are valid, and finally loads the verified firmware into the managed falcons and switches them to a priviledged mode.

This patch adds code that performs this process using PMU as the high-secure falcon, and wires it into the device core.

Currently, only the secure loading of the FECS firmware is handled, but support for other falcons (notably GPCCS and PMU) is upcoming. The reason for limiting to FECS is that GR must initiate the loading of FECS at init time, which, being managed by secure boot, will trigger the loading of all other managed firmwares. A solution to this needs to be discussed.

This code is tested on Tegra/GM20B and some minor work is required for dGPU support, but the fundations are here for general support of Secure Boot.

This work is based on Deepak Goyal's initial port of Secure Boot to Nouveau.

---
 drm/nouveau/include/nvkm/core/device.h      |   10 +
 drm/nouveau/include/nvkm/core/secure_boot.h |   52 +
 drm/nouveau/nvkm/core/Kbuild                |    1 +
 drm/nouveau/nvkm/core/secure_boot.c         | 1737 +++++++++++++++++++++++++++
 drm/nouveau/nvkm/engine/device/base.c       |    9 +
 5 files changed, 1809 insertions(+)
 create mode 100644 drm/nouveau/include/nvkm/core/secure_boot.h
 create mode 100644 drm/nouveau/nvkm/core/secure_boot.c
drm/nouveau/include/nvkm/core/device.h +10 -0
index 8f760002e401..19e75bb0f02a 100644
@@ -78,6 +78,9 @@ struct nvkm_device {
 	u64 disable_mask;
 	u32 debug;
 
+	/* secure boot state, to repeat the process when needed */
+	void *secure_boot_state;
+
 	const struct nvkm_device_chip *chip;
 	enum {
 		NV_04    = 0x04,
@@ -205,6 +208,13 @@ struct nvkm_device_chip {
 	int (*sw     )(struct nvkm_device *, int idx, struct nvkm_sw **);
 	int (*vic    )(struct nvkm_device *, int idx, struct nvkm_engine **);
 	int (*vp     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+
+	struct {
+		/* Bit-mask of IDs of managed falcons. 0 means no secure boot */
+		unsigned long managed_falcons;
+		/* ID of the falcon that will perform secure boot */
+		unsigned long boot_falcon;
+	} secure_boot;
 };
 
 struct nvkm_device *nvkm_device_find(u64 name);
drm/nouveau/include/nvkm/core/secure_boot.h new file +52 -0

52 lines not on this page · raw message

drm/nouveau/nvkm/core/Kbuild +1 -0
index 7f66963f305c..9d2ecc0effec 100644
@@ -11,4 +11,5 @@ nvkm-y += nvkm/core/object.o
 nvkm-y += nvkm/core/oproxy.o
 nvkm-y += nvkm/core/option.o
 nvkm-y += nvkm/core/ramht.o
+nvkm-y += nvkm/core/secure_boot.o
 nvkm-y += nvkm/core/subdev.o
drm/nouveau/nvkm/core/secure_boot.c new file +1737 -0

1,737 lines not on this page · raw message

drm/nouveau/nvkm/engine/device/base.c +9 -0
index 7476ac271573..3e26fc5431d7 100644
@@ -26,6 +26,7 @@
 
 #include <core/notify.h>
 #include <core/option.h>
+#include <core/secure_boot.h>
 
 #include <subdev/bios.h>
 
@@ -2273,6 +2274,10 @@ nvkm_device_del(struct nvkm_device **pdevice)
 	if (device) {
 		mutex_lock(&nv_devices_mutex);
 		device->disable_mask = 0;
+
+		if (nvkm_need_secure_boot(device))
+			nvkm_secure_boot_fini(device);
+
 		for (i = NVKM_SUBDEV_NR - 1; i >= 0; i--) {
 			struct nvkm_subdev *subdev =
 				nvkm_device_subdev(device, i);
@@ -2567,6 +2572,10 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
 	}
 
 	ret = 0;
+
+	if (nvkm_need_secure_boot(device))
+		ret = nvkm_secure_boot_init(device);
+
 done:
 	mutex_unlock(&nv_devices_mutex);
 	return ret;
Signature · 6 lines
2.6.1

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau