Skip to content

Commit cd3b36c

Browse files
shijujose4davejiang
authored andcommitted
cxl/events: Add extra validity checks for corrected memory error count in General Media Event Record
According to the CXL Specification Revision 3.2, Section 8.2.10.2.1.1, Table 8-57 (General Media Event Record), the Corrected Memory Error Count field is valid under the following conditions: 1. The Threshold Event bit is set in the Memory Event Descriptor field, and 2. The Corrected Memory Error Count must be greater than 0 for events where the Advanced Programmable Threshold Counter has expired. Additionally, if the Advanced Programmable Corrected Memory Error Counter Expire bit in the Memory Event Type field is set, then the Threshold Event bit in the Memory Event Descriptor field shall also be set. Add validity checks for the above conditions while reporting the event to the userspace. Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Shiju Jose <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent 1f4f816 commit cd3b36c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

drivers/cxl/core/mbox.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,15 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
926926
if (cxl_store_rec_gen_media((struct cxl_memdev *)cxlmd, evt))
927927
dev_dbg(&cxlmd->dev, "CXL store rec_gen_media failed\n");
928928

929+
if (evt->gen_media.media_hdr.descriptor &
930+
CXL_GMER_EVT_DESC_THRESHOLD_EVENT)
931+
WARN_ON_ONCE((evt->gen_media.media_hdr.type &
932+
CXL_GMER_MEM_EVT_TYPE_AP_CME_COUNTER_EXPIRE) &&
933+
!get_unaligned_le24(evt->gen_media.cme_count));
934+
else
935+
WARN_ON_ONCE(evt->gen_media.media_hdr.type &
936+
CXL_GMER_MEM_EVT_TYPE_AP_CME_COUNTER_EXPIRE);
937+
929938
trace_cxl_general_media(cxlmd, type, cxlr, hpa,
930939
hpa_alias, &evt->gen_media);
931940
} else if (event_type == CXL_CPER_EVENT_DRAM) {

drivers/cxl/core/trace.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,10 @@ TRACE_EVENT(cxl_general_media,
506506
uuid_copy(&__entry->region_uuid, &uuid_null);
507507
}
508508
__entry->cme_threshold_ev_flags = rec->cme_threshold_ev_flags;
509-
__entry->cme_count = get_unaligned_le24(rec->cme_count);
509+
if (rec->media_hdr.descriptor & CXL_GMER_EVT_DESC_THRESHOLD_EVENT)
510+
__entry->cme_count = get_unaligned_le24(rec->cme_count);
511+
else
512+
__entry->cme_count = 0;
510513
),
511514

512515
CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' " \

0 commit comments

Comments
 (0)