Skip to content

Commit c43c7e1

Browse files
committed
Merge: Update platform/x86/intel/ifs
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6726 JIRA: https://issues.redhat.com/browse/RHEL-45087 Signed-off-by: David Arcari <darcari@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents a7448e3 + 4391e0d commit c43c7e1

File tree

8 files changed

+443
-40
lines changed

8 files changed

+443
-40
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@
237237
#define MSR_INTEGRITY_CAPS_ARRAY_BIST BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
238238
#define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT 4
239239
#define MSR_INTEGRITY_CAPS_PERIODIC_BIST BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
240+
#define MSR_INTEGRITY_CAPS_SBAF_BIT 8
241+
#define MSR_INTEGRITY_CAPS_SBAF BIT(MSR_INTEGRITY_CAPS_SBAF_BIT)
240242
#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK GENMASK_ULL(10, 9)
241243

242244
#define MSR_LBR_NHM_FROM 0x00000680
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
obj-$(CONFIG_INTEL_IFS) += intel_ifs.o
22

3-
intel_ifs-objs := core.o load.o runtest.o sysfs.o
3+
intel_ifs-y := core.o load.o runtest.o sysfs.o

drivers/platform/x86/intel/ifs/core.c

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
#include "ifs.h"
1313

14-
#define X86_MATCH(model, array_gen) \
15-
X86_MATCH_VENDOR_FAM_MODEL_FEATURE(INTEL, 6, \
16-
INTEL_FAM6_##model, X86_FEATURE_CORE_CAPABILITIES, array_gen)
14+
#define X86_MATCH(vfm, array_gen) \
15+
X86_MATCH_VFM_FEATURE(vfm, X86_FEATURE_CORE_CAPABILITIES, array_gen)
1716

1817
static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
19-
X86_MATCH(SAPPHIRERAPIDS_X, ARRAY_GEN0),
20-
X86_MATCH(EMERALDRAPIDS_X, ARRAY_GEN0),
21-
X86_MATCH(GRANITERAPIDS_X, ARRAY_GEN0),
22-
X86_MATCH(GRANITERAPIDS_D, ARRAY_GEN0),
23-
X86_MATCH(ATOM_CRESTMONT_X, ARRAY_GEN1),
18+
X86_MATCH(INTEL_SAPPHIRERAPIDS_X, ARRAY_GEN0),
19+
X86_MATCH(INTEL_EMERALDRAPIDS_X, ARRAY_GEN0),
20+
X86_MATCH(INTEL_GRANITERAPIDS_X, ARRAY_GEN0),
21+
X86_MATCH(INTEL_GRANITERAPIDS_D, ARRAY_GEN0),
22+
X86_MATCH(INTEL_ATOM_CRESTMONT_X, ARRAY_GEN1),
23+
X86_MATCH(INTEL_ATOM_DARKMONT_X, ARRAY_GEN1),
2424
{}
2525
};
2626
MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
@@ -33,16 +33,40 @@ bool *ifs_pkg_auth;
3333
static const struct ifs_test_caps scan_test = {
3434
.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
3535
.test_num = IFS_TYPE_SAF,
36+
.image_suffix = "scan",
3637
};
3738

3839
static const struct ifs_test_caps array_test = {
3940
.integrity_cap_bit = MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT,
4041
.test_num = IFS_TYPE_ARRAY_BIST,
4142
};
4243

44+
static const struct ifs_test_msrs scan_msrs = {
45+
.copy_hashes = MSR_COPY_SCAN_HASHES,
46+
.copy_hashes_status = MSR_SCAN_HASHES_STATUS,
47+
.copy_chunks = MSR_AUTHENTICATE_AND_COPY_CHUNK,
48+
.copy_chunks_status = MSR_CHUNKS_AUTHENTICATION_STATUS,
49+
.test_ctrl = MSR_SAF_CTRL,
50+
};
51+
52+
static const struct ifs_test_msrs sbaf_msrs = {
53+
.copy_hashes = MSR_COPY_SBAF_HASHES,
54+
.copy_hashes_status = MSR_SBAF_HASHES_STATUS,
55+
.copy_chunks = MSR_AUTHENTICATE_AND_COPY_SBAF_CHUNK,
56+
.copy_chunks_status = MSR_SBAF_CHUNKS_AUTHENTICATION_STATUS,
57+
.test_ctrl = MSR_SBAF_CTRL,
58+
};
59+
60+
static const struct ifs_test_caps sbaf_test = {
61+
.integrity_cap_bit = MSR_INTEGRITY_CAPS_SBAF_BIT,
62+
.test_num = IFS_TYPE_SBAF,
63+
.image_suffix = "sbft",
64+
};
65+
4366
static struct ifs_device ifs_devices[] = {
4467
[IFS_TYPE_SAF] = {
4568
.test_caps = &scan_test,
69+
.test_msrs = &scan_msrs,
4670
.misc = {
4771
.name = "intel_ifs_0",
4872
.minor = MISC_DYNAMIC_MINOR,
@@ -57,6 +81,15 @@ static struct ifs_device ifs_devices[] = {
5781
.groups = plat_ifs_array_groups,
5882
},
5983
},
84+
[IFS_TYPE_SBAF] = {
85+
.test_caps = &sbaf_test,
86+
.test_msrs = &sbaf_msrs,
87+
.misc = {
88+
.name = "intel_ifs_2",
89+
.minor = MISC_DYNAMIC_MINOR,
90+
.groups = plat_ifs_groups,
91+
},
92+
},
6093
};
6194

6295
#define IFS_NUMTESTS ARRAY_SIZE(ifs_devices)

drivers/platform/x86/intel/ifs/ifs.h

Lines changed: 93 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
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
* -----------------
@@ -125,12 +127,38 @@
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
@@ -140,13 +168,15 @@
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+
264325
struct 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
*/
282361
struct 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

295375
struct ifs_work {
@@ -299,6 +379,7 @@ struct ifs_work {
299379

300380
struct 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+
322411
extern bool *ifs_pkg_auth;
323412
int ifs_load_firmware(struct device *dev);
324413
int do_core_test(int cpu, struct device *dev);

0 commit comments

Comments
 (0)