From: Ruidong Tian <tianruidong@linux.alibaba.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
nao.horiguchi@gmail.com, linmiaohe@huawei.com,
tianruidong@alibaba.linux.com, xueshuai@linux.alibaba.com,
Ruidong Tian <tianruidong@linux.alibaba.com>
Subject: [PATCH] mm/hwpoison: avoid speculation access after soft/hard offline
Date: Fri, 28 Jun 2024 11:35:09 +0800 [thread overview]
Message-ID: <20240628033509.27612-1-tianruidong@linux.alibaba.com> (raw)
Page that offlined can report CE/UE event due to speculation access.
Delete kernel 1:1 linner mapping after soft/hard offline to avoid it.
Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
---
drivers/base/memory.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 67858eeb92ed..502ee1107ac6 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -22,6 +22,7 @@
#include <linux/stat.h>
#include <linux/slab.h>
#include <linux/xarray.h>
+#include <linux/set_memory.h>
#include <linux/atomic.h>
#include <linux/uaccess.h>
@@ -600,6 +601,8 @@ static ssize_t soft_offline_page_store(struct device *dev,
return -EINVAL;
pfn >>= PAGE_SHIFT;
ret = soft_offline_page(pfn, 0);
+ if (!ret)
+ set_mce_nospec(pfn);
return ret == 0 ? count : ret;
}
@@ -616,6 +619,8 @@ static ssize_t hard_offline_page_store(struct device *dev,
return -EINVAL;
pfn >>= PAGE_SHIFT;
ret = memory_failure(pfn, MF_SW_SIMULATED);
+ if (!ret)
+ set_mce_nospec(pfn);
if (ret == -EOPNOTSUPP)
ret = 0;
return ret ? ret : count;
--
2.39.3
next reply other threads:[~2024-06-28 3:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 3:35 Ruidong Tian [this message]
2024-06-28 5:27 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240628033509.27612-1-tianruidong@linux.alibaba.com \
--to=tianruidong@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nao.horiguchi@gmail.com \
--cc=tianruidong@alibaba.linux.com \
--cc=xueshuai@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox