platform/x86/intel/ifs: Separate ifs_pkg_auth from ifs_data

In preparation to supporting additional tests, remove ifs_pkg_auth
from per-test scope, as it is only applicable for one test type.

This will simplify ifs_init() flow when multiple tests are added.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20230322003359.213046-2-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Jithu Joseph 2023-03-21 17:33:51 -07:00 коммит произвёл Hans de Goede
Родитель 392cacf2aa
Коммит 67f88ffa6d
3 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -20,6 +20,8 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
}; };
MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids); MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
bool *ifs_pkg_auth;
static struct ifs_device ifs_device = { static struct ifs_device ifs_device = {
.data = { .data = {
.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
@ -56,13 +58,13 @@ static int __init ifs_init(void)
if (!(msrval & BIT(ifs_device.data.integrity_cap_bit))) if (!(msrval & BIT(ifs_device.data.integrity_cap_bit)))
return -ENODEV; return -ENODEV;
ifs_device.data.pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL); ifs_pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL);
if (!ifs_device.data.pkg_auth) if (!ifs_pkg_auth)
return -ENOMEM; return -ENOMEM;
ret = misc_register(&ifs_device.misc); ret = misc_register(&ifs_device.misc);
if (ret) { if (ret) {
kfree(ifs_device.data.pkg_auth); kfree(ifs_pkg_auth);
return ret; return ret;
} }
@ -72,7 +74,7 @@ static int __init ifs_init(void)
static void __exit ifs_exit(void) static void __exit ifs_exit(void)
{ {
misc_deregister(&ifs_device.misc); misc_deregister(&ifs_device.misc);
kfree(ifs_device.data.pkg_auth); kfree(ifs_pkg_auth);
} }
module_init(ifs_init); module_init(ifs_init);

Просмотреть файл

@ -201,7 +201,6 @@ union ifs_status {
* struct ifs_data - attributes related to intel IFS driver * struct ifs_data - attributes related to intel IFS driver
* @integrity_cap_bit: MSR_INTEGRITY_CAPS bit enumerating this test * @integrity_cap_bit: MSR_INTEGRITY_CAPS bit enumerating this test
* @loaded_version: stores the currently loaded ifs image version. * @loaded_version: stores the currently loaded ifs image version.
* @pkg_auth: array of bool storing per package auth status
* @loaded: If a valid test binary has been loaded into the memory * @loaded: If a valid test binary has been loaded into the memory
* @loading_error: Error occurred on another CPU while loading image * @loading_error: Error occurred on another CPU while loading image
* @valid_chunks: number of chunks which could be validated. * @valid_chunks: number of chunks which could be validated.
@ -212,7 +211,6 @@ union ifs_status {
*/ */
struct ifs_data { struct ifs_data {
int integrity_cap_bit; int integrity_cap_bit;
bool *pkg_auth;
int loaded_version; int loaded_version;
bool loaded; bool loaded;
bool loading_error; bool loading_error;
@ -241,6 +239,7 @@ static inline struct ifs_data *ifs_get_data(struct device *dev)
return &d->data; return &d->data;
} }
extern bool *ifs_pkg_auth;
int ifs_load_firmware(struct device *dev); int ifs_load_firmware(struct device *dev);
int do_core_test(int cpu, struct device *dev); int do_core_test(int cpu, struct device *dev);
const struct attribute_group **ifs_get_groups(void); const struct attribute_group **ifs_get_groups(void);

Просмотреть файл

@ -192,7 +192,7 @@ static int scan_chunks_sanity_check(struct device *dev)
struct ifs_work local_work; struct ifs_work local_work;
int curr_pkg, cpu, ret; int curr_pkg, cpu, ret;
memset(ifsd->pkg_auth, 0, (topology_max_packages() * sizeof(bool))); memset(ifs_pkg_auth, 0, (topology_max_packages() * sizeof(bool)));
ret = validate_ifs_metadata(dev); ret = validate_ifs_metadata(dev);
if (ret) if (ret)
return ret; return ret;
@ -204,7 +204,7 @@ static int scan_chunks_sanity_check(struct device *dev)
cpus_read_lock(); cpus_read_lock();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
curr_pkg = topology_physical_package_id(cpu); curr_pkg = topology_physical_package_id(cpu);
if (ifsd->pkg_auth[curr_pkg]) if (ifs_pkg_auth[curr_pkg])
continue; continue;
reinit_completion(&ifs_done); reinit_completion(&ifs_done);
local_work.dev = dev; local_work.dev = dev;
@ -215,7 +215,7 @@ static int scan_chunks_sanity_check(struct device *dev)
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
ifsd->pkg_auth[curr_pkg] = 1; ifs_pkg_auth[curr_pkg] = 1;
} }
ret = 0; ret = 0;
out: out: