Skip to content

Commit 691a0f0

Browse files
zaidal-ampererafaeljw
authored andcommitted
ACPI: APEI: EINJ: Discover EINJv2 parameters
The EINJv2 set_error_type_with_address structure has a flex array to hold the component IDs and syndrome values used when injecting multiple errors at once. Discover the size of this array by taking the address from the ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS entry in the EINJ table and reading the BIOS copy of the structure. Derive the maximum number of components from the length field in the einjv2_extension_struct at the end of the BIOS copy. Map the whole of the structure into kernel memory (and unmap on module unload). [Tony: Code unchanged from Zaid's original. New commit message] Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com> Link: https://patch.msgid.link/20250617193026.637510-5-zaidal@os.amperecomputing.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 21cd921 commit 691a0f0

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

drivers/acpi/apei/einj-core.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static struct debugfs_blob_wrapper vendor_blob;
108108
static struct debugfs_blob_wrapper vendor_errors;
109109
static char vendor_dev[64];
110110

111+
static u32 max_nr_components;
111112
static u32 available_error_type;
112113
static u32 available_error_type_v2;
113114

@@ -178,6 +179,7 @@ static DEFINE_MUTEX(einj_mutex);
178179
bool einj_initialized __ro_after_init;
179180

180181
static void __iomem *einj_param;
182+
static u32 v5param_size;
181183

182184
static void einj_exec_ctx_init(struct apei_exec_context *ctx)
183185
{
@@ -302,11 +304,31 @@ static void __iomem *einj_get_parameter_address(void)
302304
struct set_error_type_with_address v5param;
303305
struct set_error_type_with_address __iomem *p;
304306

307+
v5param_size = sizeof(v5param);
305308
p = acpi_os_map_iomem(pa_v5, sizeof(*p));
306309
if (p) {
307-
memcpy_fromio(&v5param, p, sizeof(v5param));
310+
int offset, len;
311+
312+
memcpy_fromio(&v5param, p, v5param_size);
308313
acpi5 = 1;
309314
check_vendor_extension(pa_v5, &v5param);
315+
if (available_error_type & ACPI65_EINJV2_SUPP) {
316+
len = v5param.einjv2_struct.length;
317+
offset = offsetof(struct einjv2_extension_struct, component_arr);
318+
max_nr_components = (len - offset) /
319+
sizeof(v5param.einjv2_struct.component_arr[0]);
320+
/*
321+
* The first call to acpi_os_map_iomem above does not include the
322+
* component array, instead it is used to read and calculate maximum
323+
* number of components supported by the system. Below, the mapping
324+
* is expanded to include the component array.
325+
*/
326+
acpi_os_unmap_iomem(p, v5param_size);
327+
offset = offsetof(struct set_error_type_with_address, einjv2_struct);
328+
v5param_size = offset + struct_size(&v5param.einjv2_struct,
329+
component_arr, max_nr_components);
330+
p = acpi_os_map_iomem(pa_v5, v5param_size);
331+
}
310332
return p;
311333
}
312334
}
@@ -933,7 +955,7 @@ static void __exit einj_remove(struct faux_device *fdev)
933955

934956
if (einj_param) {
935957
acpi_size size = (acpi5) ?
936-
sizeof(struct set_error_type_with_address) :
958+
v5param_size :
937959
sizeof(struct einj_parameter);
938960

939961
acpi_os_unmap_iomem(einj_param, size);

0 commit comments

Comments
 (0)