drivers/platform/x86/amd: pmf: Check for invalid Smart PC Policies
JIRA: https://issues.redhat.com/browse/RHEL-105420 commit 8e81b9cd6e95188d12c9cc25d40b61dd5ea05ace Author: Mario Limonciello <mario.limonciello@amd.com> Date: Wed Apr 23 08:18:45 2025 -0500 drivers/platform/x86/amd: pmf: Check for invalid Smart PC Policies commit 376a8c2a14439 ("platform/x86/amd/pmf: Update PMF Driver for Compatibility with new PMF-TA") added support for platforms that support an updated TA, however it also exposed a number of platforms that although they have support for the updated TA don't actually populate a policy binary. Add an explicit check that the policy binary isn't empty before initializing the TA. Reported-by: Christian Heusel <christian@heusel.eu> Closes: https://lore.kernel.org/platform-driver-x86/ae644428-5bf2-4b30-81ba-0b259ed3449b@heusel.eu/ Fixes: 376a8c2a14439 ("platform/x86/amd/pmf: Update PMF Driver for Compatibility with new PMF-TA") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Christian Heusel <christian@heusel.eu> Link: https://lore.kernel.org/r/20250423132002.3984997-3-superm1@kernel.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
This commit is contained in:
parent
f6af07a496
commit
c57e4b77fc
|
@ -334,6 +334,11 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool amd_pmf_pb_valid(struct amd_pmf_dev *dev)
|
||||||
|
{
|
||||||
|
return memchr_inv(dev->policy_buf, 0xff, dev->policy_sz);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_AMD_PMF_DEBUG
|
#ifdef CONFIG_AMD_PMF_DEBUG
|
||||||
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev)
|
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev)
|
||||||
{
|
{
|
||||||
|
@ -361,6 +366,11 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
|
||||||
dev->policy_buf = new_policy_buf;
|
dev->policy_buf = new_policy_buf;
|
||||||
dev->policy_sz = length;
|
dev->policy_sz = length;
|
||||||
|
|
||||||
|
if (!amd_pmf_pb_valid(dev)) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
amd_pmf_hex_dump_pb(dev);
|
amd_pmf_hex_dump_pb(dev);
|
||||||
ret = amd_pmf_start_policy_engine(dev);
|
ret = amd_pmf_start_policy_engine(dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -533,6 +543,12 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
|
||||||
|
|
||||||
memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);
|
memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);
|
||||||
|
|
||||||
|
if (!amd_pmf_pb_valid(dev)) {
|
||||||
|
dev_info(dev->dev, "No Smart PC policy present\n");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto err_free_policy;
|
||||||
|
}
|
||||||
|
|
||||||
amd_pmf_hex_dump_pb(dev);
|
amd_pmf_hex_dump_pb(dev);
|
||||||
|
|
||||||
dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);
|
dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);
|
||||||
|
|
Loading…
Reference in New Issue