* [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