* + mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch added to -mm tree
@ 2022-02-22 3:48 Andrew Morton
2022-02-22 11:03 ` Borislav Petkov
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-02-22 3:48 UTC (permalink / raw)
To: mm-commits, tony.luck, tglx, naoya.horiguchi, mingo, linmiaohe,
hpa, dave.hansen, bp, luofei, akpm
The patch titled
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
has been added to the -mm tree. Its filename is
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: luofei <luofei@unicloud.com>
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
When the hwpoison page meets the filter conditions, it should not be
regarded as successful memory_failure() processing for mce handler, but
should return a value(-EHWPOISON), otherwise mce handler regards the error
page has been identified and isolated, which may lead to calling
set_mce_nospec() to change page attribute, etc.
Here a new MF_MCE_HANDLE flag is introduced to identify the call from the
mce handler and instruct hwpoison_filter() to return -EHWPOISON, otherwise
return 0 for compatibility with the hwpoison injector.
Link: https://lkml.kernel.org/r/20220221021415.2328992-1-luofei@unicloud.com
Signed-off-by: luofei <luofei@unicloud.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Fei Luo <luofei@unicloud.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/x86/kernel/cpu/mce/core.c | 15 +++++++++------
include/linux/mm.h | 1 +
mm/memory-failure.c | 14 ++++++++++++--
3 files changed, 22 insertions(+), 8 deletions(-)
--- a/arch/x86/kernel/cpu/mce/core.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/arch/x86/kernel/cpu/mce/core.c
@@ -612,7 +612,7 @@ static int uc_decode_notifier(struct not
return NOTIFY_DONE;
pfn = mce->addr >> PAGE_SHIFT;
- if (!memory_failure(pfn, 0)) {
+ if (!memory_failure(pfn, MF_MCE_HANDLE)) {
set_mce_nospec(pfn, whole_page(mce));
mce->kflags |= MCE_HANDLED_UC;
}
@@ -1286,7 +1286,7 @@ static void kill_me_now(struct callback_
static void kill_me_maybe(struct callback_head *cb)
{
struct task_struct *p = container_of(cb, struct task_struct, mce_kill_me);
- int flags = MF_ACTION_REQUIRED;
+ int flags = MF_ACTION_REQUIRED | MF_MCE_HANDLE;
int ret;
p->mce_count = 0;
@@ -1303,9 +1303,12 @@ static void kill_me_maybe(struct callbac
}
/*
- * -EHWPOISON from memory_failure() means that it already sent SIGBUS
- * to the current process with the proper error info, so no need to
- * send SIGBUS here again.
+ * -EHWPOISON from memory_failure() means that memory_failure() did
+ * not handle the error event for the following reason:
+ * - SIGBUS has already been sent to the current process with the
+ * proper error info, or
+ * - hwpoison_filter() filtered the event,
+ * so no need to deal with it more.
*/
if (ret == -EHWPOISON)
return;
@@ -1320,7 +1323,7 @@ static void kill_me_never(struct callbac
p->mce_count = 0;
pr_err("Kernel accessed poison in user space at %llx\n", p->mce_addr);
- if (!memory_failure(p->mce_addr >> PAGE_SHIFT, 0))
+ if (!memory_failure(p->mce_addr >> PAGE_SHIFT, MF_MCE_HANDLE))
set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page);
}
--- a/include/linux/mm.h~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/include/linux/mm.h
@@ -3173,6 +3173,7 @@ enum mf_flags {
MF_MUST_KILL = 1 << 2,
MF_SOFT_OFFLINE = 1 << 3,
MF_UNPOISON = 1 << 4,
+ MF_MCE_HANDLE = 1 << 5,
};
extern int memory_failure(unsigned long pfn, int flags);
extern void memory_failure_queue(unsigned long pfn, int flags);
--- a/mm/memory-failure.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/mm/memory-failure.c
@@ -1515,7 +1515,10 @@ static int memory_failure_hugetlb(unsign
if (TestClearPageHWPoison(head))
num_poisoned_pages_dec();
unlock_page(head);
- return 0;
+ if (flags & MF_MCE_HANDLE)
+ return -EHWPOISON;
+ else
+ return 0;
}
unlock_page(head);
res = MF_FAILED;
@@ -1602,7 +1605,10 @@ static int memory_failure_dev_pagemap(un
goto out;
if (hwpoison_filter(page)) {
- rc = 0;
+ if (flags & MF_MCE_HANDLE)
+ rc = -EHWPOISON;
+ else
+ rc = 0;
goto unlock;
}
@@ -1830,6 +1836,10 @@ try_again:
num_poisoned_pages_dec();
unlock_page(p);
put_page(p);
+ if (flags & MF_MCE_HANDLE)
+ res = -EHWPOISON;
+ else
+ res = 0;
goto unlock_mutex;
}
_
Patches currently in -mm which might be from luofei@unicloud.com are
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
mm-hwpoison-add-in-use-hugepage-hwpoison-filter-judgement.patch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: + mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch added to -mm tree
2022-02-22 3:48 Andrew Morton
@ 2022-02-22 11:03 ` Borislav Petkov
0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2022-02-22 11:03 UTC (permalink / raw)
To: Andrew Morton
Cc: mm-commits, tony.luck, tglx, naoya.horiguchi, mingo, linmiaohe,
hpa, dave.hansen, luofei
On Mon, Feb 21, 2022 at 07:48:20PM -0800, Andrew Morton wrote:
> The patch titled
> Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
> has been added to the -mm tree. Its filename is
> mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
Andrew, please drop this patch from your queue. Review below:
> From: luofei <luofei@unicloud.com>
> Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
>
> When the hwpoison page meets the filter conditions, it should not be
> regarded as successful memory_failure() processing for mce handler, but
> should return a value(-EHWPOISON), otherwise mce handler regards the error
> page has been identified and isolated, which may lead to calling
> set_mce_nospec() to change page attribute, etc.
>
> Here a new MF_MCE_HANDLE flag is introduced to identify the call from the
> mce handler and instruct hwpoison_filter() to return -EHWPOISON, otherwise
> return 0 for compatibility with the hwpoison injector.
>
> Link: https://lkml.kernel.org/r/20220221021415.2328992-1-luofei@unicloud.com
> Signed-off-by: luofei <luofei@unicloud.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Fei Luo <luofei@unicloud.com>
> Cc: Miaohe Lin <linmiaohe@huawei.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> arch/x86/kernel/cpu/mce/core.c | 15 +++++++++------
> include/linux/mm.h | 1 +
> mm/memory-failure.c | 14 ++++++++++++--
> 3 files changed, 22 insertions(+), 8 deletions(-)
>
> --- a/arch/x86/kernel/cpu/mce/core.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
> +++ a/arch/x86/kernel/cpu/mce/core.c
> @@ -612,7 +612,7 @@ static int uc_decode_notifier(struct not
> return NOTIFY_DONE;
>
> pfn = mce->addr >> PAGE_SHIFT;
> - if (!memory_failure(pfn, 0)) {
> + if (!memory_failure(pfn, MF_MCE_HANDLE)) {
> set_mce_nospec(pfn, whole_page(mce));
> mce->kflags |= MCE_HANDLED_UC;
> }
> @@ -1286,7 +1286,7 @@ static void kill_me_now(struct callback_
> static void kill_me_maybe(struct callback_head *cb)
> {
> struct task_struct *p = container_of(cb, struct task_struct, mce_kill_me);
> - int flags = MF_ACTION_REQUIRED;
> + int flags = MF_ACTION_REQUIRED | MF_MCE_HANDLE;
> int ret;
>
> p->mce_count = 0;
> @@ -1303,9 +1303,12 @@ static void kill_me_maybe(struct callbac
> }
>
> /*
> - * -EHWPOISON from memory_failure() means that it already sent SIGBUS
> - * to the current process with the proper error info, so no need to
> - * send SIGBUS here again.
> + * -EHWPOISON from memory_failure() means that memory_failure() did
> + * not handle the error event for the following reason:
> + * - SIGBUS has already been sent to the current process with the
> + * proper error info, or
> + * - hwpoison_filter() filtered the event,
> + * so no need to deal with it more.
So you're overloading what we do for -EHWPOISON because it is just fits?
The right way to do this is to return a *distinct* error value which
means "ignore this error" and the MCE code can then ignore it.
> --- a/include/linux/mm.h~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
> +++ a/include/linux/mm.h
> @@ -3173,6 +3173,7 @@ enum mf_flags {
> MF_MUST_KILL = 1 << 2,
> MF_SOFT_OFFLINE = 1 << 3,
> MF_UNPOISON = 1 << 4,
> + MF_MCE_HANDLE = 1 << 5,
This thing is too x86-specific and means nothing for other arches which
use memory_failure().
And I don't like this jumping through hoops one bit:
MCE code sets MF_MCE_HANDLE to tell the memory failure code to return a
special error which it does and then the MCE code again looks looks at
that special error. That's just nuts.
As said above, all you wanna do is have memory_failure() return a
distinct error value which says "ignore this error and don't do any
further processing". Without a new MF flag.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
* + mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch added to -mm tree
@ 2022-02-24 2:58 Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2022-02-24 2:58 UTC (permalink / raw)
To: mm-commits, tony.luck, tglx, naoya.horiguchi, mingo, linmiaohe,
hpa, dave.hansen, bp, luofei, akpm
The patch titled
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
has been added to the -mm tree. Its filename is
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: luofei <luofei@unicloud.com>
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
When the hwpoison page meets the filter conditions, it should not be
regarded as successful memory_failure() processing for mce handler, but
should return a value(-EHWPOISON), otherwise mce handler regards the error
page has been identified and isolated, which may lead to calling
set_mce_nospec() to change page attribute, etc.
Here a new MF_MCE_HANDLE flag is introduced to identify the call from the
mce handler and instruct hwpoison_filter() to return -EHWPOISON, otherwise
return 0 for compatibility with the hwpoison injector.
Link: https://lkml.kernel.org/r/20220221021415.2328992-1-luofei@unicloud.com
Signed-off-by: luofei <luofei@unicloud.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/x86/kernel/cpu/mce/core.c | 15 +++++++++------
include/linux/mm.h | 1 +
mm/memory-failure.c | 14 ++++++++++++--
3 files changed, 22 insertions(+), 8 deletions(-)
--- a/arch/x86/kernel/cpu/mce/core.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/arch/x86/kernel/cpu/mce/core.c
@@ -612,7 +612,7 @@ static int uc_decode_notifier(struct not
return NOTIFY_DONE;
pfn = mce->addr >> PAGE_SHIFT;
- if (!memory_failure(pfn, 0)) {
+ if (!memory_failure(pfn, MF_MCE_HANDLE)) {
set_mce_nospec(pfn, whole_page(mce));
mce->kflags |= MCE_HANDLED_UC;
}
@@ -1286,7 +1286,7 @@ static void kill_me_now(struct callback_
static void kill_me_maybe(struct callback_head *cb)
{
struct task_struct *p = container_of(cb, struct task_struct, mce_kill_me);
- int flags = MF_ACTION_REQUIRED;
+ int flags = MF_ACTION_REQUIRED | MF_MCE_HANDLE;
int ret;
p->mce_count = 0;
@@ -1303,9 +1303,12 @@ static void kill_me_maybe(struct callbac
}
/*
- * -EHWPOISON from memory_failure() means that it already sent SIGBUS
- * to the current process with the proper error info, so no need to
- * send SIGBUS here again.
+ * -EHWPOISON from memory_failure() means that memory_failure() did
+ * not handle the error event for the following reason:
+ * - SIGBUS has already been sent to the current process with the
+ * proper error info, or
+ * - hwpoison_filter() filtered the event,
+ * so no need to deal with it more.
*/
if (ret == -EHWPOISON)
return;
@@ -1320,7 +1323,7 @@ static void kill_me_never(struct callbac
p->mce_count = 0;
pr_err("Kernel accessed poison in user space at %llx\n", p->mce_addr);
- if (!memory_failure(p->mce_addr >> PAGE_SHIFT, 0))
+ if (!memory_failure(p->mce_addr >> PAGE_SHIFT, MF_MCE_HANDLE))
set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page);
}
--- a/include/linux/mm.h~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/include/linux/mm.h
@@ -3177,6 +3177,7 @@ enum mf_flags {
MF_MUST_KILL = 1 << 2,
MF_SOFT_OFFLINE = 1 << 3,
MF_UNPOISON = 1 << 4,
+ MF_MCE_HANDLE = 1 << 5,
};
extern int memory_failure(unsigned long pfn, int flags);
extern void memory_failure_queue(unsigned long pfn, int flags);
--- a/mm/memory-failure.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/mm/memory-failure.c
@@ -1515,7 +1515,10 @@ static int memory_failure_hugetlb(unsign
if (TestClearPageHWPoison(head))
num_poisoned_pages_dec();
unlock_page(head);
- return 0;
+ if (flags & MF_MCE_HANDLE)
+ return -EHWPOISON;
+ else
+ return 0;
}
unlock_page(head);
res = MF_FAILED;
@@ -1602,7 +1605,10 @@ static int memory_failure_dev_pagemap(un
goto out;
if (hwpoison_filter(page)) {
- rc = 0;
+ if (flags & MF_MCE_HANDLE)
+ rc = -EHWPOISON;
+ else
+ rc = 0;
goto unlock;
}
@@ -1836,6 +1842,10 @@ try_again:
num_poisoned_pages_dec();
unlock_page(p);
put_page(p);
+ if (flags & MF_MCE_HANDLE)
+ res = -EHWPOISON;
+ else
+ res = 0;
goto unlock_mutex;
}
_
Patches currently in -mm which might be from luofei@unicloud.com are
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
mm-hwpoison-add-in-use-hugepage-hwpoison-filter-judgement.patch
^ permalink raw reply [flat|nested] 4+ messages in thread
* + mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch added to -mm tree
@ 2022-02-24 4:38 Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2022-02-24 4:38 UTC (permalink / raw)
To: mm-commits, tony.luck, tglx, naoya.horiguchi, mingo, linmiaohe,
hpa, dave.hansen, bp, luofei, akpm
The patch titled
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
has been added to the -mm tree. Its filename is
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: luofei <luofei@unicloud.com>
Subject: mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler
When the hwpoison page meets the filter conditions, it should not be
regarded as successful memory_failure() processing for mce handler, but
should return a distinct value, otherwise mce handler regards the error
page has been identified and isolated, which may lead to calling
set_mce_nospec() to change page attribute, etc.
Here memory_failure() return -EOPNOTSUPP to indicate that the error event
is filtered, mce handler should not take any action for this situation and
hwpoison injector should treat as correct.
Link: https://lkml.kernel.org/r/20220223082135.2769649-1-luofei@unicloud.com
Signed-off-by: luofei <luofei@unicloud.com>
Acked-by: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/x86/kernel/cpu/mce/core.c | 8 +++++---
drivers/base/memory.c | 2 ++
mm/hwpoison-inject.c | 3 ++-
mm/madvise.c | 2 ++
mm/memory-failure.c | 9 +++++++--
5 files changed, 18 insertions(+), 6 deletions(-)
--- a/arch/x86/kernel/cpu/mce/core.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/arch/x86/kernel/cpu/mce/core.c
@@ -1304,10 +1304,12 @@ static void kill_me_maybe(struct callbac
/*
* -EHWPOISON from memory_failure() means that it already sent SIGBUS
- * to the current process with the proper error info, so no need to
- * send SIGBUS here again.
+ * to the current process with the proper error info,
+ * -EOPNOTSUPP means hwpoison_filter() filtered the error event,
+ *
+ * In both cases, no further processing is required.
*/
- if (ret == -EHWPOISON)
+ if (ret == -EHWPOISON || ret == -EOPNOTSUPP)
return;
pr_err("Memory error not recovered");
--- a/drivers/base/memory.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/drivers/base/memory.c
@@ -555,6 +555,8 @@ static ssize_t hard_offline_page_store(s
return -EINVAL;
pfn >>= PAGE_SHIFT;
ret = memory_failure(pfn, 0);
+ if (ret == -EOPNOTSUPP)
+ ret = 0;
return ret ? ret : count;
}
--- a/mm/hwpoison-inject.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/mm/hwpoison-inject.c
@@ -48,7 +48,8 @@ static int hwpoison_inject(void *data, u
inject:
pr_info("Injecting memory failure at pfn %#lx\n", pfn);
- return memory_failure(pfn, 0);
+ err = memory_failure(pfn, 0);
+ return (err == -EOPNOTSUPP) ? 0 : err;
}
static int hwpoison_unpoison(void *data, u64 val)
--- a/mm/madvise.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/mm/madvise.c
@@ -1067,6 +1067,8 @@ static int madvise_inject_error(int beha
pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
pfn, start);
ret = memory_failure(pfn, MF_COUNT_INCREASED);
+ if (ret == -EOPNOTSUPP)
+ ret = 0;
}
if (ret)
--- a/mm/memory-failure.c~mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler
+++ a/mm/memory-failure.c
@@ -1515,7 +1515,7 @@ static int memory_failure_hugetlb(unsign
if (TestClearPageHWPoison(head))
num_poisoned_pages_dec();
unlock_page(head);
- return 0;
+ return -EOPNOTSUPP;
}
unlock_page(head);
res = MF_FAILED;
@@ -1602,7 +1602,7 @@ static int memory_failure_dev_pagemap(un
goto out;
if (hwpoison_filter(page)) {
- rc = 0;
+ rc = -EOPNOTSUPP;
goto unlock;
}
@@ -1671,6 +1671,10 @@ static DEFINE_MUTEX(mf_mutex);
*
* Must run in process context (e.g. a work queue) with interrupts
* enabled and no spinlocks hold.
+ *
+ * Return: 0 for successfully handled the memory error,
+ * -EOPNOTSUPP for memory_filter() filtered the error event,
+ * < 0(except -EOPNOTSUPP) on failure.
*/
int memory_failure(unsigned long pfn, int flags)
{
@@ -1836,6 +1840,7 @@ try_again:
num_poisoned_pages_dec();
unlock_page(p);
put_page(p);
+ res = -EOPNOTSUPP;
goto unlock_mutex;
}
_
Patches currently in -mm which might be from luofei@unicloud.com are
mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch
mm-hwpoison-add-in-use-hugepage-hwpoison-filter-judgement.patch
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-24 4:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24 2:58 + mm-hwpoison-avoid-the-impact-of-hwpoison_filter-return-value-on-mce-handler.patch added to -mm tree Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2022-02-24 4:38 Andrew Morton
2022-02-22 3:48 Andrew Morton
2022-02-22 11:03 ` Borislav Petkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.