lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 22 Apr 2024 15:25:47 -0700
From: Ira Weiny <ira.weiny@...el.com>
To: Dave Jiang <dave.jiang@...el.com>, 
 Dan Williams <dan.j.williams@...el.com>, 
 Jonathan Cameron <jonathan.cameron@...wei.com>, 
 Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>, 
 Shiju Jose <shiju.jose@...wei.com>
Cc: Dan Carpenter <dan.carpenter@...aro.org>, 
 Yazen Ghannam <yazen.ghannam@....com>, Davidlohr Bueso <dave@...olabs.net>, 
 Alison Schofield <alison.schofield@...el.com>, 
 Vishal Verma <vishal.l.verma@...el.com>, Ard Biesheuvel <ardb@...nel.org>, 
 linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-cxl@...r.kernel.org, Ira Weiny <ira.weiny@...el.com>, 
 "Rafael J. Wysocki" <rafael@...nel.org>, Tony Luck <tony.luck@...el.com>, 
 Borislav Petkov <bp@...en8.de>
Subject: [PATCH v2 3/3] ras/events: Trace CXL CPER events without CXL stack

If CXL is solely managed by firmware (including HDM configuration and
event processing via firmware first) it is possible to run the system
without the CXL software loaded.  In this case no CXL callback will be
loaded and CXL CPER errors will not be processed at all.

In this case memory device and region (HPA) information is missing but
omitting the error completely is not friendly.  Some device information
is available the event.

Trace CXL CPER events if the CXL stack is not loaded.  A balance was
chosen to decode only the CPER header as this configuration is likely
rare.

Cc: Ard Biesheuvel <ardb@...nel.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: Tony Luck <tony.luck@...el.com>
Cc: Borislav Petkov <bp@...en8.de>
Suggested-by: Dan Williams <dan.j.williams@...el.com>
Signed-off-by: Ira Weiny <ira.weiny@...el.com>

---
Changes:
[djbw: remove local work task and call trace directly]
[djbw: strip down the generic trace information]
---
 drivers/acpi/apei/ghes.c |  6 +++++-
 include/ras/ras_event.h  | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index cdcfdf6ebe81..20a0e622f829 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -739,8 +739,12 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
 
 	guard(spinlock_irqsave)(&cxl_cper_work_lock);
 
-	if (!cxl_cper_work)
+	if (!cxl_cper_work) {
+		union cxl_event *evt = &rec->event;
+
+		trace_cper_cxl_event(rec, &evt->generic, event_type);
 		return;
+	}
 
 	wd.event_type = event_type;
 	memcpy(&wd.rec, rec, sizeof(wd.rec));
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
index c011ea236e9b..c1fac66fb44a 100644
--- a/include/ras/ras_event.h
+++ b/include/ras/ras_event.h
@@ -422,6 +422,57 @@ TRACE_EVENT(memory_failure_event,
 	)
 );
 #endif /* CONFIG_MEMORY_FAILURE */
+
+#include <linux/cxl-event.h>
+#include <asm-generic/unaligned.h>
+
+TRACE_EVENT(cper_cxl_event,
+
+	TP_PROTO(struct cxl_cper_event_rec *cper_rec,
+		 struct cxl_event_generic *gen_rec,
+		 enum cxl_event_type event_type),
+
+	TP_ARGS(cper_rec, gen_rec, event_type),
+
+	/* packed record */
+	TP_STRUCT__entry(
+		__field(u16, segment)
+		__field(u8, bus)
+		__field(u8, device)
+		__field(u32, hdr_flags)
+		__field(u64, serial)
+		__field(u64, hdr_timestamp)
+		__field(u8, func)
+		__field(u8, hdr_length)
+		__field(u8, hdr_maint_op_class)
+		__field(u8, event_type)
+		__array(u8, data, CXL_EVENT_RECORD_DATA_LENGTH)
+	),
+
+	TP_fast_assign(
+		__entry->event_type = event_type;
+		__entry->segment = cper_rec->hdr.device_id.segment_num;
+		__entry->bus = cper_rec->hdr.device_id.bus_num;
+		__entry->device = cper_rec->hdr.device_id.device_num;
+		__entry->func = cper_rec->hdr.device_id.func_num;
+		__entry->serial = (((u64)cper_rec->hdr.dev_serial_num.upper_dw) << 32) |
+				 cper_rec->hdr.dev_serial_num.lower_dw;
+		__entry->hdr_length = gen_rec->hdr.length;
+		__entry->hdr_flags = get_unaligned_le24(gen_rec->hdr.flags);
+		__entry->hdr_timestamp = le64_to_cpu(gen_rec->hdr.timestamp);
+		__entry->hdr_maint_op_class = gen_rec->hdr.maint_op_class;
+		memcpy(__entry->data, gen_rec->data, CXL_EVENT_RECORD_DATA_LENGTH);
+	),
+
+	TP_printk("device=%04x:%02x:%02x.%02x serial=%lld : event_type=%d time=%llu "
+		  "len=%d flags=%x maint_op_class=%u : %s",
+		__entry->segment, __entry->bus, __entry->device, __entry->func,
+		__entry->serial, __entry->event_type, __entry->hdr_timestamp,
+		__entry->hdr_length, __entry->hdr_flags, __entry->hdr_maint_op_class,
+		__print_hex(__entry->data, CXL_EVENT_RECORD_DATA_LENGTH))
+
+);
+
 #endif /* _TRACE_HW_EVENT_MC_H */
 
 /* This part must be outside protection */

-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ