public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kun Qin" <kuqin12@gmail.com>
To: "Marvin Häuser" <mhaeuser@posteo.de>, devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>, Eric Dong <eric.dong@intel.com>,
	Ray Ni <ray.ni@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Zhiguang Liu <zhiguang.liu@intel.com>,
	Andrew Fish <afish@apple.com>, Laszlo Ersek <lersek@redhat.com>,
	Leif Lindholm <leif@nuviainc.com>
Subject: Re: [edk2-devel] [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER
Date: Wed, 16 Jun 2021 13:58:44 -0700	[thread overview]
Message-ID: <cc05af2a-dba4-b1df-0244-954cde273304@gmail.com> (raw)
In-Reply-To: <93fd191e-e62f-f02e-11d0-403173fcdf42@posteo.de>

Hi Marvin,

Thanks for reaching out. Please see my comment inline.

Regards,
Kun

On 06/16/2021 00:02, Marvin Häuser wrote:
> Good day,
> 
> May I ask about two small things?
> 
> 1) Was there any rationale as to e.g. code compatibility with choosing 
> UINT64 for the data length? I understand that this is the maximum of the 
> two as of currently, but I wonder whether a message length that exceeds 
> the UINT32 range (4 GB!) can possibly be considered sane or a good idea.
I agree that >4GB communication buffer may not be practical as of today. 
That is why we modified the SMM communication routine in PiSmmIpl to use 
SafeInt functions in Patch 2 of this series. With that change, at least 
for 32bit MM, larger than 4GB will be considered insane. But in the 
meantime, I do not want to rule out the >4GB communication capability 
that a 64bit MM currently already have.

Please let me know if I missed anything in regards to adding SafeInt 
functions to SmmCommunication routine.
> 
> 2) Is it feasible yet with the current set of supported compilers to 
> support flexible arrays?
My impression is that flexible arrays are already supported (as seen in 
UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkTypes.h). Please 
correct me if I am wrong.

Would you mind letting me know why this is applicable here? We are 
trying to seek ideas on how to catch developer mistakes caused by this 
change. So any input is appreciated.
> 
> Thank you for your work!
> 
> Best regards,
> Marvin
> 
> On 10.06.21 03:42, Kun Qin wrote:
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3430
>>
>> In PI Spec v1.7 Errata A, Vol.4, Sec 5.7 MM Communication Protocol, the
>> MessageLength field of EFI_MM_COMMUNICATE_HEADER (also derived 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 being 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;
>> ```
>>
>> Patch v1 branch: 
>> https://github.com/kuqin12/edk2/tree/BZ3398-MmCommunicate-Length
>>
>> Cc: Jian J Wang <jian.j.wang@intel.com>
>> Cc: Hao A Wu <hao.a.wu@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Ray Ni <ray.ni@intel.com>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
>> Cc: Andrew Fish <afish@apple.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Leif Lindholm <leif@nuviainc.com>
>>
>> Kun Qin (5):
>>    EDK2 Code First: PI Specification: EFI_MM_COMMUNICATE_HEADER Update
>>    MdeModulePkg: PiSmmIpl: Update MessageLength calculation for
>>      MmCommunicate
>>    MdeModulePkg: MemoryProfileInfo: Updated MessageLength calculation
>>    MdeModulePkg: SmiHandlerProfileInfo: Updated MessageLength calculation
>>    MdePkg: MmCommunication: Extend MessageLength field size to UINT64
>>
>>   
>> MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c         
>> | 20 +++--
>>   
>> MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c 
>> |  8 +-
>>   
>> MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c                                 
>> | 13 ++-
>>   
>> BZ3430-SpecChange.md                                                   
>> | 88 ++++++++++++++++++++
>>   
>> MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf                               
>> |  1 +
>>   
>> MdePkg/Include/Protocol/MmCommunication.h                              
>> |  3 +-
>>   6 files changed, 124 insertions(+), 9 deletions(-)
>>   create mode 100644 BZ3430-SpecChange.md
>>
> 

  reply	other threads:[~2021-06-16 20:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10  1:42 [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER Kun Qin
2021-06-10  1:42 ` [PATCH v1 1/5] EDK2 Code First: PI Specification: EFI_MM_COMMUNICATE_HEADER Update Kun Qin
2021-06-11  7:46   ` [edk2-devel] " Wu, Hao A
2021-06-15 20:51     ` Kun Qin
2021-06-16  1:15       ` Wu, Hao A
2021-06-24  0:53         ` Kun Qin
2021-06-24  3:26           ` [EXTERNAL] " Bret Barkelew
2021-06-28  6:18             ` Wu, Hao A
2021-06-10  1:42 ` [PATCH v1 2/5] MdeModulePkg: PiSmmIpl: Update MessageLength calculation for MmCommunicate Kun Qin
2021-06-11  7:46   ` Wu, Hao A
2021-06-10  1:42 ` [PATCH v1 3/5] MdeModulePkg: MemoryProfileInfo: Updated MessageLength calculation Kun Qin
2021-06-11  7:46   ` Wu, Hao A
2021-06-11 21:29     ` Kun Qin
2021-06-14 23:20       ` [edk2-devel] " Wu, Hao A
2021-06-10  1:42 ` [PATCH v1 4/5] MdeModulePkg: SmiHandlerProfileInfo: " Kun Qin
2021-06-11  7:47   ` Wu, Hao A
2021-06-10  1:42 ` [PATCH v1 5/5] MdePkg: MmCommunication: Extend MessageLength field size to UINT64 Kun Qin
2021-06-16  7:02 ` [edk2-devel] [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER Marvin Häuser
2021-06-16 20:58   ` Kun Qin [this message]
2021-06-18  9:37     ` Marvin Häuser
2021-06-22 15:34       ` Laszlo Ersek
2021-06-23  6:54         ` Marvin Häuser
2021-06-23 15:26           ` Laszlo Ersek
2021-06-24  0:24             ` Kun Qin
2021-06-24  8:00               ` Marvin Häuser
2021-06-24 15:25                 ` Michael D Kinney
2021-06-25 18:47                   ` Kun Qin
2021-06-28 14:57                     ` Laszlo Ersek
2021-06-28 15:43                       ` Marvin Häuser
2021-06-29  6:49                         ` [EXTERNAL] " Bret Barkelew
2021-06-29  8:58                           ` Marvin Häuser
2021-06-29 15:59                             ` Bret Barkelew
2021-06-29 17:28                               ` Michael D Kinney
2021-06-29 23:10                                 ` Kun Qin
2021-06-30  1:07                                   ` Michael D Kinney
2021-06-30  7:56                                     ` Kun Qin
2021-06-29 17:22                         ` Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc05af2a-dba4-b1df-0244-954cde273304@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox