From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.5596.1623397601100508918 for ; Fri, 11 Jun 2021 00:46:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=yqzx9SBK; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: hao.a.wu@intel.com) IronPort-SDR: V5sJf/YBU+3t+AKqxEFtZkZnXz1CnV2JfxVdt7ibXJrE9PCt0VqvULhb1H0gFBerWXv6AJRohi ZJHphOzKfaCg== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="202454711" X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="202454711" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2021 00:46:39 -0700 IronPort-SDR: KeJygBn7gsDEVz4RqYAzC9K2+/DYwEJ4EF+xPCNiBDD5Eth5A2+8o1liiQcEJtKjvZkVSR4I/r kVO9jM2oSgbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="470549771" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga004.fm.intel.com with ESMTP; 11 Jun 2021 00:46:39 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 11 Jun 2021 00:46:39 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Fri, 11 Jun 2021 00:46:39 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Fri, 11 Jun 2021 00:46:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7h6Wz0ISiPfDAmmntmqcKXPijr9x7DnozKRN1eYBjDJvwiaQmqqXWeRJFiPZAEFnD6AHX/P0Hh5ixXIs9sPMpg+u3yfVWbN+0NZkTAokaByDDynX5vrWbwQmDH3iJe1s9UwlpGFM7ZNhmYQAqeZE9RfW8rw4TR3ERqTzCgZcYG9uLEtGfOecPU4wPI51fXWjHUw2/xL5pHnoGwUhVVrb/235Az0YvSsT15NXSkJ99qeAg+g5Y8jhXHkfvLIAQfv9aMr5TTV8bwuwx8Ne9Tzc1DgouZa88T70K1O3VcV1O7w4CfOnmqmOqQyX5oHb8jqBvpgDNgqitJ9Ty+jE05hSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RfR6iCRNoZLlGgB9avcO7FCmk0uAF6O8g7AWufJ4PlQ=; b=EvLpmBXkHa/kw8c/Qxj1tI4wlYOhxJDdAm2N2ZFPTt/gDFpOWzir2/ckDj4fmwA0WZDL/ReO76MCWOgZHYOJ6fsqaFmYPGRtuE9LyU1VCxr3/PtPYh005NGi9+fbJsRPXTse42FFiRMpIOlOrTp+6/D4VAQBLbu9PkPhoLIkH1fGiTMSEcFtd3ynoLlYsacU5LSs40k+Hg2EizlODhK/edwCQbc5sNDOIdwBgDUMhrGwnKEZvRa+GNWqwj/YyU3RNfQMtDS3bteNkvGHmS3UdjSyb80SuQvolSU9HsDUmwzVikygxFM8q0xIB3TgiBeM2zMlwFYV7zXgvHPhtnFl9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RfR6iCRNoZLlGgB9avcO7FCmk0uAF6O8g7AWufJ4PlQ=; b=yqzx9SBKA//YGB3mwYlUOpywVzBbvuH86rdw0y6qCdtLJNeiFKpSDwYZhtbxd7lLejXrhWwneKRlcbD7vIuwyoh1BTJaNY/emZjo9+RlB0YZbnKMt4Yte1fJeBpOtmscW7z7+l0IFX9WCqDRfDxlkIc1u2/gONcMocdM/aEmZv0= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR1101MB2161.namprd11.prod.outlook.com (2603:10b6:405:52::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.26; Fri, 11 Jun 2021 07:46:37 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::b9d0:5694:1b70:c031%4]) with mapi id 15.20.4195.032; Fri, 11 Jun 2021 07:46:37 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "kuqin12@gmail.com" CC: "Kinney, Michael D" , Liming Gao , "Liu, Zhiguang" , "Andrew Fish" , Laszlo Ersek , Leif Lindholm Subject: Re: [edk2-devel] [PATCH v1 1/5] EDK2 Code First: PI Specification: EFI_MM_COMMUNICATE_HEADER Update Thread-Topic: [edk2-devel] [PATCH v1 1/5] EDK2 Code First: PI Specification: EFI_MM_COMMUNICATE_HEADER Update Thread-Index: AQHXXZpnzCD566nGBUCicqQmjnUV3asObx+g Date: Fri, 11 Jun 2021 07:46:37 +0000 Message-ID: References: <20210610014259.1151-1-kuqin12@gmail.com> <20210610014259.1151-2-kuqin12@gmail.com> In-Reply-To: <20210610014259.1151-2-kuqin12@gmail.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.143.16] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: be9d6e26-76d3-4fb2-8dac-08d92cad0ae1 x-ms-traffictypediagnostic: BN6PR1101MB2161: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FtRAoniXppBlhmEimAB/Hkub2pEWLyBtjLq98ncR5lDcnBHD/LwtqQ4ZNegHrbY75m/kOxNOLm7BER3ZgKT9inlJD4Rv9BCD4nhG4Nv+MJHu6ncHoMWZAj4cuNv/dJWyrKar0VmK6Ovf9nxnkMAeV6GzdGr9j6HTJxaPIz61V6fAFfu7QtFf16capqe3C4hNsthFsNLerV1EXv2Zq7k/gw0XvITWZ/rTRowWH4b2Ma/qw/E/KRzUNSt+RmMmLMtm+8ZRbMiU1PZDtFXUbEB7jKsFYj9AbgRcZgQULoogQj0Llkz64ElXjfnb78SoV6i9WRmF7+CyEdIsWqqY75Bu2AKJjOn/45jsgwWBYjxZyntjmQj7hYgE7oePP4MDJG8GbYrmpquFRydHud80aLUcRPauZh8RhtFfsXPpnsZgyZpdWfvy0Bwn1rXszB3HcEPKH+5vrSKUGFQvfllV8Vrc1XxIPgGUw78NL1PPoezUEP5lxo5UxNrmuuJZm6SlP6RFq4t/88+kTPrMycSA0EyMyvSq18IfNnliGMIMb3Yw15HH6PcNuDneHfwsErtw1cbh5MzmZR4erXIcMgO+7rapQcji23igJU64F0w5XqjzA/I5HE50aEcnKAQEjMs1XYQdctTul4woDf4CkTjrs8Ta1Hw/nWatAwHrwvK9RL3P5d1GiWW4gAGg1p8UTJj/F2CiNZYoSid3jkLkJQJl9FKKJfBbLK8Itjh2gbPEUZsKQLSrJ49rVWicRfwOzL3LwW4RKTQm1/TyT4VKMPkpwWNp/Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(366004)(376002)(136003)(396003)(39860400002)(52536014)(54906003)(66946007)(15650500001)(76116006)(86362001)(2906002)(110136005)(66446008)(4326008)(6506007)(316002)(66556008)(7696005)(38100700002)(8936002)(33656002)(19627235002)(478600001)(66476007)(64756008)(53546011)(966005)(8676002)(9686003)(55016002)(5660300002)(71200400001)(186003)(122000001)(83380400001)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?OljaHoi1gfvdvizWmMwHXjXQ6Y9TbXZtYhWX8xNxTto8/eJ59Jeg2EjwwrcQ?= =?us-ascii?Q?uGnUEAjX8nf+kR84wHbYB4nNiK8/pj6h5+5cv5CDp5ajw/gayKrFHQK0FL8j?= =?us-ascii?Q?Rv94WBUSiZQMOoSrOVKFk+jzVeWRX0YTxS3sxmO97rePDxP00Xbi18l4UhfN?= =?us-ascii?Q?Lq7cyQXqvtSfO99yE4gs/QnhuikQGEc69NyqSI8cZ29gRn3/Qh0hseBHBOCt?= =?us-ascii?Q?wvKrWqAN9AtZX7nQml4oTykYxxTi5H4DAEC1KPCPkmmbx1Lz/KX/l4/Gd/+c?= =?us-ascii?Q?aC+8HRmCCmnLokW0GTiCQpCUiEvYtI0gUzcBZu3e/br56UhIPU8UuCFMly7T?= =?us-ascii?Q?gxGyke//EjqEwl0+hkp/1ZqGWiq6/XNHCO6UoSKDI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qGojUsvcRD1gVFjJ9fUpIjl09NQQReBo909qEJ8cqn?= =?us-ascii?Q?U8H2RvuvXNi905WXCcGFwMu4?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: be9d6e26-76d3-4fb2-8dac-08d92cad0ae1 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2021 07:46:37.2284 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fl13Qjt4LZ/kH3tRHN6wRDFHIuTjqlioaPwO162G9VBEvNAb8yRZJ/kAsMFENP5+S4vdvortzWmkRdmhZ7MEjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2161 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Kun Qin > Sent: Thursday, June 10, 2021 9:43 AM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Liming Gao > ; Liu, Zhiguang ; > Andrew Fish ; Laszlo Ersek ; Leif > Lindholm > Subject: [edk2-devel] [PATCH v1 1/5] EDK2 Code First: PI Specification: > EFI_MM_COMMUNICATE_HEADER Update >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3430 >=20 > This change includes specification update markdown file that describes t= he > proposed PI Specification v1.7 Errata A in detail and potential impact t= o the > existing codebase. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Andrew Fish > Cc: Laszlo Ersek > Cc: Leif Lindholm >=20 > Signed-off-by: Kun Qin > --- > BZ3430-SpecChange.md | 88 ++++++++++++++++++++ > 1 file changed, 88 insertions(+) >=20 > diff --git a/BZ3430-SpecChange.md b/BZ3430-SpecChange.md new file mode > 100644 index 000000000000..33a1ffda447b > --- /dev/null > +++ b/BZ3430-SpecChange.md > @@ -0,0 +1,88 @@ > +# Title: Change MessageLength Field of EFI_MM_COMMUNICATE_HEADER > to > +UINT64 > + > +## Status: Draft > + > +## Document: UEFI Platform Initialization Specification Version 1.7 > +Errata A > + > +## License > + > +SPDX-License-Identifier: CC-BY-4.0 > + > +## Submitter: [TianoCore Community](https://www.tianocore.org) > + > +## Summary of the change > + > +Change the `MessageLength` Field of `EFI_MM_COMMUNICATE_HEADER` > from UINTN to UINT64 to remove architecture dependency: > + > +```c > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[ANYSIZE_ARRAY]; > +} EFI_MM_COMMUNICATE_HEADER; > +``` > + > +## Benefits of the change > + > +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 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. > + > +## Impact of the change > + > +This change will impact the known structure consumers including: > + > +```bash > +MdeModulePkg/Core/PiSmmCore/PiSmmIpl > +MdeModulePkg/Application/SmiHandlerProfileInfo > +MdeModulePkg/Application/MemoryProfileInfo > +``` > + > +For consumers that are not using > `OFFSET_OF(EFI_MM_COMMUNICATE_HEADER, Data)`, but performing > explicit addition such as the existing > MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c, > one will need to change code implementation to match new structure > definition. Otherwise, the code compiled on IA32 architecture will > experience structure field dereference error. > + > +User who currently uses UINTN local variables as place holder of > MessageLength will need to use caution to make cast from UINTN to UINT64 > and vice versa. It is recommended to use `SafeUint64ToUintn` for such > operations when the value is indeterministic. > + > +Note: MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib is also > consuming this structure, but it handled this size discrepancy internall= y. If this Hello Kun, Sorry for a question. I am not sure why the current codes in file SmmLockBoxDxeLib.c will work p= roperly after the UINTN -> UINT64 change. For example: LockBoxGetSmmCommBuffer(): MinimalSizeNeeded =3D sizeof (EFI_GUID) + sizeof (UINTN) + MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE), MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATT= RIBUTES), MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UP= DATE), MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMET= ER_RESTORE), sizeof (EFI_SMM_LOCK_BOX_PARAMET= ER_RESTORE_ALL_IN_PLACE))))); SaveLockBox(): UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof= (UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)]; Is the series missed changes for SmmLockBoxDxeLib or I got something wrong= ? Best Regards, Hao Wu > potential spec change is not applied, all applicable PEI MM communicate > callers will need to use the same routine as that of SmmLockBoxPeiLib to > invoke a properly populated EFI_MM_COMMUNICATE_HEADER to be used > in X64 MM foundation. > + > +## Detailed description of the change [normative updates] > + > +### Specification Changes > + > +1. In PI Specification v1.7 Errata A: Vol. 4 Page-91, the definition of > `EFI_MM_COMMUNICATE_HEADER` should be changed from current: > + > +```c > +typedef struct { > + EFI_GUID HeaderGuid; > + UINTN MessageLength; > + UINT8 Data[ANYSIZE_ARRAY]; > +} EFI_MM_COMMUNICATE_HEADER; > +``` > + > +to: > + > +```c > +typedef struct { > + EFI_GUID HeaderGuid; > + UINT64 MessageLength; > + UINT8 Data[ANYSIZE_ARRAY]; > +} EFI_MM_COMMUNICATE_HEADER; > +``` > + > +### Code Changes > + > +1. Remove the explicit calculation of the offset of `Data` in > `EFI_MM_COMMUNICATE_HEADER`. Thus applicable calculations of > `sizeof(EFI_GUID) + sizeof(UINTN)` should be replaced with > `OFFSET_OF(EFI_MM_COMMUNICATE_HEADER, Data)` or similar > alternatives. These calculations are identified in: > + > +```bash > +MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo. > c > +MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c > +``` > + > +1. Resolve potentially mismatched type between `UINTN` and `UINT64`. > This would occur when `MessageLength` or its derivitive are used for loc= al > calculation with existing `UINTN` typed variables. Code change regarding= this > perspective is per case evaluation: if the variables involved are all > deterministic values, and there is no overflow or underflow risk, a cast > operation (from `UINTN` to `UINT64`) can be safely used. Otherwise, the > calculation will be performed in `UINT64` bitwidth and then convert to > `UINTN` using `SafeUint64*` and `SafeUint64ToUintn`, respectively. These > operations are identified in: > + > +```bash > +MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > +MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo. > c > +MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c > +``` > + > +1. After all above changes applied and specification updated, > `MdePkg/Include/Protocol/MmCommunication.h` will need to be updated to > match new definition that includes the field type update. > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20