Add libpldmd patches needed for unit testing Upstream review for these patches are at; - https://gerrit.openbmc.org/c/openbmc/libpldm/+/83436 - https://gerrit.openbmc.org/c/openbmc/libpldm/+/83663 Tested: Unit tested Google-Bug-Id: 423027264 Change-Id: Ibb820b0d935be1f2ae34be5bdd5f68d81204eddb Signed-off-by: Kasun Athukorala <kasunath@google.com>
diff --git a/.gitignore b/.gitignore index fd9ea53..fa0c2bc 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,5 +1,6 @@ build*/ subprojects/* !subprojects/*.wrap +!subprojects/packagefiles .vscode
diff --git a/subprojects/libpldm.wrap b/subprojects/libpldm.wrap index 5c90142..55d06c2 100644 --- a/subprojects/libpldm.wrap +++ b/subprojects/libpldm.wrap
@@ -1,6 +1,7 @@ [wrap-git] url = https://github.com/openbmc/libpldm.git -revision = HEAD +revision = aa0aeda7c38dda911c81e9bcd9fae5f8210d303b +diff_files = libpldm/0001-dsp-base-Fix-MultipartReceive-Request-decoding.patch, libpldm/0002-dsp-base-Omit-checksum-for-Multipart-receive-ACKNOWL.patch [provide] libpldm = libpldm_dep
diff --git a/subprojects/packagefiles/libpldm/0001-dsp-base-Fix-MultipartReceive-Request-decoding.patch b/subprojects/packagefiles/libpldm/0001-dsp-base-Fix-MultipartReceive-Request-decoding.patch new file mode 100644 index 0000000..dac0990 --- /dev/null +++ b/subprojects/packagefiles/libpldm/0001-dsp-base-Fix-MultipartReceive-Request-decoding.patch
@@ -0,0 +1,113 @@ +From 92388b2c470dd4b01bf47902132349319b8f0cd6 Mon Sep 17 00:00:00 2001 +From: Kasun Athukorala <kasunath@google.com> +Date: Fri, 5 Sep 2025 18:50:26 +0000 +Subject: [PATCH] dsp: base: Fix MultipartReceive Request decoding + +This fix is based on DSP0240 v1.2.0 section 9.6.5 MultipartReceive. + +- Removed RequestedSectionOffset check. + +The Property can be 0 for any TransferOperation flag. + +- Changed DataTransferHandle check. + +The property can be 0 except with PLDM_XFER_NEXT_PART. Eg. In +DSP0242 v1.0.0, when using MultipartReceive to read a file, +the client has to send transfer handle 0 with XFER_FIRST_PART. + +Change-Id: I06428556f9dee341de97f72b015ed0347adc9454 +Signed-off-by: Kasun Athukorala <kasunath@google.com> +--- + CHANGELOG.md | 4 ++++ + src/dsp/base.c | 11 ++++------- + tests/dsp/base.cpp | 37 ------------------------------------- + 3 files changed, 8 insertions(+), 44 deletions(-) + +diff --git a/CHANGELOG.md b/CHANGELOG.md +index 9f28c0d..b28a4fc 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -96,6 +96,10 @@ Change categories: + - include, tests: Address concerns from -Wsign-compare + - dsp: base: decode_pldm_base_negotiate_transfer_params_resp() is stable + ++- base: ++ - Removed RequestedSectionOffset check in decode_multipart_receive_req() ++ - Updated DataTransferHandle check in decode_multipart_receive_req() ++ + ### Security + + ## [0.14.0] 2025-08-11 +diff --git a/src/dsp/base.c b/src/dsp/base.c +index cc805df..eb0aaa4 100644 +--- a/src/dsp/base.c ++++ b/src/dsp/base.c +@@ -569,13 +569,10 @@ int decode_multipart_receive_req(const struct pldm_msg *msg, + return PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION; + } + +- // A section offset of 0 is only valid on FIRST_PART or COMPLETE Xfers. +- if (*section_offset == 0 && (*transfer_opflag != PLDM_XFER_FIRST_PART && +- *transfer_opflag != PLDM_XFER_COMPLETE)) { +- return PLDM_ERROR_INVALID_DATA; +- } +- +- if (*transfer_handle == 0 && *transfer_opflag != PLDM_XFER_COMPLETE) { ++ // Transfer handle can be 0 only if the transfer flag is one of XFER_FIRST_PART, ++ // PLDM_XFER_CURRENT_PART, XFER_ABORT or XFER_COMPLETE. ++ if ((*transfer_handle == 0) && ++ (*transfer_opflag == PLDM_XFER_NEXT_PART)) { + return PLDM_ERROR_INVALID_DATA; + } + +diff --git a/tests/dsp/base.cpp b/tests/dsp/base.cpp +index f146e7c..b2e9294 100644 +--- a/tests/dsp/base.cpp ++++ b/tests/dsp/base.cpp +@@ -674,43 +674,6 @@ TEST(DecodeMultipartReceiveRequest, testDecodeRequestFailBadTransferFlag) + PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION); + } + +-TEST(DecodeMultipartReceiveRequest, testDecodeRequestFailBadOffset) +-{ +- constexpr uint8_t kPldmType = PLDM_BASE; +- constexpr uint8_t kFlag = PLDM_XFER_NEXT_PART; +- constexpr uint32_t kTransferCtx = 0x01; +- constexpr uint32_t kTransferHandle = 0x01; +- constexpr uint32_t kSectionOffset = 0x0; +- +- PLDM_MSG_DEFINE_P(msg, PLDM_MULTIPART_RECEIVE_REQ_BYTES); +- PLDM_MSGBUF_RW_DEFINE_P(buf); +- int rc; +- +- // Header values don't matter for this test. +- rc = pldm_msgbuf_init_errno(buf, PLDM_MULTIPART_RECEIVE_REQ_BYTES, +- msg->payload, PLDM_MULTIPART_RECEIVE_REQ_BYTES); +- ASSERT_EQ(rc, 0); +- pldm_msgbuf_insert_uint8(buf, kPldmType); +- pldm_msgbuf_insert_uint8(buf, kFlag); +- pldm_msgbuf_insert_uint32(buf, kTransferCtx); +- pldm_msgbuf_insert_uint32(buf, kTransferHandle); +- pldm_msgbuf_insert_uint32(buf, kSectionOffset); +- rc = pldm_msgbuf_complete(buf); +- ASSERT_EQ(rc, 0); +- +- uint8_t pldm_type; +- uint8_t flag; +- uint32_t transfer_ctx; +- uint32_t transfer_handle; +- uint32_t section_offset; +- uint32_t section_length; +- EXPECT_EQ(decode_multipart_receive_req( +- msg, PLDM_MULTIPART_RECEIVE_REQ_BYTES, &pldm_type, &flag, +- &transfer_ctx, &transfer_handle, §ion_offset, +- §ion_length), +- PLDM_ERROR_INVALID_DATA); +-} +- + TEST(DecodeMultipartReceiveRequest, testDecodeRequestFailBadHandle) + { + constexpr uint8_t kPldmType = PLDM_BASE; +-- +2.51.0.536.g15c5d4f767-goog +
diff --git a/subprojects/packagefiles/libpldm/0002-dsp-base-Omit-checksum-for-Multipart-receive-ACKNOWL.patch b/subprojects/packagefiles/libpldm/0002-dsp-base-Omit-checksum-for-Multipart-receive-ACKNOWL.patch new file mode 100644 index 0000000..4c4f2d1 --- /dev/null +++ b/subprojects/packagefiles/libpldm/0002-dsp-base-Omit-checksum-for-Multipart-receive-ACKNOWL.patch
@@ -0,0 +1,121 @@ +From 4d2419632b6317efae974fb6695f844e62b47439 Mon Sep 17 00:00:00 2001 +From: Kasun Athukorala <kasunath@google.com> +Date: Sat, 13 Sep 2025 00:37:59 +0000 +Subject: [PATCH] dsp: base: Omit checksum for Multipart receive + ACKNOWLEDGE_COMPLETION + +This fix is based on DSP0240 v1.2.0 section 9.6.5 MultipartReceive. + +DataIntegrityChecksum property should be there unless the +response TransferFlag property is ACKNOWLEDGE_COMPLETION + +This patch fixes the issue where DataIntegrityChecksum is only +included if the TransferFlag is PLDM_END or PLDM_START_AND_END + +gitlint-ignore: T1 +Change-Id: I6d715d21d9d9d55bbda6139108be9cfb288ad209 +Signed-off-by: Kasun Athukorala <kasunath@google.com> +--- + CHANGELOG.md | 2 ++ + src/dsp/base.c | 12 +++++++++--- + tests/dsp/base.cpp | 34 ++++++++++------------------------ + 3 files changed, 21 insertions(+), 27 deletions(-) + +diff --git a/CHANGELOG.md b/CHANGELOG.md +index b28a4fc..712c858 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -99,6 +99,8 @@ Change categories: + - base: + - Removed RequestedSectionOffset check in decode_multipart_receive_req() + - Updated DataTransferHandle check in decode_multipart_receive_req() ++ - Updated encode_base_multipart_receive_resp() to insert checksum except when ++ TransferFlag is ACKNOWLEDGE_COMPLETION + + ### Security + +diff --git a/src/dsp/base.c b/src/dsp/base.c +index eb0aaa4..e69d286 100644 +--- a/src/dsp/base.c ++++ b/src/dsp/base.c +@@ -680,7 +680,11 @@ int encode_base_multipart_receive_resp( + PLDM_MSGBUF_RW_DEFINE_P(buf); + int rc; + +- if (!msg || !resp || !payload_length || !resp->data.ptr) { ++ if (!msg || !resp || !payload_length) { ++ return -EINVAL; ++ } ++ ++ if ((resp->data.length > 0) && !resp->data.ptr) { + return -EINVAL; + } + +@@ -725,8 +729,10 @@ int encode_base_multipart_receive_resp( + return pldm_msgbuf_discard(buf, rc); + } + +- if (resp->transfer_flag == PLDM_END || +- resp->transfer_flag == PLDM_START_AND_END) { ++ // Checksum is present for all data parts except when response transfer flag is ++ // ACKNOWLEDGE_COMPLETION ++ if (resp->transfer_flag != ++ PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_ACK_COMPLETION) { + pldm_msgbuf_insert(buf, checksum); + } + +diff --git a/tests/dsp/base.cpp b/tests/dsp/base.cpp +index b2e9294..88539ba 100644 +--- a/tests/dsp/base.cpp ++++ b/tests/dsp/base.cpp +@@ -1093,37 +1093,23 @@ TEST(EncodeMultipartReceiveResponse, GoodTestWithoutChecksum) + { + uint8_t instance_id = 0; + uint8_t completionCode = PLDM_SUCCESS; +- uint8_t transferFlag = PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_START; +- uint32_t nextDataTransferHandle = 0x16; +- static constexpr const uint32_t dataLength = 9; +- std::vector<uint8_t> data = {1, 2, 3, 4, 5, 6, 7, 8, 9}; ++ uint8_t transferFlag = ++ PLDM_BASE_MULTIPART_RECEIVE_TRANSFER_FLAG_ACK_COMPLETION; ++ uint32_t nextDataTransferHandle = 0; ++ static constexpr const uint32_t dataLength = 0; + static constexpr const size_t responseMsgLength = + PLDM_BASE_MULTIPART_RECEIVE_RESP_MIN_BYTES + dataLength; + size_t payload_length = responseMsgLength; + +- struct variable_field payload = {data.data(), dataLength}; ++ struct variable_field payload = {nullptr, dataLength}; + struct pldm_base_multipart_receive_resp resp_data = { + completionCode, transferFlag, nextDataTransferHandle, payload}; + std::array<uint8_t, responseMsgLength> responseMsg = { +- completionCode, +- transferFlag, +- 0x16, // nextDataTransferHandle +- 0x00, +- 0x00, +- 0x00, +- 0x09, // dataLength +- 0x00, +- 0x00, +- 0x00, +- 0x1, // data +- 0x2, +- 0x3, +- 0x4, +- 0x5, +- 0x6, +- 0x7, +- 0x8, +- 0x9}; ++ completionCode, transferFlag, ++ 0x00, // nextDataTransferHandle ++ 0x00, 0x00, 0x00, ++ 0x00, // dataLength ++ 0x00, 0x00, 0x00}; + + PLDM_MSG_DEFINE_P(responsePtr, responseMsgLength); + int rc; +-- +2.51.0.536.g15c5d4f767-goog +