Skip to content

Commit 376a8c2

Browse files
Shyam Sundar S Kij-intel
authored andcommitted
platform/x86/amd/pmf: Update PMF Driver for Compatibility with new PMF-TA
The PMF driver allocates a shared memory buffer using tee_shm_alloc_kernel_buf() for communication with the PMF-TA. The latest PMF-TA version introduces new structures with OEM debug information and additional policy input conditions for evaluating the policy binary. Consequently, the shared memory size must be increased to ensure compatibility between the PMF driver and the updated PMF-TA. To do so, introduce the new PMF-TA UUID and update the PMF shared memory configuration to ensure compatibility with the latest PMF-TA version. Additionally, export the TA UUID. These updates will result in modifications to the prototypes of amd_pmf_tee_init() and amd_pmf_ta_open_session(). Link: https://lore.kernel.org/all/55ac865f-b1c7-fa81-51c4-d211c7963e7e@linux.intel.com/ Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Link: https://lore.kernel.org/r/20250305045842.4117767-2-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 9ba93cb commit 376a8c2

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ struct cookie_header {
106106
#define PMF_TA_IF_VERSION_MAJOR 1
107107
#define TA_PMF_ACTION_MAX 32
108108
#define TA_PMF_UNDO_MAX 8
109-
#define TA_OUTPUT_RESERVED_MEM 906
109+
#define TA_OUTPUT_RESERVED_MEM 922
110110
#define MAX_OPERATION_PARAMS 4
111111

112+
#define TA_ERROR_CRYPTO_INVALID_PARAM 0x20002
113+
#define TA_ERROR_CRYPTO_BIN_TOO_LARGE 0x2000d
114+
112115
#define PMF_IF_V1 1
113116
#define PMF_IF_V2 2
114117

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ module_param(pb_side_load, bool, 0444);
2727
MODULE_PARM_DESC(pb_side_load, "Sideload policy binaries debug policy failures");
2828
#endif
2929

30-
static const uuid_t amd_pmf_ta_uuid = UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d,
31-
0xb1, 0x2d, 0xc5, 0x29, 0xb1, 0x3d, 0x85, 0x43);
30+
static const uuid_t amd_pmf_ta_uuid[] = { UUID_INIT(0xd9b39bf2, 0x66bd, 0x4154, 0xaf, 0xb8, 0x8a,
31+
0xcc, 0x2b, 0x2b, 0x60, 0xd6),
32+
UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d, 0xb1, 0x2d, 0xc5,
33+
0x29, 0xb1, 0x3d, 0x85, 0x43),
34+
};
3235

3336
static const char *amd_pmf_uevent_as_str(unsigned int state)
3437
{
@@ -321,7 +324,7 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
321324
*/
322325
schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms * 3));
323326
} else {
324-
dev_err(dev->dev, "ta invoke cmd init failed err: %x\n", res);
327+
dev_dbg(dev->dev, "ta invoke cmd init failed err: %x\n", res);
325328
dev->smart_pc_enabled = false;
326329
return res;
327330
}
@@ -390,12 +393,12 @@ static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const voi
390393
return ver->impl_id == TEE_IMPL_ID_AMDTEE;
391394
}
392395

393-
static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id)
396+
static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t *uuid)
394397
{
395398
struct tee_ioctl_open_session_arg sess_arg = {};
396399
int rc;
397400

398-
export_uuid(sess_arg.uuid, &amd_pmf_ta_uuid);
401+
export_uuid(sess_arg.uuid, uuid);
399402
sess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC;
400403
sess_arg.num_params = 0;
401404

@@ -434,7 +437,7 @@ static int amd_pmf_register_input_device(struct amd_pmf_dev *dev)
434437
return 0;
435438
}
436439

437-
static int amd_pmf_tee_init(struct amd_pmf_dev *dev)
440+
static int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
438441
{
439442
u32 size;
440443
int ret;
@@ -445,7 +448,7 @@ static int amd_pmf_tee_init(struct amd_pmf_dev *dev)
445448
return PTR_ERR(dev->tee_ctx);
446449
}
447450

448-
ret = amd_pmf_ta_open_session(dev->tee_ctx, &dev->session_id);
451+
ret = amd_pmf_ta_open_session(dev->tee_ctx, &dev->session_id, uuid);
449452
if (ret) {
450453
dev_err(dev->dev, "Failed to open TA session (%d)\n", ret);
451454
ret = -EINVAL;
@@ -489,7 +492,8 @@ static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)
489492

490493
int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
491494
{
492-
int ret;
495+
bool status;
496+
int ret, i;
493497

494498
ret = apmf_check_smart_pc(dev);
495499
if (ret) {
@@ -502,10 +506,6 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
502506
return -ENODEV;
503507
}
504508

505-
ret = amd_pmf_tee_init(dev);
506-
if (ret)
507-
return ret;
508-
509509
INIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);
510510

511511
ret = amd_pmf_set_dram_addr(dev, true);
@@ -534,8 +534,30 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
534534
goto error;
535535
}
536536

537-
ret = amd_pmf_start_policy_engine(dev);
538-
if (ret)
537+
for (i = 0; i < ARRAY_SIZE(amd_pmf_ta_uuid); i++) {
538+
ret = amd_pmf_tee_init(dev, &amd_pmf_ta_uuid[i]);
539+
if (ret)
540+
return ret;
541+
542+
ret = amd_pmf_start_policy_engine(dev);
543+
switch (ret) {
544+
case TA_PMF_TYPE_SUCCESS:
545+
status = true;
546+
break;
547+
case TA_ERROR_CRYPTO_INVALID_PARAM:
548+
case TA_ERROR_CRYPTO_BIN_TOO_LARGE:
549+
amd_pmf_tee_deinit(dev);
550+
status = false;
551+
break;
552+
default:
553+
goto error;
554+
}
555+
556+
if (status)
557+
break;
558+
}
559+
560+
if (!status && !pb_side_load)
539561
goto error;
540562

541563
if (pb_side_load)

0 commit comments

Comments
 (0)