From: Jithu Joseph <[email protected]> The MSR_LAST_SAF_WP register provides information about the core when the last WRMSR(ACTIVATE_SCAN) was executed. It is available only if enumerated in bits [10:9] of MSR_INTEGRITY_CAPABILITIES.
Add a new sysfs interface, addnl_details_list, to the user space to provide additional details about the last In-Field Scan testing. [ Qiuxu: wrote the commit message. ] Signed-off-by: Jithu Joseph <[email protected]> Signed-off-by: Ehab Ababneh <[email protected]> --- drivers/platform/x86/intel/ifs/ifs.h | 2 ++ drivers/platform/x86/intel/ifs/runtest.c | 4 ++++ drivers/platform/x86/intel/ifs/sysfs.c | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/drivers/platform/x86/intel/ifs/ifs.h b/drivers/platform/x86/intel/ifs/ifs.h index 1043378c60e5..3f11ae08dce1 100644 --- a/drivers/platform/x86/intel/ifs/ifs.h +++ b/drivers/platform/x86/intel/ifs/ifs.h @@ -139,6 +139,7 @@ #define MSR_CHUNKS_AUTHENTICATION_STATUS 0x000002c5 #define MSR_ACTIVATE_SCAN 0x000002c6 #define MSR_SCAN_STATUS 0x000002c7 +#define MSR_LAST_SAF_WP 0x000002c9 #define MSR_ARRAY_TRIGGER 0x000002d6 #define MSR_ARRAY_STATUS 0x000002d7 #define MSR_SAF_CTRL 0x000004f0 @@ -332,6 +333,7 @@ struct ifs_device { struct ifs_test_output { u64 test_details; + u64 addnl_details; int test_result; }; diff --git a/drivers/platform/x86/intel/ifs/runtest.c b/drivers/platform/x86/intel/ifs/runtest.c index 6c3d025817e7..d5303dd72233 100644 --- a/drivers/platform/x86/intel/ifs/runtest.c +++ b/drivers/platform/x86/intel/ifs/runtest.c @@ -177,6 +177,7 @@ static int doscan(void *data) struct run_params *params = data; union ifs_status status; struct ifs_data *ifsd; + u64 saf_wp = 0; ifsd = params->ifsd; pcpu_scan = this_cpu_ptr(ifsd->result_ptr); @@ -202,6 +203,8 @@ static int doscan(void *data) wrmsrq(MSR_ACTIVATE_SCAN, params->activate->data); rdmsrq(MSR_SCAN_STATUS, status.data); + if (ifsd->generation) + rdmsrq(MSR_LAST_SAF_WP, saf_wp); trace_ifs_status(ifsd->cur_batch, start, stop, status.data); /* Pass back the result of the scan */ @@ -209,6 +212,7 @@ static int doscan(void *data) params->status = status; pcpu_scan->test_details = status.data; + pcpu_scan->addnl_details = saf_wp; return 0; } diff --git a/drivers/platform/x86/intel/ifs/sysfs.c b/drivers/platform/x86/intel/ifs/sysfs.c index 82a603cd1fd3..3cbab2acca72 100644 --- a/drivers/platform/x86/intel/ifs/sysfs.c +++ b/drivers/platform/x86/intel/ifs/sysfs.c @@ -188,6 +188,28 @@ static ssize_t cpus_ran_list_show(struct device *dev, struct device_attribute *a } static DEVICE_ATTR_RO(cpus_ran_list); + +static ssize_t addnl_details_list_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct ifs_data *ifsd = ifs_get_data(dev); + struct ifs_test_output *pcpu_state; + int lcpu, len = 0; + + if (cpumask_weight(&ifsd->grp_cpumask) == 0) + return sysfs_emit(buf, "%s\n", "none"); + + for_each_cpu(lcpu, &ifsd->grp_cpumask) { + pcpu_state = per_cpu_ptr(ifsd->result_ptr, lcpu); + len += sysfs_emit_at(buf, len, "%s%#llx", (len > 0) ? " " : "", + pcpu_state->addnl_details); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + +static DEVICE_ATTR_RO(addnl_details_list); + /* global scan sysfs attributes */ struct attribute *plat_ifs_attrs[] = { &dev_attr_details.attr, @@ -198,6 +220,7 @@ struct attribute *plat_ifs_attrs[] = { &dev_attr_status_list.attr, &dev_attr_details_list.attr, &dev_attr_cpus_ran_list.attr, + &dev_attr_addnl_details_list.attr, NULL }; -- 2.43.0
