[Nouveau] [PATCH v4 32/33] secboot: support optional falcons

Alexandre Courbot acourbot at nvidia.com
Mon Nov 21 08:29:29 UTC 2016


PMU support has been enabled for r352 ACR, but it must remain optional
if we want to preserve existing user-space that do not include it. Allow
ACR to be instanciated with a list of optional LS falcons, that will not
produce a fatal error if their firmware is not loaded. Also change the
secure boot bootstrap logic to be able to fall back to legacy behavior
if it turns out the boot falcon's LS firmware cannot be loaded.

Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>
---
 drm/nouveau/nvkm/subdev/secboot/acr.h      |  2 +-
 drm/nouveau/nvkm/subdev/secboot/acr_r352.c | 61 +++++++++++++----------
 2 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/drm/nouveau/nvkm/subdev/secboot/acr.h b/drm/nouveau/nvkm/subdev/secboot/acr.h
index 175f14fbda61..88825f6e0cb1 100644
--- a/drm/nouveau/nvkm/subdev/secboot/acr.h
+++ b/drm/nouveau/nvkm/subdev/secboot/acr.h
@@ -50,6 +50,7 @@ struct nvkm_acr_func {
  *
  * @boot_falcon: ID of the falcon that will perform secure boot
  * @managed_falcons: bitfield of falcons managed by this ACR
+ * @optional_falcons: bitfield of falcons we can live without
  * @start_address: virtual start address of the HS bootloader
  * @dmem_size: size of DMEM of the managing falcon
  */
@@ -59,6 +60,7 @@ struct nvkm_acr {
 
 	enum nvkm_falconidx boot_falcon;
 	unsigned long managed_falcons;
+	unsigned long optional_falcons;
 	u32 start_address;
 	u32 dmem_size;
 };
diff --git a/drm/nouveau/nvkm/subdev/secboot/acr_r352.c b/drm/nouveau/nvkm/subdev/secboot/acr_r352.c
index c9091483d45d..4eab1bbe98a2 100644
--- a/drm/nouveau/nvkm/subdev/secboot/acr_r352.c
+++ b/drm/nouveau/nvkm/subdev/secboot/acr_r352.c
@@ -412,6 +412,12 @@ acr_r352_prepare_ls_blob(struct acr_r352 *acr, u64 wpr_addr, u32 wpr_size)
 
 		img = acr->func->ls_ucode_img_load(acr, falcon_id);
 		if (IS_ERR(img)) {
+			if (acr->base.optional_falcons & BIT(falcon_id)) {
+				managed_falcons &= ~BIT(falcon_id);
+				nvkm_info(subdev, "skipping %s falcon...\n",
+					  nvkm_falcon_name[falcon_id]);
+				continue;
+			}
 			ret = PTR_ERR(img);
 			goto cleanup;
 		}
@@ -420,6 +426,23 @@ acr_r352_prepare_ls_blob(struct acr_r352 *acr, u64 wpr_addr, u32 wpr_size)
 		managed_count++;
 	}
 
+	/* Commit the actual list of falcons we will manage from now on */
+	acr->base.managed_falcons = managed_falcons;
+
+	/*
+	 * If we have a PMU firmware, let it manage the bootstrap of other
+	 * falcons.
+	 */
+	if (acr->func->ls_func[acr->base.boot_falcon] &&
+	    (managed_falcons & BIT(acr->base.boot_falcon))) {
+		for_each_set_bit(falcon_id, &managed_falcons, NVKM_FALCON_END) {
+			if (falcon_id == acr->base.boot_falcon)
+				continue;
+
+			acr->lazy_bootstrap |= BIT(falcon_id);
+		}
+	}
+
 	/*
 	 * Fill the WPR and LSF headers with the right offsets and compute
 	 * required WPR size
@@ -864,20 +887,25 @@ acr_r352_reset(struct nvkm_acr *_acr, struct nvkm_secboot *sb,
 	struct acr_r352 *acr = acr_r352(_acr);
 	struct nvkm_pmu *pmu = sb->subdev.device->pmu;
 	const char *fname = nvkm_falcon_name[falcon];
+	bool wpr_already_set = sb->wpr_set;
 	int ret;
 
-	/* Not self-managed? Redo secure boot entirely */
-	if (!nvkm_secboot_is_managed(sb, _acr->boot_falcon))
-		return acr_r352_reset_nopmu(acr, sb, falcon);
-
-	/*
-	 * Otherwise ensure secure boot is done, and command the PMU to reset
-	 * the desired falcon.
-	 */
+	/* Make sure secure boot is performed */
 	ret = acr_r352_bootstrap(acr, sb);
 	if (ret)
 		return ret;
 
+	/* No PMU interface? */
+	if (!nvkm_secboot_is_managed(sb, _acr->boot_falcon)) {
+		/* Redo secure boot entirely if it was already done */
+		if (wpr_already_set)
+			return acr_r352_reset_nopmu(acr, sb, falcon);
+		/* Else return the result of the initial invokation */
+		else
+			return ret;
+	}
+
+	/* Otherwise just ask the PMU to reset the falcon */
 	nvkm_debug(&sb->subdev, "resetting %s falcon\n", fname);
 	ret = nvkm_pmu_acr_boot_falcon(pmu, falcon);
 	if (ret) {
@@ -1073,23 +1101,6 @@ acr_r352_new_(const struct acr_r352_func *func, enum nvkm_falconidx boot_falcon,
 	acr->base.func = &acr_r352_base_func;
 	acr->func = func;
 
-	/*
-	 * If we have a PMU firmware, let it manage the bootstrap of other
-	 * falcons.
-	 */
-	if (func->ls_func[NVKM_FALCON_PMU] &&
-	    (managed_falcons & BIT(NVKM_FALCON_PMU))) {
-		int i;
-
-		for (i = 0; i < NVKM_FALCON_END; i++) {
-			if (i == NVKM_FALCON_PMU)
-				continue;
-
-			if (func->ls_func[i])
-				acr->lazy_bootstrap |= BIT(i);
-		}
-	}
-
 	return &acr->base;
 }
 
-- 
git-series 0.8.10


More information about the Nouveau mailing list