Skip to contentSkip to conversation

drm/i915/huc: Avoid attempting to authenticate non-existent fw

PATCH Superseded Michał Winiarski 3 participants 3 messages Jan 20, 2017

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/huc: Avoid attempting to authenticate non-existent fw

HuC authentication is called even if HuC firmware is not present in the system, leading to NULL ptr dereference on not allocated gem_object. Let's avoid trying to authenticate HuC if its firmware is not loaded succesfully.

While I'm here let's also assert that HuC vma is placed in GuC accessible range for consistency.

Fixes dac84a388528 ("drm/i915/huc: Support HuC authentication")
Cc Anusha Srivatsa <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 4 +++-
 drivers/gpu/drm/i915/intel_huc.c        | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +3 -1
index 2f1cf9a..777c0e0 100644
@@ -443,6 +443,7 @@ static int guc_hw_reset(struct drm_i915_private *dev_priv)
 int intel_guc_setup(struct drm_i915_private *dev_priv)
 {
 	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+	struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
 	const char *fw_path = guc_fw->path;
 	int retries, ret, err;
 
@@ -524,7 +525,8 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->fetch_status),
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
-	intel_guc_auth_huc(dev_priv);
+	if (huc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS)
+		intel_guc_auth_huc(dev_priv);
 
 	if (i915.enable_guc_submission) {
 		if (i915.guc_log_level >= 0)
drivers/gpu/drm/i915/intel_huc.c +1 -1
index 897ef31..ba53ea6 100644
@@ -309,7 +309,7 @@ void intel_guc_auth_huc(struct drm_i915_private *dev_priv)
 
 	/* Specify auth action and where public signature is. */
 	data[0] = INTEL_GUC_ACTION_AUTHENTICATE_HUC;
-	data[1] = i915_ggtt_offset(vma) + huc->fw.rsa_offset;
+	data[1] = guc_ggtt_offset(vma) + huc->fw.rsa_offset;
 
 	ret = intel_guc_send(guc, data, ARRAY_SIZE(data));
 	if (ret) {
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 33 lines · Michał Winiarski

HuC authentication is called even if HuC firmware is not present in the system, leading to NULL ptr dereference on not allocated gem_object. Let's avoid trying to authenticate HuC if its firmware is not loaded succesfully.

While I'm here let's also assert that HuC vma is placed in GuC accessible range for consistency.

Fixes dac84a388528 ("drm/i915/huc: Support HuC authentication")
Cc Anusha Srivatsa <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Michal Wajdeczko <[email protected]>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 4 +++-
 drivers/gpu/drm/i915/intel_huc.c        | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_guc_loader.c +1 -0
index 2f1cf9a..777c0e0 100644
@@ -443,6 +443,7 @@ static int guc_hw_reset(struct drm_i915_private *dev_priv)
 int intel_guc_setup(struct drm_i915_private *dev_priv)
 {
 	struct intel_uc_fw *guc_fw = &dev_priv->guc.fw;
+	struct intel_uc_fw *huc_fw = &dev_priv->huc.fw;
 	const char *fw_path = guc_fw->path;
 	int retries, ret, err;
 

drivers/gpu/drm/i915/intel_guc_loader.c int intel_guc_setup(struct drm_i915_private *dev_priv) · line 528

Quoted 5 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -1
@@ -524,7 +525,8 @@ int intel_guc_setup(struct drm_i915_private *dev_priv)
 		intel_uc_fw_status_repr(guc_fw->fetch_status),
 		intel_uc_fw_status_repr(guc_fw->load_status));
 
-	intel_guc_auth_huc(dev_priv);
+	if (huc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS)

Can we move this check into intel_guc_huc_auth() function? Note that similar check inside is done in intel_huc_load().

Quoted 9 lines
drivers/gpu/drm/i915/intel_guc_loader.c +1 -0
+		intel_guc_auth_huc(dev_priv);
 
 	if (i915.enable_guc_submission) {
 		if (i915.guc_log_level >= 0)
drivers/gpu/drm/i915/intel_huc.c +0 -0
index 897ef31..ba53ea6 100644

drivers/gpu/drm/i915/intel_huc.c void intel_guc_auth_huc(struct drm_i915_private *dev_priv) · line 312

Quoted 5 lines
drivers/gpu/drm/i915/intel_huc.c +1 -1
@@ -309,7 +309,7 @@ void intel_guc_auth_huc(struct drm_i915_private *dev_priv)
 
 	/* Specify auth action and where public signature is. */
 	data[0] = INTEL_GUC_ACTION_AUTHENTICATE_HUC;
-	data[1] = i915_ggtt_offset(vma) + huc->fw.rsa_offset;
+	data[1] = guc_ggtt_offset(vma) + huc->fw.rsa_offset;

While this is correct, I guess separate patch would be better.

Thanks,
Michal

Quoted 6 lines
drivers/gpu/drm/i915/intel_huc.c +0 -0
 	ret = intel_guc_send(guc, data, ARRAY_SIZE(data));
 	if (ret) {
Signature · 1 line
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✗ Fi.CI.BAT: warning for drm/i915/huc: Avoid attempting to authenticate non-existent fw

In reply to Michał Winiarski
== Series Details ==

== Series Details ==

Series: drm/i915/huc: Avoid attempting to authenticate non-existent fw
URL : https://patchwork.freedesktop.org/series/18300/
State : warning

== Summary ==

Series 18300v1 drm/i915/huc: Avoid attempting to authenticate non-existent fw
https://patchwork.freedesktop.org/api/1.0/series/18300/revisions/1/mbox/

Test kms_pipe_crc_basic:

        Subgroup read-crc-pipe-b:
                pass       -> DMESG-WARN (fi-snb-2520m)
fi-bdw-5557u     total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-bsw-n3050     total:246  pass:207  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-bxt-t5700     total:79   pass:66   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-j1900     total:246  pass:219  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-hsw-4770r     total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-ivb-3520m     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-ivb-3770      total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-kbl-7500u     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6260u     total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-skl-6700hq    total:246  pass:226  dwarn:0   dfail:0   fail:0   skip:20 
fi-skl-6700k     total:246  pass:222  dwarn:3   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-snb-2520m     total:246  pass:214  dwarn:1   dfail:0   fail:0   skip:31 
fi-snb-2600      total:246  pass:214  dwarn:0   dfail:0   fail:0   skip:32 

aa012aa081f6a6d2dd5a1df0f3c3736017df0d56 drm-tip: 2017y-01m-20d-09h-33m-30s UTC integration manifest cbe787f drm/i915/huc: Avoid attempting to authenticate non-existent fw

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3560/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx