Reporting Issues
Bug 3430 - EFI_MM_COMMUNICATE_HEADER has architecture dependent sized field
Summary: EFI_MM_COMMUNICATE_HEADER has architecture dependent sized field
Status: CONFIRMED
Alias: None
Product: EDK2 Code First
Classification: Unclassified
Component: Specification Update (show other bugs)
Version: Current
Hardware: All All
: Normal normal
Assignee: kun.qin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-02 21:41 UTC by kun.qin
Modified: 2022-01-14 15:21 UTC (History)
2 users (show)

See Also:
EDK II Code First industry standard specifications: UEFI Platform Initialization Specification Specification
Branch URL:
Release(s) the issue is observed:
The OS the target platform is running: ---
Package:
Release(s) the issues must be fixed:
Tianocore documents:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kun.qin 2021-06-02 21:41:04 UTC
In PI Spec v1.7 Errata A, Vol.4, Sec 5.7 MM Communication Protocol, the MessageLength field of EFI_MM_COMMUNICATE_HEADER (also defined as EFI_SMM_COMMUNICATE_HEADER) is currently defined as type UINTN.

But this structure, as a generic definition, could be used for both PEI and DXE MM communication. Thus for a system that supports PEI MM launch, but operates PEI in 32bit mode and MM foundation in 64bit, the current EFI_MM_COMMUNICATE_HEADER definition will cause structure parse error due to UINTN used.

The suggested change is to make the MessageLength field defined with definitive size as below:
```
typedef struct {
EFI_GUID  HeaderGuid;
UINT64    MessageLength;
UINT8     Data[ANYSIZE_ARRAY];
} EFI_MM_COMMUNICATE_HEADER;
```

This change will impact the structure consumers including:
MdeModulePkg/Core/PiSmmCore
MdeModulePkg/Application/SmiHandlerProfileInfo
MdeModulePkg/Application/MemoryProfileInfo

Note: MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib is also consuming this structure, but it handled this size discrepancy internally. (Without the spec change in this ticket, all applicable PEI MM communicate callers will need to engage the same routine)

The reference implementation is tracked by ticket: https://bugzilla.tianocore.org/show_bug.cgi?id=3398.
Comment 1 gaoliming 2021-06-08 21:44:37 UTC
Kun is working on it.
Comment 2 kun.qin 2021-06-09 21:45:48 UTC
(In reply to gaoliming from comment #1)
> Kun is working on it.

First round of review is sent here: https://edk2.groups.io/g/devel/message/76303.

I cannot seem to push edk2-staging repo, so this round of code patches are still based off the personal branch on github.

Please advise if any. Thanks.
Comment 3 kun.qin 2021-06-18 05:07:16 UTC
v2 patch sent here: https://edk2.groups.io/g/devel/message/76738
Comment 4 kun.qin 2022-01-14 15:21:30 UTC
v4 patch sent here to request change of PI spec: https://edk2.groups.io/g/devel/message/85308