Re: [PATCH] x86/fault: Send SIGBUS to user process always for hwpoison page access.

From: Luck, Tony
Date: Fri Jan 29 2021 - 17:56:19 EST


Thanks for the explanation and test code. I think I see better what
is going on here.

[I took your idea for using madvise(...MADV_HWPOISON) and added a new "-S"
option to my einj_mem_uc test program to use madvise instead of ACPI/EINJ
for injections. Update pushed here:
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/ras-tools.git ]

There have been some small changes to arch/x86/mm/fault.c since you wrote
the patch. Can you rebase to v5.11-rc5?

Also maybe this might be a case to use IS_ENABLED() instead of #ifdef to
make the code a little less ugly. At least for the 2nd hunk in your patch
this would work well:

if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
(fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)))
no_context(regs, error_code, address, SIGBUS, BUS_MCEERR_AR);
else
no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);

The first hunk might need a bit more thought.

-Tony