From nobody Thu Nov 14 06:59:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1689614370; cv=none; d=zohomail.com; s=zohoarc; b=Ei1QaWb8MvrEqXH5RvJpavV4agdtxqHoYtV7wdXXT4nacSMUw3KZAQGDD0wz+RFnthPfla8zeIbbA1uJq5cDPXYtmExo0aaLWmkU3N6C6AXb4T0ftMVz5N8kQFvboGvd3Wy+CFkIzEn4dtzK7dTNaHCl3NiN1rCZQrYzbQtnYq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689614370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=3AMjsfQxKMOv4K+yh2w+vS99NiJ4+tGDjKQA/awEFTA=; b=PB5BUsXXahzKu7MHOLGAzWOKWv5l8TLmQJVpPGhbuaUaWx20KUWCf2K2EqL/QKQbxBzt011YNnHy+JOYYjogHoVpgqr9hYpGXYWYDdeQM3uOjUD9P3tONBSsUbo71PPJULA2BgaubnMzPYvzE6LMsQxP/lYhtraThgjLxsobRL8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689614370165821.7730223678969; Mon, 17 Jul 2023 10:19:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLRsV-00088I-CZ; Mon, 17 Jul 2023 13:19:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLRs3-0007tJ-8i for qemu-devel@nongnu.org; Mon, 17 Jul 2023 13:18:53 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLRs0-0004BR-MN for qemu-devel@nongnu.org; Mon, 17 Jul 2023 13:18:51 -0400 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4R4TJL5Y2pz6J6rX; Tue, 18 Jul 2023 01:16:18 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 17 Jul 2023 18:18:46 +0100 To: , Dan Williams , CC: , Alison Schofield , Ira Weiny , Dave Jiang , Davidlohr Bueso , Viacheslav Dubeyko , Shesha Bhushan Sreenivasamurthy , Fan Ni , Michael Tsirkin , Jonathan Zhang , Klaus Jensen Subject: [RFC PATCH 04/17] hw/mbox: Split mailbox command payload into separate input and output Date: Mon, 17 Jul 2023 18:16:33 +0100 Message-ID: <20230717171646.8972-5-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230717171646.8972-1-Jonathan.Cameron@huawei.com> References: <20230717171646.8972-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1689614371547100001 Content-Type: text/plain; charset="utf-8" New CCI types that will be supported shortly do not have a single buffer used in both directions. As such, split it up. For CXL mailboxes the two pointers will be aliases of the same memory so all callbacks must allow for that. Signed-off-by: Jonathan Cameron --- include/hw/cxl/cxl_device.h | 7 +- hw/cxl/cxl-events.c | 2 +- hw/cxl/cxl-mailbox-utils.c | 222 +++++++++++++++++++++--------------- 3 files changed, 132 insertions(+), 99 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index f84f6813aa..fc15c2729d 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -136,8 +136,9 @@ typedef enum { =20 struct cxl_cmd; typedef CXLRetCode (*opcode_handler)(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, uint16_t = *len); + uint8_t *payload_in, size_t len_in, + uint8_t *payload_out, size_t *len_out, + CXLDeviceState *cxl_dstate); struct cxl_cmd { const char *name; opcode_handler handler; @@ -416,7 +417,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLo= gType log_type, CXLEventRecordRaw *event); CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload= *pl, uint8_t log_type, int max_recs, - uint16_t *len); + size_t *len); CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPayload *pl); =20 diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index d161d57456..a985bb3e09 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -143,7 +143,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLo= gType log_type, =20 CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload= *pl, uint8_t log_type, int max_recs, - uint16_t *len) + size_t *len) { CXLEventLog *log; CXLEvent *entry; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index f0d94b9ae4..785c3fa7d0 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -72,9 +72,9 @@ enum { =20 =20 static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, size_t len_i= n, + uint8_t *payload_out, size_t *len= _out, + CXLDeviceState *cxlds) { CXLGetEventPayload *pl; uint8_t log_type; @@ -84,9 +84,9 @@ static CXLRetCode cmd_events_get_records(const struct cxl= _cmd *cmd, return CXL_MBOX_INVALID_INPUT; } =20 - log_type =3D payload[0]; + log_type =3D payload_in[0]; =20 - pl =3D (CXLGetEventPayload *)payload; + pl =3D (CXLGetEventPayload *)payload_out; memset(pl, 0, sizeof(*pl)); =20 max_recs =3D (cxlds->payload_size - CXL_EVENT_PAYLOAD_HDR_SIZE) / @@ -95,30 +95,34 @@ static CXLRetCode cmd_events_get_records(const struct c= xl_cmd *cmd, max_recs =3D 0xFFFF; } =20 - return cxl_event_get_records(cxlds, pl, log_type, max_recs, len); + return cxl_event_get_records(cxlds, pl, log_type, max_recs, len_out); } =20 static CXLRetCode cmd_events_clear_records(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLClearEventPayload *pl; =20 - pl =3D (CXLClearEventPayload *)payload; - *len =3D 0; + pl =3D (CXLClearEventPayload *)payload_in; + *len_out =3D 0; return cxl_event_clear_records(cxlds, pl); } =20 static CXLRetCode cmd_events_get_interrupt_policy(const struct cxl_cmd *cm= d, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 - policy =3D (CXLEventInterruptPolicy *)payload; + policy =3D (CXLEventInterruptPolicy *)payload_out; memset(policy, 0, sizeof(*policy)); =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; @@ -147,23 +151,25 @@ static CXLRetCode cmd_events_get_interrupt_policy(con= st struct cxl_cmd *cmd, policy->dyn_cap_settings =3D CXL_INT_MSI_MSIX; } =20 - *len =3D sizeof(*policy); + *len_out =3D sizeof(*policy); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_events_set_interrupt_policy(const struct cxl_cmd *cm= d, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 - if (*len < CXL_EVENT_INT_SETTING_MIN_LEN) { + if (len_in < CXL_EVENT_INT_SETTING_MIN_LEN) { return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } =20 - policy =3D (CXLEventInterruptPolicy *)payload; + policy =3D (CXLEventInterruptPolicy *)payload_in; =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; log->irq_enabled =3D (policy->info_settings & CXL_EVENT_INT_MODE_MASK)= =3D=3D @@ -182,7 +188,7 @@ static CXLRetCode cmd_events_set_interrupt_policy(const= struct cxl_cmd *cmd, CXL_INT_MSI_MSIX; =20 /* DCD is optional */ - if (*len < sizeof(*policy)) { + if (len_in < sizeof(*policy)) { return CXL_MBOX_SUCCESS; } =20 @@ -190,15 +196,17 @@ static CXLRetCode cmd_events_set_interrupt_policy(con= st struct cxl_cmd *cmd, log->irq_enabled =3D (policy->dyn_cap_settings & CXL_EVENT_INT_MODE_MA= SK) =3D=3D CXL_INT_MSI_MSIX; =20 - *len =3D sizeof(*policy); + *len_out =3D 0; return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint8_t slots_supported; @@ -217,7 +225,7 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - fw_info =3D (void *)payload; + fw_info =3D (void *)payload_out; memset(fw_info, 0, sizeof(*fw_info)); =20 fw_info->slots_supported =3D 2; @@ -225,36 +233,40 @@ static CXLRetCode cmd_firmware_update_get_info(const = struct cxl_cmd *cmd, fw_info->caps =3D 0; pstrcpy(fw_info->fw_rev1, sizeof(fw_info->fw_rev1), "BWFW VERSION 0"); =20 - *len =3D sizeof(*fw_info); + *len_out =3D sizeof(*fw_info); return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.3.1 */ static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 - stq_le_p(payload, final_time); - *len =3D 8; + stq_le_p(payload_out, final_time); + *len_out =3D 8; =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.3.2 */ static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { cxl_dstate->timestamp.set =3D true; cxl_dstate->timestamp.last_set =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUA= L); =20 - cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)payload); + cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)payload_in= ); =20 - *len =3D 0; + *len_out =3D 0; return CXL_MBOX_SUCCESS; } =20 @@ -266,9 +278,11 @@ static const QemuUUID cel_uuid =3D { =20 /* 8.2.9.4.1 */ static CXLRetCode cmd_logs_get_supported(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint16_t entries; @@ -277,22 +291,24 @@ static CXLRetCode cmd_logs_get_supported(const struct= cxl_cmd *cmd, QemuUUID uuid; uint32_t size; } log_entries[1]; - } QEMU_PACKED *supported_logs =3D (void *)payload; + } QEMU_PACKED *supported_logs =3D (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*supported_logs) !=3D 0x1c); =20 supported_logs->entries =3D 1; supported_logs->log_entries[0].uuid =3D cel_uuid; supported_logs->log_entries[0].size =3D 4 * cxl_dstate->cel_size; =20 - *len =3D sizeof(*supported_logs); + *len_out =3D sizeof(*supported_logs); return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.4.2 */ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { QemuUUID uuid; @@ -300,7 +316,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd= *cmd, uint32_t length; } QEMU_PACKED QEMU_ALIGNED(16) *get_log; =20 - get_log =3D (void *)payload; + get_log =3D (void *)payload_in; =20 /* * 8.2.9.4.2 @@ -324,19 +340,21 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_c= md *cmd, } =20 /* Store off everything to local variables so we can wipe out the payl= oad */ - *len =3D get_log->length; + *len_out =3D get_log->length; =20 - memmove(payload, cxl_dstate->cel_log + get_log->offset, - get_log->length); + memmove(payload_out, cxl_dstate->cel_log + get_log->offset, + get_log->length); =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.5.1.1 */ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { char fw_revision[0x10]; @@ -364,7 +382,7 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - id =3D (void *)payload; + id =3D (void *)payload_out; memset(id, 0, sizeof(*id)); =20 snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); @@ -378,21 +396,23 @@ static CXLRetCode cmd_identify_memory_device(const st= ruct cxl_cmd *cmd, /* No limit - so limited by main poison record limit */ stw_le_p(&id->inject_poison_limit, 0); =20 - *len =3D sizeof(*id); + *len_out =3D sizeof(*id); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint64_t active_vmem; uint64_t active_pmem; uint64_t next_vmem; uint64_t next_pmem; - } QEMU_PACKED *part_info =3D (void *)payload; + } QEMU_PACKED *part_info =3D (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*part_info) !=3D 0x20); =20 if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || @@ -409,14 +429,16 @@ static CXLRetCode cmd_ccls_get_partition_info(const s= truct cxl_cmd *cmd, stq_le_p(&part_info->active_pmem, cxl_dstate->pmem_size / CXL_CAPACITY= _MULTIPLIER); stq_le_p(&part_info->next_pmem, 0); =20 - *len =3D sizeof(*part_info); + *len_out =3D sizeof(*part_info); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint32_t offset; @@ -426,46 +448,47 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_c= md *cmd, CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); uint32_t offset, length; =20 - get_lsa =3D (void *)payload; + get_lsa =3D (void *)payload_in; offset =3D get_lsa->offset; length =3D get_lsa->length; =20 if (offset + length > cvc->get_lsa_size(ct3d)) { - *len =3D 0; + *len_out =3D 0; return CXL_MBOX_INVALID_INPUT; } =20 - *len =3D cvc->get_lsa(ct3d, get_lsa, length, offset); + *len_out =3D cvc->get_lsa(ct3d, payload_out, length, offset); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct set_lsa_pl { uint32_t offset; uint32_t rsvd; uint8_t data[]; } QEMU_PACKED; - struct set_lsa_pl *set_lsa_payload =3D (void *)payload; + struct set_lsa_pl *set_lsa_payload =3D (void *)payload_in; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); const size_t hdr_len =3D offsetof(struct set_lsa_pl, data); - uint16_t plen =3D *len; =20 - *len =3D 0; - if (!plen) { + *len_out =3D 0; + if (!len_in) { return CXL_MBOX_SUCCESS; } =20 - if (set_lsa_payload->offset + plen > cvc->get_lsa_size(ct3d) + hdr_len= ) { + if (set_lsa_payload->offset + len_in > cvc->get_lsa_size(ct3d) + hdr_l= en) { return CXL_MBOX_INVALID_INPUT; } - plen -=3D hdr_len; + len_in -=3D hdr_len; =20 - cvc->set_lsa(ct3d, set_lsa_payload->data, plen, set_lsa_payload->offse= t); + cvc->set_lsa(ct3d, set_lsa_payload->data, len_in, set_lsa_payload->off= set); return CXL_MBOX_SUCCESS; } =20 @@ -476,9 +499,11 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cm= d *cmd, * testing that kernel functionality. */ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct get_poison_list_pl { uint64_t pa; @@ -498,8 +523,8 @@ static CXLRetCode cmd_media_get_poison_list(const struc= t cxl_cmd *cmd, } QEMU_PACKED records[]; } QEMU_PACKED; =20 - struct get_poison_list_pl *in =3D (void *)payload; - struct get_poison_list_out_pl *out =3D (void *)payload; + struct get_poison_list_pl *in =3D (void *)payload_in; + struct get_poison_list_out_pl *out =3D (void *)payload_out; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); uint16_t record_count =3D 0, i =3D 0; uint64_t query_start, query_length; @@ -548,14 +573,16 @@ static CXLRetCode cmd_media_get_poison_list(const str= uct cxl_cmd *cmd, stq_le_p(&out->overflow_timestamp, ct3d->poison_list_overflow_ts); } stw_le_p(&out->count, record_count); - *len =3D out_pl_len; + *len_out =3D out_pl_len; return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len_unused) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLPoisonList *poison_list =3D &ct3d->poison_list; @@ -563,7 +590,7 @@ static CXLRetCode cmd_media_inject_poison(const struct = cxl_cmd *cmd, struct inject_poison_pl { uint64_t dpa; }; - struct inject_poison_pl *in =3D (void *)payload; + struct inject_poison_pl *in =3D (void *)payload_in; uint64_t dpa =3D ldq_le_p(&in->dpa); CXLPoison *p; =20 @@ -588,14 +615,17 @@ static CXLRetCode cmd_media_inject_poison(const struc= t cxl_cmd *cmd, */ QLIST_INSERT_HEAD(poison_list, p, node); ct3d->poison_list_cnt++; + *len_out =3D 0; =20 return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len_unused) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLPoisonList *poison_list =3D &ct3d->poison_list; @@ -607,7 +637,7 @@ static CXLRetCode cmd_media_clear_poison(const struct c= xl_cmd *cmd, CXLPoison *ent; uint64_t dpa; =20 - struct clear_poison_pl *in =3D (void *)payload; + struct clear_poison_pl *in =3D (void *)payload_in; =20 dpa =3D ldq_le_p(&in->dpa); if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->mem_size) { @@ -668,6 +698,7 @@ static CXLRetCode cmd_media_clear_poison(const struct c= xl_cmd *cmd, } /* Any fragments have been added, free original entry */ g_free(ent); + *len_out =3D 0; =20 return CXL_MBOX_SUCCESS; } @@ -718,15 +749,16 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) =20 uint8_t set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET); uint8_t cmd =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND); - uint16_t len =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH); + uint16_t len_in =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGT= H); uint8_t *pl =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; + size_t len_out =3D 0; =20 cxl_cmd =3D &cxl_dstate->cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; if (h) { - if (len =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { - ret =3D (*h)(cxl_cmd, pl, cxl_dstate, &len); - assert(len <=3D cxl_dstate->payload_size); + if (len_in =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { + ret =3D (*h)(cxl_cmd, pl, len_in, pl, &len_out, cxl_dstate); + assert(len_out <=3D cxl_dstate->payload_size); } else { ret =3D CXL_MBOX_INVALID_PAYLOAD_LENGTH; } @@ -742,7 +774,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) /* Set the return length */ command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET, 0); command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND, = 0); - command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH, l= en); + command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH, l= en_out); =20 cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_CMD] =3D command_reg; cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; --=20 2.39.2