2323 * IFS Image
2424 * ---------
2525 *
26- * Intel provides a firmware file containing the scan tests via
27- * github [#f1]_. Similar to microcode there is a separate file for each
26+ * Intel provides firmware files containing the scan tests via the webpage [#f1]_.
27+ * Look under "In-Field Scan Test Images Download" section towards the
28+ * end of the page. Similar to microcode, there are separate files for each
2829 * family-model-stepping. IFS Images are not applicable for some test types.
2930 * Wherever applicable the sysfs directory would provide a "current_batch" file
3031 * (see below) for loading the image.
3132 *
33+ * .. [#f1] https://intel.com/InFieldScan
3234 *
3335 * IFS Image Loading
3436 * -----------------
125127 * 2) Hardware allows for some number of cores to be tested in parallel.
126128 * The driver does not make use of this, it only tests one core at a time.
127129 *
128- * .. [#f1] https://github.com/intel/TBD
130+ * Structural Based Functional Test at Field (SBAF):
131+ * -------------------------------------------------
132+ *
133+ * SBAF is a new type of testing that provides comprehensive core test
134+ * coverage complementing Scan at Field (SAF) testing. SBAF mimics the
135+ * manufacturing screening environment and leverages the same test suite.
136+ * It makes use of Design For Test (DFT) observation sites and features
137+ * to maximize coverage in minimum time.
138+ *
139+ * Similar to the SAF test, SBAF isolates the core under test from the
140+ * rest of the system during execution. Upon completion, the core
141+ * seamlessly resets to its pre-test state and resumes normal operation.
142+ * Any machine checks or hangs encountered during the test are confined to
143+ * the isolated core, preventing disruption to the overall system.
144+ *
145+ * Like the SAF test, the SBAF test is also divided into multiple batches,
146+ * and each batch test can take hundreds of milliseconds (100-200 ms) to
147+ * complete. If such a lengthy interruption is undesirable, it is
148+ * recommended to relocate the time-sensitive applications to other cores.
129149 */
130150#include <linux/device.h>
131151#include <linux/miscdevice.h>
132152
133153#define MSR_ARRAY_BIST 0x00000105
154+
155+ #define MSR_COPY_SBAF_HASHES 0x000002b8
156+ #define MSR_SBAF_HASHES_STATUS 0x000002b9
157+ #define MSR_AUTHENTICATE_AND_COPY_SBAF_CHUNK 0x000002ba
158+ #define MSR_SBAF_CHUNKS_AUTHENTICATION_STATUS 0x000002bb
159+ #define MSR_ACTIVATE_SBAF 0x000002bc
160+ #define MSR_SBAF_STATUS 0x000002bd
161+
134162#define MSR_COPY_SCAN_HASHES 0x000002c2
135163#define MSR_SCAN_HASHES_STATUS 0x000002c3
136164#define MSR_AUTHENTICATE_AND_COPY_CHUNK 0x000002c4
140168#define MSR_ARRAY_TRIGGER 0x000002d6
141169#define MSR_ARRAY_STATUS 0x000002d7
142170#define MSR_SAF_CTRL 0x000004f0
171+ #define MSR_SBAF_CTRL 0x000004f8
143172
144173#define SCAN_NOT_TESTED 0
145174#define SCAN_TEST_PASS 1
146175#define SCAN_TEST_FAIL 2
147176
148177#define IFS_TYPE_SAF 0
149178#define IFS_TYPE_ARRAY_BIST 1
179+ #define IFS_TYPE_SBAF 2
150180
151181#define ARRAY_GEN0 0
152182#define ARRAY_GEN1 1
@@ -196,7 +226,8 @@ union ifs_chunks_auth_status_gen2 {
196226 u16 valid_chunks ;
197227 u16 total_chunks ;
198228 u32 error_code :8 ;
199- u32 rsvd2 :24 ;
229+ u32 rsvd2 :8 ;
230+ u32 max_bundle :16 ;
200231 };
201232};
202233
@@ -253,6 +284,34 @@ union ifs_array {
253284 };
254285};
255286
287+ /* MSR_ACTIVATE_SBAF bit fields */
288+ union ifs_sbaf {
289+ u64 data ;
290+ struct {
291+ u32 bundle_idx :9 ;
292+ u32 rsvd1 :5 ;
293+ u32 pgm_idx :2 ;
294+ u32 rsvd2 :16 ;
295+ u32 delay :31 ;
296+ u32 sigmce :1 ;
297+ };
298+ };
299+
300+ /* MSR_SBAF_STATUS bit fields */
301+ union ifs_sbaf_status {
302+ u64 data ;
303+ struct {
304+ u32 bundle_idx :9 ;
305+ u32 rsvd1 :5 ;
306+ u32 pgm_idx :2 ;
307+ u32 rsvd2 :16 ;
308+ u32 error_code :8 ;
309+ u32 rsvd3 :21 ;
310+ u32 test_fail :1 ;
311+ u32 sbaf_status :2 ;
312+ };
313+ };
314+
256315/*
257316 * Driver populated error-codes
258317 * 0xFD: Test timed out before completing all the chunks.
@@ -261,9 +320,28 @@ union ifs_array {
261320#define IFS_SW_TIMEOUT 0xFD
262321#define IFS_SW_PARTIAL_COMPLETION 0xFE
263322
323+ #define IFS_SUFFIX_SZ 5
324+
264325struct ifs_test_caps {
265326 int integrity_cap_bit ;
266327 int test_num ;
328+ char image_suffix [IFS_SUFFIX_SZ ];
329+ };
330+
331+ /**
332+ * struct ifs_test_msrs - MSRs used in IFS tests
333+ * @copy_hashes: Copy test hash data
334+ * @copy_hashes_status: Status of copied test hash data
335+ * @copy_chunks: Copy chunks of the test data
336+ * @copy_chunks_status: Status of the copied test data chunks
337+ * @test_ctrl: Control the test attributes
338+ */
339+ struct ifs_test_msrs {
340+ u32 copy_hashes ;
341+ u32 copy_hashes_status ;
342+ u32 copy_chunks ;
343+ u32 copy_chunks_status ;
344+ u32 test_ctrl ;
267345};
268346
269347/**
@@ -278,6 +356,7 @@ struct ifs_test_caps {
278356 * @generation: IFS test generation enumerated by hardware
279357 * @chunk_size: size of a test chunk
280358 * @array_gen: test generation of array test
359+ * @max_bundle: maximum bundle index
281360 */
282361struct ifs_data {
283362 int loaded_version ;
@@ -290,6 +369,7 @@ struct ifs_data {
290369 u32 generation ;
291370 u32 chunk_size ;
292371 u32 array_gen ;
372+ u32 max_bundle ;
293373};
294374
295375struct ifs_work {
@@ -299,6 +379,7 @@ struct ifs_work {
299379
300380struct ifs_device {
301381 const struct ifs_test_caps * test_caps ;
382+ const struct ifs_test_msrs * test_msrs ;
302383 struct ifs_data rw_data ;
303384 struct miscdevice misc ;
304385};
@@ -319,6 +400,14 @@ static inline const struct ifs_test_caps *ifs_get_test_caps(struct device *dev)
319400 return d -> test_caps ;
320401}
321402
403+ static inline const struct ifs_test_msrs * ifs_get_test_msrs (struct device * dev )
404+ {
405+ struct miscdevice * m = dev_get_drvdata (dev );
406+ struct ifs_device * d = container_of (m , struct ifs_device , misc );
407+
408+ return d -> test_msrs ;
409+ }
410+
322411extern bool * ifs_pkg_auth ;
323412int ifs_load_firmware (struct device * dev );
324413int do_core_test (int cpu , struct device * dev );
0 commit comments