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 DD3C2C761AF for ; Thu, 30 Mar 2023 09:53:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D7156B0074; Thu, 30 Mar 2023 05:53:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 688656B0075; Thu, 30 Mar 2023 05:53:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54F856B0078; Thu, 30 Mar 2023 05:53:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4777A6B0074 for ; Thu, 30 Mar 2023 05:53:10 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0ED001C5BFF for ; Thu, 30 Mar 2023 09:53:10 +0000 (UTC) X-FDA: 80625101340.01.1C73D50 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 433AB1A0019 for ; Thu, 30 Mar 2023 09:53:08 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf19.hostedemail.com: domain of rjwysocki@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=rjwysocki@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680169988; 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=pqe5ft05YTqZZrlrtJn4uLGU7lFwiC2JxhR5rWQ+Q8g=; b=pIpHwmkuzmhrvq21hqj/XmjIzC90mzOPUuSUl7d47m34qdVZV6KhWciqcZOkQaaTUAibwI pvrNG1P6MLLlfSfhPLgUvz5eqBQh29WiHv9BHt63W0Z4MGrkNuHNMKi6Qw+cSG6dvX7rcg avsZANO861JxPxQtJoQqHaVxdQwtWXc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf19.hostedemail.com: domain of rjwysocki@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=rjwysocki@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680169988; a=rsa-sha256; cv=none; b=OfOzFL7L3VWGNPK1lnHfYTnmhqpUtRh5UiGqUk4QuKfEyo74/EFkfVQSWGfH6a74HSwpoH Z0eRjJAugK6ImyKzjD5si01FEuyG1OvBkO53czYbsX4znu/yPKZXTqPelDyh1Y63SRHbpC dYi4Q9uAGpgDoChDcprGz5dwZGGIIAw= Received: by mail-ed1-f48.google.com with SMTP id er13so33164249edb.9 for ; Thu, 30 Mar 2023 02:53:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680169987; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pqe5ft05YTqZZrlrtJn4uLGU7lFwiC2JxhR5rWQ+Q8g=; b=MhlEyeUl0nxC85OQRMTOwSzIjvhluhW1G8vFWOOLa1hf/UeB0H3YKl1pDeP9dsyldc 8nc5Z5k0K43Kt9kJgMalGFSbyibiQWs5oddrIKkr8Itou23+MlDHP5yobYzwObu4ToCH wcFy3E5LM5onu88BFDSSApA97K5yl8BUCnTglOTafpkXJ4ROOP4vIzRKwyQazzjYv1Fa uet4NPipGanQN4OhbgjlGrWcgW62qDqpXyq+B0/IyVmc9Rm2FAzwAAvxKt9IO+d8dygr LddTKJTVuEZpqCAPd0TKaC4Ydqgjk7SxD1oQJ7vmgemuJbrzbmQWPyuEictqIUT+iA1J hVqw== X-Gm-Message-State: AAQBX9e4zhtan7zvdh/vQg82vwf4aefzy1nvGTPFLivPp1+s977ltgMZ 6mJP2p4P4AHdoRu1V50toPt7+2o3HYz78jsLQBA= X-Google-Smtp-Source: AKy350Z45/pRbKJkp18uUEnf+mk/6tbUDffgMY0DkTOBryHmnIlDDouxUDdqMGt09ydRaqVsp5gW3mAezBlV94dAcwk= X-Received: by 2002:a17:907:a0cd:b0:947:4b15:51e5 with SMTP id hw13-20020a170907a0cd00b009474b1551e5mr1049320ejc.2.1680169986727; Thu, 30 Mar 2023 02:53:06 -0700 (PDT) MIME-Version: 1.0 References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230317072443.3189-1-xueshuai@linux.alibaba.com> <0133c209-b098-e822-58d7-27568888c282@linux.alibaba.com> In-Reply-To: <0133c209-b098-e822-58d7-27568888c282@linux.alibaba.com> From: "Rafael J. Wysocki" Date: Thu, 30 Mar 2023 11:52:55 +0200 Message-ID: Subject: Re: [PATCH v3 0/2] ACPI: APEI: handle synchronous exceptions with proper si_code To: Shuai Xue Cc: "Rafael J. Wysocki" , tony.luck@intel.com, james.morse@arm.com, bp@alien8.de, Naoya Horiguchi , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 433AB1A0019 X-Stat-Signature: 79984ndhft1dkhbubfcm9oxabh5s1qhr X-Rspam-User: X-HE-Tag: 1680169988-811110 X-HE-Meta: U2FsdGVkX1+EKmipIMuD9VJDaT4TjbghrS16qzbBrv7vwNXKNJSP3DKYiRf84ztczVW9cLDrdsXjKAzwF74OaPbJZNNL+DMCgHXN9SOmWOALk0EOqB3jL6OIs9stetjnRTnvu8JIhjT88pCG8UHJEQoBSDdP9aEx1fdsla1UYoy1WvCc480uAj/Nigojjt4381SCbMXASLy9Q4dKkH3N22S6odl9PTddZgl04McZKjPLa275AGhrd1XKXyevrZor6Ww2ELHej+yioGMCbOu8npgljAGbzRjnFw8w95B3Vlo5RfntJekxdywJqpvhsEypEzfIk8sfJfNerMaNzSBoEfrgBmXmv0KFoJMMZM4iIrEZEsElDlRWRZS89pVM56mVF0KKMeOgOe/AMva6ul+gSplqVY1dB62oDgJkFIFWZPSWWYzkN/zLOxCi9EmgeBA0RT/M3N9p+nAvPqVIscAgq5TgX/ao6ZN8CjlM7IKgMQkNI+snzr1YxQbE1Sr2r75k5IsQ5fvr3zVLL7VpTE5VYDS6ewWDNnzTJuhj0RRxThZ1As5cD10ux8IDT3nlzv/6n7Gjtq6EnqkoByvuwVukk6dj0AX2ok6IOcQkyr6a1nJSMhWvtzgMu9HXpCS7kbj9gR3qgHPV2MhmBqWG4kLQBNG1hIULUjrysdtmHrJTw9xTzQqsUnlZTpYBdedptOfKOj1CjBhVvToCh6B3HfQr1S9F3zT4MmwIeEAGZ5KH/zG+0p4uYNzUTLfDbIBQN1aB66BFNe1AvcmmzlBHfTAxGmUEPeIfZB5OPiF1RaWBHFbiXHZyAuW4lKHEW88XYmEO8h9m16na7sWSgurEAhWgnYyQ8JH81FCCtyvZAMVQX7zsMPCaCjhKSsaFLiOFMHWrGE6d+fti4kyk3ZB5oaP16MzB3Nzp2Njg6zjC+Wb5O/C7uZl3aJQQz63wSzjZWWAjeRbXDp+sRLh1U83q5tw 9z85+ioH 3a65KLNvE0u0+BooLWauhZ1cRTuyLtRM38VCF78ttnrBXKxJe5wum+lC7UFWnz3X6L/J5u5I62MCKNYRuaZ5BT4te0Lf77wJQiAQu9BgzpGsB/wdv/LfyxtjKMa5lIrw9b0wevU1Z1olDzrMWDQpxvG6PIOsfs4xNxGSDw4DnQagpamaygNNeG33bS7mxgTGCVDvjiiIlOiDZo8imBERW17p41dSmfmHAsenxe6rChjWgJZ214v3aIeB/qKyZVwwj9USALvcSiWZzJHus9X9xrs8iApI8aDPnIzRXREFlAzo074IF4xC/OmJTg1p8Uh2y+8R2S2lWaIyWBKa5Q7WFxL/iu6N6NO0eZK7QMtaPS374lb5iy1AeTGcGwuwd6Iz3Hq64QhB81d8FM9eAnZym1NxvgQwfJF8Y9N0tmAahdyeeuvOVX1KMZAqb8rDXyXne2XzeOKt0dGhyeR7S0BroobMRDRrbV5crmpYfYtr1dvDBadFsOPq0MlDu2pYrczorHN89Z4/wXK9liI/cXuK80EqHO5x4Qmc3CmuyPgkap2m3YNB02EpVkUhoX41qH+K9bJ3u 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 Thu, Mar 30, 2023 at 8:11=E2=80=AFAM Shuai Xue wrote: > > > On 2023/3/21 AM2:03, Rafael J. Wysocki wrote: > > On Fri, Mar 17, 2023 at 8:25=E2=80=AFAM 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-bd2ae610b= 088@linux.alibaba.com/T/#mb3dede6b7a6d189dc8de3cf9310071e38a192f8e > >> > >> changes since v1: > >> - synchronous events by notify type > >> - Link: https://lore.kernel.org/lkml/20221206153354.92394-3-xueshuai@l= inux.alibaba.com/ > >> > >> Currently, both synchronous and asynchronous error are queued and hand= led > >> by a dedicated kthread in workqueue. And Memory failure for synchronou= s > >> error is synced by a cancel_work_sync trick which ensures that the > >> corrupted page is unmapped and poisoned. And after returning to user-s= pace, > >> the task starts at current instruction which triggering a page fault i= n > >> which kernel will send SIGBUS to current process due to VM_FAULT_HWPOI= SON. > >> > >> However, the memory failure recovery for hwpoison-aware mechanisms doe= s not > >> work as expected. For example, hwpoison-aware user-space processes lik= e > >> QEMU register their customized SIGBUS handler and enable early kill mo= de by > >> seting PF_MCE_EARLY at initialization. Then the kernel will directy no= tify > >> 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 instea= d of > >> BUS_MCEERR_AR. > >> > >> To address this problem: > >> > >> - PATCH 1 sets mf_flags as MF_ACTION_REQUIRED on synchronous events wh= ich > >> 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 disc= ussed > >> 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 u= sed for > >> asynchronous error. As SDEI TRM[1] describes "the dispatcher can simul= ate an > >> exception-like entry into the client, **with the client providing an a= dditional > >> asynchronous entry point similar to an interrupt entry point**". The c= lient > >> (kernel) lacks complete synchronous context, e.g. systeam register (EL= R, 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=3D1 > >> vm.memory_failure_early_kill =3D 1 > >> > >> # STEP2: inject an UCE error and consume it to trigger a synch= ronous error > >> #einj_mem_uc single > >> 0: single vaddr =3D 0xffffb0d75400 paddr =3D 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=3D1 > >> vm.memory_failure_early_kill =3D 1 > >> > >> # STEP2: inject an UCE error and consume it to trigger a synch= ronous error > >> #einj_mem_uc single > >> 0: single vaddr =3D 0xffffb0d75400 paddr =3D 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-xi= exiuqi@huawei.com/T/ > >> [3] https://lore.kernel.org/lkml/20221209095407.383211-1-lvying6@huawe= i.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 t= his. > > Gentle ping. As already stated in this thread, this series requires reviews from the designated APEI reviewers (Tony, Boris, James). Thanks!