Skip to content

Commit ecff121

Browse files
author
Jocelyn Falempe
committed
drm/i915/pxp: add huc authentication and loading command
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2041690 Upstream Status: git://anongit.freedesktop.org/drm/drm commit 887a193 Author: Tomas Winkler <tomas.winkler@intel.com> AuthorDate: Tue Sep 27 17:41:39 2022 -0700 Commit: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> CommitDate: Mon Oct 3 11:29:15 2022 -0700 Add support for loading HuC via a pxp stream command. V4: 1. Remove unnecessary include in intel_pxp_huc.h (Jani) 2. Adjust copyright year to 2022 Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Vitaly Lubart <vitaly.lubart@intel.com> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Cc: Alan Previn <alan.previn.teres.alexis@intel.com> Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220928004145.745803-10-daniele.ceraolospurio@intel.com Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
1 parent ad239f8 commit ecff121

File tree

4 files changed

+106
-2
lines changed

4 files changed

+106
-2
lines changed

drivers/gpu/drm/i915/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ i915-y += i915_perf.o
310310
# Protected execution platform (PXP) support. Base support is required for HuC
311311
i915-y += \
312312
pxp/intel_pxp.o \
313-
pxp/intel_pxp_tee.o
313+
pxp/intel_pxp_tee.o \
314+
pxp/intel_pxp_huc.o
314315

315316
i915-$(CONFIG_DRM_I915_PXP) += \
316317
pxp/intel_pxp_cmd.o \
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright(c) 2021-2022, Intel Corporation. All rights reserved.
4+
*/
5+
6+
#include "drm/i915_drm.h"
7+
#include "i915_drv.h"
8+
9+
#include "gem/i915_gem_region.h"
10+
#include "gt/intel_gt.h"
11+
12+
#include "intel_pxp.h"
13+
#include "intel_pxp_huc.h"
14+
#include "intel_pxp_tee.h"
15+
#include "intel_pxp_types.h"
16+
#include "intel_pxp_tee_interface.h"
17+
18+
int intel_pxp_huc_load_and_auth(struct intel_pxp *pxp)
19+
{
20+
struct intel_gt *gt = pxp_to_gt(pxp);
21+
struct intel_huc *huc = &gt->uc.huc;
22+
struct pxp_tee_start_huc_auth_in huc_in = {0};
23+
struct pxp_tee_start_huc_auth_out huc_out = {0};
24+
dma_addr_t huc_phys_addr;
25+
u8 client_id = 0;
26+
u8 fence_id = 0;
27+
int err;
28+
29+
if (!pxp->pxp_component)
30+
return -ENODEV;
31+
32+
huc_phys_addr = i915_gem_object_get_dma_address(huc->fw.obj, 0);
33+
34+
/* write the PXP message into the lmem (the sg list) */
35+
huc_in.header.api_version = PXP_TEE_43_APIVER;
36+
huc_in.header.command_id = PXP_TEE_43_START_HUC_AUTH;
37+
huc_in.header.status = 0;
38+
huc_in.header.buffer_len = sizeof(huc_in.huc_base_address);
39+
huc_in.huc_base_address = huc_phys_addr;
40+
41+
err = intel_pxp_tee_stream_message(pxp, client_id, fence_id,
42+
&huc_in, sizeof(huc_in),
43+
&huc_out, sizeof(huc_out));
44+
if (err < 0) {
45+
drm_err(&gt->i915->drm,
46+
"Failed to send HuC load and auth command to GSC [%d]!\n",
47+
err);
48+
return err;
49+
}
50+
51+
/*
52+
* HuC does sometimes survive suspend/resume (it depends on how "deep"
53+
* a sleep state the device reaches) so we can end up here on resume
54+
* with HuC already loaded, in which case the GSC will return
55+
* PXP_STATUS_OP_NOT_PERMITTED. We can therefore consider the GuC
56+
* correctly transferred in this scenario; if the same error is ever
57+
* returned with HuC not loaded we'll still catch it when we check the
58+
* authentication bit later.
59+
*/
60+
if (huc_out.header.status != PXP_STATUS_SUCCESS &&
61+
huc_out.header.status != PXP_STATUS_OP_NOT_PERMITTED) {
62+
drm_err(&gt->i915->drm,
63+
"HuC load failed with GSC error = 0x%x\n",
64+
huc_out.header.status);
65+
return -EPROTO;
66+
}
67+
68+
return 0;
69+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright(c) 2021-2022, Intel Corporation. All rights reserved.
4+
*/
5+
6+
#ifndef __INTEL_PXP_HUC_H__
7+
#define __INTEL_PXP_HUC_H__
8+
9+
struct intel_pxp;
10+
11+
int intel_pxp_huc_load_and_auth(struct intel_pxp *pxp);
12+
13+
#endif /* __INTEL_PXP_HUC_H__ */

drivers/gpu/drm/i915/pxp/intel_pxp_tee_interface.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: MIT */
22
/*
3-
* Copyright(c) 2020, Intel Corporation. All rights reserved.
3+
* Copyright(c) 2020-2022, Intel Corporation. All rights reserved.
44
*/
55

66
#ifndef __INTEL_PXP_TEE_INTERFACE_H__
@@ -9,8 +9,20 @@
99
#include <linux/types.h>
1010

1111
#define PXP_TEE_APIVER 0x40002
12+
#define PXP_TEE_43_APIVER 0x00040003
1213
#define PXP_TEE_ARB_CMDID 0x1e
1314
#define PXP_TEE_ARB_PROTECTION_MODE 0x2
15+
#define PXP_TEE_43_START_HUC_AUTH 0x0000003A
16+
17+
/*
18+
* there are a lot of status codes for PXP, but we only define the ones we
19+
* actually can handle in the driver. other failure codes will be printed to
20+
* error msg for debug.
21+
*/
22+
enum pxp_status {
23+
PXP_STATUS_SUCCESS = 0x0,
24+
PXP_STATUS_OP_NOT_PERMITTED = 0x4013
25+
};
1426

1527
/* PXP TEE message header */
1628
struct pxp_tee_cmd_header {
@@ -33,4 +45,13 @@ struct pxp_tee_create_arb_out {
3345
struct pxp_tee_cmd_header header;
3446
} __packed;
3547

48+
struct pxp_tee_start_huc_auth_in {
49+
struct pxp_tee_cmd_header header;
50+
__le64 huc_base_address;
51+
};
52+
53+
struct pxp_tee_start_huc_auth_out {
54+
struct pxp_tee_cmd_header header;
55+
};
56+
3657
#endif /* __INTEL_PXP_TEE_INTERFACE_H__ */

0 commit comments

Comments
 (0)