From nobody Sun Feb 8 20:53:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996B2EB64D9 for ; Tue, 4 Jul 2023 12:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231331AbjGDMTd (ORCPT ); Tue, 4 Jul 2023 08:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbjGDMTc (ORCPT ); Tue, 4 Jul 2023 08:19:32 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E109E10CA for ; Tue, 4 Jul 2023 05:19:27 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QwMKK5Zqnz1HCsQ; Tue, 4 Jul 2023 20:19:01 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 4 Jul 2023 20:19:25 +0800 From: Miaohe Lin To: , CC: , , Subject: [RFC PATCH] mm: memory-failure: add missing set_mce_nospec() for memory_failure() Date: Tue, 4 Jul 2023 20:19:48 +0800 Message-ID: <20230704121948.1331846-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 #include #include +#include #include "swap.h" #include "internal.h" #include "ras/ras_event.h" @@ -2407,7 +2408,9 @@ static void memory_failure_work_func(struct work_stru= ct *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); } } =20 --=20 2.33.0