From mboxrd@z Thu Jan 1 00:00:00 1970 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 25DA9C48BF6 for ; Mon, 19 Feb 2024 01:47:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FDAC8D0003; Sun, 18 Feb 2024 20:47:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ADD38D0001; Sun, 18 Feb 2024 20:47:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 575838D0003; Sun, 18 Feb 2024 20:47:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 45D208D0001 for ; Sun, 18 Feb 2024 20:47:11 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DD1D31C014B for ; Mon, 19 Feb 2024 01:47:10 +0000 (UTC) X-FDA: 81806865420.20.51AAB9B Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf04.hostedemail.com (Postfix) with ESMTP id 686C94000A for ; Mon, 19 Feb 2024 01:47:06 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=b2WI0sfX; spf=pass (imf04.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xueshuai@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=1708307229; 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:in-reply-to:references:references:dkim-signature; bh=6cJ+ZJtAysi52r932E530yoSx3LcIwhYcvRHFW0VzE4=; b=a8PeovfTOHdxhTPhBy+tGEXyTD1SJ2snBqYtYNfDAuBfeu0Et1AZfxKpBzGxNum/NEkzx6 uBTqezWI6zBLWnLyj8uv/i+kR+2gstfm21B1SJgoDsmFSf1e8QLnUO7JcXKVUWKfPmoYY3 XvppydGvXg8TC9T6i8L7cWVV3UxSjUM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708307229; a=rsa-sha256; cv=none; b=YrYmekqqMYpMlgO13NXabJf0qCGDR6U6394XkEFZ3u1P7nJLBOY4q9Avt/EVKujm5Ne/o8 T179EOn15bf2Uig2FjrGI6G7/rqAVBOjN0a9wl8DvsWNpMWaiiXm5pKV05CIfLreRsU5Ke d917IQt0T5AYO9IZKrNzhnc8b2sHvpk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=b2WI0sfX; spf=pass (imf04.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708307222; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=6cJ+ZJtAysi52r932E530yoSx3LcIwhYcvRHFW0VzE4=; b=b2WI0sfXVlPPa3ggzXZD9rbNWNuVkuLm7hXKU9MJL1yi3QlPiSYS7fvm8jYKtWSYdoJSTHzn7hsv5VYjG4s0kQVn7KWupBVd7iIALFSAg2nccJdmdQMnItctWyV3mZqx3f66k7dz9CxIpJPfwUlDpwiHyS2SrAb3zKB8jpXjO1Q= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=32;SR=0;TI=SMTPD_---0W0mV91Q_1708307218; Received: from 30.240.113.204(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0W0mV91Q_1708307218) by smtp.aliyun-inc.com; Mon, 19 Feb 2024 09:47:01 +0800 Message-ID: Date: Mon, 19 Feb 2024 09:46:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 0/3] ACPI: APEI: handle synchronous exceptions in task work to send correct SIGBUS si_code To: bp@alien8.de, rafael@kernel.org, wangkefeng.wang@huawei.com, tanxiaofei@huawei.com, mawupeng1@huawei.com, tony.luck@intel.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, james.morse@arm.com, gregkh@linuxfoundation.org, will@kernel.org, jarkko@kernel.org Cc: linux-acpi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, linux-edac@vger.kernel.org, x86@kernel.org, justin.he@arm.com, ardb@kernel.org, ying.huang@intel.com, ashish.kalra@amd.com, baolin.wang@linux.alibaba.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, lenb@kernel.org, hpa@zytor.com, robert.moore@intel.com, lvying6@huawei.com, xiexiuqi@huawei.com, zhuo.song@linux.alibaba.com References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20240204080144.7977-1-xueshuai@linux.alibaba.com> Content-Language: en-US From: Shuai Xue In-Reply-To: <20240204080144.7977-1-xueshuai@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: zkc5175xnwn9p61xjmzxcbsuboryotqd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 686C94000A X-Rspam-User: X-HE-Tag: 1708307226-665175 X-HE-Meta: U2FsdGVkX1/VaS5WOfDGRIuk13Niq0k1ImmNkzLx0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W/47AvUzmAwvNcPD1lV9ABsLxl0cAGX9XmB9HlWts48HBeboOJXErSFngbOvfITmjYss896Sdu5cTXfjWD14Nz22nLFJL27vMa3YeQ7EXQ354Dw/rOltA5mkI6rCRrhl945wVzHSuZoSCoczlNCxXU8CLB8RsWjkYAxd2HzDLvnGG1Gqh+I55YUNSU4hqstK5onF7cAzSHx18C7ayEoI9RtrVQsIwsprAWkobv8xVDTX5WxpSi/1k+bxx38hiN47JlWPjlqFduc/hQiTw0gEfgohODlK2wHZeZaSBNuiooIn92DpMbHUsfBVI+AcSyzYQKj4+gLsQtkWJfZJWe/fAQghWHMvtOYHg74RPDPCaXV63qqA7KpB4m7HVaeOKqug== 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: Hi, James and Borislav, Gentle Ping. Any feedback to this new version? Thank you. Best Regards, Shuai On 2024/2/4 16:01, Shuai Xue wrote: > ## Changes Log > changes since v10: > - rebase to v6.8-rc2 > > changes since v9: > - split patch 2 to address exactly one issue in one patch (per Borislav) > - rewrite commit log according to template (per Borislav) > - pickup reviewed-by tag of patch 1 from James Morse > - alloc and free twcb through gen_pool_{alloc, free) (Per James) > - rewrite cover letter > > changes since v8: > - remove the bug fix tag of patch 2 (per Jarkko Sakkinen) > - remove the declaration of memory_failure_queue_kick (per Naoya Horiguchi) > - rewrite the return value comments of memory_failure (per Naoya Horiguchi) > > changes since v7: > - rebase to Linux v6.6-rc2 (no code changed) > - rewritten the cover letter to explain the motivation of this patchset > > changes since v6: > - add more explicty error message suggested by Xiaofei > - pick up reviewed-by tag from Xiaofei > - pick up internal reviewed-by tag from Baolin > > changes since v5 by addressing comments from Kefeng: > - document return value of memory_failure() > - drop redundant comments in call site of memory_failure() > - make ghes_do_proc void and handle abnormal case within it > - pick up reviewed-by tag from Kefeng Wang > > changes since v4 by addressing comments from Xiaofei: > - do a force kill only for abnormal sync errors > > changes since v3 by addressing comments from Xiaofei: > - do a force kill for abnormal memory failure error such as invalid PA, > unexpected severity, OOM, etc > - pcik up tested-by tag from Ma Wupeng > > changes since v2 by addressing comments from Naoya: > - rename mce_task_work to sync_task_work > - drop ACPI_HEST_NOTIFY_MCE case in is_hest_sync_notify() > - add steps to reproduce this problem in cover letter > > changes since v1: > - synchronous events by notify type > - Link: https://lore.kernel.org/lkml/20221206153354.92394-3-xueshuai@linux.alibaba.com/ > > ## Cover Letter > > There are two major types of uncorrected recoverable (UCR) errors : > > - Synchronous error: The error is detected and raised at the point of the > consumption in the execution flow, e.g. when a CPU tries to access > a poisoned cache line. The CPU will take a synchronous error exception > such as Synchronous External Abort (SEA) on Arm64 and Machine Check > Exception (MCE) on X86. OS requires to take action (for example, offline > failure page/kill failure thread) to recover this uncorrectable error. > > - Asynchronous error: The error is detected out of processor execution > context, e.g. when an error is detected by a background scrubber. Some data > in the memory are corrupted. But the data have not been consumed. OS is > optional to take action to recover this uncorrectable error. > > Since commit a70297d22132 ("ACPI: APEI: set memory failure flags as > MF_ACTION_REQUIRED on synchronous events")', the flag MF_ACTION_REQUIRED > could be used to determine whether a synchronous exception occurs on ARM64 > platform. When a synchronous exception is detected, the kernel should > terminate the current process which accessing the poisoned page. This is > done by sending a SIGBUS signal with an error code BUS_MCEERR_AR, > indicating an action-required machine check error on read. > > However, the memory failure recovery is incorrectly sending a SIGBUS > with wrong error code BUS_MCEERR_AO for synchronous errors in early kill > mode, even MF_ACTION_REQUIRED is set. The main problem is that > synchronous errors are queued as a memory_failure() work, and are > executed within a kernel thread context, not the user-space process that > encountered the corrupted memory on ARM64 platform. As a result, when > kill_proc() is called to terminate the process, it sends the incorrect > SIGBUS error code because the context in which it operates is not the > one where the error was triggered. > > To this end, fix the problem by: > > - Patch 1: performing a force kill if no memory_failure() work is queued for > synchronous errors. > - Patch 2: a minor comments improvement. > - Patch 3: queue memory_failure() as a task_work so that it runs in the > context of the process that is actually consuming the poisoned > data, and it will send SIBBUS with si_code BUS_MCEERR_AR. > > Lv Ying and XiuQi from Huawei also proposed to address similar problem[2][4]. > Acknowledge to discussion with them. > > ## Steps to Reproduce This Problem > > To reproduce this problem: > > # STEP1: enable early kill mode > #sysctl -w vm.memory_failure_early_kill=1 > vm.memory_failure_early_kill = 1 > > # STEP2: inject an UCE error and consume it to trigger a synchronous error > #einj_mem_uc single > 0: single vaddr = 0xffffb0d75400 paddr = 4092d55b400 > injecting ... > triggering ... > signal 7 code 5 addr 0xffffb0d75000 > page not present > Test passed > > The si_code (code 5) from einj_mem_uc indicates that it is BUS_MCEERR_AO error > and it is not fact. > > After this patch set: > > # STEP1: enable early kill mode > #sysctl -w vm.memory_failure_early_kill=1 > vm.memory_failure_early_kill = 1 > > # STEP2: inject an UCE error and consume it to trigger a synchronous error > #einj_mem_uc single > 0: single vaddr = 0xffffb0d75400 paddr = 4092d55b400 > injecting ... > triggering ... > signal 7 code 4 addr 0xffffb0d75000 > page not present > Test passed > > The si_code (code 4) from einj_mem_uc indicates that it is BUS_MCEERR_AR error > as we expected. > > [1] Add ARMv8 RAS virtualization support in QEMU https://patchew.org/QEMU/20200512030609.19593-1-gengdongjiu@huawei.com/ > [2] https://lore.kernel.org/lkml/20221205115111.131568-3-lvying6@huawei.com/ > [3] https://lkml.kernel.org/r/20220914064935.7851-1-xueshuai@linux.alibaba.com > [4] https://lore.kernel.org/lkml/20221209095407.383211-1-lvying6@huawei.com/ > > Shuai Xue (3): > ACPI: APEI: send SIGBUS to current task if synchronous memory error > not recovered > mm: memory-failure: move return value documentation to function > declaration > ACPI: APEI: handle synchronous exceptions in task work to send correct > SIGBUS si_code > > arch/x86/kernel/cpu/mce/core.c | 9 +--- > drivers/acpi/apei/ghes.c | 84 +++++++++++++++++++++------------- > include/acpi/ghes.h | 3 -- > mm/memory-failure.c | 22 +++------ > 4 files changed, 59 insertions(+), 59 deletions(-) >