Skip to content

Commit d8145bb

Browse files
shijujose4davejiang
authored andcommitted
cxl/events: Add extra validity checks for CVME count in DRAM Event Record
According to the CXL Specification Revision 3.2, Section 8.2.10.2.1.2, Table 8-58 (DRAM Event Record), the CVME (Corrected Volatile 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 CVME 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 cd3b36c commit d8145bb

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
@@ -941,6 +941,15 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
941941
if (cxl_store_rec_dram((struct cxl_memdev *)cxlmd, evt))
942942
dev_dbg(&cxlmd->dev, "CXL store rec_dram failed\n");
943943

944+
if (evt->dram.media_hdr.descriptor &
945+
CXL_GMER_EVT_DESC_THRESHOLD_EVENT)
946+
WARN_ON_ONCE((evt->dram.media_hdr.type &
947+
CXL_DER_MEM_EVT_TYPE_AP_CME_COUNTER_EXPIRE) &&
948+
!get_unaligned_le24(evt->dram.cvme_count));
949+
else
950+
WARN_ON_ONCE(evt->dram.media_hdr.type &
951+
CXL_DER_MEM_EVT_TYPE_AP_CME_COUNTER_EXPIRE);
952+
944953
trace_cxl_dram(cxlmd, type, cxlr, hpa, hpa_alias,
945954
&evt->dram);
946955
}

drivers/cxl/core/trace.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,10 @@ TRACE_EVENT(cxl_dram,
661661
CXL_EVENT_GEN_MED_COMP_ID_SIZE);
662662
__entry->sub_channel = rec->sub_channel;
663663
__entry->cme_threshold_ev_flags = rec->cme_threshold_ev_flags;
664-
__entry->cvme_count = get_unaligned_le24(rec->cvme_count);
664+
if (rec->media_hdr.descriptor & CXL_GMER_EVT_DESC_THRESHOLD_EVENT)
665+
__entry->cvme_count = get_unaligned_le24(rec->cvme_count);
666+
else
667+
__entry->cvme_count = 0;
665668
),
666669

667670
CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' descriptor='%s' type='%s' sub_type='%s' " \

0 commit comments

Comments
 (0)