platform/x86/intel/ifs: Store IFS generation number
authorJithu Joseph <jithu.joseph@intel.com>
Thu, 5 Oct 2023 19:51:29 +0000 (12:51 -0700)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 6 Oct 2023 10:05:13 +0000 (13:05 +0300)
IFS generation number is reported via MSR_INTEGRITY_CAPS.  As IFS
support gets added to newer CPUs, some differences are expected during
IFS image loading and test flows.

Define MSR bitmasks to extract and store the generation in driver data,
so that driver can modify its MSR interaction appropriately.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Link: https://lore.kernel.org/r/20231005195137.3117166-2-jithu.joseph@intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
arch/x86/include/asm/msr-index.h
drivers/platform/x86/intel/ifs/core.c
drivers/platform/x86/intel/ifs/ifs.h

index 1d111350197f3169a8eec402d77980dd617c6b95..838e5a013a07ca978d95285f9daf6a5e101b7cc7 100644 (file)
 #define MSR_INTEGRITY_CAPS_ARRAY_BIST          BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT   4
 #define MSR_INTEGRITY_CAPS_PERIODIC_BIST       BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
+#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK        GENMASK_ULL(10, 9)
 
 #define MSR_LBR_NHM_FROM               0x00000680
 #define MSR_LBR_NHM_TO                 0x000006c0
index 306f886b52d2084e90c03108d489713c8050b652..4ff2aa4b484bc5d6b0e60a65272c09ca2fa2c27d 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright(c) 2022 Intel Corporation. */
 
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/kdev_t.h>
 #include <linux/semaphore.h>
@@ -94,6 +95,8 @@ static int __init ifs_init(void)
        for (i = 0; i < IFS_NUMTESTS; i++) {
                if (!(msrval & BIT(ifs_devices[i].test_caps->integrity_cap_bit)))
                        continue;
+               ifs_devices[i].rw_data.generation = FIELD_GET(MSR_INTEGRITY_CAPS_SAF_GEN_MASK,
+                                                             msrval);
                ret = misc_register(&ifs_devices[i].misc);
                if (ret)
                        goto err_exit;
index 93191855890f2cddde4b28bab5bf73a23dabccd7..d666aeed20fc2db7039c74b0f000c2f75a3f2305 100644 (file)
@@ -229,6 +229,7 @@ struct ifs_test_caps {
  * @status: it holds simple status pass/fail/untested
  * @scan_details: opaque scan status code from h/w
  * @cur_batch: number indicating the currently loaded test file
+ * @generation: IFS test generation enumerated by hardware
  */
 struct ifs_data {
        int     loaded_version;
@@ -238,6 +239,7 @@ struct ifs_data {
        int     status;
        u64     scan_details;
        u32     cur_batch;
+       u32     generation;
 };
 
 struct ifs_work {