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 AFD36C74A5B for ; Thu, 30 Mar 2023 06:11:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0275C6B0072; Thu, 30 Mar 2023 02:11:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF25E6B0074; Thu, 30 Mar 2023 02:11:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D930D6B0075; Thu, 30 Mar 2023 02:11:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C157E6B0072 for ; Thu, 30 Mar 2023 02:11:55 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9B603120512 for ; Thu, 30 Mar 2023 06:11:55 +0000 (UTC) X-FDA: 80624543790.02.0596C8E Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf24.hostedemail.com (Postfix) with ESMTP id BDA0518000F for ; Thu, 30 Mar 2023 06:11:52 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf24.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680156713; 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; bh=QLLjlbdzQf7tA3WrAZhdqXVEtecZtCd258Eep53XVTM=; b=DA9hq3Rl29JEPTN82L6HGy9PGbs/giJAdTLYJNl1TLWR8Qp5o545Cw8bMsdvlUc+68syEy njecyJLRyQIHgoCvIfep6DikNIyzmMN6wzlRT4J7rBrws+drh0OumpBQ4FVWuX2Kh95enN 31p9EEXthyhZRuiUckqRt/PPI40+mUM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf24.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680156713; a=rsa-sha256; cv=none; b=aG0pBHVvAYolsIQIfr9avyppp9D4K6lIqUPxXzv/ajhNNuhjBRAq0S/hVhRttoHRnKzb4P tfOyNL2iNFi7Xw+OUXUYhhjUFy9Dh6Gh/fmCcf3a3iPB2tcqaHbVUv3fU4n4H+KKWHG+ds gsULwkpSbkbUbyh1d/yMPY4If1Xy5Go= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VezS-Oc_1680156705; Received: from 30.240.113.3(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VezS-Oc_1680156705) by smtp.aliyun-inc.com; Thu, 30 Mar 2023 14:11:47 +0800 Message-ID: <0133c209-b098-e822-58d7-27568888c282@linux.alibaba.com> Date: Thu, 30 Mar 2023 14:11:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v3 0/2] ACPI: APEI: handle synchronous exceptions with proper si_code Content-Language: en-US To: "Rafael J. Wysocki" , tony.luck@intel.com, james.morse@arm.com, bp@alien8.de, Naoya Horiguchi Cc: linux-acpi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, justin.he@arm.com, akpm@linux-foundation.org, ardb@kernel.org, ashish.kalra@amd.com, baolin.wang@linux.alibaba.com, cuibixuan@linux.alibaba.com, dave.hansen@linux.intel.com, jarkko@kernel.org, lenb@kernel.org, linmiaohe@huawei.com, lvying6@huawei.com, xiexiuqi@huawei.com, zhuo.song@linux.alibaba.com References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230317072443.3189-1-xueshuai@linux.alibaba.com> From: Shuai Xue In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BDA0518000F X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ocp15dnbj9hroy6bcuxhwo9416sirdbm X-HE-Tag: 1680156712-426424 X-HE-Meta: U2FsdGVkX1/bqEbut2cjV5faudwopRim9vuIYj6Bkf8bzVn2Sr6eonAiei8C2tx+kfFIUAznRtclTNqKjaFsfglzRqOe+evV7y0ZaBNm5cEEN+1sYeJlkJxtb/hg9y4pVUyqSVxbnQtzyy0b2VfWHiqiNnHn4mhbJPQ0Am079XVKkwHjskfh7opkT3NfiPSiDzRFYGGcIsRImPC514FDYiK7wPWeEmyk/PcKg3FF3b/x4EycfnlZQmFBeCBITsFGKMhQ+0/QXxdrZ3G1FSTAzCaFf9V0u8nUKCZkOafCgli1qFkGXYC0osy+w4OH0y9rgi2gKkZNFrOrDtDeOlOPf5s1J1xRKa1ASaqTFPU4KEUett8efXmptlv1yPJKh7F4Axbc+72Br3nBOnIOfo9wXynqx5XGrDa10YMg1PW8tED9RiYtxLUAWzJqzdQz9Wuicr1GuCm3qZi8T05SOp3/w7luNopyxyKoMQQ6230830mRpTVvuhbblc6Rh4gK7I4a8Ups/qh1YEVBgKJYyYdxH4u2KiZ8Tgybi8OiD79+ETgoEEtVkLv2Gd3YwPMn/X4kV+R6Y7psLxV1y2u6p/z/hA0VxIjuBpdVDp5F7b0fTi2lP7LQuqblhRPz5AloXP0c0pONsDxdScQc9Z3VdI7b1kQKZ29wSxqTuAx2dKwvAw24+C/2afhp20LhV/chhR/VRVOua/hywAngovzjeIbe3rfmX1EEIPSNz/oq8pTk2aC8tC/snvmKS287g66Cfu9Nw+nNBmfFiM6qlpMqjNFKzprQpNd1Su6zpOhaww83Q9xqCa3liWT+uUMfn6ZB5621mTxwxALVL+rROWJMf+QSiO1sSgSdZS8+u+a2IZ7vkSEhtn4FY2yM/NataSXA1Bxia4MJ1WP19VNy+i1hhnje8g+3Qzosxn/kmZGEy6If52AYAGZEy91jt87VrJYZLOr/4zu3QZ/3m7HhRJjclIY GkLBlJvG SMc3HRjCu8IXdj5ehiOJnFLwmGCsRVaY9+QxxzH7h/qXy/i2anj+JQ8/F/b1CJH+lwAkAkXFJS+fERnZ6mqPhzjdam8YsZKya62xJXxZ2Cjx7YQlP06PSxal6u8uO5sZZb5c1J/yWfX7Uty13bbpPK2EyzrqM+R02+DPy42hJttPsydR8BOTgM2nu/G3fKGB7gfuLgoc4dSGvMxhQ5WxiNhw5e54CWABLMWuW/Ht3WIVVpto4w5tsHVWMtSgO4gtDhGcegPKFBUOqE1hva0HdDtMyens65y7dV5n7FHD2PpPJdw68x+fm681F0zjx0/Ceqxbd 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: On 2023/3/21 AM2:03, Rafael J. Wysocki wrote: > On Fri, Mar 17, 2023 at 8:25 AM Shuai Xue wrote: >> >> 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 >> - Link: https://lore.kernel.org/lkml/1aa0ca90-d44c-aa99-1e2d-bd2ae610b088@linux.alibaba.com/T/#mb3dede6b7a6d189dc8de3cf9310071e38a192f8e >> >> changes since v1: >> - synchronous events by notify type >> - Link: https://lore.kernel.org/lkml/20221206153354.92394-3-xueshuai@linux.alibaba.com/ >> >> Currently, both synchronous and asynchronous error are queued and handled >> by a dedicated kthread in workqueue. And Memory failure for synchronous >> error is synced by a cancel_work_sync trick which ensures that the >> corrupted page is unmapped and poisoned. And after returning to user-space, >> the task starts at current instruction which triggering a page fault in >> which kernel will send SIGBUS to current process due to VM_FAULT_HWPOISON. >> >> However, the memory failure recovery for hwpoison-aware mechanisms does not >> work as expected. For example, hwpoison-aware user-space processes like >> QEMU register their customized SIGBUS handler and enable early kill mode by >> seting PF_MCE_EARLY at initialization. Then the kernel will directy notify >> the process by sending a SIGBUS signal in memory failure with wrong >> si_code: BUS_MCEERR_AO si_code to the actual user-space process instead of >> BUS_MCEERR_AR. >> >> To address this problem: >> >> - PATCH 1 sets mf_flags as MF_ACTION_REQUIRED on synchronous events which >> indicates error happened in current execution context >> - PATCH 2 separates synchronous error handling into task work so that the >> current context in memory failure is exactly belongs to the task >> consuming poison data. >> >> Then, kernel will send SIGBUS with proper si_code in kill_proc(). >> >> Lv Ying and XiuQi also proposed to address similar problem and we discussed >> about new solution to add a new flag(acpi_hest_generic_data::flags bit 8) to >> distinguish synchronous event. [2][3] The UEFI community still has no response. >> After a deep dive into the SDEI TRM, the SDEI notification should be used for >> asynchronous error. As SDEI TRM[1] describes "the dispatcher can simulate an >> exception-like entry into the client, **with the client providing an additional >> asynchronous entry point similar to an interrupt entry point**". The client >> (kernel) lacks complete synchronous context, e.g. systeam register (ELR, ESR, >> etc). So notify type is enough to distinguish synchronous event. >> >> 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] https://developer.arm.com/documentation/den0054/latest/ >> [2] https://lore.kernel.org/linux-arm-kernel/20221205160043.57465-4-xiexiuqi@huawei.com/T/ >> [3] https://lore.kernel.org/lkml/20221209095407.383211-1-lvying6@huawei.com/ >> >> Shuai Xue (2): >> ACPI: APEI: set memory failure flags as MF_ACTION_REQUIRED on >> synchronous events >> ACPI: APEI: handle synchronous exceptions in task work >> >> drivers/acpi/apei/ghes.c | 135 ++++++++++++++++++++++++--------------- >> include/acpi/ghes.h | 3 - >> mm/memory-failure.c | 13 ---- >> 3 files changed, 83 insertions(+), 68 deletions(-) >> >> -- > > I really need the designated APEI reviewers to give their feedback on this. Gentle ping. Best Regards. Shuai