From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by mx.groups.io with SMTP id smtpd.web10.136.1623877126114259171 for ; Wed, 16 Jun 2021 13:58:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iQDY1LQU; spf=pass (domain: gmail.com, ip: 209.85.215.173, mailfrom: kuqin12@gmail.com) Received: by mail-pg1-f173.google.com with SMTP id w31so3046164pga.6 for ; Wed, 16 Jun 2021 13:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=P4aBoIYjPXszEfcgKf09beBkRcRTOkDaxP8hhL3FsJU=; b=iQDY1LQUVMTfOi5SdtFOM19kVrAvrQW39Xjbipia0er8VXvto141R+HfooanvUKxdU YjZMBcstFkBymkQV8Ll1Ac/vSL1CYlWPUhA0167Nn5BdEBnEMDHAdop5CaB1Ey4AGuWK iO1TBi/zG3DF5uiRgUfhmvBNtmrH1bNjc+NdmA/OYkpSm47d6afhEKr3nu9nFVbEPaPC 11gBxTk32Br4Y5bIGsO8oSj0BTA6TuYoEX7Xnf5bomxeWnmO6xUjyt0oouA0BXlVRgVJ fin5hv8LQwPCDNEuJte4q4QIdNvzZ1+3rygNyYx8MZc2+gFeje1DREZ1eRxD7PTfbLUE k36w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=P4aBoIYjPXszEfcgKf09beBkRcRTOkDaxP8hhL3FsJU=; b=pVvzeor8rZsba8NVTyAM51XMyoWKDBiqdOhqFt0qqAH3pDzvmWvauE7v+ydqJc3UuM d/T4OUK0SRwCx3OXWY5392gR4N9bD4su+VARJiNWD5Dabm6tRFJtJxSynQG+omXqtllS 6tQCk/V3In618+cYXNjkG0+4+JAtWBun25N9y8BxiGuJDwGqsnp7Z0wfFKfEi8LLqthY 8Hp5Il0pwlNPSphnorM1adePV07fmVdM9Z8ru9/00L3V1O7tSUn/EiUbrKiwUHxIifr5 m36DGPJMJrFj9y7WEKxEjVPoBpPpAjIXg0+bNPO07Y3DktOLx9/JJ8wAPPHdiIfxBSHl ohjg== X-Gm-Message-State: AOAM530+qYAK7q5+iQHSTe0/sCiPwvu033CMM0wiLMNujijSu8H+wG8N WMgGRR00IsRzVvN6/Mp1MxU= X-Google-Smtp-Source: ABdhPJx/CHGJCVZVxNTRyZn/CetLpVfISiaNziEz/rIhQX7UpIqEw+yVCAlzvdft8uTMuaeBHS0xJg== X-Received: by 2002:a05:6a00:2395:b029:2fe:7c89:e5d1 with SMTP id f21-20020a056a002395b02902fe7c89e5d1mr227419pfc.27.1623877125589; Wed, 16 Jun 2021 13:58:45 -0700 (PDT) Return-Path: Received: from [192.168.50.18] ([50.35.88.161]) by smtp.gmail.com with ESMTPSA id i22sm2970338pfq.6.2021.06.16.13.58.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jun 2021 13:58:45 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER To: =?UTF-8?Q?Marvin_H=c3=a4user?= , devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Eric Dong , Ray Ni , Michael D Kinney , Liming Gao , Zhiguang Liu , Andrew Fish , Laszlo Ersek , Leif Lindholm References: <20210610014259.1151-1-kuqin12@gmail.com> <93fd191e-e62f-f02e-11d0-403173fcdf42@posteo.de> From: "Kun Qin" Message-ID: Date: Wed, 16 Jun 2021 13:58:44 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <93fd191e-e62f-f02e-11d0-403173fcdf42@posteo.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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 >> Cc: Hao A Wu >> Cc: Eric Dong >> Cc: Ray Ni >> Cc: Michael D Kinney >> Cc: Liming Gao >> Cc: Zhiguang Liu >> Cc: Andrew Fish >> Cc: Laszlo Ersek >> Cc: Leif Lindholm >> >> 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 >> >