linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hwpoison: avoid speculation access after soft/hard offline
@ 2024-06-28  3:35 Ruidong Tian
  2024-06-28  5:27 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: Ruidong Tian @ 2024-06-28  3:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, akpm, nao.horiguchi, linmiaohe, tianruidong, xueshuai,
	Ruidong Tian

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-28  5:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28  3:35 [PATCH] mm/hwpoison: avoid speculation access after soft/hard offline Ruidong Tian
2024-06-28  5:27 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).