Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1267543rdh; Mon, 25 Sep 2023 07:54:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHplYHQlbQZFRk8nkdvN81xq+7wf9dogpW/Mkb8Eu01xuJ3RBHPhWuVle2Gov6gNqeEjcXQ X-Received: by 2002:a05:6870:32d3:b0:1d6:40f9:804a with SMTP id r19-20020a05687032d300b001d640f9804amr9602389oac.57.1695653650861; Mon, 25 Sep 2023 07:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695653650; cv=none; d=google.com; s=arc-20160816; b=B+GNkeM+hpzMEBmpg45F6ys/CShdch6mq/034dh8HdELhRz9mq3mqS9R1TP3p3pwg1 xh5X18bFfRx7igoBw8XTTjNuU3Y4qAwhu/w6Tj9KPQnvq2CLC3VuWy11SB8qjWR1JdCg cXZKjWpkz3TyLiL+Jq6TBwsJv0YUCUwjrwUbHMi17JIrJ7rDHsnYhxprqHwzeW2OFw1T zoEUFsP9jcp9YVbRR8VetaLdFzDIdYl+4AYjClpoFchgrlBkCJnyA7NlPx1HDTrJFT/y vOXnzac2iwRCMKG/0J3gK0CIMxtjHbpWpr1xYYF26t5vIESoBf2VAm3ZajGgZAM6C9vX SsjA== 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:to:from:subject:cc :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=YtbvCkOfeIQBXRIQ7T8EjU2PDb1ifWMvDHkBrDbRj2A=; fh=+XCMLSeIVLOKtv6JTxIE2YFPjnuJ8mSVJtKlbCpYyHU=; b=jocpvfLQvymoL0OcLUXzzMz1Lx5lTeX/af/4BLA6ZeIRiBaz1Hdw0nwc3rT5/ZcPBj jdGchb82G4uNY65RjhrF1rGgGhk32jWMIKiTWQBHhVUBZruqjexBek8WeHDvbnKF1pTA 1VZXpnBD4Hjg5a3stOgbbxQx2yVCkg9i50DtIdZm3yj+bVyYoFr60K3Wr2FBjLN6hPrZ XUwGmt8eXCZ4VWYaapHnXH38uxa+k4/zfRfcYkloEDvCRfddgGPZidQpIKqHwuP0JRwC t8sARrhm4YQUzw0JVCm1HuiLFC3DZjzEf9OinHV3KHc4w8vC8a8gSuyVEPBT2eUZVqjm SQ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qw77X9fk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b19-20020a656693000000b005775e2f160fsi9886311pgw.667.2023.09.25.07.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 07:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qw77X9fk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id DCC388077A44; Mon, 25 Sep 2023 07:43:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232306AbjIYOnc (ORCPT + 99 others); Mon, 25 Sep 2023 10:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjIYOna (ORCPT ); Mon, 25 Sep 2023 10:43:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAC8101; Mon, 25 Sep 2023 07:43:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693E4C433C7; Mon, 25 Sep 2023 14:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695653004; bh=zLu+VnRpIsjtnAXABy7BDzCTOqyINaVoPvsO++Hkwow=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=qw77X9fkt0hBOpDdvTU2WKmu46P3XwVZXqEmHv04wqXA/tZs4NgonJaHKf7T8MZAC oPNae1MmhWZ3eOq+eqzdXMUr7j7oPNnBXePU3V/yvxGYt+LT2sEv94UA86N3ssa4p9 fz6Z0JVoPlrWpHUK4hmHg0rA8lKjUp3uYG452ywN2dkQxUZlpqN4ML0W/HvnTG/LnR mQw58kFoNZmb/HPdqzWT0XPfhg/ijXT/GT5Lcx89pnr12GhQ1x5zAlOPlUT4HhfwTS xy1RrnkmKut5d1yXF7k93DE2LrJT+5zXjmyv4CnjDdS+Abrr+nZp1g5CeFrS7FcnLD QhF4td3R7tIOg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 Sep 2023 17:43:15 +0300 Message-Id: Cc: , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [RESEND PATCH v8 1/2] ACPI: APEI: set memory failure flags as MF_ACTION_REQUIRED on synchronous events From: "Jarkko Sakkinen" To: "Shuai Xue" , , , , , , , , , , X-Mailer: aerc 0.14.0 References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230919022127.69732-2-xueshuai@linux.alibaba.com> In-Reply-To: <20230919022127.69732-2-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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 07:43:31 -0700 (PDT) On Tue Sep 19, 2023 at 5:21 AM EEST, Shuai Xue wrote: > There are two major types of uncorrected recoverable (UCR) errors : > > - Action Required (AR): The error is detected and the processor already > consumes the memory. OS requires to take action (for example, offline > failure page/kill failure thread) to recover this uncorrectable error. > > - Action Optional (AO): The error is detected out of processor execution > context. 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. > > The essential difference between AR and AO errors is that AR is a > synchronous event, while AO is an asynchronous event. The hardware will > signal a synchronous exception (Machine Check Exception on X86 and > Synchronous External Abort on Arm64) when an error is detected and the > memory access has been architecturally executed. > > When APEI firmware first is enabled, a platform may describe one error > source for the handling of synchronous errors (e.g. MCE or SEA notificati= on > ), or for handling asynchronous errors (e.g. SCI or External Interrupt > notification). In other words, we can distinguish synchronous errors by > APEI notification. For AR errors, kernel will kill current process > accessing the poisoned page by sending SIGBUS with BUS_MCEERR_AR. In > addition, for AO errors, kernel will notify the process who owns the > poisoned page by sending SIGBUS with BUS_MCEERR_AO in early kill mode. > However, the GHES driver always sets mf_flags to 0 so that all UCR errors > are handled as AO errors in memory failure. > > To this end, set memory failure flags as MF_ACTION_REQUIRED on synchronou= s > events. > > Fixes: ba61ca4aab47 ("ACPI, APEI, GHES: Add hardware memory error recover= y support")' > Signed-off-by: Shuai Xue > Tested-by: Ma Wupeng > Reviewed-by: Kefeng Wang > Reviewed-by: Xiaofei Tan > Reviewed-by: Baolin Wang > --- > drivers/acpi/apei/ghes.c | 29 +++++++++++++++++++++++------ > 1 file changed, 23 insertions(+), 6 deletions(-) > > diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c > index ef59d6ea16da..88178aa6222d 100644 > --- a/drivers/acpi/apei/ghes.c > +++ b/drivers/acpi/apei/ghes.c > @@ -101,6 +101,20 @@ static inline bool is_hest_type_generic_v2(struct gh= es *ghes) > return ghes->generic->header.type =3D=3D ACPI_HEST_TYPE_GENERIC_ERROR_V= 2; > } > =20 > +/* > + * A platform may describe one error source for the handling of synchron= ous > + * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. S= CI > + * or External Interrupt). On x86, the HEST notifications are always > + * asynchronous, so only SEA on ARM is delivered as a synchronous > + * notification. > + */ > +static inline bool is_hest_sync_notify(struct ghes *ghes) > +{ > + u8 notify_type =3D ghes->generic->notify.type; > + > + return notify_type =3D=3D ACPI_HEST_NOTIFY_SEA; > +} > + > /* > * This driver isn't really modular, however for the time being, > * continuing to use module_param is the easiest way to remain > @@ -475,7 +489,7 @@ static bool ghes_do_memory_failure(u64 physical_addr,= int flags) > } > =20 > static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gd= ata, > - int sev) > + int sev, bool sync) > { > int flags =3D -1; > int sec_sev =3D ghes_severity(gdata->error_severity); > @@ -489,7 +503,7 @@ static bool ghes_handle_memory_failure(struct acpi_he= st_generic_data *gdata, > (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED)) > flags =3D MF_SOFT_OFFLINE; > if (sev =3D=3D GHES_SEV_RECOVERABLE && sec_sev =3D=3D GHES_SEV_RECOVERA= BLE) > - flags =3D 0; > + flags =3D sync ? MF_ACTION_REQUIRED : 0; Not my territory but this branching looks a bit weird to my eyes so just in case putting a comment. What *if* the previous condition sets MF_SOFT_OFFLINE and this condition overwrites the value? I know that earlier it could have been overwritten by zero. Neither the function comment has any explanation why it is ok overwrite like this. Or if these cannot happen simultaenously why there is not immediate return after settting MF_SOFT_OFFLINE? For someone like me the functions logic is tediously hard to understand tbh. BR, Jarkko