From patchwork Tue Jul 4 12:19:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13301046 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C33E2EB64DD for ; Tue, 4 Jul 2023 12:19:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B408280073; Tue, 4 Jul 2023 08:19:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 463FB90000D; Tue, 4 Jul 2023 08:19:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 352ED280073; Tue, 4 Jul 2023 08:19:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2460090000D for ; Tue, 4 Jul 2023 08:19:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CDAB5A0A98 for ; Tue, 4 Jul 2023 12:19:35 +0000 (UTC) X-FDA: 80973835110.16.FBAFDA9 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf27.hostedemail.com (Postfix) with ESMTP id 74CFD40005 for ; Tue, 4 Jul 2023 12:19:32 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688473173; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=WzINyPxiImXbXbfG0RrP/e7vlMFBDhPBnDHL1BUHGCk=; b=8VMeTK5UVWBm0GG17tgPvTLSQ5QcmnnxrcN13HyS3DcnZtVijzUPDP+ORt7rVRgpXaHhGn LGoRt9UQx4yA3py59G/fJn7LUBXUTSV3P1J0RzsK80hLgh/dHIix+ISK1qajTgIgzb6eXr so83nKOIUPVZoMtcgRqNn1k5dAdI8pA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688473173; a=rsa-sha256; cv=none; b=5i3RtLZudE7lOBP0dRBRbtzMHHwr4dsuxAp1W6sEUonhNcjMZVGrXMShN32EM3OLHEanWA 2poJ6SH/96k/uAbM8r8R9B/WyucDabANFzJqOXMDCbrBDjcgC834pGUGap1EGL6rv+nDE9 4ChiizthA27uGCt+wShN05nlk53RueM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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 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 X-Stat-Signature: qhgh636deiki5fb1p6ske9ysfhw7bdwa X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 74CFD40005 X-Rspam-User: X-HE-Tag: 1688473172-592832 X-HE-Meta: U2FsdGVkX1+ww/9qGbUGAT7Bt/K9CvdYsy3mfFZLYPqasetqsHNeyZkDV7HSSuEYrjH4bqXhnLA7fnKQEE9ImEC085USAfc6782LKP2W3WCgTV0fvgYKKc2KiqotVB9yMnDJhLE58cBGrSm8Py/HLJMMKn8C/IKG3rGpd0SQSs6bp/nTkJ/4DkijqruTbz1nqp7x0gsTDSmuX/xZeanmZLItPE1dQ2MoNW4UC7rkPAEo2Qu7z+fHyvDG1f1/HlnlM82UzY4iizS614WJgWJsUTQOHjFt8pBTDrZDQy+kKvAI/at6+gxZaMYTBQ/gv9KcrI5HXd4ZYPRXMwdNYcT+bAHNQ8ccl3OUzHmJdXRY/Ody5ViRhjKOS/Dwd7tfOj8Aj0zvc8gEmMDDGe5MLL8agkSzHCIrc+2eZfeyq6pc7YXtkg9u/FlZvuHWaeT1iJv/semW8oYbOATy+SgqHT7nm5Of2SNJORVx20MfRNXtMHxgnkuFtwgs5jHkv7iMwnpZnraXaZh/h4cIJa67nJV0UfRRpkuAljN7aP92VTMR/F5aWv2lSZee6MNIcrjdHt3lkkPgGwRMz6YW7Z2HtNBGCyvwTnwzKURG8F0XY4jpMk71MutzCgApSDI8SzSobhZeShIGak+rkw7Ehp7UGBTsx3hxj0GWw39JWzWmMZFzihUALrzQpghNsh5VkjqO/itBui11pzsAH8gDQa0eENXDnBrPrxODTvl5+5DQtM4i2fJjX8PvBmQeVbsKgdgxXBgYoBSr/evJMQFvWAMuOe6MRfKhh6nxmgAYq3SLkEMZn9BZp89r/pe9U+Kdlc3uy+EDxKJKuyxfouUvAQl7j/+qwylckcMxx4JyRbKOtihDewWESUhZzqJSKAj0XLHF8Ddd8UltvoWzQRXhFxJnDJB2B09RjrQEkArvIXKTPY6o306vkzBEOOWSc+UecIjofXrLo/QcGwHoeyPFD2PdGdb BJhQpwex LZpDzX90cBeNvRSj3EynBKKiPlz45tFNEjDq+5LJgkNsG+UBbLH5tURwtM1DabPXs5PBPCI0ya7JB+utE06YQ64C9Qniacf6deEzEyIFEx2qRsIEv6CwEa44jnhCpOzM7sZPi/xAxc/Ly6LofTCXgGOKUeS7uo/lx/aSzM6OGIhWLbZj3fQOWWmZbSyd+7Z3sv59AtTZYJiv5Br8fuXv4b7RSzDi0UCmH9Dsx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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_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); } }