Skip to content

Commit fb57fc7

Browse files
jithu83jwrdegoede
authored andcommitted
platform/x86/intel/ifs: Read IFS firmware image
Driver probe routine allocates structure to communicate status and parameters between functions in the driver. Also call load_ifs_binary() to load the scan image file. There is a separate scan image file for each processor family, model, stepping combination. This is read from the static path: /lib/firmware/intel/ifs/{ff-mm-ss}.scan Step 1 in loading is to generate the correct path and use request_firmware_direct() to load into memory. Subsequent patches will use the IFS MSR interfaces to copy the image to BIOS reserved memory and validate the SHA256 checksums. Reviewed-by: Dan Williams <[email protected]> Signed-off-by: Jithu Joseph <[email protected]> Co-developed-by: Tony Luck <[email protected]> Signed-off-by: Tony Luck <[email protected]> Acked-by: Hans de Goede <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
1 parent 67896ef commit fb57fc7

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed
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
3+
intel_ifs-objs := core.o load.o

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <asm/cpu_device_id.h>
88

9+
#include "ifs.h"
10+
911
#define X86_MATCH(model) \
1012
X86_MATCH_VENDOR_FAM_MODEL_FEATURE(INTEL, 6, \
1113
INTEL_FAM6_##model, X86_FEATURE_CORE_CAPABILITIES, NULL)
@@ -16,6 +18,17 @@ static const struct x86_cpu_id ifs_cpu_ids[] __initconst = {
1618
};
1719
MODULE_DEVICE_TABLE(x86cpu, ifs_cpu_ids);
1820

21+
static struct ifs_device ifs_device = {
22+
.data = {
23+
.integrity_cap_bit = MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT,
24+
},
25+
.misc = {
26+
.name = "intel_ifs_0",
27+
.nodename = "intel_ifs/0",
28+
.minor = MISC_DYNAMIC_MINOR,
29+
},
30+
};
31+
1932
static int __init ifs_init(void)
2033
{
2134
const struct x86_cpu_id *m;
@@ -34,11 +47,18 @@ static int __init ifs_init(void)
3447
if (rdmsrl_safe(MSR_INTEGRITY_CAPS, &msrval))
3548
return -ENODEV;
3649

37-
return 0;
50+
if ((msrval & BIT(ifs_device.data.integrity_cap_bit)) &&
51+
!misc_register(&ifs_device.misc)) {
52+
ifs_load_firmware(ifs_device.misc.this_device);
53+
return 0;
54+
}
55+
56+
return -ENODEV;
3857
}
3958

4059
static void __exit ifs_exit(void)
4160
{
61+
misc_deregister(&ifs_device.misc);
4262
}
4363

4464
module_init(ifs_init);

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/* Copyright(c) 2022 Intel Corporation. */
3+
4+
#ifndef _IFS_H_
5+
#define _IFS_H_
6+
7+
#include <linux/device.h>
8+
#include <linux/miscdevice.h>
9+
10+
/**
11+
* struct ifs_data - attributes related to intel IFS driver
12+
* @integrity_cap_bit: MSR_INTEGRITY_CAPS bit enumerating this test
13+
*/
14+
struct ifs_data {
15+
int integrity_cap_bit;
16+
};
17+
18+
struct ifs_device {
19+
struct ifs_data data;
20+
struct miscdevice misc;
21+
};
22+
23+
void ifs_load_firmware(struct device *dev);
24+
25+
#endif

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright(c) 2022 Intel Corporation. */
3+
4+
#include <linux/firmware.h>
5+
6+
#include "ifs.h"
7+
8+
/*
9+
* Load ifs image. Before loading ifs module, the ifs image must be located
10+
* in /lib/firmware/intel/ifs and named as {family/model/stepping}.{testname}.
11+
*/
12+
void ifs_load_firmware(struct device *dev)
13+
{
14+
const struct firmware *fw;
15+
char scan_path[32];
16+
int ret;
17+
18+
snprintf(scan_path, sizeof(scan_path), "intel/ifs/%02x-%02x-%02x.scan",
19+
boot_cpu_data.x86, boot_cpu_data.x86_model, boot_cpu_data.x86_stepping);
20+
21+
ret = request_firmware_direct(&fw, scan_path, dev);
22+
if (ret) {
23+
dev_err(dev, "ifs file %s load failed\n", scan_path);
24+
return;
25+
}
26+
27+
release_firmware(fw);
28+
}

0 commit comments

Comments
 (0)