From nobody Thu Oct 9 00:32:52 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C08A6267700; Mon, 23 Jun 2025 14:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750690534; cv=none; b=bVh1MyttiKooMOGEIcG3kLmk5/pW9lasEDD5az4nU9QLWsbuV+x0Raew92IAJXbesnhOmYEog8FNDUcfAeS6+gbEMkLxTjbAZEn7IAvDhp3Nta3u/hiAQs/9RmSPwvz67x12xfh36hm3Il6vG6nknl6aZpVXWWIAqmg1UYmamik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750690534; c=relaxed/simple; bh=gszoEZ/bHkrFTTc3IzYuM4m4Ycm6E1VSniTVLUWbC0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HSTUXZ4uhhUZwWwV6imj2Ng/PkS4t015f/tzaxJUq5U4jFSs9WXDEjXo3qTLhzDC3EUKZWDxc4RuQGZE1AIw+Y8WBjOIb4ava92C6ebZl/Uw6hecojAgz7T/ujx2eHdsnU7KWFNQPEKPJUPLHr/BSmYD6px6ZPuG07TmHmnelmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SozZaton; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SozZaton" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750690533; x=1782226533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gszoEZ/bHkrFTTc3IzYuM4m4Ycm6E1VSniTVLUWbC0I=; b=SozZatonz5IC6KTnNz1eYoxlSq99K+gs5Ex36Iiv0a9HrYbaH4KGvult Dc12MhB862G49BES/63yPnjSWenrZWfvYGXzmAV1jIENRwX3u4GK+seAQ QuB+tMGt3tgKgE6oJJ/qLbLGbhMLN8/+BYDe/crAsjB1uqFIU4Tm3Wzko mvlQ59fszYmGDZBJJljBjBQPzZnPmWdt2kyeGJohhMgpI+hyaMghWsFjn heuUPvtsnPf273wfn4Uch4erPoe5KUBkBj45tuPsH7ciBldLdrEeAp6uE BeEIQj9a0GS1Tg9w//yWsI6GQIXmV4DqX9wQCe4Loy8YozylMYNp++8Hp g==; X-CSE-ConnectionGUID: nLhdkNukQN+y+kSFxR/KOg== X-CSE-MsgGUID: LYqF57++TFq5jGeNPXfMhw== X-IronPort-AV: E=McAfee;i="6800,10657,11473"; a="53042732" X-IronPort-AV: E=Sophos;i="6.16,258,1744095600"; d="scan'208";a="53042732" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2025 07:55:32 -0700 X-CSE-ConnectionGUID: IDXBrUhASwOrAxLiN9UO2g== X-CSE-MsgGUID: i9GOdjm+QLG4QDGi+dI36A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,258,1744095600"; d="scan'208";a="155997410" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.intel.com) ([10.245.246.11]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2025 07:55:24 -0700 From: "Fabio M. De Francesco" To: linux-cxl@vger.kernel.org Cc: "Rafael J . Wysocki" , Len Brown , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Mahesh J Salgaonkar , Oliver O'Halloran , Bjorn Helgaas , Tony Luck , Borislav Petkov , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-edac@vger.kernel.org, "Fabio M. De Francesco" , Kuppuswamy Sathyanarayanan Subject: [PATCH 3/3 v4] ACPI: extlog: Trace CPER CXL Protocol Error Section Date: Mon, 23 Jun 2025 16:54:20 +0200 Message-ID: <20250623145453.1046660-4-fabio.m.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623145453.1046660-1-fabio.m.de.francesco@linux.intel.com> References: <20250623145453.1046660-1-fabio.m.de.francesco@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When Firmware First is enabled, BIOS handles errors first and then it makes them available to the kernel via the Common Platform Error Record (CPER) sections (UEFI 2.10 Appendix N). Linux parses the CPER sections via one of two similar paths, either ELOG or GHES. The errors managed by ELOG are signaled to the BIOS by the I/O Machine Check Architecture (I/O MCA). Currently, ELOG and GHES show some inconsistencies in how they report to userspace via trace events. Therefore, make the two mentioned paths act similarly by tracing the CPER CXL Protocol Error Section (UEFI v2.10, Appendix N.2.13). Cc: Dan Williams Reviewed-by: Kuppuswamy Sathyanarayanan Signed-off-by: Fabio M. De Francesco --- drivers/acpi/acpi_extlog.c | 62 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/ras.c | 6 ++++ include/cxl/event.h | 2 ++ 3 files changed, 70 insertions(+) diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index cefe8d2d8affc..9a37b08aacfea 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -160,6 +161,60 @@ static void extlog_print_pcie(struct cper_sec_pcie *pc= ie_err, pci_dev_put(pdev); } =20 +static void +extlog_cxl_cper_handle_prot_err(struct cxl_cper_sec_prot_err *prot_err, + int severity) +{ + struct cxl_cper_prot_err_work_data wd; + u8 *dvsec_start, *cap_start; + + if (!(prot_err->valid_bits & PROT_ERR_VALID_AGENT_ADDRESS)) { + pr_warn_ratelimited("CXL CPER invalid agent type\n"); + return; + } + + if (!(prot_err->valid_bits & PROT_ERR_VALID_ERROR_LOG)) { + pr_warn_ratelimited("CXL CPER invalid protocol error log\n"); + return; + } + + if (prot_err->err_len !=3D sizeof(struct cxl_ras_capability_regs)) { + pr_warn_ratelimited("CXL CPER invalid RAS Cap size (%u)\n", + prot_err->err_len); + return; + } + + if ((prot_err->agent_type =3D=3D RCD || prot_err->agent_type =3D=3D DEVIC= E || + prot_err->agent_type =3D=3D LD || prot_err->agent_type =3D=3D FMLD) = && + !(prot_err->valid_bits & PROT_ERR_VALID_SERIAL_NUMBER)) + pr_warn_ratelimited(FW_WARN + "CXL CPER no device serial number\n"); + + switch (prot_err->agent_type) { + case RCD: + case DEVICE: + case LD: + case FMLD: + case RP: + case DSP: + case USP: + memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err)); + + dvsec_start =3D (u8 *)(prot_err + 1); + cap_start =3D dvsec_start + prot_err->dvsec_len; + + memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap)); + wd.severity =3D cper_severity_to_aer(severity); + break; + default: + pr_err_ratelimited("CXL CPER reserved agent type: %d\n", + prot_err->agent_type); + return; + } + + cxl_cper_ras_handle_prot_err(&wd); +} + static int extlog_print(struct notifier_block *nb, unsigned long val, void *data) { @@ -211,6 +266,12 @@ static int extlog_print(struct notifier_block *nb, uns= igned long val, if (gdata->error_data_length >=3D sizeof(*mem)) trace_extlog_mem_event(mem, err_seq, fru_id, fru_text, (u8)gdata->error_severity); + } else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) { + struct cxl_cper_sec_prot_err *prot_err =3D + acpi_hest_get_payload(gdata); + + extlog_cxl_cper_handle_prot_err(prot_err, + gdata->error_severity); } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) { struct cper_sec_pcie *pcie_err =3D acpi_hest_get_payload(gdata); =20 @@ -378,3 +439,4 @@ module_exit(extlog_exit); MODULE_AUTHOR("Chen, Gong "); MODULE_DESCRIPTION("Extended MCA Error Log Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("CXL"); diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c index 485a831695c70..56db290c88d35 100644 --- a/drivers/cxl/core/ras.c +++ b/drivers/cxl/core/ras.c @@ -98,6 +98,12 @@ static void cxl_cper_handle_prot_err(struct cxl_cper_pro= t_err_work_data *data) cxl_cper_trace_uncorr_prot_err(pdev, data->ras_cap); } =20 +void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd) +{ + cxl_cper_handle_prot_err(wd); +} +EXPORT_SYMBOL_NS_GPL(cxl_cper_ras_handle_prot_err, "CXL"); + static void cxl_cper_prot_err_work_fn(struct work_struct *work) { struct cxl_cper_prot_err_work_data wd; diff --git a/include/cxl/event.h b/include/cxl/event.h index f9ae1796da85f..aef906e260330 100644 --- a/include/cxl/event.h +++ b/include/cxl/event.h @@ -285,4 +285,6 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cx= l_cper_prot_err_work_data } #endif =20 +void cxl_cper_ras_handle_prot_err(struct cxl_cper_prot_err_work_data *wd); + #endif /* _LINUX_CXL_EVENT_H */ --=20 2.49.0