On Mon, Aug 25, 2025 at 10:33:48PM +0000, Jiaqi Yan wrote: > 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. > > Signed-off-by: Jiaqi Yan <jiaqiyan@xxxxxxxxxx> > --- > drivers/acpi/apei/einj-core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c > index 2561b045acc7b..e746fa66f92ff 100644 > --- a/drivers/acpi/apei/einj-core.c > +++ b/drivers/acpi/apei/einj-core.c > @@ -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. > (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