Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86/intel/ifs: Introduce Array Scan test to IFS

Array BIST is a new type of core test introduced under the Intel Infield
Scan (IFS) suite of tests.

Emerald Rapids (EMR) is the first CPU to support Array BIST.
Array BIST performs tests on some portions of the core logic such as
caches and register files. These are different portions of the silicon
compared to the parts tested by the first test type
i.e Scan at Field (SAF).

Make changes in the device driver init flow to register this new test
type with the device driver framework. Each test will have its own
sysfs directory (intel_ifs_0 , intel_ifs_1) under misc hierarchy to
accommodate for the differences in test type and how they are initiated.

Upcoming patches will add actual support.

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-6-jithu.joseph@intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Jithu Joseph and committed by
Hans de Goede
d31bbdf4 c68e3d47

+50 -18
+47 -18
drivers/platform/x86/intel/ifs/core.c
··· 16 16 17 17 static const struct x86_cpu_id ifs_cpu_ids[] __initconst = { 18 18 X86_MATCH(SAPPHIRERAPIDS_X), 19 + X86_MATCH(EMERALDRAPIDS_X), 19 20 {} 20 21 }; 21 22 MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids); ··· 27 26 28 27 static const struct ifs_test_caps scan_test = { 29 28 .integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT, 30 - .test_num = 0, 29 + .test_num = IFS_TYPE_SAF, 31 30 }; 32 31 33 - static struct ifs_device ifs_device = { 34 - .test_caps = &scan_test, 35 - .misc = { 36 - .name = "intel_ifs_0", 37 - .minor = MISC_DYNAMIC_MINOR, 38 - .groups = plat_ifs_groups, 32 + static const struct ifs_test_caps array_test = { 33 + .integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT, 34 + .test_num = IFS_TYPE_ARRAY_BIST, 35 + }; 36 + 37 + static struct ifs_device ifs_devices[] = { 38 + [IFS_TYPE_SAF] = { 39 + .test_caps = &scan_test, 40 + .misc = { 41 + .name = "intel_ifs_0", 42 + .minor = MISC_DYNAMIC_MINOR, 43 + .groups = plat_ifs_groups, 44 + }, 45 + }, 46 + [IFS_TYPE_ARRAY_BIST] = { 47 + .test_caps = &array_test, 48 + .misc = { 49 + .name = "intel_ifs_1", 50 + .minor = MISC_DYNAMIC_MINOR, 51 + }, 39 52 }, 40 53 }; 54 + 55 + #define IFS_NUMTESTS ARRAY_SIZE(ifs_devices) 56 + 57 + static void ifs_cleanup(void) 58 + { 59 + int i; 60 + 61 + for (i = 0; i < IFS_NUMTESTS; i++) { 62 + if (ifs_devices[i].misc.this_device) 63 + misc_deregister(&ifs_devices[i].misc); 64 + } 65 + kfree(ifs_pkg_auth); 66 + } 41 67 42 68 static int __init ifs_init(void) 43 69 { 44 70 const struct x86_cpu_id *m; 45 71 u64 msrval; 46 - int ret; 72 + int i, ret; 47 73 48 74 m = x86_match_cpu(ifs_cpu_ids); 49 75 if (!m) ··· 85 57 if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval)) 86 58 return -ENODEV; 87 59 88 - if (!(msrval & BIT(ifs_device.test_caps->integrity_cap_bit))) 89 - return -ENODEV; 90 - 91 60 ifs_pkg_auth = kmalloc_array(topology_max_packages(), sizeof(bool), GFP_KERNEL); 92 61 if (!ifs_pkg_auth) 93 62 return -ENOMEM; 94 63 95 - ret = misc_register(&ifs_device.misc); 96 - if (ret) { 97 - kfree(ifs_pkg_auth); 98 - return ret; 64 + for (i = 0; i < IFS_NUMTESTS; i++) { 65 + if (!(msrval & BIT(ifs_devices[i].test_caps->integrity_cap_bit))) 66 + continue; 67 + ret = misc_register(&ifs_devices[i].misc); 68 + if (ret) 69 + goto err_exit; 99 70 } 100 - 101 71 return 0; 72 + 73 + err_exit: 74 + ifs_cleanup(); 75 + return ret; 102 76 } 103 77 104 78 static void __exit ifs_exit(void) 105 79 { 106 - misc_deregister(&ifs_device.misc); 107 - kfree(ifs_pkg_auth); 80 + ifs_cleanup(); 108 81 } 109 82 110 83 module_init(ifs_init);
+3
drivers/platform/x86/intel/ifs/ifs.h
··· 137 137 #define SCAN_TEST_PASS 1 138 138 #define SCAN_TEST_FAIL 2 139 139 140 + #define IFS_TYPE_SAF 0 141 + #define IFS_TYPE_ARRAY_BIST 1 142 + 140 143 /* MSR_SCAN_HASHES_STATUS bit fields */ 141 144 union ifs_scan_hashes_status { 142 145 u64 data;