Linux CXL
 help / color / mirror / Atom feed
* [PATCH 0/3] QEMU/CXL: A few more fixes for 7.1 related to LSA
@ 2022-08-17 14:57 Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries Jonathan Cameron
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-08-17 14:57 UTC (permalink / raw)
  To: qemu-devel, Michael S . Tsirkin, Peter Maydell, Igor Mammedov
  Cc: linux-cxl, linuxarm, Shameerali Kolothum Thodi, Ben Widawsky,
	Paolo Bonzini

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/20220815154044.24733-1-Jonathan.Cameron@huawei.com

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(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries.
  2022-08-17 14:57 [PATCH 0/3] QEMU/CXL: A few more fixes for 7.1 related to LSA Jonathan Cameron
@ 2022-08-17 14:57 ` Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 2/3] hw/cxl: Fix Get LSA input payload size which should be 8 bytes Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 3/3] hw/cxl: Correctly handle variable sized mailbox input payloads Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-08-17 14:57 UTC (permalink / raw)
  To: qemu-devel, Michael S . Tsirkin, Peter Maydell, Igor Mammedov
  Cc: linux-cxl, linuxarm, Shameerali Kolothum Thodi, Ben Widawsky,
	Paolo Bonzini

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.

Fixes: 6364adacdf ("hw/cxl/device: Implement the CAP array (8.2.8.1-2)")
Reported-by: Bobo WL <lmw.bobo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 hw/cxl/cxl-device-utils.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c
index 687759b301..83ce7a8270 100644
--- a/hw/cxl/cxl-device-utils.c
+++ b/hw/cxl/cxl-device-utils.c
@@ -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,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] hw/cxl: Fix Get LSA input payload size which should be 8 bytes.
  2022-08-17 14:57 [PATCH 0/3] QEMU/CXL: A few more fixes for 7.1 related to LSA Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries Jonathan Cameron
@ 2022-08-17 14:57 ` Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 3/3] hw/cxl: Correctly handle variable sized mailbox input payloads Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-08-17 14:57 UTC (permalink / raw)
  To: qemu-devel, Michael S . Tsirkin, Peter Maydell, Igor Mammedov
  Cc: linux-cxl, linuxarm, Shameerali Kolothum Thodi, Ben Widawsky,
	Paolo Bonzini

Get LSA needs 4 byte offset and 4 byte length arguments.
CXL rev 2.0 Table 178.

Fixes: 3ebe676a34 ("hw/cxl/device: Implement get/set Label Storage Area (LSA)")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 hw/cxl/cxl-mailbox-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index bb66c765a5..3cea8b17a8 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -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 },
 };
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] hw/cxl: Correctly handle variable sized mailbox input payloads.
  2022-08-17 14:57 [PATCH 0/3] QEMU/CXL: A few more fixes for 7.1 related to LSA Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries Jonathan Cameron
  2022-08-17 14:57 ` [PATCH 2/3] hw/cxl: Fix Get LSA input payload size which should be 8 bytes Jonathan Cameron
@ 2022-08-17 14:57 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-08-17 14:57 UTC (permalink / raw)
  To: qemu-devel, Michael S . Tsirkin, Peter Maydell, Igor Mammedov
  Cc: linux-cxl, linuxarm, Shameerali Kolothum Thodi, Ben Widawsky,
	Paolo Bonzini

A 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.

Fixes: 464e14ac43 ("hw/cxl/device: Implement basic mailbox (8.2.8.4)")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 hw/cxl/cxl-mailbox-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 3cea8b17a8..bc1bb18844 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -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);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-17 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-17 14:57 [PATCH 0/3] QEMU/CXL: A few more fixes for 7.1 related to LSA Jonathan Cameron
2022-08-17 14:57 ` [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries Jonathan Cameron
2022-08-17 14:57 ` [PATCH 2/3] hw/cxl: Fix Get LSA input payload size which should be 8 bytes Jonathan Cameron
2022-08-17 14:57 ` [PATCH 3/3] hw/cxl: Correctly handle variable sized mailbox input payloads Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox