Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1280446rdh; Mon, 25 Sep 2023 08:10:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrEU3INSEkqIo2IGocrT1/cH8+xiwmfDU/cVSWgHeSyfJMHvC6FlH3Hi0mqesn07KahY6s X-Received: by 2002:a05:6a00:15c5:b0:68f:fa41:4e92 with SMTP id o5-20020a056a0015c500b0068ffa414e92mr5455256pfu.1.1695654657328; Mon, 25 Sep 2023 08:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695654657; cv=none; d=google.com; s=arc-20160816; b=IanWE98hueihCEiqhZ0cDgkAAJXrChFxpFKfWpaXUnkIneVhVhdjCifeJIa66XX2Eh GBCMhoOe8P5Xz6bVHiZrw5Jqpq9bkGoNeyJCLDngP3xPvpSGUIIMyag6CZDs9QZhUmev dje9aqXKw7WL4iB42radYWJscHtkZYhcy64I/EHqANs8JCD1KNn4NHGiafJyD1XAWInb /RLv8XuQTjA7tKCePPE5rOQTF46YbHTZjCiRBwiMGRsp0IcATl+27jYjU2Eior8e7rTO NLmOmVZYiUyFYtTNvHnp8ZKGlO2NeaCD9umAmJNQ4i1KNHoUuLELKjeNKAa21Qkj2hIa 19zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from:subject :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=Ar6vJsvAfAgIQxJE/WFggoio7iHsMq1XYC0Oa4Jnfys=; fh=KOE29Uh0+E0g0dVYnlOUvG3viH1p6/ogY5bgcNFfLv0=; b=otgPwwpr9X0EnNHFIypJdCg86M7+AY+loLpKLd8yw4AJSG/OXvRU0K6YXimmCtD7kk R8WwNWggqfcIH8ZdkkKoyjtyKdKR8+1Y1SlvwKFP7QzSM6NxOPYQwnDRYfATinledLff 0trmae6AnF5Jz0/0Dz8LWaRvUHK9NtwJW5cMFpYP7mxhsIKfKcV8pb6yGBohkapuaScx MeH117Jn14fMWs5SMbj0x1G8+v7KuXlNlGNRb/5/a5zC65KnoiFJ29Q7Q8e7aVyzcfU3 yUIXmCodViaXbTIgMFG/DkR2/siv/K70hJkA/xiSDD0ISMKWYp5irVd6SvfDOOR3RcLk 4yxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pOGJqd26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f20-20020a637554000000b00578cc8d2599si10274935pgn.211.2023.09.25.08.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 08:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pOGJqd26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1189580A5B78; Mon, 25 Sep 2023 08:01:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232291AbjIYPBM (ORCPT + 99 others); Mon, 25 Sep 2023 11:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232413AbjIYPBK (ORCPT ); Mon, 25 Sep 2023 11:01:10 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4255A111; Mon, 25 Sep 2023 08:01:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BE86C433C8; Mon, 25 Sep 2023 15:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695654060; bh=GUTPMlEVCxAI4XqyqO0Rqf3KWAa3RuxtFqcc2gmHP1w=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=pOGJqd26WmXtEWG9MwBrMWw6yfwLBt3Fw2NdJtV5xHWOD9eyLgAixcnEsCAXLJ0c4 7TJ5DR4cATHHVbGVNr+Q3jly+GM51Q2ZlonAvbt1NhNKnW31AscOFyc1S4kvdkUiFM NWQyqQHZ5bj9XsrhrHNcluOpevJyyVSBpDTTYVHhmrH7/OVKUA4aUkIQWJdMfNAII+ Hj8TmgzsACQLRXu6XyBY01uCt3rFzIl5g88tina/t3F2zrwDagissLn4I2EDC7UG+A Rv+zkYxxCros8yPuumZmQe9IYfZiz7vyqRTKGDzfZ1aP8XOR9pCn6QybtRugRVLJVo 0+wnUc4uR62/Q== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 Sep 2023 18:00:52 +0300 Message-Id: Subject: Re: [RESEND PATCH v8 2/2] ACPI: APEI: handle synchronous exceptions in task work From: "Jarkko Sakkinen" To: "Shuai Xue" , , , , , , , , , , Cc: , , , , , , , , , , , , , , , , , , , , , , X-Mailer: aerc 0.14.0 References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230919022127.69732-3-xueshuai@linux.alibaba.com> In-Reply-To: <20230919022127.69732-3-xueshuai@linux.alibaba.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:01:23 -0700 (PDT) On Tue Sep 19, 2023 at 5:21 AM EEST, Shuai Xue wrote: > Hardware errors could be signaled by synchronous interrupt, e.g. when an > error is detected by a background scrubber, or signaled by synchronous > exception, e.g. when an uncorrected error is consumed. Both synchronous a= nd > asynchronous error are queued and handled by a dedicated kthread in > workqueue. > > commit 7f17b4a121d0 ("ACPI: APEI: Kick the memory_failure() queue for > synchronous errors") keep track of whether memory_failure() work was > queued, and make task_work pending to flush out the workqueue so that the > work for synchronous error is processed before returning to user-space. > The trick ensures that the corrupted page is unmapped and poisoned. And > after returning to user-space, the task starts at current instruction whi= ch > triggering a page fault in which kernel will send SIGBUS to current proce= ss > due to VM_FAULT_HWPOISON. > > However, the memory failure recovery for hwpoison-aware mechanisms does n= ot > 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 notif= y > the process by sending a SIGBUS signal in memory failure with wrong > si_code: the actual user-space process accessing the corrupt memory > location, but its memory failure work is handled in a kthread context, so > it will send SIGBUS with BUS_MCEERR_AO si_code to the actual user-space > process instead of BUS_MCEERR_AR in kill_proc(). > > To this end, separate synchronous and asynchronous error handling into > different paths like X86 platform does: > > - valid synchronous errors: queue a task_work to synchronously send SIGBU= S > before ret_to_user. > - valid asynchronous errors: queue a work into workqueue to asynchronousl= y > handle memory failure. > - abnormal branches such as invalid PA, unexpected severity, no memory > failure config support, invalid GUID section, OOM, etc. > > Then for valid synchronous errors, the current context in memory failure = is > exactly belongs to the task consuming poison data and it will send SIBBUS > with proper si_code. > > Fixes: 7f17b4a121d0 ("ACPI: APEI: Kick the memory_failure() queue for syn= chronous errors") > Signed-off-by: Shuai Xue > Tested-by: Ma Wupeng > Reviewed-by: Kefeng Wang > Reviewed-by: Xiaofei Tan > Reviewed-by: Baolin Wang Did 7f17b4a121d0 actually break something that was not broken before? If not, this is (afaik) not a bug fix. BR, Jarkko