ACPI: APEI: EINJ: Fix EINJV2 memory error injection
Tony Luck
reviewerPATCH v3 1/1 ACPI: APEI: EINJ: Fix EINJV2 memory error injection
Error types in EINJV2 use different bit positions for each flavor of injection from legacy EINJ.
Two issues:
1) The address sanity checks in einj_error_inject() were skipped for V2 injections. Noted by sashiko[1]
2) __einj_error_trigger() failed to drop the entry of the target physical address from the list of resources that need to be requested.
Add a helper function that checks if an injection is to memory and use it to solve each of these issues.
Note that the old test in __einj_error_trigger() checked that param2 was not zero. This isn't needed because the sanity checks in einj_error_inject() reject memory injections with param2 == 0.
#Reported-by: sashiko <[email protected]>
---
Changes since V2:
Fix additional issue reported by sashiko when reviewing earlier version.
drivers/acpi/apei/einj-core.c | 51 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 20 deletions(-)
drivers/acpi/apei/einj-core.c +31 -20
@@ -46,6 +46,12 @@ ACPI_EINJ_CXL_MEM_UNCORRECTABLE | \ ACPI_EINJ_CXL_MEM_FATAL) +/* EINJV2 Error types from ACPI v6.5 specification */ +#define ACPI_EINJV2_PROCESSOR BIT(0) +#define ACPI_EINJV2_MEMORY BIT(1) +#define ACPI_EINJV2_PCIX BIT(2) +#define ACPI_EINJV2_VENDOR BIT(31) +/* * ACPI version 5 provides a SET_ERROR_TYPE_WITH_ADDRESS action. */
@@ -401,8 +407,18 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(return NULL ; } + +static bool is_memory_injection (u32 type,u32 flags) +{ +if (flags &SETWA_FLAGS_EINJV2 ) +return !!(type &ACPI_EINJV2_MEMORY ); +if (type &ACPI5_VENDOR_BIT ) +return !!(vendor_flags &SETWA_FLAGS_MEM ); +return !!(type &MEM_ERROR_MASK ); +} +/* Execute instructions in trigger error action table */ -static int __einj_error_trigger (u64 trigger_paddr,u32 type, +static int __einj_error_trigger (u64 trigger_paddr,u32 type,u32 flags,u64 param1,u64 param2) {struct acpi_einj_trigger trigger_tab;
@@ -480,7 +496,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,* This will cause resource conflict with regular memory. So * remove it from trigger table resources. */ -if ((param_extension || acpi5) && (type &MEM_ERROR_MASK ) && param2) { +if ((param_extension || acpi5) &&is_memory_injection (type, flags)) {struct apei_resources addr_resources;apei_resources_init (&addr_resources);
@@ -660,7 +676,7 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,return rc; trigger_paddr =apei_exec_ctx_get_output (&ctx);if (notrigger ==0 ) { - rc =__einj_error_trigger (trigger_paddr, type, param1, param2); + rc =__einj_error_trigger (trigger_paddr, type, flags, param1, param2);if (rc)return rc; }
@@ -718,35 +734,30 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, SETWA_FLAGS_PCIE_SBDF | SETWA_FLAGS_EINJV2)))return -EINVAL ; +/* +* Injections targeting a CXL 1.0/1.1 port have to be injected +* via the einj_cxl_rch_error_inject() path as that does the proper +* validation of the given RCRB base (MMIO) address. +*/ +if (einj_is_cxl_error_type (type) && (flags &SETWA_FLAGS_MEM )) +return -EINVAL ; +/* check if type is a valid EINJv2 error type */ if (is_v2) {if (!(type & available_error_type_v2))return -EINVAL ; } -/* -* We need extra sanity checks for memory errors. -* Other types leap directly to injection. -*/ /* ensure param1/param2 existed */ if (!(param_extension || acpi5)) goto inject; -/* ensure injection is memory related */ -if (type &ACPI5_VENDOR_BIT ) { -if (vendor_flags !=SETWA_FLAGS_MEM ) - goto inject; - }else if (!(type &MEM_ERROR_MASK ) && !(flags &SETWA_FLAGS_MEM )) { - goto inject; - } -/* -* Injections targeting a CXL 1.0/1.1 port have to be injected -* via the einj_cxl_rch_error_inject() path as that does the proper -* validation of the given RCRB base (MMIO) address. +* We need extra sanity checks for memory errors. +* Other types leap directly to injection. */ -if (einj_is_cxl_error_type (type) && (flags &SETWA_FLAGS_MEM )) -return -EINVAL ; +if (!is_memory_injection (type, flags)) + goto inject;/* * Disallow crazy address masks that give BIOS leeway to pick
Signature · 1 line
2.53.0