Commit graph

15 commits

Author SHA1 Message Date
Leif Lindholm
a6a060f940 ManageabilityPkg: SsifWriteRequest post-refactor cleanup
Now the logic of the function is less convoluted, drop some redundant
casts, variable initialisations and move the MiddleCount definition
into the only block where it's used.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Leif Lindholm
150339f262 ManageabilityPkg: SsifWriteRequest loop refactoring
A multi-part request can consist of a Start, zero-to-several Middle,
and an End packet. For what I can only assume was an attempt to
confuse the enemy, SsifWriteRequest () handled this by setting up
three separate loops.

Rewrite this as a single loop in order to reduce confusion for
revewers and compilers.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Leif Lindholm
598025e866 ManageabilityPkg: fix/cleanup request size check in SsifWriteRequest
From the IPMI v2.0 (April 21, 2015 E7 Markup) specification,
Table 22-12, Get System Interface Capabilities Command:

"Input message size in bytes. (1 based.)"
...
"A BMC that supports multi-part Start and End would return
 a value from 33 to 64. A BMC that supports multi-part with Middle
 transactions would return a value from 65 to 255."

Yet the comment in the existing code describes this as being a
counter of the number of middle packets, with Start and End packets
counting outside of that. This seems very incorrect to me.

Address this, and simplify the code, by using the already existing
global variable mMaxRequestSize. Update the debug error message
text to reflect the functional change.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Leif Lindholm
e8cbfab461 ManageabilityPkg: refactor SsifWriteRequest #1
Separate input validation from argument marshalling.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Leif Lindholm
be62f3ded5 ManageabilityPkg: reorganise ManageabilityTransportSsifLib
For some reason this module was created "backwards", with .inf files
in subdirectories, as well as identical apart from failes to keep in
sync source files for Dxe and Pei drivers.

Flip the thing the right way around and delete the duplicated files.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Leif Lindholm
40c898febe ManageabilityPkg: simplify HelperManageabilityPayLoadDebugPrint ()
While reviewing PR #12035, I found this function a bit overcomplicated,
with a bunch of live-coded integers, so I reworked it for improved
human and compiler readability.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-07-31 05:45:58 +00:00
Michael Kubacki
df9111c2d3 Global: Set MarkdownLintCheck plugin to AuditOnly
In preparation for the MarkdownLintCheck plugin being added to the
repo, this change defaults the plugin to `AuditOnly` mode in each
package. This allows package maintainers to enable the plugin as they
see fit.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-29 12:32:09 +00:00
Michael Kubacki
96e2af4cc4 ManageabilityPkg: Follow pragma once coding convention
Update recent changes in ManageabilityPkg to follow the latest EDK II
C Coding Standards Specification (5.3) to use '#pragma once' instead
of traditional macro-based include guards in header files.

https://tianocore-docs.github.io/edk2-CCodingStandardsSpecification/draft/5_source_files/53_include_files.html#53-include-files

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-25 19:40:31 +00:00
Phineas Su
6d127c2140 ManageabilityPkg: Fix IPMI vulnerabilities and memory leak
Fix vulnerabilities and a memory leak in the IPMI Blob Transfer driver:
- Prevent integer underflow and OOB read by validating response size before
  accessing CompletionCode, OEN, and CRC.
- Prevent buffer overflow by ensuring BMC response size does not exceed the
  caller's buffer capacity, avoiding potential memory overwriting.
- Fix memory leak by freeing IpmiResponseData and IpmiSendData.

Additionally, fix unit test failures caused by the changes and pre-existing bugs:
- Allocate a safe fixed size (70 bytes) for IpmiResponseData in
  IpmiBlobTransferSendIpmi to prevent heap overflow if the BMC returns
  more data than expected. Add validation to check if returned size
  exceeds this allocation.
- Modify IpmiBlobTransferStat and IpmiBlobTransferSessionStat to only
  copy MetaDataLen bytes of metadata instead of always copying the max
  size (64 bytes), preventing buffer overflow when caller allocates
  a smaller buffer.
- Add missing ASSERT(FALSE) in IpmiBlobTransferStat parameter validation.
- Fix IpmiBlobTransferWriteMeta parameter validation to allow 0-length
  writes (Data can be NULL when WriteLength is 0), which was causing
  test failure.
- Fix syntax errors in unit tests where arrays were assigned values
  after declaration using brace-enclosed lists.
- Fix sizeof misuse on macros representing size values in unit tests,
  which caused too small allocations and buffer overflows in mock setups.
- Fix queue order in OpenValidResponse test to match the actual call
  order (GetCount, Enumerate, Open) and free all mock buffers.
- Remove unnecessary MockIpmiSubmitCommand calls from invalid buffer
  tests to prevent mock queue leaks to subsequent tests.
- Fix memory leaks of ExpectedMetadata in unit tests by changing them
  to static arrays.

Signed-off-by: Phineas Su <pohaosu@google.com>
2026-06-25 03:33:25 +00:00
Tuan Phan
32e139d51b ManageabilityPkg: TransportHelperLib: Fix uninitialized variable warning
In HelperManageabilityPayLoadDebugPrint(), Page256 is only assigned
inside an if block within the while loop but is accessed outside of
it, causing an uninitialized variable warning.

Initialize Page256 to zero before the while loop to fix this.

Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-06-24 14:49:50 +00:00
Tuan Phan
370f9021f1 ManageabilityPkg: TransportSsifLib: Fix uninitialized variable warning
In SsifWriteRequest(), MiddleCount is only assigned inside an if
block but is accessed in a subsequent loop, causing an uninitialized
variable warning.

Initialize MiddleCount to zero at declaration to fix this.

Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-06-24 14:49:50 +00:00
Qihang Gao
0573bda1c6 ManageabilityPkg: Fix build failure issue on CLANGDWARF X64
When building ManageabilityPkg with `-a X64 -t CLANGDWARF`, error
message is throwed:
BaseManageabilityTransportHelper.c:462:3: error:
'__builtin_ms_va_start' used in System V ABI function
  462 |   VA_START (Marker, Format);
      |   ^

Functions that call VA_START()/VA_END() must be declared with EFIAPI. The
function HelperManageabilityDebugPrint() should also be declared with
EFIAPI to ensure compliance with Microsoft X64 calling convention for
CLANG.

Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-06-19 17:30:22 +00:00
Abdul Lateef Attar
4e5672043b ManageabilityPkg: add configurable KCS status-check timeout PCD
Replace the hardcoded IPMI_KCS_TIMEOUT_5_SEC macro in WaitStatusSet() and
WaitStatusClear() with PcdKcsStatusCheckTimeout so platform firmware can
tune the KCS timeout without recompiling the library.

- ManageabilityPkg.dec: declare PcdKcsStatusCheckTimeout (UINT64, 5000000 us)
- KcsCommon.c: use PcdGet64(PcdKcsStatusCheckTimeout); add DEBUG on timeout
- ManageabilityTransportKcs.h: remove now-unused IPMI_KCS_TIMEOUT_5_SEC macro
- BaseManageabilityTransportKcs.inf, Dxe/DxeManageabilityTransportKcs.inf:
  add PcdKcsStatusCheckTimeout to [FixedPcd]

Co-authored-by: Abner Chang <abner.chang@amd.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
2026-05-06 13:32:00 +00:00
Abner Chang
19d4bdefde ManageabilityPkg: Add ManageabilityPkg CI yaml
Adding edk2 CI yaml for ManageabilityPkg.

Signed-off-by: Abner Chang <abner.chang@amd.com>
2026-04-27 13:15:26 +00:00
Abner Chang
c9c309146e ManageabilityPkg: Initial version of ManageabilityPkg
ManageabilityPkg is migrated from edk2-platform repository.
The last commit ID of ManageabilityPkg on edk2-platform is
<4538a1b94c0e55d58e3841b2d640df7da0a3b149>.

Signed-off-by: Abner Chang <abner.chang@amd.com>
2026-04-27 13:15:26 +00:00