[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/53] hw/cxl: Add poison injection via the mailbox.
From: |
Michael S. Tsirkin |
Subject: |
[PULL 03/53] hw/cxl: Add poison injection via the mailbox. |
Date: |
Mon, 26 Jun 2023 08:27:55 -0400 |
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Very simple implementation to allow testing of corresponding
kernel code. Note that for now we track each 64 byte section
independently. Whilst a valid implementation choice, it may
make sense to fuse entries so as to prove out more complex
corners of the kernel code.
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20230526170010.574-4-Jonathan.Cameron@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/cxl/cxl-mailbox-utils.c | 42 ++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 1f74b26ea2..6c476ad7f4 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -64,6 +64,7 @@ enum {
#define SET_LSA 0x3
MEDIA_AND_POISON = 0x43,
#define GET_POISON_LIST 0x0
+ #define INJECT_POISON 0x1
};
/* 8.2.8.4.5.1 Command Return Codes */
@@ -472,6 +473,45 @@ static CXLRetCode cmd_media_get_poison_list(struct cxl_cmd
*cmd,
return CXL_MBOX_SUCCESS;
}
+static CXLRetCode cmd_media_inject_poison(struct cxl_cmd *cmd,
+ CXLDeviceState *cxl_dstate,
+ uint16_t *len_unused)
+{
+ CXLType3Dev *ct3d = container_of(cxl_dstate, CXLType3Dev, cxl_dstate);
+ CXLPoisonList *poison_list = &ct3d->poison_list;
+ CXLPoison *ent;
+ struct inject_poison_pl {
+ uint64_t dpa;
+ };
+ struct inject_poison_pl *in = (void *)cmd->payload;
+ uint64_t dpa = ldq_le_p(&in->dpa);
+ CXLPoison *p;
+
+ QLIST_FOREACH(ent, poison_list, node) {
+ if (dpa >= ent->start &&
+ dpa + CXL_CACHE_LINE_SIZE <= ent->start + ent->length) {
+ return CXL_MBOX_SUCCESS;
+ }
+ }
+
+ if (ct3d->poison_list_cnt == CXL_POISON_LIST_LIMIT) {
+ return CXL_MBOX_INJECT_POISON_LIMIT;
+ }
+ p = g_new0(CXLPoison, 1);
+
+ p->length = CXL_CACHE_LINE_SIZE;
+ p->start = dpa;
+ p->type = CXL_POISON_TYPE_INJECTED;
+
+ /*
+ * Possible todo: Merge with existing entry if next to it and if same type
+ */
+ QLIST_INSERT_HEAD(poison_list, p, node);
+ ct3d->poison_list_cnt++;
+
+ return CXL_MBOX_SUCCESS;
+}
+
#define IMMEDIATE_CONFIG_CHANGE (1 << 1)
#define IMMEDIATE_DATA_CHANGE (1 << 2)
#define IMMEDIATE_POLICY_CHANGE (1 << 3)
@@ -501,6 +541,8 @@ static struct cxl_cmd cxl_cmd_set[256][256] = {
~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE },
[MEDIA_AND_POISON][GET_POISON_LIST] = { "MEDIA_AND_POISON_GET_POISON_LIST",
cmd_media_get_poison_list, 16, 0 },
+ [MEDIA_AND_POISON][INJECT_POISON] = { "MEDIA_AND_POISON_INJECT_POISON",
+ cmd_media_inject_poison, 8, 0 },
};
void cxl_process_mailbox(CXLDeviceState *cxl_dstate)
--
MST
- [PULL 00/53] virtio,pc,pci: fixes, features, cleanups, Michael S. Tsirkin, 2023/06/26
- [PULL 01/53] bswap: Add the ability to store to an unaligned 24 bit field, Michael S. Tsirkin, 2023/06/26
- [PULL 02/53] hw/cxl: QMP based poison injection support, Michael S. Tsirkin, 2023/06/26
- [PULL 03/53] hw/cxl: Add poison injection via the mailbox.,
Michael S. Tsirkin <=
- [PULL 04/53] hw/cxl: Add clear poison mailbox command support., Michael S. Tsirkin, 2023/06/26
- [PULL 05/53] hw/cxl/events: Add event status register, Michael S. Tsirkin, 2023/06/26
- [PULL 06/53] hw/cxl: Move CXLRetCode definition to cxl_device.h, Michael S. Tsirkin, 2023/06/26
- [PULL 07/53] hw/cxl/events: Wire up get/clear event mailbox commands, Michael S. Tsirkin, 2023/06/26
- [PULL 08/53] hw/cxl/events: Add event interrupt support, Michael S. Tsirkin, 2023/06/26
- [PULL 09/53] hw/cxl/events: Add injection of General Media Events, Michael S. Tsirkin, 2023/06/26
- [PULL 10/53] hw/cxl/events: Add injection of DRAM events, Michael S. Tsirkin, 2023/06/26
- [PULL 11/53] hw/cxl/events: Add injection of Memory Module Events, Michael S. Tsirkin, 2023/06/26
- [PULL 12/53] cryptodev-vhost-user: add asymmetric crypto support, Michael S. Tsirkin, 2023/06/26
- [PULL 13/53] softmmu: Introduce qemu_target_page_mask() helper, Michael S. Tsirkin, 2023/06/26