Re: [PATCH 04/14] platform/x86/intel/ifs: Remove image loading during init

From: Sohil Mehta
Date: Tue Nov 01 2022 - 03:00:45 EST


Thanks for the psuedo code. I think I understand the reasoning now.

There would be an IFS device array created for each type of test that exists. Based on the capabilities supported in MSR_INTEGRITY_CAPS the specific IFS devices would be created to run the tests.

multiple devices will be created if support for more than one is advertised by MSR_INTEGRITY_CAPS as shown below


Well, it would also depend on whether the currently running kernel has enumerated that test. IIUC, older kernels running on newer hardware would only create ifs test devices they are aware of.

It would have been great if the above statement would be true as is :)

static int __init ifs_init(void)
{

....
if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval))
return -ENODEV;

for (i = 0; i < IFS_NUMTESTS; i++) {
if (!(msrval & BIT(ifs_devices[i].data.integrity_cap_bit)))
continue;

ifs_devices[i].misc.groups = ifs_get_groups();
if (!misc_register(&ifs_devices[i].misc)) {
ndevices++;
}
}

return ndevices ? 0 : -ENODEV;
}


Nit:

The _BIT extension is probably unnecessary. How about?

.data = {
.integrity_cap = MSR_INTEGRITY_CAPS_PERIODIC_BIST,
},