QEMU CXL Provide mock CXL events and irq support
v9 cover QEMU CXL Provide mock CXL events and irq support
v9: A few remaining QMP documentation formatting fixes from Markus. Fingers crossed it's now clean!
Based on:
[PATCH v8 0/4] hw/cxl: Poison get, inject, clear
Based on: Message-ID: [email protected]
Updated cover letter from earlier versions:
One challenge here is striking the right balance between lots of constraints in the injection code to enforce particular reserved bits etc by breaking out all the flags as individual parameters vs having a reasonably concise API. I think this set strikes the right balance but others may well
disagree :) Note that Ira raised the question of whether we should be
automatically establishing the volatile flag based on the Device Physical Address of the injected error. My proposal is to not do so for now, but to possibly revisit tightening the checking of injected errors in future. Whilst the volatile flag is straight forwards, some of the other flags that could be automatically set (or perhaps checked for validiaty) are much more complex. Adding verification at this stage would greatly increase the complexity of the patch + we are missing other elements that would interact with this. I'm not concerned about potential breaking of backwards compatibility if it only related to the injection of errors that make no sense for a real device.
CXL Event records inform the OS of various CXL device events. Thus far CXL memory devices are emulated and therefore don't naturally generate events.
Add an event infrastructure and mock event injection. Previous versions included a bulk insertion of lots of events. However, this series focuses on providing the ability to inject individual events through QMP. Only the General Media Event is included in this series as an example. Other events can be added pretty easily once the infrastructure is acceptable.
In addition, this version updates the code to be in line with the specification based on discussions around the kernel patches.
Injection examples;
{ "execute": "cxl-inject-general-media-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"dpa": 1000,
"descriptor": 3,
"type": 3,
"transaction-type": 192,
"channel": 3,
"device": 5,
"component-id": "iras mem"
}}{ "execute": "cxl-inject-dram-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"dpa": 1000,
"descriptor": 3,
"type": 3,
"transaction-type": 192,
"channel": 3,
"rank": 17,
"nibble-mask": 37421234,
"bank-group": 7,
"bank": 11,
"row": 2,
"column": 77,
"correction-mask": [33, 44, 55, 66]
}}{ "execute": "cxl-inject-memory-module-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"type": 3,
"health-status": 3,
"media-status": 7,
"additional-status": 33,
"life-used": 30,
"temperature": -15,
"dirty-shutdown-count": 4,
"corrected-volatile-error-count": 3233,
"corrected-persistent-error-count": 1300}}
Ira Weiny (4):
hw/cxl/events: Add event status register hw/cxl/events: Wire up get/clear event mailbox commands hw/cxl/events: Add event interrupt support hw/cxl/events: Add injection of General Media Events
Jonathan Cameron (3):
hw/cxl: Move CXLRetCode definition to cxl_device.h hw/cxl/events: Add injection of DRAM events hw/cxl/events: Add injection of Memory Module Events
qapi/cxl.json | 188 +++++++++++++++++++++++ include/hw/cxl/cxl_device.h | 80 +++++++++- include/hw/cxl/cxl_events.h | 168 +++++++++++++++++++++ hw/cxl/cxl-device-utils.c | 43 +++++- hw/cxl/cxl-events.c | 248 ++++++++++++++++++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 166 ++++++++++++++------ hw/mem/cxl_type3.c | 292 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3_stubs.c | 35 +++++ hw/cxl/meson.build | 1 + 9 files changed, 1165 insertions(+), 56 deletions(-) create mode 100644 include/hw/cxl/cxl_events.h create mode 100644 hw/cxl/cxl-events.c
Signature · 1 line
2.39.2
PATCH v9 1/7 hw/cxl/events: Add event status register
From: Ira Weiny <[email protected]>
The device status register block was defined. However, there were no individual registers nor any data wired up.
Define the event status register [CXL 3.0; 8.2.8.3.1] as part of the device status register block. Wire up the register and initialize the event status for each log.
To support CXL 3.0 the version of the device status register block needs to be 2. Change the macro to allow for setting the version.
--- include/hw/cxl/cxl_device.h | 23 +++++++++++++++++--- include/hw/cxl/cxl_events.h | 28 ++++++++++++++++++++++++ hw/cxl/cxl-device-utils.c | 43 ++++++++++++++++++++++++++++++++----- 3 files changed, 86 insertions(+), 8 deletions(-)
include/hw/cxl/cxl_device.h +20 -3
@@ -13,6 +13,7 @@#include "hw/cxl/cxl_component.h" #include "hw/pci/pci_device.h" #include "hw/register.h" +#include "hw/cxl/cxl_events.h" /* * The following is how a CXL device's Memory Device registers are laid out.
@@ -86,7 +87,16 @@ typedef struct cxl_device_state {MemoryRegion device_registers;/* mmio for device capabilities array - 8.2.8.2 */ -MemoryRegion device; +struct { +MemoryRegion device; +union { +uint8_t dev_reg_state[CXL_DEVICE_STATUS_REGISTERS_LENGTH ]; +uint16_t dev_reg_state16[CXL_DEVICE_STATUS_REGISTERS_LENGTH /2 ]; +uint32_t dev_reg_state32[CXL_DEVICE_STATUS_REGISTERS_LENGTH /4 ]; +uint64_t dev_reg_state64[CXL_DEVICE_STATUS_REGISTERS_LENGTH /8 ]; + }; +uint64_t event_status; + };MemoryRegion memory_device;struct {MemoryRegion caps;
@@ -141,6 +151,9 @@ REG64(CXL_DEV_CAP_ARRAY, 0) /* Documented as 128 bit register but 64 byte access FIELD(CXL_DEV_CAP_ARRAY, CAP_VERSION, 16, 8) FIELD(CXL_DEV_CAP_ARRAY, CAP_COUNT, 32, 16) +void cxl_event_set_status (CXLDeviceState *cxl_dstate,CXLEventLogType log_type, +bool available); +/* * Helper macro to initialize capability headers for CXL devices. *
@@ -175,7 +188,7 @@ CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MEMORY_DEVICE,void cxl_initialize_mailbox (CXLDeviceState *cxl_dstate);void cxl_process_mailbox (CXLDeviceState *cxl_dstate); -#define cxl_device_cap_init (dstate, reg, cap_id) \ +#define cxl_device_cap_init (dstate, reg, cap_id, ver) \ do { \ uint32_t *cap_hdrs = dstate->caps_reg_state32; \ int which = R_CXL_DEV_##reg##_CAP_HDR0; \
@@ -183,7 +196,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate); FIELD_DP32(cap_hdrs[which], CXL_DEV_##reg##_CAP_HDR0, \ CAP_ID, cap_id); \ cap_hdrs[which] = FIELD_DP32( \ - cap_hdrs[which], CXL_DEV_##reg##_CAP_HDR0, CAP_VERSION, 1); \ + cap_hdrs[which], CXL_DEV_##reg##_CAP_HDR0, CAP_VERSION, ver); \ cap_hdrs[which + 1] = \ FIELD_DP32(cap_hdrs[which + 1], CXL_DEV_##reg##_CAP_HDR1, \ CAP_OFFSET, CXL_##reg##_REGISTERS_OFFSET); \
@@ -192,6 +205,10 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate); CAP_LENGTH, CXL_##reg##_REGISTERS_LENGTH); \ } while (0) +/* CXL 3.0 8.2.8.3.1 Event Status Register */ +REG64(CXL_DEV_EVENT_STATUS, 0) + FIELD(CXL_DEV_EVENT_STATUS, EVENT_STATUS, 0, 32) +/* CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register */ REG32(CXL_DEV_MAILBOX_CAP, 0)FIELD (CXL_DEV_MAILBOX_CAP ,PAYLOAD_SIZE ,0 ,5 )
include/hw/cxl/cxl_events.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* QEMU CXL Events +* +* Copyright (c) 2022 Intel +* +* This work is licensed under the terms of the GNU GPL, version 2. See the +* COPYING file in the top-level directory. +*/ + +#ifndef CXL_EVENTS_H +#define CXL_EVENTS_H + +/* +* CXL rev 3.0 section 8.2.9.2.2; Table 8-49 +* +* Define these as the bit position for the event status register for ease of +* setting the status. +*/ +typedef enum CXLEventLogType { +CXL_EVENT_TYPE_INFO =0 , +CXL_EVENT_TYPE_WARN =1 , +CXL_EVENT_TYPE_FAIL =2 , +CXL_EVENT_TYPE_FATAL =3 , +CXL_EVENT_TYPE_DYNAMIC_CAP =4 , +CXL_EVENT_TYPE_MAX +}CXLEventLogType ; + +#endif /* CXL_EVENTS_H */
hw/cxl/cxl-device-utils.c +38 -5
65 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v9 2/7 hw/cxl: Move CXLRetCode definition to cxl_device.h
In reply to Jonathan CameronFollowing patches will need access to the mailbox return code type so move it to the header.
--- include/hw/cxl/cxl_device.h | 28 ++++++++++++++++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-)
include/hw/cxl/cxl_device.h +28 -0
@@ -83,6 +83,34 @@ (CXL_DEVICE_CAP_REG_SIZE +CXL_DEVICE_STATUS_REGISTERS_LENGTH + \CXL_MAILBOX_REGISTERS_LENGTH +CXL_MEMORY_DEVICE_REGISTERS_LENGTH ) +/* 8.2.8.4.5.1 Command Return Codes */ +typedef enum { +CXL_MBOX_SUCCESS =0x0 , +CXL_MBOX_BG_STARTED =0x1 , +CXL_MBOX_INVALID_INPUT =0x2 , +CXL_MBOX_UNSUPPORTED =0x3 , +CXL_MBOX_INTERNAL_ERROR =0x4 , +CXL_MBOX_RETRY_REQUIRED =0x5 , +CXL_MBOX_BUSY =0x6 , +CXL_MBOX_MEDIA_DISABLED =0x7 , +CXL_MBOX_FW_XFER_IN_PROGRESS =0x8 , +CXL_MBOX_FW_XFER_OUT_OF_ORDER =0x9 , +CXL_MBOX_FW_AUTH_FAILED =0xa , +CXL_MBOX_FW_INVALID_SLOT =0xb , +CXL_MBOX_FW_ROLLEDBACK =0xc , +CXL_MBOX_FW_REST_REQD =0xd , +CXL_MBOX_INVALID_HANDLE =0xe , +CXL_MBOX_INVALID_PA =0xf , +CXL_MBOX_INJECT_POISON_LIMIT =0x10 , +CXL_MBOX_PERMANENT_MEDIA_FAILURE =0x11 , +CXL_MBOX_ABORTED =0x12 , +CXL_MBOX_INVALID_SECURITY_STATE =0x13 , +CXL_MBOX_INCORRECT_PASSPHRASE =0x14 , +CXL_MBOX_UNSUPPORTED_MAILBOX =0x15 , +CXL_MBOX_INVALID_PAYLOAD_LENGTH =0x16 , +CXL_MBOX_MAX =0x17 +}CXLRetCode ; + typedef struct cxl_device_state { MemoryRegion device_registers;
hw/cxl/cxl-mailbox-utils.c +0 -28
@@ -68,34 +68,6 @@ enum {#define CLEAR_POISON 0x2 }; -/* 8.2.8.4.5.1 Command Return Codes */ -typedef enum { -CXL_MBOX_SUCCESS =0x0 , -CXL_MBOX_BG_STARTED =0x1 , -CXL_MBOX_INVALID_INPUT =0x2 , -CXL_MBOX_UNSUPPORTED =0x3 , -CXL_MBOX_INTERNAL_ERROR =0x4 , -CXL_MBOX_RETRY_REQUIRED =0x5 , -CXL_MBOX_BUSY =0x6 , -CXL_MBOX_MEDIA_DISABLED =0x7 , -CXL_MBOX_FW_XFER_IN_PROGRESS =0x8 , -CXL_MBOX_FW_XFER_OUT_OF_ORDER =0x9 , -CXL_MBOX_FW_AUTH_FAILED =0xa , -CXL_MBOX_FW_INVALID_SLOT =0xb , -CXL_MBOX_FW_ROLLEDBACK =0xc , -CXL_MBOX_FW_REST_REQD =0xd , -CXL_MBOX_INVALID_HANDLE =0xe , -CXL_MBOX_INVALID_PA =0xf , -CXL_MBOX_INJECT_POISON_LIMIT =0x10 , -CXL_MBOX_PERMANENT_MEDIA_FAILURE =0x11 , -CXL_MBOX_ABORTED =0x12 , -CXL_MBOX_INVALID_SECURITY_STATE =0x13 , -CXL_MBOX_INCORRECT_PASSPHRASE =0x14 , -CXL_MBOX_UNSUPPORTED_MAILBOX =0x15 , -CXL_MBOX_INVALID_PAYLOAD_LENGTH =0x16 , -CXL_MBOX_MAX =0x17 -}CXLRetCode ; -struct cxl_cmd ;typedef CXLRetCode (*opcode_handler )(struct cxl_cmd *cmd,CXLDeviceState *cxl_dstate,uint16_t *len);
Signature · 1 line
2.39.2
PATCH v9 3/7 hw/cxl/events: Wire up get/clear event mailbox commands
In reply to Jonathan CameronFrom: Ira Weiny <[email protected]>
CXL testing is benefited from an artificial event log injection mechanism.
Add an event log infrastructure to insert, get, and clear events from the various logs available on a device.
Replace the stubbed out CXL Get/Clear Event mailbox commands with commands that operate on the new infrastructure.
--- include/hw/cxl/cxl_device.h | 25 +++++ include/hw/cxl/cxl_events.h | 55 +++++++++ hw/cxl/cxl-events.c | 217 ++++++++++++++++++++++++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 40 ++++++- hw/mem/cxl_type3.c | 1 + hw/cxl/meson.build | 1 + 6 files changed, 337 insertions(+), 2 deletions(-)
include/hw/cxl/cxl_device.h +25 -0
@@ -111,6 +111,20 @@ typedef enum { CXL_MBOX_MAX = 0x17 } CXLRetCode; +typedef struct CXLEvent { +CXLEventRecordRaw data; +QSIMPLEQ_ENTRY (CXLEvent) node; +}CXLEvent ; + +typedef struct CXLEventLog { +uint16_t next_handle; +uint16_t overflow_err_count; +uint64_t first_overflow_timestamp; +uint64_t last_overflow_timestamp; +QemuMutex lock; + QSIMPLEQ_HEAD(, CXLEvent) events; +}CXLEventLog ; + typedef struct cxl_device_state { MemoryRegion device_registers;
@@ -161,6 +175,8 @@ typedef struct cxl_device_state {uint64_t mem_size;uint64_t pmem_size;uint64_t vmem_size; + +CXLEventLog event_logs[CXL_EVENT_TYPE_MAX ]; } CXLDeviceState;/* Initialize the register block for a device */
@@ -353,6 +369,15 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data,uint64_t cxl_device_get_timestamp (CXLDeviceState *cxlds); +void cxl_event_init (CXLDeviceState *cxlds); +bool cxl_event_insert (CXLDeviceState *cxlds,CXLEventLogType log_type, +CXLEventRecordRaw *event); +CXLRetCode cxl_event_get_records (CXLDeviceState *cxlds,CXLGetEventPayload *pl, +uint8_t log_type,int max_recs, +uint16_t *len); +CXLRetCode cxl_event_clear_records (CXLDeviceState *cxlds, +CXLClearEventPayload *pl); +void cxl_set_poison_list_overflowed (CXLType3Dev *ct3d);#endif
include/hw/cxl/cxl_events.h +55 -0
65 lines not on this page · raw message
hw/cxl/cxl-events.c new file +217 -0
217 lines not on this page · raw message
hw/cxl/cxl-mailbox-utils.c +38 -2
@@ -9,6 +9,7 @@#include "qemu/osdep.h" #include "hw/cxl/cxl.h" +#include "hw/cxl/cxl_events.h" #include "hw/pci/pci.h" #include "qemu/cutils.h" #include "qemu/log.h"
@@ -95,11 +96,46 @@ struct cxl_cmd {return CXL_MBOX_SUCCESS ; \ } -DEFINE_MAILBOX_HANDLER_ZEROED (events_get_records,0x20 ); -DEFINE_MAILBOX_HANDLER_NOP (events_clear_records);DEFINE_MAILBOX_HANDLER_ZEROED (events_get_interrupt_policy,4 );DEFINE_MAILBOX_HANDLER_NOP (events_set_interrupt_policy); +static CXLRetCode cmd_events_get_records (struct cxl_cmd *cmd, +CXLDeviceState *cxlds, +uint16_t *len) +{ +CXLGetEventPayload *pl; +uint8_t log_type; +int max_recs; + +if (cmd->in <sizeof (log_type)) { +return CXL_MBOX_INVALID_INPUT ; + } + + log_type = *((uint8_t *)cmd->payload); + + pl = (CXLGetEventPayload *)cmd->payload; +memset (pl,0 ,sizeof (*pl)); + + max_recs = (cxlds->payload_size -CXL_EVENT_PAYLOAD_HDR_SIZE ) / +CXL_EVENT_RECORD_SIZE ; +if (max_recs >0xFFFF ) { + max_recs =0xFFFF ; + } + +return cxl_event_get_records (cxlds, pl, log_type, max_recs, len); +} + +static CXLRetCode cmd_events_clear_records (struct cxl_cmd *cmd, +CXLDeviceState *cxlds, +uint16_t *len) +{ +CXLClearEventPayload *pl; + + pl = (CXLClearEventPayload *)cmd->payload; + *len =0 ; +return cxl_event_clear_records (cxlds, pl); +} +/* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(struct cxl_cmd *cmd, CXLDeviceState *cxl_dstate,
hw/mem/cxl_type3.c +1 -0
@@ -724,6 +724,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) goto err_release_cdat; } +cxl_event_init (&ct3d->cxl_dstate);return ; err_release_cdat:
hw/cxl/meson.build +1 -0
@@ -5,6 +5,7 @@ softmmu_ss.add(when: 'CONFIG_CXL', 'cxl-mailbox-utils.c', 'cxl-host.c', 'cxl-cdat.c', + 'cxl-events.c', ), if_false: files( 'cxl-host-stubs.c',
Signature · 1 line
2.39.2
PATCH v9 4/7 hw/cxl/events: Add event interrupt support
In reply to Jonathan CameronFrom: Ira Weiny <[email protected]>
Replace the stubbed out CXL Get/Set Event interrupt policy mailbox commands. Enable those commands to control interrupts for each of the event log types.
Skip the standard input mailbox length on the Set command due to DCD being optional. Perform the checks separately.
--- include/hw/cxl/cxl_device.h | 6 +- include/hw/cxl/cxl_events.h | 23 ++++++++ hw/cxl/cxl-events.c | 33 ++++++++++- hw/cxl/cxl-mailbox-utils.c | 106 +++++++++++++++++++++++++++++------- hw/mem/cxl_type3.c | 4 +- 5 files changed, 147 insertions(+), 25 deletions(-)
include/hw/cxl/cxl_device.h +5 -1
@@ -121,6 +121,8 @@ typedef struct CXLEventLog {uint16_t overflow_err_count;uint64_t first_overflow_timestamp;uint64_t last_overflow_timestamp; +bool irq_enabled; +int irq_vec;QemuMutex lock; QSIMPLEQ_HEAD(, CXLEvent) events; } CXLEventLog;
@@ -369,7 +371,7 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data,uint64_t cxl_device_get_timestamp (CXLDeviceState *cxlds); -void cxl_event_init (CXLDeviceState *cxlds); +void cxl_event_init (CXLDeviceState *cxlds,int start_msg_num);bool cxl_event_insert (CXLDeviceState *cxlds,CXLEventLogType log_type,CXLEventRecordRaw *event); CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl,
@@ -378,6 +380,8 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl,CXLRetCode cxl_event_clear_records (CXLDeviceState *cxlds,CXLClearEventPayload *pl); +void cxl_event_irq_assert (CXLType3Dev *ct3d); +void cxl_set_poison_list_overflowed (CXLType3Dev *ct3d);#endif
include/hw/cxl/cxl_events.h +23 -0
@@ -80,4 +80,27 @@ typedef struct CXLClearEventPayload {uint16_t handle[]; } CXLClearEventPayload; +/** +* Event Interrupt Policy +* +* CXL rev 3.0 section 8.2.9.2.4; Table 8-52 +*/ +typedef enum CXLEventIntMode { +CXL_INT_NONE =0x00 , +CXL_INT_MSI_MSIX =0x01 , +CXL_INT_FW =0x02 , +CXL_INT_RES =0x03 , +}CXLEventIntMode ; +#define CXL_EVENT_INT_MODE_MASK 0x3 +#define CXL_EVENT_INT_SETTING (vector) ((((uint8_t)vector & 0xf) << 4) | CXL_INT_MSI_MSIX) +typedef struct CXLEventInterruptPolicy { +uint8_t info_settings; +uint8_t warn_settings; +uint8_t failure_settings; +uint8_t fatal_settings; +uint8_t dyn_cap_settings; +} QEMU_PACKED CXLEventInterruptPolicy; +/* DCD is optional but other fields are not */ +#define CXL_EVENT_INT_SETTING_MIN_LEN 4 +#endif /* CXL_EVENTS_H */
hw/cxl/cxl-events.c +32 -1
@@ -13,6 +13,8 @@#include "qemu/bswap.h" #include "qemu/typedefs.h" #include "qemu/error-report.h" +#include "hw/pci/msi.h" +#include "hw/pci/msix.h" #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h"
@@ -26,7 +28,7 @@ static void reset_overflow(CXLEventLog *log) log->last_overflow_timestamp =0 ; } -void cxl_event_init (CXLDeviceState *cxlds) +void cxl_event_init (CXLDeviceState *cxlds,int start_msg_num) {CXLEventLog *log;int i;
@@ -37,9 +39,16 @@ void cxl_event_init(CXLDeviceState *cxlds) log->overflow_err_count =0 ; log->first_overflow_timestamp =0 ; log->last_overflow_timestamp =0 ; + log->irq_enabled = false; + log->irq_vec = start_msg_num++;qemu_mutex_init (&log->lock);QSIMPLEQ_INIT (&log->events); } + +/* Override -- Dynamic Capacity uses the same vector as info */ + cxlds->event_logs[CXL_EVENT_TYPE_DYNAMIC_CAP ].irq_vec = + cxlds->event_logs[CXL_EVENT_TYPE_INFO ].irq_vec; + }static CXLEvent *cxl_event_get_head (CXLEventLog *log)
@@ -215,3 +224,25 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPayload *return CXL_MBOX_SUCCESS ; } + +void cxl_event_irq_assert (CXLType3Dev *ct3d) +{ +CXLDeviceState *cxlds = &ct3d->cxl_dstate; +PCIDevice *pdev = &ct3d->parent_obj; +int i; + +for (i =0 ; i <CXL_EVENT_TYPE_MAX ; i++) { +CXLEventLog *log = &cxlds->event_logs[i]; + +if (!log->irq_enabled ||cxl_event_empty (log)) { +continue ; + } + +/* Notifies interrupt, legacy IRQ is not supported */ +if (msix_enabled (pdev)) { +msix_notify (pdev, log->irq_vec); + }else if (msi_enabled (pdev)) { +msi_notify (pdev, log->irq_vec); + } + } +}
hw/cxl/cxl-mailbox-utils.c +85 -21
125 lines not on this page · raw message
hw/mem/cxl_type3.c +2 -2
@@ -659,7 +659,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)ComponentRegisters *regs = &cxl_cstate->crb;MemoryRegion *mr = ®s->component_registers;uint8_t *pci_conf = pci_dev->config; -unsigned short msix_num =1 ; +unsigned short msix_num =6 ;int i, rc;QTAILQ_INIT (&ct3d->error_list);
@@ -723,8 +723,8 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)if (rc) { goto err_release_cdat; } +cxl_event_init (&ct3d->cxl_dstate,2 ); -cxl_event_init (&ct3d->cxl_dstate);return ; err_release_cdat:
Signature · 1 line
2.39.2
PATCH v9 5/7 hw/cxl/events: Add injection of General Media Events
In reply to Jonathan CameronFrom: Ira Weiny <[email protected]>
To facilitate testing provide a QMP command to inject a general media event. The event can be added to the log specified.
---
v9: Double space after . for consistency.
--- qapi/cxl.json | 74 ++++++++++++++++++++++++ include/hw/cxl/cxl_events.h | 20 +++++++ hw/mem/cxl_type3.c | 111 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 10 ++++ 4 files changed, 215 insertions(+)
qapi/cxl.json +74 -0
@@ -5,6 +5,80 @@ # = CXL devices ## +## +# @CxlEventLog: +# +# CXL has a number of separate event logs for different types of +# events. Each such event log is handled and signaled independently. +# +# @informational: Information Event Log +# +# @warning: Warning Event Log +# +# @failure: Failure Event Log +# +# @fatal: Fatal Event Log +# +# Since: 8.1 +## +{ 'enum': 'CxlEventLog', + 'data': ['informational', + 'warning', + 'failure', + 'fatal'] + } + +## +# @cxl-inject-general-media-event: +# +# Inject an event record for a General Media Event (CXL r3.0 +# 8.2.9.2.1.1). This event type is reported via one of the event logs +# specified via the log parameter. +# +# @path: CXL type 3 device canonical QOM path +# +# @log: event log to add the event to +# +# @flags: Event Record Flags. See CXL r3.0 Table 8-42 Common Event +# Record Format, Event Record Flags for subfield definitions. +# +# @dpa: Device Physical Address (relative to @path device). Note +# lower bits include some flags. See CXL r3.0 Table 8-43 General +# Media Event Record, Physical Address. +# +# @descriptor: Memory Event Descriptor with additional memory event +# information. See CXL r3.0 Table 8-43 General Media Event +# Record, Memory Event Descriptor for bit definitions. +# +# @type: Type of memory event that occurred. See CXL r3.0 Table 8-43 +# General Media Event Record, Memory Event Type for possible +# values. +# +# @transaction-type: Type of first transaction that caused the event +# to occur. See CXL r3.0 Table 8-43 General Media Event Record, +# Transaction Type for possible values. +# +# @channel: The channel of the memory event location. A channel is an +# interface that can be independently accessed for a transaction. +# +# @rank: The rank of the memory event location. A rank is a set of +# memory devices on a channel that together execute a transaction. +# +# @device: Bitmask that represents all devices in the rank associated +# with the memory event location. +# +# @component-id: Device specific component identifier for the event. +# May describe a field replaceable sub-component of the device. +# +# Since: 8.1 +## +{ 'command': 'cxl-inject-general-media-event', + 'data': { 'path': 'str', 'log': 'CxlEventLog', 'flags': 'uint8', + 'dpa': 'uint64', 'descriptor': 'uint8', + 'type': 'uint8', 'transaction-type': 'uint8', + '*channel': 'uint8', '*rank': 'uint8', + '*device': 'uint32', '*component-id': 'str' } } + ## # @cxl-inject-poison: #
include/hw/cxl/cxl_events.h +20 -0
@@ -103,4 +103,24 @@ typedef struct CXLEventInterruptPolicy {/* DCD is optional but other fields are not */ #define CXL_EVENT_INT_SETTING_MIN_LEN 4 +/* +* General Media Event Record +* CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 +*/ +#define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10 +#define CXL_EVENT_GEN_MED_RES_SIZE 0x2e +typedef struct CXLEventGenMedia { +CXLEventRecordHdr hdr; +uint64_t phys_addr; +uint8_t descriptor; +uint8_t type; +uint8_t transaction_type; +uint16_t validity_flags; +uint8_t channel; +uint8_t rank; +uint8_t device[3 ]; +uint8_t component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE ]; +uint8_t reserved[CXL_EVENT_GEN_MED_RES_SIZE ]; +} QEMU_PACKED CXLEventGenMedia; +#endif /* CXL_EVENTS_H */
hw/mem/cxl_type3.c +111 -0
117 lines not on this page · raw message
hw/mem/cxl_type3_stubs.c +10 -0
@@ -3,6 +3,16 @@#include "qapi/error.h" #include "qapi/qapi-commands-cxl.h" +void qmp_cxl_inject_general_media_event (const char *path,CxlEventLog log, +uint8_t flags,uint64_t dpa, +uint8_t descriptor,uint8_t type, +uint8_t transaction_type, +bool has_channel,uint8_t channel, +bool has_rank,uint8_t rank, +bool has_device,uint32_t device, +const char *component_id, +Error **errp) {} +void qmp_cxl_inject_poison (const char *path,uint64_t start,uint64_t length,Error **errp) {
Signature · 1 line
2.39.2
PATCH v9 6/7 hw/cxl/events: Add injection of DRAM events
In reply to Jonathan CameronDefined in CXL r3.0 8.2.9.2.1.2 DRAM Event Record, this event provides information related to DRAM devices.
Example injection command in QMP:
{ "execute": "cxl-inject-dram-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"dpa": 1000,
"descriptor": 3,
"type": 3,
"transaction-type": 192,
"channel": 3,
"rank": 17,
"nibble-mask": 37421234,
"bank-group": 7,
"bank": 11,
"row": 2,
"column": 77,
"correction-mask": [33, 44, 55,66]
}}--- qapi/cxl.json | 61 +++++++++++++++++++ include/hw/cxl/cxl_events.h | 23 +++++++ hw/mem/cxl_type3.c | 116 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 13 ++++ 4 files changed, 213 insertions(+)
qapi/cxl.json +61 -0
@@ -79,6 +79,67 @@ '*channel': 'uint8', '*rank': 'uint8', '*device': 'uint32', '*component-id': 'str' } } +## +# @cxl-inject-dram-event: +# +# Inject an event record for a DRAM Event (CXL r3.0 8.2.9.2.1.2). +# This event type is reported via one of the event logs specified via +# the log parameter. +# +# @path: CXL type 3 device canonical QOM path +# +# @log: Event log to add the event to +# +# @flags: Event Record Flags. See CXL r3.0 Table 8-42 Common Event +# Record Format, Event Record Flags for subfield definitions. +# +# @dpa: Device Physical Address (relative to @path device). Note +# lower bits include some flags. See CXL r3.0 Table 8-44 DRAM +# Event Record, Physical Address. +# +# @descriptor: Memory Event Descriptor with additional memory event +# information. See CXL r3.0 Table 8-44 DRAM Event Record, Memory +# Event Descriptor for bit definitions. +# +# @type: Type of memory event that occurred. See CXL r3.0 Table 8-44 +# DRAM Event Record, Memory Event Type for possible values. +# +# @transaction-type: Type of first transaction that caused the event +# to occur. See CXL r3.0 Table 8-44 DRAM Event Record, +# Transaction Type for possible values. +# +# @channel: The channel of the memory event location. A channel is an +# interface that can be independently accessed for a transaction. +# +# @rank: The rank of the memory event location. A rank is a set of +# memory devices on a channel that together execute a transaction. +# +# @nibble-mask: Identifies one or more nibbles that the error affects +# +# @bank-group: Bank group of the memory event location, incorporating +# a number of Banks. +# +# @bank: Bank of the memory event location. A single bank is accessed +# per read or write of the memory. +# +# @row: Row address within the DRAM. +# +# @column: Column address within the DRAM. +# +# @correction-mask: Bits within each nibble. Used in order of bits +# set in the nibble-mask. Up to 4 nibbles may be covered. +# +# Since: 8.1 +## +{ 'command': 'cxl-inject-dram-event', + 'data': { 'path': 'str', 'log': 'CxlEventLog', 'flags': 'uint8', + 'dpa': 'uint64', 'descriptor': 'uint8', + 'type': 'uint8', 'transaction-type': 'uint8', + '*channel': 'uint8', '*rank': 'uint8', '*nibble-mask': 'uint32', + '*bank-group': 'uint8', '*bank': 'uint8', '*row': 'uint32', + '*column': 'uint16', '*correction-mask': [ 'uint64' ] + }} + ## # @cxl-inject-poison: #
include/hw/cxl/cxl_events.h +23 -0
@@ -123,4 +123,27 @@ typedef struct CXLEventGenMedia {uint8_t reserved[CXL_EVENT_GEN_MED_RES_SIZE ]; } QEMU_PACKED CXLEventGenMedia; +/* +* DRAM Event Record +* CXL Rev 3.0 Section 8.2.9.2.1.2: Table 8-44 +* All fields little endian. +*/ +typedef struct CXLEventDram { +CXLEventRecordHdr hdr; +uint64_t phys_addr; +uint8_t descriptor; +uint8_t type; +uint8_t transaction_type; +uint16_t validity_flags; +uint8_t channel; +uint8_t rank; +uint8_t nibble_mask[3 ]; +uint8_t bank_group; +uint8_t bank; +uint8_t row[3 ]; +uint16_t column; +uint64_t correction_mask[4 ]; +uint8_t reserved[0x17 ]; +} QEMU_PACKED CXLEventDram; +#endif /* CXL_EVENTS_H */
hw/mem/cxl_type3.c +116 -0
128 lines not on this page · raw message
hw/mem/cxl_type3_stubs.c +13 -0
@@ -13,6 +13,19 @@ void qmp_cxl_inject_general_media_event(const char *path, CxlEventLog log, const char *component_id, Error **errp) {} +void qmp_cxl_inject_dram_event(const char *path, CxlEventLog log, uint8_t flags, + uint64_t dpa, uint8_t descriptor, + uint8_t type, uint8_t transaction_type, + bool has_channel, uint8_t channel, + bool has_rank, uint8_t rank, + bool has_nibble_mask, uint32_t nibble_mask, + bool has_bank_group, uint8_t bank_group, + bool has_bank, uint8_t bank, + bool has_row, uint32_t row, + bool has_column, uint16_t column, + bool has_correction_mask, uint64List *correction_mask, + Error **errp) {} + void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, Error **errp) {
Signature · 1 line
2.39.2
PATCH v9 7/7 hw/cxl/events: Add injection of Memory Module Events
In reply to Jonathan CameronThese events include a copy of the device health information at the time of the event. Actually using the emulated device health would require a lot of controls to manipulate that state. Given the aim of this injection code is to just test the flows when events occur, inject the contents of the device health state as well.
Future work may add more sophisticate device health emulation including direct generation of these records when events occur (such as a temperature threshold being crossed). That does not reduce the usefulness of this more basic generation of the events.
---
v9:
- Double space after . for consistency.
- Missing 'of'
--- qapi/cxl.json | 53 +++++++++++++++++++++++++++++++ include/hw/cxl/cxl_events.h | 19 ++++++++++++ hw/mem/cxl_type3.c | 62 +++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 12 +++++++ 4 files changed, 146 insertions(+)
qapi/cxl.json +53 -0
@@ -140,6 +140,59 @@ '*column': 'uint16', '*correction-mask': [ 'uint64' ] }} +## +# @cxl-inject-memory-module-event: +# +# Inject an event record for a Memory Module Event (CXL r3.0 +# 8.2.9.2.1.3). This event includes a copy of the Device Health +# info at the time of the event. +# +# @path: CXL type 3 device canonical QOM path +# +# @log: Event Log to add the event to +# +# @flags: Event Record Flags. See CXL r3.0 Table 8-42 Common Event +# Record Format, Event Record Flags for subfield definitions. +# +# @type: Device Event Type. See CXL r3.0 Table 8-45 Memory Module +# Event Record for bit definitions for bit definiions. +# +# @health-status: Overall health summary bitmap. See CXL r3.0 Table +# 8-100 Get Health Info Output Payload, Health Status for bit +# definitions. +# +# @media-status: Overall media health summary. See CXL r3.0 Table +# 8-100 Get Health Info Output Payload, Media Status for bit +# definitions. +# +# @additional-status: See CXL r3.0 Table 8-100 Get Health Info Output +# Payload, Additional Status for subfield definitions. +# +# @life-used: Percentage (0-100) of factory expected life span. +# +# @temperature: Device temperature in degrees Celsius. +# +# @dirty-shutdown-count: Number of times the device has been unable +# to determine whether data loss may have occurred. +# +# @corrected-volatile-error-count: Total number of correctable errors +# in volatile memory. +# +# @corrected-persistent-error-count: Total number of correctable +# errors in persistent memory +# +# Since: 8.1 +## +{ 'command': 'cxl-inject-memory-module-event', + 'data': { 'path': 'str', 'log': 'CxlEventLog', 'flags' : 'uint8', + 'type': 'uint8', 'health-status': 'uint8', + 'media-status': 'uint8', 'additional-status': 'uint8', + 'life-used': 'uint8', 'temperature' : 'int16', + 'dirty-shutdown-count': 'uint32', + 'corrected-volatile-error-count': 'uint32', + 'corrected-persistent-error-count': 'uint32' + }} + ## # @cxl-inject-poison: #
include/hw/cxl/cxl_events.h +19 -0
@@ -146,4 +146,23 @@ typedef struct CXLEventDram {uint8_t reserved[0x17 ]; } QEMU_PACKED CXLEventDram; +/* +* Memory Module Event Record +* CXL Rev 3.0 Section 8.2.9.2.1.3: Table 8-45 +* All fields little endian. +*/ +typedef struct CXLEventMemoryModule { +CXLEventRecordHdr hdr; +uint8_t type; +uint8_t health_status; +uint8_t media_status; +uint8_t additional_status; +uint8_t life_used; +int16_t temperature; +uint32_t dirty_shutdown_count; +uint32_t corrected_volatile_error_count; +uint32_t corrected_persistent_error_count; +uint8_t reserved[0x3d ]; +} QEMU_PACKED CXLEventMemoryModule; +#endif /* CXL_EVENTS_H */
hw/mem/cxl_type3.c +62 -0
74 lines not on this page · raw message
hw/mem/cxl_type3_stubs.c +12 -0
@@ -26,6 +26,18 @@ void qmp_cxl_inject_dram_event(const char *path, CxlEventLog log, uint8_t flags, bool has_correction_mask, uint64List *correction_mask, Error **errp) {} +void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log, + uint8_t flags, uint8_t type, + uint8_t health_status, + uint8_t media_status, + uint8_t additional_status, + uint8_t life_used, + int16_t temperature, + uint32_t dirty_shutdown_count, + uint32_t corrected_volatile_error_count, + uint32_t corrected_persistent_error_count, + Error **errp) {} + void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, Error **errp) {
Signature · 1 line
2.39.2
Hello, Jonathan
When during the test of qmps of CXL events like "cxl-inject-general-media-event", I am confuesd about the argument "flags". According to "qapi/cxl.json" in qemu, this argument represents "Event Record Flags" in Common Event Record Format. However, it seems like the specific 'Event Record Severity' in this field can be different from the value of 'Event Status' in "Event Status Register".
For instance (take an injection example in the coverlatter):
{ "execute": "cxl-inject-general-media-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"dpa": 1000,
"descriptor": 3,
"type": 3,
"transaction-type": 192,
"channel": 3,
"device": 5,
"component-id": "iras mem"
}}In my understanding, the 'Event Status' is informational and the 'Event Record Severity' is Warning event, which means these two arguments are independent of each other. Is my understanding correct?
Many thanks
Yuquan
Quoted 24 lines · On Fri, 15 Mar 2024 09:52:28 +0800 Yuquan Wang <[email protected]>…
Hello, Jonathan
When during the test of qmps of CXL events like "cxl-inject-general-media-event", I am confuesd about the argument "flags". According to "
qapi/cxl.json" in qemu, this argument represents "Event Record Flags" in Common Event Record Format. However, it seems like the specific 'Event Record Severity' in this field can be different from the value of 'Event Status' in "Event Status Register".For instance (take an injection example in the coverlatter):
{ "execute": "cxl-inject-general-media-event",
"arguments": { "path": "/machine/peripheral/cxl-mem0", "log": "informational", "flags": 1, "dpa": 1000, "descriptor": 3, "type": 3, "transaction-type": 192, "channel": 3, "device": 5, "component-id": "iras mem" }}
Quoted 3 lines
In my understanding, the 'Event Status' is informational and the 'Event Record Severity' is Warning event, which means these two arguments are independent of each other. Is my understanding correct?
The event status registers dictates the notification path (which log). So I think that's "informational" here.
Whereas flags is about the specific error. One case where they might be different is where the Related Event Record Handle is set.
An error might be reported as
1) Several things that were non fatal (each with their own record)
2) In combination they result in a fatal situation (also has it's own record).
The QEMU injection shouldn't restrict these combinations more than the spec does (which is not at all!).
This same disconnect in error severity is seen in UEFI CPER records for example where there is a containing record with one severity field, but more specific parts of record can have lower (or in theory higher) severity.
Jonathan
Quoted 4 lines
Many thanks
Yuquan