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.web09.1637.1624412007217215493 for ; Tue, 22 Jun 2021 18:33:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=WiAbgQAp; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: hao.a.wu@intel.com) IronPort-SDR: RmneGeQCKdKkCJiiHIwSD+QpZmLhTAZdeumgWH82BJH6LXjnd7GATIwPoLDDxskl5IL31Pq7eu bnxsb2a6Bo+A== X-IronPort-AV: E=McAfee;i="6200,9189,10023"; a="204167282" X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="204167282" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 18:33:24 -0700 IronPort-SDR: QJOrptRkF1RxWIj73FI6uWwUhqjkk1GnJ8YUCeVQs5zMCh82OHZdpXURD78ImPVRUYNTL/esuW Sh2Qm3leb3/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="406523201" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by orsmga003.jf.intel.com with ESMTP; 22 Jun 2021 18:33:23 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 22 Jun 2021 18:33:22 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Tue, 22 Jun 2021 18:33:22 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.48) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Tue, 22 Jun 2021 18:33:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmTJ6QtmEa5cNF3LAFrqkAorrSifg9eBioiiP709UWDQLBKPVghfsgmfuoChSjSPuZDJcWUjmCjcwT83ovzUuRotumqRP4C/Bgv/FtxlMUPbyQl9cI8mZGSdxpEvoKxc6NpofrXMH1qGoC3aREz3K5IZzpcZ2GMU+j2H4NBK/OLMT1g77QxX0jSeCsv7b7ddYAIZtn3CYyU4rZmesfYZwKWMfA0J/Mf62HRac5Pn9v0b8W7RpXDoXdMtiDaMaakA9C3fb9eJh9FWxguuKkDWQvmk/haY2HSJkjJjxrhPsc3ZXropAQAuf77QayIty8d34dwdeqcqUwW3YiI004D/7A== 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=kNJSFLsu+73KzZWP0JWb/pKiPAq39V8C/DWQDs8T7Rs=; b=epYoyKakY3b0VC06XjNE5eiBxgSprt5ts2q2oEeL6n/3rvZcYNJRotwClnebgRPNwpIW+wxWJSiIyRsrH8JttBIgHJZ63Pv4n6M7xujsVE9kZFxiRxE9hg6tp7h5G8JHiE9ZtTnz2IP3UEl7SiclojD8sez4hfEQvx28x0IxJX40UNx6aPoj7TtjU0C+pJxtFu/r9d/kncdpq2VS5Yl89WRTl4sKHFiFjf8uq8aMih9b+2Pn9260DH9hjg+obAEPWczsDWWBRg9aLt7o+NDdkhowM3mZmXGkU2edOohq+vlphNTBIw6EdBXkn8x4kL0oEbck6+v19SHysxfY0eWDcQ== 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=kNJSFLsu+73KzZWP0JWb/pKiPAq39V8C/DWQDs8T7Rs=; b=WiAbgQAphFZd5aOQHXTkpBgOXoVujm39/JtHLXyDhvuqktmwBHokIidHN9GTX62kcBwghYoQA0pnkj1mg137ZCQO3sult8HXvAHwi/7ibKwvHdz5FtEPxDkJ8MMrd0aqbmlzOpm+tYsiDicPmQRYZ+4rijOXrbgoaEvEqPE1e78= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR11MB2033.namprd11.prod.outlook.com (2603:10b6:404:47::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.23; Wed, 23 Jun 2021 01:33:21 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::cd58:25ce:5017:619d]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::cd58:25ce:5017:619d%5]) with mapi id 15.20.4242.024; Wed, 23 Jun 2021 01:33:21 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "kuqin12@gmail.com" CC: "Wang, Jian J" , "Dong, Eric" , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo: Updated MessageLength calculation Thread-Topic: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo: Updated MessageLength calculation Thread-Index: AQHXZCDFs4eNNTAQKEyAqp1d0LLlxqsg0tSQ Date: Wed, 23 Jun 2021 01:33:20 +0000 Message-ID: References: <20210618090243.2517-1-kuqin12@gmail.com> <20210618090243.2517-5-kuqin12@gmail.com> In-Reply-To: <20210618090243.2517-5-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.142.16] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a1035391-2f1c-4e90-5cc8-08d935e6e299 x-ms-traffictypediagnostic: BN6PR11MB2033: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2512; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tWAtpRpRGlUBCNfqlFqThoWscaNeH5Nzh4UiPm7cTn1g1EbQnIig6mBqlWScCVlUuuJVt3F4MPzAHNYgDvqCEH8TxhVtMaj0+LkLdJfs1bIIxN4C7AqMMJSSePfzUO69cBkP2m697CudDbPHcrkMsPU8lKlfn7jqiut7a9U5aAXq9gXtyRv3jV36TJN7FsT09ASMSVjp+ux9ElZ8wQo0QDNUfhHR9JWbHahJg0/jINW7TNrG2FI5zKwgqVwcWG+0g15AD2Q4OZOA4r3SNJBs56fILZ2tCWYjs5NpYxEIwIan/+/cUJ5BJ7rcT0yKiiVYy3aaVpRv2WX5Z1B54OtT081SInc07zBOVxQDDbGAEDsZYEK25oZKfZmNiBuVXRCK24tcmPw6WQaV17OLUyf3phdef94FhQpQkO9BkUkQe9cbEOxtj1Lu8AeNnjaT8fys3FNmRacRiFf19ycZQ2A4kqkPyesr9WyuXCcx29HcqOcv3XxdfC0B2HXgGch/1a3xKPf5fPif3Wq6gsfrzkZ6wFK9+jndfxYtsjMI1REd6X6HXSsWshQumBrVxa2VgQUc3SCTLczVy/TG1ifFKhJrrLEdT1Que1AZbJkM/HqUzwtHuvFEqcea3x/Z0yqUNARidNEAl2eew4KM259YHTbp6ORxy2eb4D6fd5EJwC51HpP1hAFlqurRla1mFZSojlnzObEm/3tuT96/yauAiFK9EAB8SEZm4vLs1Jk2LdxNme4gHCF59Y5+6y4EjtQrMoyasHrWJ5n7iLbdqX7iDMy44SkceafpG9hMiUM26fXAYOXaOotpUSjEC+W6FFmiunZk 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:(376002)(39860400002)(346002)(366004)(396003)(136003)(8676002)(8936002)(38100700002)(83380400001)(107886003)(53546011)(55016002)(9686003)(186003)(966005)(2906002)(33656002)(26005)(122000001)(4326008)(478600001)(54906003)(6506007)(316002)(66446008)(64756008)(66556008)(86362001)(7696005)(110136005)(71200400001)(15650500001)(66476007)(66946007)(76116006)(5660300002)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?1cWYYnQVSySkbR+uVqNK1skJftE7OkGUgiq2b1wtU2t4FSfiN2cVHfjGkspG?= =?us-ascii?Q?w/AueWyJ6nTL+wqi3ATcaBCJZXxSy1JJgmfkaAYvIZn8zrIQGzP3LUGoF49P?= =?us-ascii?Q?19MjGufznadmCwTgpHeaMWJtWulaAa76Sbvo9Oyneq7Fl5Ro1xjEmg5Yvv4g?= =?us-ascii?Q?n1uQaopxxSN9I8DyycyS2p0CIudydFEbGlW4gsZBG6Y3bWZ2jk/o/MQDRZWA?= =?us-ascii?Q?Ls9QHSyQt4w/Sjmt1ZX8iJHoPKPxh62noOeNlaaSnunobYuXcvSS2LDSZjFt?= =?us-ascii?Q?yAB4LMWiWe9TH9HaREillgKbZgYShhExATud5/PvZ5cnnSXxcBGsUjHOGdXx?= =?us-ascii?Q?zITWAwM6wO6gKho9o1DmEEaQ6BSFkkniAMTBEZwB+V+h54FdTqVhl+W2nT6z?= =?us-ascii?Q?qf4PxOaUxM+pxbHi6FVX890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q?Csi8u0clZn8QN0mjSkli3d5y?= 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: a1035391-2f1c-4e90-5cc8-08d935e6e299 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2021 01:33:20.8548 (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: GLeSHlJKdZs8s9Gc19lerYfTV//TPmEUKlirKX0Jzdr1jpWxetMO/SFIOTdzOYY+8cOfJlIxahyTw3IZqdX32Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB2033 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: Friday, June 18, 2021 5:03 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A = ; > Dong, Eric ; Ni, Ray > Subject: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo= : > Updated MessageLength calculation >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3398 >=20 > This change replaced the calculation of communication buffer size from > explicitly adding the size of each member with the OFFSET macro function= . > This will make the structure field defition change transparent to consum= ers. >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Eric Dong > Cc: Ray Ni >=20 > Signed-off-by: Kun Qin > --- >=20 > Notes: > v2: > - Updated comments by removing "BZ" tags [Hao] Reviewed-by: Hao A Wu Best Regards, Hao Wu >=20 > MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c > | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > diff --git > a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo > .c > b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo > .c > index 4153074b7a80..4bfd5946caba 100644 > --- > a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo > .c > +++ > b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileIn > +++ fo.c > @@ -116,7 +116,10 @@ GetSmiHandlerProfileDatabase( > CommGetInfo->Header.ReturnStatus =3D (UINT64)-1; > CommGetInfo->DataSize =3D 0; >=20 > - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader- > >MessageLength; > + // > + // The CommHeader->MessageLength contains a definitive value, thus > UINTN cast is safe here. > + // > + CommSize =3D OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) + > + (UINTN)CommHeader->MessageLength; > Status =3D SmmCommunication->Communicate(SmmCommunication, > CommBuffer, &CommSize); > if (EFI_ERROR(Status)) { > Print(L"SmiHandlerProfile: SmmCommunication - %r\n", Status); @@ - > 149,7 +152,10 @@ GetSmiHandlerProfileDatabase( > CommGetData->Header.DataLength =3D sizeof(*CommGetData); > CommGetData->Header.ReturnStatus =3D (UINT64)-1; >=20 > - CommSize =3D sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader- > >MessageLength; > + // > + // The CommHeader->MessageLength contains a definitive value, thus > UINTN cast is safe here. > + // > + CommSize =3D OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) + > + (UINTN)CommHeader->MessageLength; > Buffer =3D (UINT8 *)CommHeader + CommSize; > Size -=3D CommSize; >=20 > -- > 2.31.1.windows.1 >=20 >=20 >=20 >=20 >=20