linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>, <naoya.horiguchi@nec.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<linmiaohe@huawei.com>
Subject: [RFC PATCH] mm: memory-failure: add missing set_mce_nospec() for memory_failure()
Date: Tue, 4 Jul 2023 20:19:48 +0800	[thread overview]
Message-ID: <20230704121948.1331846-1-linmiaohe@huawei.com> (raw)

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



                 reply	other threads:[~2023-07-04 12:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230704121948.1331846-1-linmiaohe@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.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;
as well as URLs for NNTP newsgroup(s).