From patchwork Fri Jun 28 03:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruidong Tian X-Patchwork-Id: 13715412 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 1F636C2BBCA for ; Fri, 28 Jun 2024 03:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9BDA6B00C5; Thu, 27 Jun 2024 23:35:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4B806B00C8; Thu, 27 Jun 2024 23:35:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93A9C6B00C9; Thu, 27 Jun 2024 23:35:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 758806B00C5 for ; Thu, 27 Jun 2024 23:35:21 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 34D18C12C0 for ; Fri, 28 Jun 2024 03:35:21 +0000 (UTC) X-FDA: 82278882042.03.D9E565B Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by imf21.hostedemail.com (Postfix) with ESMTP id D8DE71C0013 for ; Fri, 28 Jun 2024 03:35:18 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=KpCF54BF; spf=pass (imf21.hostedemail.com: domain of tianruidong@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=tianruidong@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719545696; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=1w+8Hz62/OAiOuIAShxlhOWk3yei/75Rw/aW5MatOU4=; b=xUlWo+u/pUIPr2sYR26qlEwfuEDnQdHBuI8snVPblfWIqiu5f44eACIULAV3/SEGgQ30UQ dCYG47+Mnd3OhILWmRwPL9lEaMrvjEXTQlZE8e2W9bLYa+zoxC3y8Xd4FNvQqn7SVC7VgN o2SZZ1cJnfYHSV3qR2GAfHwE/neSirA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=KpCF54BF; spf=pass (imf21.hostedemail.com: domain of tianruidong@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=tianruidong@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719545696; a=rsa-sha256; cv=none; b=U96814mJFj4YOS3d/CjhD9JrOZBqbt/qVimAXhlzn9wGCW6YVkLp4HOPG69aC55sR+Mzc+ h+IaO8CGXrO8L0eWUiOcKViuUnyRtuuaDu5gdKIKL4sxhml2DugFX8Vp9Syq+wVYHHkoB6 bzaR3M/SLOTzzjDiPRSmD6auq00Gz3U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1719545714; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=1w+8Hz62/OAiOuIAShxlhOWk3yei/75Rw/aW5MatOU4=; b=KpCF54BFZL+JGfyxfFx7RiFfmu+gYKGFxmkgdmN6yit5DXri+t93u48W+PogbfAuYGBOmmcev8x3dMzIic6RVb2knrk9s/g/JeWeFR6tcAdvhYCHOP3UnjLhgMSGp57E8ghJDJDNC3zcTKtiJFPbFvpiPst57/OGYxV5D3bPVM0= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R851e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0W9OqxVW_1719545710; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0W9OqxVW_1719545710) by smtp.aliyun-inc.com; Fri, 28 Jun 2024 11:35:13 +0800 From: Ruidong Tian To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, nao.horiguchi@gmail.com, linmiaohe@huawei.com, tianruidong@alibaba.linux.com, xueshuai@linux.alibaba.com, Ruidong Tian Subject: [PATCH] mm/hwpoison: avoid speculation access after soft/hard offline Date: Fri, 28 Jun 2024 11:35:09 +0800 Message-Id: <20240628033509.27612-1-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D8DE71C0013 X-Stat-Signature: n4g94wddwwyb6mq157aprtoipka78kxd X-Rspam-User: X-HE-Tag: 1719545718-914112 X-HE-Meta: U2FsdGVkX18tAEc+y1xvkZrxpqxIQKqDbNds0oCFdGXgCVlce/cc1DBC8Ef5YYBr/EA6L3ydUeEOA+KESetQsZ/Fbt2g+H1NfhnMPwXhLHXU+SwUCO1KoGd5RtSq2GaKqrrJbgTNPUQ7jNTXGci5dfF7f7RXFtSEzlkJZ9knUUYf7jcK8EZd1jkZnweS5XlFsdoPWMEjQFy7HFHeqDTTuwKFkB1WnJeDaz50aLZZ3xhlxQRlSMiXtqRQeUTruoVUtu4ULed3lSGL1ZUhB+mIR8kcYLItCVJ26mOWxXG4ITTgbY2fVSTHxH3thbF0I7sIhAbjhwfsX14k2vixp/rOkZkwIRgsfXwUmRsJg2a7W7fkFXpx6neAL3VHA7ulrJYtd5UzuzHGdfEc/kSeDKNA/yg47zLU9ncmluqCchCRZg693a4xDPRyo/cFRYtoniYiZbvAWGRZk6WtN+XKsJlFjozFwwGKK1qWpS1iCUtKyCDDFxfRYf2LQfhZ+c7xUNiVPQpBpM68pmFZxN+XwtdJsxJgd+NNSawh2JZGhmk0Kf8NtrZGXBc8ezuo8Z7pKTJ+8AHTU2vgmx5pTGr3ldVF3K1doLmYAcHU+Zkf+wIB5jDV6wwBH9PfAjEtUqYYnafeK379cg7jebiJGpcnk1Zs4m+oEvolKxLkXLW6OKpoxvMc4gpOeXkGRXjlQRBrkyWiHRjpr4JTf0t6ncZQwQuiK2+uMjzh7vl2lMulPO4Lmm0cCvV3rOesL2Uf/E8hJy+mW7hi709z9I5lbaXVvVfByB5KV+AP2We8eHsk/4hwmmLgtjokvbLjw18/weQXtBZMTU94G/6q8pfTBYFtviolLHly0kABHXCYefMl2F6GNp5fGpFMTa6SJMtK3IwKz2yPke4abmeOqzES1FVYOdfMpbA+KTFK4ikzYblWfiIvlrH73hM3l91Zr7Ym6kyP/x+z3CAVOFqwwJbOljD5/5p 7xIcbajb i+N5/nGciXANF9i8fmEBJkNE7x5twOPK9ytqNuk2zv2fyqNRadoaidB9itnbYlmcxgE9cgn98bkFo74mIIlSpPSB/A6NnmSSpB3trV+zkspcL3OFXcL5OGMrrmHCv32Yw4m+LuhCkUlOJZ6d8YBRGUX8QplKlvOGonwG178AKHd6OJoDHNfZg6oUURBG804O5yB+jlaHoUPt9jVBEYXX1VtKoJms0noJix3z8Wn5Whcly7GeO1iErTi0ujXJtEVcKr5mdOcQB4dpGcN5dhsry4h5N/tUiVjevNxPB+wUqg6LrnmlWIr4BfosV+bvNxjssmq/t31Cip4JolnUW6VK+Niiw9w== 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: List-Subscribe: List-Unsubscribe: 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 --- 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 #include #include +#include #include #include @@ -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;