QEMU/CXL: A few more fixes for 7.1 related to LSA
cover QEMU/CXL: A few more fixes for 7.1 related to LSA
The recent addition of CXL Region setup to the 6.0-rc1 Linux kernel has allowed us to test a few paths that weren't exercised fully until now. That threw up a mixture of bugs in QEMU emulation and the kernel (kernel fixes already posted).
The first patch is down to a wrong assumption about RO MemoryRegions and was hit due to a kernel bug overruning the mailbox and into another register region. Kernel bug fix:
https://lore.kernel.org/linux-cxl/[email protected]
The later 2 have shown up because the Get / Set LSA commands have started getting proper user in the kernel.
With these fixes in place I've tested an 8 way interleave on a host bridge to directly connected CXL devices and zeroed LSA regions. On that we can bring up a CXL region on which we can create an fsdax namespace and make a filesystem. For now, the cookie used to identify device for re establishing that region/namespace will be 0. A new feature patch will follow that will add the ability to provide the necessary serial numbers for correct namespace cookie creation allowing the namespace/filesystem to be remounted after a full restart.
Jonathan Cameron (3):
hw/cxl: Add stub write function for RO MemoryRegionOps entries. hw/cxl: Fix Get LSA input payload size which should be 8 bytes. hw/cxl: Correctly handle variable sized mailbox input payloads.
hw/cxl/cxl-device-utils.c | 12 +++++++++--- hw/cxl/cxl-mailbox-utils.c | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/3 hw/cxl: Add stub write function for RO MemoryRegionOps entries.
There is no checking on the availability of a write callback. Hence QEMU crashes if a write does occur to one of these regions.
Discovered whilst chasing a Linux kernel bug that incorrectly wrote into one of these regions.
--- hw/cxl/cxl-device-utils.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
hw/cxl/cxl-device-utils.c +9 -3
@@ -141,9 +141,15 @@ static uint64_t mdev_reg_read(void *opaque, hwaddr offset, unsigned size)return retval; } +static void ro_reg_write (void *opaque,hwaddr offset,uint64_t value, +unsigned size) +{ +/* Many register sets are read only */ +} +static const MemoryRegionOps mdev_ops = { .read = mdev_reg_read, - .write =NULL ,/* memory device register is read only */ + .write = ro_reg_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =1 ,
@@ -173,7 +179,7 @@ static const MemoryRegionOps mailbox_ops = {static const MemoryRegionOps dev_ops = { .read = dev_reg_read, - .write =NULL ,/* status register is read only */ + .write = ro_reg_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =1 ,
@@ -188,7 +194,7 @@ static const MemoryRegionOps dev_ops = {static const MemoryRegionOps caps_ops = { .read = caps_reg_read, - .write =NULL ,/* caps registers are read only */ + .write = ro_reg_write, .endianness =DEVICE_LITTLE_ENDIAN , .valid = { .min_access_size =1 ,
Signature · 1 line
2.32.0
PATCH 2/3 hw/cxl: Fix Get LSA input payload size which should be 8 bytes.
In reply to Jonathan CameronGet LSA needs 4 byte offset and 4 byte length arguments. CXL rev 2.0 Table 178.
--- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/cxl/cxl-mailbox-utils.c +1 -1
@@ -406,7 +406,7 @@ static struct cxl_cmd cxl_cmd_set[256][256] = { cmd_identify_memory_device, 0, 0 }, [CCLS][GET_PARTITION_INFO] = { "CCLS_GET_PARTITION_INFO", cmd_ccls_get_partition_info, 0, 0 }, - [CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 0, 0 }, + [CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 }, [CCLS][SET_LSA] = { "CCLS_SET_LSA", cmd_ccls_set_lsa, ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, };
Signature · 1 line
2.32.0
PATCH 3/3 hw/cxl: Correctly handle variable sized mailbox input payloads.
In reply to Jonathan CameronA placeholder of ~0 is used to indicate variable payload size. Whilst the checks for output payload correctly took this into account, those for input payload did not.
This results in failure of the Set LSA command.
--- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/cxl/cxl-mailbox-utils.c +1 -1
@@ -425,7 +425,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) cxl_cmd = &cxl_cmd_set[set][cmd]; h = cxl_cmd->handler;if (h) { -if (len == cxl_cmd->in) { +if (len == cxl_cmd->in || cxl_cmd->in == ~0 ) { cxl_cmd->payload = cxl_dstate->mbox_reg_state +A_CXL_DEV_CMD_PAYLOAD ; ret = (*h)(cxl_cmd, cxl_dstate, &len);
Signature · 1 line
2.32.0