Anusha Srivatsa | bd13285 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2017 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
Michal Wajdeczko | ead92ed | 2017-10-06 09:02:09 +0000 | [diff] [blame] | 24 | |
| 25 | #include <linux/types.h> |
| 26 | |
| 27 | #include "intel_huc.h" |
Anusha Srivatsa | bd13285 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 28 | #include "i915_drv.h" |
Anusha Srivatsa | bd13285 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 29 | |
Michal Wajdeczko | 2fe2d4e | 2017-12-06 13:53:10 +0000 | [diff] [blame] | 30 | void intel_huc_init_early(struct intel_huc *huc) |
| 31 | { |
Sagar Arun Kamble | 57312ea | 2018-03-01 22:15:45 +0530 | [diff] [blame^] | 32 | intel_huc_fw_init_early(huc); |
Anusha Srivatsa | bd13285 | 2017-01-18 08:05:53 -0800 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | /** |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 36 | * intel_huc_auth() - Authenticate HuC uCode |
| 37 | * @huc: intel_huc structure |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 38 | * |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 39 | * Called after HuC and GuC firmware loading during intel_uc_init_hw(). |
| 40 | * |
| 41 | * This function pins HuC firmware image object into GGTT. |
| 42 | * Then it invokes GuC action to authenticate passing the offset to RSA |
| 43 | * signature through intel_guc_auth_huc(). It then waits for 50ms for |
| 44 | * firmware verification ACK and unpins the object. |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 45 | */ |
Michal Wajdeczko | 0dfa1ce | 2017-12-06 13:53:16 +0000 | [diff] [blame] | 46 | int intel_huc_auth(struct intel_huc *huc) |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 47 | { |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 48 | struct drm_i915_private *i915 = huc_to_i915(huc); |
| 49 | struct intel_guc *guc = &i915->guc; |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 50 | struct i915_vma *vma; |
| 51 | int ret; |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 52 | |
Michał Winiarski | 7e8d12b | 2017-01-20 20:23:46 +0100 | [diff] [blame] | 53 | if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) |
Michal Wajdeczko | 0dfa1ce | 2017-12-06 13:53:16 +0000 | [diff] [blame] | 54 | return -ENOEXEC; |
Michał Winiarski | 7e8d12b | 2017-01-20 20:23:46 +0100 | [diff] [blame] | 55 | |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 56 | vma = i915_gem_object_ggtt_pin(huc->fw.obj, NULL, 0, 0, |
| 57 | PIN_OFFSET_BIAS | GUC_WOPCM_TOP); |
| 58 | if (IS_ERR(vma)) { |
Michal Wajdeczko | 0dfa1ce | 2017-12-06 13:53:16 +0000 | [diff] [blame] | 59 | ret = PTR_ERR(vma); |
| 60 | DRM_ERROR("HuC: Failed to pin huc fw object %d\n", ret); |
| 61 | return ret; |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 64 | ret = intel_guc_auth_huc(guc, |
| 65 | guc_ggtt_offset(vma) + huc->fw.rsa_offset); |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 66 | if (ret) { |
| 67 | DRM_ERROR("HuC: GuC did not ack Auth request %d\n", ret); |
| 68 | goto out; |
| 69 | } |
| 70 | |
| 71 | /* Check authentication status, it should be done by now */ |
Sagar Arun Kamble | 9a2cbf2 | 2017-09-26 12:47:16 +0530 | [diff] [blame] | 72 | ret = intel_wait_for_register(i915, |
| 73 | HUC_STATUS2, |
| 74 | HUC_FW_VERIFIED, |
| 75 | HUC_FW_VERIFIED, |
| 76 | 50); |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 77 | if (ret) { |
| 78 | DRM_ERROR("HuC: Authentication failed %d\n", ret); |
| 79 | goto out; |
| 80 | } |
| 81 | |
| 82 | out: |
| 83 | i915_vma_unpin(vma); |
Michal Wajdeczko | 0dfa1ce | 2017-12-06 13:53:16 +0000 | [diff] [blame] | 84 | return ret; |
Anusha Srivatsa | dac84a3 | 2017-01-18 08:05:57 -0800 | [diff] [blame] | 85 | } |