diff mbox

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

Message ID 20170120145430.3804-1-michal.winiarski@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michał Winiarski Jan. 20, 2017, 2:54 p.m. UTC
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 <anusha.srivatsa@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/intel_guc_loader.c | 4 +++-
 drivers/gpu/drm/i915/intel_huc.c        | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Michal Wajdeczko Jan. 20, 2017, 3:03 p.m. UTC | #1
On Fri, Jan 20, 2017 at 03:54:30PM +0100, Michał Winiarski wrote:
> 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 <anusha.srivatsa@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_guc_loader.c | 4 +++-
>  drivers/gpu/drm/i915/intel_huc.c        | 2 +-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
> index 2f1cf9a..777c0e0 100644
> --- a/drivers/gpu/drm/i915/intel_guc_loader.c
> +++ b/drivers/gpu/drm/i915/intel_guc_loader.c
> @@ -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)

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


> +		intel_guc_auth_huc(dev_priv);
>  
>  	if (i915.enable_guc_submission) {
>  		if (i915.guc_log_level >= 0)
> diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
> index 897ef31..ba53ea6 100644
> --- a/drivers/gpu/drm/i915/intel_huc.c
> +++ b/drivers/gpu/drm/i915/intel_huc.c
> @@ -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

>  
>  	ret = intel_guc_send(guc, data, ARRAY_SIZE(data));
>  	if (ret) {
> -- 
> 2.9.3
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 2f1cf9a..777c0e0 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -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)
diff --git a/drivers/gpu/drm/i915/intel_huc.c b/drivers/gpu/drm/i915/intel_huc.c
index 897ef31..ba53ea6 100644
--- a/drivers/gpu/drm/i915/intel_huc.c
+++ b/drivers/gpu/drm/i915/intel_huc.c
@@ -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) {