ACPI: APEI: EINJ: Allow injection on legacy persistent memory
PATCH 1/1 ACPI: APEI: EINJ: Allow injection on legacy persistent memory
Legacy persistent memory, e.g. Device DAX configured like the following
440000000-303fffffff : Persistent Memory (legacy)
440000000-47fffffff : dax1.0
480000000-4bfffffff : dax2.0
4c0000000-4ffffffff : dax3.0
500000000-53fffffff : dax4.0
...can support recover from Machine Check Exception due to memory failure. Therefore there is need to test it by injecting memory error using EINJ to legacy persistent memory.
However, current EINJ only check if physical address falls into the IORES_DESC_PERSISTENT_MEMORY_LEGACY region. So attempt to inject error to "Persistent Memory (legacy)" fails with -EINVAL.
Allow EINJ to inject at physical address belongin to IORES_DESC_PERSISTENT_MEMORY_LEGACY.
Tested on a machine configured with Device DAX:
memmap=4G!12G nd_e820.pmem=12G,4G,mode=fsdax memmap=176G!17G nd_e820.pmem=17G,1G,mode=devdax,align=1G memmap=176G!209G nd_e820.pmem=209G,1G,mode=devdax,align=1G memmap=176G!401G nd_e820.pmem=401G,1G,mode=devdax,align=1G memmap=176G!593G nd_e820.pmem=593G,1G,mode=devdax,align=1G
Injected error at 0x35238d2000, within Device DAX region and allocated to a userspace test process. EINJ driver now issue the injection request to firmware, and firmware logs shows injection at 0x35238d2000 succeeded. The userspace test process then accessed 0x35238d2000, caused a MCE, and killed by SIGBUS.
--- drivers/acpi/apei/einj-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/apei/einj-core.c +2 -0
@@ -712,6 +712,8 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, != REGION_INTERSECTS) && (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY ) !=REGION_INTERSECTS ) && + (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY_LEGACY ) + !=REGION_INTERSECTS ) && (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_SOFT_RESERVED ) !=REGION_INTERSECTS ) && !arch_is_platform_page(base_addr)))
Signature · 1 line
2.51.0.268.g9569e192d0-goog
Luck, Tony
reviewerQuoted 43 lines · Jiaqi Yan
Legacy persistent memory, e.g. Device DAX configured like the following
440000000-303fffffff : Persistent Memory (legacy)
440000000-47fffffff : dax1.0 480000000-4bfffffff : dax2.0 4c0000000-4ffffffff : dax3.0 500000000-53fffffff : dax4.0 ...can support recover from Machine Check Exception due to memory failure. Therefore there is need to test it by injecting memory error using EINJ to legacy persistent memory.
However, current EINJ only check if physical address falls into the
IORES_DESC_PERSISTENT_MEMORY_LEGACYregion. So attempt to inject error to "Persistent Memory (legacy)" fails with-EINVAL.Allow EINJ to inject at physical address belongin to
IORES_DESC_PERSISTENT_MEMORY_LEGACY.Tested on a machine configured with Device DAX:
memmap=4G!12G nd_e820.pmem=12G,4G,mode=fsdax memmap=176G!17G nd_e820.pmem=17G,1G,mode=devdax,align=1G memmap=176G!209G nd_e820.pmem=209G,1G,mode=devdax,align=1G memmap=176G!401G nd_e820.pmem=401G,1G,mode=devdax,align=1G memmap=176G!593G nd_e820.pmem=593G,1G,mode=devdax,align=1GInjected error at
0x35238d2000, within Device DAX region and allocated to a userspace test process. EINJ driver now issue the injection request to firmware, and firmware logs shows injection at0x35238d2000succeeded. The userspace test process then accessed0x35238d2000, caused a MCE, and killed by SIGBUS.Signed-off-by Jiaqi Yan <[email protected]>--- drivers/acpi/apei/einj-core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/acpi/apei/einj-core.c +0
-0
drivers/acpi/apei/einj-core.c int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, · line 716
Quoted 5 lines
drivers/acpi/apei/einj-core.c +2
-0@@ -712,6 +712,8 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, != REGION_INTERSECTS) && (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY ) !=REGION_INTERSECTS ) && + (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY_LEGACY ) + != REGION_INTERSECTS) &&
I chatted offline with Dan Williams. He wondered whether this sanity check should just be reduced to pass through any address except MMIO and leave it to the BIOS to decide what is a legitimate injection target.
Quoted 5 lines
drivers/acpi/apei/einj-core.c +0
-0(region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_SOFT_RESERVED ) !=REGION_INTERSECTS ) && !arch_is_platform_page(base_addr)))Signature · 1 line
2.51.0.268.g9569e192d0-goog
-Tony
Quoted 40 lines · Tony
Quoted 38 lines · Jiaqi Yan
Legacy persistent memory, e.g. Device DAX configured like the following
440000000-303fffffff : Persistent Memory (legacy)
440000000-47fffffff : dax1.0 480000000-4bfffffff : dax2.0 4c0000000-4ffffffff : dax3.0 500000000-53fffffff : dax4.0 ...can support recover from Machine Check Exception due to memory failure. Therefore there is need to test it by injecting memory error using EINJ to legacy persistent memory.
However, current EINJ only check if physical address falls into the
IORES_DESC_PERSISTENT_MEMORY_LEGACYregion. So attempt to inject error to "Persistent Memory (legacy)" fails with-EINVAL.Allow EINJ to inject at physical address belongin to
IORES_DESC_PERSISTENT_MEMORY_LEGACY.Tested on a machine configured with Device DAX:
memmap=4G!12G nd_e820.pmem=12G,4G,mode=fsdax memmap=176G!17G nd_e820.pmem=17G,1G,mode=devdax,align=1G memmap=176G!209G nd_e820.pmem=209G,1G,mode=devdax,align=1G memmap=176G!401G nd_e820.pmem=401G,1G,mode=devdax,align=1G memmap=176G!593G nd_e820.pmem=593G,1G,mode=devdax,align=1GInjected error at
0x35238d2000, within Device DAX region and allocated to a userspace test process. EINJ driver now issue the injection request to firmware, and firmware logs shows injection at0x35238d2000succeeded. The userspace test process then accessed0x35238d2000, caused a MCE, and killed by SIGBUS.Signed-off-by Jiaqi Yan <[email protected]>--- drivers/acpi/apei/einj-core.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 15 lines
drivers/acpi/apei/einj-core.c int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, · line 716
Quoted 10 lines
drivers/acpi/apei/einj-core.c +2
-0@@ -712,6 +712,8 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, != REGION_INTERSECTS) && (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY ) !=REGION_INTERSECTS ) && + (region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_PERSISTENT_MEMORY_LEGACY ) + != REGION_INTERSECTS) &&I chatted offline with Dan Williams. He wondered whether this sanity check should just be reduced to pass through any address except MMIO and leave it to the BIOS to decide what is a legitimate injection target.
I guess that's fine, but wonder should the EINJ driver still exclude IORES_DESC_ACPI_TABLES and IORES_DESC_ACPI_NV_STORAGE? to prevent that, say, by coincidence or not an error "corrupted" EINJ table itself, or "corrupted" other ACPI data.
Quoted 8 lines
Quoted 6 lines
drivers/acpi/apei/einj-core.c +0
-1(region_intersects (base_addr, size,IORESOURCE_MEM ,IORES_DESC_SOFT_RESERVED ) !=REGION_INTERSECTS ) && !arch_is_platform_page(base_addr))) --2.51.0.268.g9569e192d0-goog
-Tony
Luck, Tony
reviewerQuoted 9 lines
Quoted 4 lines
I chatted offline with Dan Williams. He wondered whether this sanity check should just be reduced to pass through any address except MMIO and leave it to the BIOS to decide what is a legitimate injection target.
I guess that's fine, but wonder should the EINJ driver still exclude
IORES_DESC_ACPI_TABLESandIORES_DESC_ACPI_NV_STORAGE? to prevent that, say, by coincidence or not an error "corrupted" EINJ table itself, or "corrupted" other ACPI data.
What if I want to find out what the system does with a corrupted ACPI table?
See discussion earlier this year about limiting error injection:
https://lore.kernel.org/all/aDt77p9GYCIRIOMa@agluck-desk3/
-Tony
Quoted 6 lines · Tony
Quoted 6 lines
Quoted 5 lines
I chatted offline with Dan Williams. He wondered whether this sanity check should just be reduced to pass through any address except MMIO and leave it to the BIOS to decide what is a legitimate injection target.
Quoted 6 lines
Quoted 4 lines
I guess that's fine, but wonder should the EINJ driver still exclude
IORES_DESC_ACPI_TABLESandIORES_DESC_ACPI_NV_STORAGE? to prevent that, say, by coincidence or not an error "corrupted" EINJ table itself, or "corrupted" other ACPI data.What if I want to find out what the system does with a corrupted ACPI table?
Yeah, it sounds like a valid use case for a smart user of EINJ. I guess I just wasn't thinking "wild" enough ;).
If other APEI maintainers and reviewers agree, I will do it in V2; IIUC basically the following small diff:
drivers/acpi/apei/einj-core.c +0 -0
@@ -707,14 +707,7 @@ int einj_error_inject(u32 type, u32 flags, u64
param1, u64 param2, u64 param3,
base_addr = param1 & param2;
size = ~param2 + 1;- if (((param2 & PAGE_MASK) != PAGE_MASK) ||
- ((region_intersects(base_addr, size,IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
- != REGION_INTERSECTS) &&
- (region_intersects(base_addr, size, IORESOURCE_MEM,IORES_DESC_PERSISTENT_MEMORY)
- != REGION_INTERSECTS) &&
- (region_intersects(base_addr, size, IORESOURCE_MEM,IORES_DESC_SOFT_RESERVED)
- != REGION_INTERSECTS) &&
- !arch_is_platform_page(base_addr)))
+ if (((param2 & PAGE_MASK) != PAGE_MASK))
return -EINVAL;
Quoted 6 lines
See discussion earlier this year about limiting error injection:
https://lore.kernel.org/all/aDt77p9GYCIRIOMa@agluck-desk3/
-Tony