Skip to content

Commit a138ac2

Browse files
jithu83ij-intel
authored andcommitted
platform/x86/intel/ifs: Refactor image loading code
IFS image loading flow is slightly different for newer IFS generations. In preparation for adding support for newer IFS generations, refactor portions of existing image loading code for reuse. 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-3-jithu.joseph@intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 97a5e80 commit a138ac2

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

  • drivers/platform/x86/intel/ifs

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_typ
8080
return NULL;
8181
}
8282

83+
static void hashcopy_err_message(struct device *dev, u32 err_code)
84+
{
85+
if (err_code >= ARRAY_SIZE(scan_hash_status))
86+
dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
87+
else
88+
dev_err(dev, "Hash copy error : %s\n", scan_hash_status[err_code]);
89+
}
90+
91+
static void auth_err_message(struct device *dev, u32 err_code)
92+
{
93+
if (err_code >= ARRAY_SIZE(scan_authentication_status))
94+
dev_err(dev, "invalid error code 0x%x for authentication\n", err_code);
95+
else
96+
dev_err(dev, "Chunk authentication error : %s\n",
97+
scan_authentication_status[err_code]);
98+
}
99+
83100
/*
84101
* To copy scan hashes and authenticate test chunks, the initiating cpu must point
85102
* to the EDX:EAX to the test image in linear address.
@@ -109,11 +126,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
109126

110127
if (!hashes_status.valid) {
111128
ifsd->loading_error = true;
112-
if (err_code >= ARRAY_SIZE(scan_hash_status)) {
113-
dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
114-
goto done;
115-
}
116-
dev_err(dev, "Hash copy error : %s", scan_hash_status[err_code]);
129+
hashcopy_err_message(dev, err_code);
117130
goto done;
118131
}
119132

@@ -133,13 +146,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
133146

134147
if (err_code) {
135148
ifsd->loading_error = true;
136-
if (err_code >= ARRAY_SIZE(scan_authentication_status)) {
137-
dev_err(dev,
138-
"invalid error code 0x%x for authentication\n", err_code);
139-
goto done;
140-
}
141-
dev_err(dev, "Chunk authentication error %s\n",
142-
scan_authentication_status[err_code]);
149+
auth_err_message(dev, err_code);
143150
goto done;
144151
}
145152
}

0 commit comments

Comments
 (0)