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 28B54C77B6E for ; Wed, 12 Apr 2023 03:56:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ACF3900002; Tue, 11 Apr 2023 23:56:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 536826B0075; Tue, 11 Apr 2023 23:56:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FD90900002; Tue, 11 Apr 2023 23:56:00 -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 2CEC46B0074 for ; Tue, 11 Apr 2023 23:56:00 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DD70380231 for ; Wed, 12 Apr 2023 03:55:59 +0000 (UTC) X-FDA: 80671375638.18.4946687 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 60CA714000C for ; Wed, 12 Apr 2023 03:55:55 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of tanxiaofei@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tanxiaofei@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681271757; 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=6jwKj+h4ZQ0g2BkoRunX/vkvcoCgAAsLXIRnC2F8d5g=; b=Py062IEwJoFqJRg3MFUS3/X94kgMvtMMEMLdpW+DXZ7LPgcIBi/FFPEP0YjAAtkG1qwjLr pHJ1v1Kc11rxkbot441G67eqvidiu1a9UINp99W/Hlty7SJWJYPXUOzMwo0nFDlBS3AJkC EBuTsuMaXENmXhwuoF1RLPkOLlUllrk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of tanxiaofei@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tanxiaofei@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681271757; a=rsa-sha256; cv=none; b=LoXElQhkaIjvV0HGQ62lpB8M6oxzbbxV5uQriGkCEdQMVZsrs3QV0thGs12497YAuPL1Qp PdbQCORBpPlXGDYfhtiGjHFa3a556c5reaT4fD232QHPWQ2r8a/6L0S8pDAxnE5EVQCk+r 81WoFndOAF1IxAr6eZ3KfrifZ1YQ+IE= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Px80V54y7zSrbc; Wed, 12 Apr 2023 11:51:54 +0800 (CST) Received: from [10.67.100.236] (10.67.100.236) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 12 Apr 2023 11:55:50 +0800 Message-ID: <3dda3629-3623-ad63-9d9d-73706aacbcc0@huawei.com> Date: Wed, 12 Apr 2023 11:55:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v5 1/2] ACPI: APEI: set memory failure flags as MF_ACTION_REQUIRED on synchronous events To: Shuai Xue , , , CC: , , , , , , , , , , , , , , , , , , References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> <20230411104842.37079-2-xueshuai@linux.alibaba.com> From: Xiaofei Tan In-Reply-To: <20230411104842.37079-2-xueshuai@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.100.236] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 60CA714000C X-Stat-Signature: en7mtdmew6eu11r6t3h3jriubzhnhfa3 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681271755-258569 X-HE-Meta: U2FsdGVkX183dx1BkNAhAy6PS+8kxgDcDJUz+nwXVD1/dTdXK7+jteR9d4f08tUvcqo5Q0+DJju9H3/FcDFl+qF7pSLdYdoA7IVUnLOSjsYjfB7LgSSauW8/Bc1WCaQBJI4faniKSTEtI+hRJ8wZzDCX1sD+674FT47pWW/zeYqxNx8Yy8ZpZ0a79iyhnSrIeORhIwNoYckdseOp8u1977+gc8Ni5af250+B6iFlpnnaJAzZF1M+k+zrXGY2l62osABU9f4qGzJ8uMFn/enIx68WRtenQBjdryvKtkREZnCwiDKTHrLuxF7nWLpvCUd9PFG2F+nLeyLV2pkSqXIWYoWByh8hNZdBHpXBpeD1+elaqLD5GoJBCoPVc+yGd8sp1yaFznxYkc2xR8uXaX38s/K/gUrp83AlGStUo+x+suAlMe0+4K1Zuiy7uLZFKGu63R4CiIqf5nyqN3RKxJkWKMynCEtDgQF/GyYZu6N6mXqCmkIrgHYmkhxka9bQ1WNSn8Yb0HrdVhmXIfN5FfHsoSH4akUoTFmmhsv+uixE3N/7u4RZ9FPEmQuuHB2NUDswHi0Pbtm3VrC5NHOZb+zJMjnv4B1wRI6H5mefXmfICXV1xblouLMxz+KwLeM0Leoq7FYcmfLVo94umAXrcEn4XZhAVbf/iSs8CgZR+j0DhKAaqS8xhi2ER5buaQFjwcIINYym5R5PDoJ9aOobWw2f1kkIuQE3aptxvSfA+ZK3nTRiyAFDz0f3qArWWLUUiCVt8X5lrsgrXDSotmCzlmG14qeczDRWK63amdOUBwZYk0Mh9oyj9AGyBf71FVKW4tGgxtqRVpFPwhCPypVudsaDNGC/YwXJ1P581VCAfqatrAB1KMWVyhk8+P3dYODgp44ZKdhl/rsrWSbQnf8foaiz/9q54nvMD2q6QKp7pdG0pq/gBgbBMMenwO9QtnU1rO9L9K3ID8y/3ntXaDcU5ph V5FJb2sF AGrdlpbIBoA0uSZqWbcsezY4G+2epr/o7BHnWr1OUvq2SeZgJXBkzfo25HLeMV7HgNVhYdokUgPsb83T9yMbwFO20nqh6Igba7UkR+cztgWJ7MOR/Qw1nkZfcJDhI1b1OAZwTrGMd9OWfqDybGkHumVe764UdDxt99fbcSIy4Rm7uTtfwZYldkNPTcfpg0O15TW+vUClAojcSwHE= 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: Reviewed-by: Xiaofei Tan 在 2023/4/11 18:48, Shuai Xue 写道: > 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 notification > ), 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 synchronous > events. > > Fixes: ba61ca4aab47 ("ACPI, APEI, GHES: Add hardware memory error recovery support")' > Signed-off-by: Shuai Xue > Tested-by: Ma Wupeng > --- > 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 34ad071a64e9..c479b85899f5 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 ghes *ghes) > return ghes->generic->header.type == ACPI_HEST_TYPE_GENERIC_ERROR_V2; > } > > +/* > + * A platform may describe one error source for the handling of synchronous > + * errors (e.g. MCE or SEA), or for handling asynchronous errors (e.g. SCI > + * 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 = ghes->generic->notify.type; > + > + return notify_type == 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 > @@ -477,7 +491,7 @@ static bool ghes_do_memory_failure(u64 physical_addr, int flags) > } > > static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, > - int sev) > + int sev, bool sync) > { > int flags = -1; > int sec_sev = ghes_severity(gdata->error_severity); > @@ -491,7 +505,7 @@ static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, > (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED)) > flags = MF_SOFT_OFFLINE; > if (sev == GHES_SEV_RECOVERABLE && sec_sev == GHES_SEV_RECOVERABLE) > - flags = 0; > + flags = sync ? MF_ACTION_REQUIRED : 0; > > if (flags != -1) > return ghes_do_memory_failure(mem_err->physical_addr, flags); > @@ -499,9 +513,11 @@ static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, > return false; > } > > -static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, int sev) > +static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, > + int sev, bool sync) > { > struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); > + int flags = sync ? MF_ACTION_REQUIRED : 0; > bool queued = false; > int sec_sev, i; > char *p; > @@ -526,7 +542,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, int s > * and don't filter out 'corrected' error here. > */ > if (is_cache && has_pa) { > - queued = ghes_do_memory_failure(err_info->physical_fault_addr, 0); > + queued = ghes_do_memory_failure(err_info->physical_fault_addr, flags); > p += err_info->length; > continue; > } > @@ -647,6 +663,7 @@ static bool ghes_do_proc(struct ghes *ghes, > const guid_t *fru_id = &guid_null; > char *fru_text = ""; > bool queued = false; > + bool sync = is_hest_sync_notify(ghes); > > sev = ghes_severity(estatus->error_severity); > apei_estatus_for_each_section(estatus, gdata) { > @@ -664,13 +681,13 @@ static bool ghes_do_proc(struct ghes *ghes, > atomic_notifier_call_chain(&ghes_report_chain, sev, mem_err); > > arch_apei_report_mem_error(sev, mem_err); > - queued = ghes_handle_memory_failure(gdata, sev); > + queued = ghes_handle_memory_failure(gdata, sev, sync); > } > else if (guid_equal(sec_type, &CPER_SEC_PCIE)) { > ghes_handle_aer(gdata); > } > else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) { > - queued = ghes_handle_arm_hw_error(gdata, sev); > + queued = ghes_handle_arm_hw_error(gdata, sev, sync); > } else { > void *err = acpi_hest_get_payload(gdata); >