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

From: Aili Yao
Date: Mon Feb 01 2021 - 02:25:00 EST


On Fri, 29 Jan 2021 14:55:29 -0800
"Luck, Tony" <tony.luck@xxxxxxxxx> wrote:

> 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?

Yes, I will rebase it to newest version.

> 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.
>
Do you mean the force_sig_mceerr and force_sig_fault difference? I see a hwpoison related comment
there, but it's better to follow the usual way force_sig_mceerr, I will modify this in a v2 patch.

Or something other, you may post a better one.

Thanks

--
Best Regards!

Aili Yao