Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3500317pxb; Mon, 24 Jan 2022 10:51:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPlpXuyyE397576n7d1D1r3iG2MjSMB5TLg1uXy0Zm6Vto4cK6syD2CdtBNeOmb9SO8R7v X-Received: by 2002:a62:dd56:0:b0:4c7:8603:3ffe with SMTP id w83-20020a62dd56000000b004c786033ffemr12379395pff.15.1643050302861; Mon, 24 Jan 2022 10:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050302; cv=none; d=google.com; s=arc-20160816; b=FfHuj/4WW51RYIpcm8vNVDT2PfpfUpGTwV/1jJVFkc1gHMSxsDaXEzIy1Nezjze/SG uyBvi+dv2dRhWKolHDc+FkWsLFrPvsKiYgTjxkhQMJ/PW5Xz25mXEeruyi9VoKJJ6T/c okpenketfUVoIyYZY3L6s2gC094Jjr3bJJQKvj5bwYez12ausapPZsnoafgw4OoHhRme NTgm240T06YypG+soIM2TM+mGTFMdYO8WNc7+OadrUbr8vMi8SeF22Z7nJYJCA6cx4oj +axVNnss68ztTRGP/L7BLAb5oFzE80ZOfkvlF2deRaPI47jHvhJ1tEq4zbofSN6e6Yzp SJEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=muDPoXOYVr+RYcLLsdGrIE4Rg3wyZllAtrtJpaaro0A=; b=sx6zq4hFhr4GRcenoXmiFdDDClEMpuDTao2BYUJj1hjQumdmSvstnmUJ0qapdiNNQp 98nAAqIqYzyRp1Nnv4hVgY/DeAttsGRFOuvvQmVM+P3+9b6y1qzlkcj0P3z7JN7eLJLW l9+o2tQdyf4wf0t1x0ANb1mqv4eyqQpDWTigyKjgXjF5Kw7RYU7YbjwfpsK/EOEPklYy i42t1DxLChqoqzO5mFddXqN6bgyi9o7Rn4gePYWIwGwyAdwytqVjMHCbKkCKP7oniWOi qrR88GOmaX4T1y+kuCBVzfV5wgWdYsSwGv7i0E1ODuIIpcOVtuXOseH3f7clmw39/f0o Emxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si14462719pgp.38.2022.01.24.10.51.30; Mon, 24 Jan 2022 10:51:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242199AbiAXIfa (ORCPT + 99 others); Mon, 24 Jan 2022 03:35:30 -0500 Received: from eage.unicloud.com ([220.194.70.58]:37451 "EHLO spam.unicloud.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242184AbiAXIf3 (ORCPT ); Mon, 24 Jan 2022 03:35:29 -0500 X-Greylist: delayed 1013 seconds by postgrey-1.27 at vger.kernel.org; Mon, 24 Jan 2022 03:35:28 EST Received: from spam.unicloud.com (localhost [127.0.0.2] (may be forged)) by spam.unicloud.com with ESMTP id 20O8IZTI013105; Mon, 24 Jan 2022 16:18:35 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 20O8FmIt011955; Mon, 24 Jan 2022 16:15:48 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from localhost.localdomain (10.10.1.7) by zgys-ex-mb09.Unicloud.com (10.10.0.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Mon, 24 Jan 2022 16:15:47 +0800 From: luofei To: , , , , , CC: , , , luofei Subject: [PATCH] x86/mce: Always call kill_me_maybe() to handle memory failure in user mode Date: Mon, 24 Jan 2022 03:15:01 -0500 Message-ID: <20220124081501.235236-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb07.Unicloud.com (10.10.0.27) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL: spam.unicloud.com 20O8IZTI013105 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just killing the current process is not enough, it is necessory to offload the faulty page. In the virtualization scenario, qemu does not set MCG_STATUS_RIPV by default. When injecting an SRAR error into the virtual machine, only the current process will be killed, but the faulty page will be released and reused, which is very likely to cause the virtual machine to crash. Signed-off-by: luofei --- arch/x86/kernel/cpu/mce/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 5818b837fd4d..bc6c353b9250 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1519,10 +1519,8 @@ noinstr void do_machine_check(struct pt_regs *regs) BUG_ON(!on_thread_stack() || !user_mode(regs)); if (kill_current_task) - queue_task_work(&m, msg, kill_me_now); - else - queue_task_work(&m, msg, kill_me_maybe); - + force_sig(SIGBUS); + queue_task_work(&m, msg, kill_me_maybe); } else { /* * Handle an MCE which has happened in kernel space but from -- 2.27.0