Skip to content

Commit 22fca62

Browse files
Avadhut Naikrafaeljw
authored andcommitted
ACPI: APEI: EINJ: Add support for vendor defined error types
Vendor-Defined Error types are supported by the platform apart from standard error types if bit 31 is set in the output of GET_ERROR_TYPE Error Injection Action.[1] While the errors themselves and the length of their associated "OEM Defined data structure" might vary between vendors, the physical address of this structure can be computed through vendor_extension and length fields of "SET_ERROR_TYPE_WITH_ADDRESS" and "Vendor Error Type Extension" Structures respectively.[2][3] Currently, however, the einj module only computes the physical address of Vendor Error Type Extension Structure. Neither does it compute the physical address of OEM Defined structure nor does it establish the memory mapping required for injecting Vendor-defined errors. Consequently, userspace tools have to establish the very mapping through /dev/mem, nopat kernel parameter and system calls like mmap/munmap initially before injecting Vendor-defined errors. Circumvent the issue by computing the physical address of OEM Defined data structure and establishing the required mapping with the structure. Create a new file "oem_error", if the system supports Vendor-defined errors, to export this mapping, through debugfs_create_blob(). Userspace tools can then populate their respective OEM Defined structure instances and just write to the file as part of injecting Vendor-defined Errors. Similarly, the tools can also read from the file if the system firmware provides some information through the OEM defined structure after error injection. [1] ACPI specification 6.5, section 18.6.4 [2] ACPI specification 6.5, Table 18.31 [3] ACPI specification 6.5, Table 18.32 Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Avadhut Naik <Avadhut.Naik@amd.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0706526 commit 22fca62

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/acpi/apei/einj.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static u32 notrigger;
7373

7474
static u32 vendor_flags;
7575
static struct debugfs_blob_wrapper vendor_blob;
76+
static struct debugfs_blob_wrapper vendor_errors;
7677
static char vendor_dev[64];
7778

7879
/*
@@ -182,6 +183,21 @@ static int einj_timedout(u64 *t)
182183
return 0;
183184
}
184185

186+
static void get_oem_vendor_struct(u64 paddr, int offset,
187+
struct vendor_error_type_extension *v)
188+
{
189+
unsigned long vendor_size;
190+
u64 target_pa = paddr + offset + sizeof(struct vendor_error_type_extension);
191+
192+
vendor_size = v->length - sizeof(struct vendor_error_type_extension);
193+
194+
if (vendor_size)
195+
vendor_errors.data = acpi_os_map_memory(target_pa, vendor_size);
196+
197+
if (vendor_errors.data)
198+
vendor_errors.size = vendor_size;
199+
}
200+
185201
static void check_vendor_extension(u64 paddr,
186202
struct set_error_type_with_address *v5param)
187203
{
@@ -194,6 +210,7 @@ static void check_vendor_extension(u64 paddr,
194210
v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
195211
if (!v)
196212
return;
213+
get_oem_vendor_struct(paddr, offset, v);
197214
sbdf = v->pcie_sbdf;
198215
sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
199216
sbdf >> 24, (sbdf >> 16) & 0xff,
@@ -596,6 +613,7 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
596613
{ BIT(15), "CXL.mem Protocol Correctable" },
597614
{ BIT(16), "CXL.mem Protocol Uncorrectable non-fatal" },
598615
{ BIT(17), "CXL.mem Protocol Uncorrectable fatal" },
616+
{ BIT(31), "Vendor Defined Error Types" },
599617
};
600618

601619
static int available_error_type_show(struct seq_file *m, void *v)
@@ -768,6 +786,10 @@ static int __init einj_init(void)
768786
einj_debug_dir, &vendor_flags);
769787
}
770788

789+
if (vendor_errors.size)
790+
debugfs_create_blob("oem_error", 0600, einj_debug_dir,
791+
&vendor_errors);
792+
771793
pr_info("Error INJection is initialized.\n");
772794

773795
return 0;
@@ -793,6 +815,8 @@ static void __exit einj_exit(void)
793815
sizeof(struct einj_parameter);
794816

795817
acpi_os_unmap_iomem(einj_param, size);
818+
if (vendor_errors.size)
819+
acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size);
796820
}
797821
einj_exec_ctx_init(&ctx);
798822
apei_exec_post_unmap_gars(&ctx);

0 commit comments

Comments
 (0)