All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] mm: memory-failure: add missing set_mce_nospec() for memory_failure()
@ 2023-07-04 12:19 Miaohe Lin
  2023-07-04 16:13 ` kernel test robot
  2023-07-04 16:23 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Miaohe Lin @ 2023-07-04 12:19 UTC (permalink / raw)
  To: akpm, naoya.horiguchi; +Cc: linux-mm, linux-kernel, linmiaohe

If memory_failure() succeeds to hwpoison a page, the set_mce_nospec() is
expected to be called to prevent speculative access to the page by marking
it not-present. Add such missing call to set_mce_nospec() in async memory
failure handling scene.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e245191e6b04..c7f88c4042d4 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -63,6 +63,7 @@
 #include <linux/pagewalk.h>
 #include <linux/shmem_fs.h>
 #include <linux/sysctl.h>
+#include <linux/set_memory.h>
 #include "swap.h"
 #include "internal.h"
 #include "ras/ras_event.h"
@@ -2407,7 +2408,9 @@ static void memory_failure_work_func(struct work_struct *work)
 		if (entry.flags & MF_SOFT_OFFLINE)
 			soft_offline_page(entry.pfn, entry.flags);
 		else
-			memory_failure(entry.pfn, entry.flags);
+			if (!memory_failure(entry.pfn, entry.flags))
+				if (!entry.flags & MF_SW_SIMULATED)
+					set_mce_nospec(entry.pfn);
 	}
 }
 
-- 
2.33.0



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

end of thread, other threads:[~2023-07-05  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-04 12:19 [RFC PATCH] mm: memory-failure: add missing set_mce_nospec() for memory_failure() Miaohe Lin
2023-07-04 16:13 ` kernel test robot
2023-07-04 16:23 ` kernel test robot
2023-07-05  1:53   ` Miaohe Lin

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.