From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.34714.1630000526996659051 for ; Thu, 26 Aug 2021 10:55:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=HgKlopr+; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="217524226" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="217524226" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 10:55:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="685019185" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 26 Aug 2021 10:55:24 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Thu, 26 Aug 2021 10:55:24 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Thu, 26 Aug 2021 10:55:24 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) 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.10; Thu, 26 Aug 2021 10:55:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MpaZA8ajv0oLLQvGWkw4YiCIw0ALyrMcKDRWQkpEV19O0XRP2vy8nXh9hsFp8R/S3hn7/q/1b64xIyPIi/88mmjUKaWUnmphYdpe5CxjIXFPtbBd1g/K/W993X5KDEe0B1hDsRrHYUrmxcXmbwQNkc5bq1uxpZyuD/VbCDIwbcREIgMUTrw/CCLQYs4BSlLAnyCz/Usq70VcVvplRXU8pMjVBvLFvxZYQwqAVlJb7wrifbZvQJTaRcDsSuhK5f2CPpCuG+Nk3rMDGNaTCRLDXy1tW5i40u23Tb7v5JBQqwTJ5x6LOLl30grST6SLDRXWxCCc95DbcAvJQelkseERBQ== 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=7uEzMVX0Sp57Vbt5KUKvRtTWnFzMGraFtQuNFDcwIbo=; b=ZRWHmm1Li8Lkq4N2NwL0WXfhpeOXF8lGsnfl5yF8GvgTTR0xGROlys43MGvHJmuawLtbSFN5oiU/OYhxAHWjBF9ltpEVv/iXw5DFzyzWJfUHx5chwgRMcFuZj2uYNrucqgQr+OpQfs264gdo3ULU0Ck2m2zEEnpa99ZzCFG57Z62QMkhXg6ajI5sgx0GCnK0H23O7eLb5yzyv+GJXhiRI0sfAlcC81SzVL0j7mPo4L3ayf549wW1fw/Mw29BjzGiVSQUgrmjXVTXRdSGlotS2fIRaDTWGB5uGf19iNgzcIeMBC3fz+XbGeSpVISYMrZbYB1JtauILY44HkgR8ctQoA== 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=7uEzMVX0Sp57Vbt5KUKvRtTWnFzMGraFtQuNFDcwIbo=; b=HgKlopr+eIOVUvr9gyPs1zxdlx41NTNrcG30yWGywWbsWUGNkqGyCQ9GQTPWPZ1S6DN9hoNYIQothZ/VC89RzUO5lcdcfR2nvoQXwwU7dTwv9wnXAU/bRhDefyaN40RbC0mSfjVOtDU2LToHEbv4gkdb5eUsL8Dj57RnF2xy0xM= Received: from CO1PR11MB4930.namprd11.prod.outlook.com (2603:10b6:303:9b::11) by MWHPR11MB1327.namprd11.prod.outlook.com (2603:10b6:300:2a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18; Thu, 26 Aug 2021 17:55:23 +0000 Received: from CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::c98d:a1f9:48a8:8865]) by CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::c98d:a1f9:48a8:8865%6]) with mapi id 15.20.4436.025; Thu, 26 Aug 2021 17:55:23 +0000 From: "Ni, Ray" To: Mark Wilson , "devel@edk2.groups.io" CC: "Dong, Eric" Subject: Re: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments. Thread-Topic: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks and comments. Thread-Index: AQHWuVC3eRpoPbCEOEuBfWvExydtsquH1DaQ Date: Thu, 26 Aug 2021 17:55:23 +0000 Message-ID: References: <20201113000518.338-1-Mark.Wilson@amd.com> <20201113000518.338-2-Mark.Wilson@amd.com> In-Reply-To: <20201113000518.338-2-Mark.Wilson@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.100.41 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f8e1e5c0-746b-4a63-ac48-08d968baad7d x-ms-traffictypediagnostic: MWHPR11MB1327: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1751; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pA7EP1K036ejEq9Dqs7pONKd9NnCmakGVlD7oyssmuZc6ChMe0sp6dArWZJ14+TUz3exM8UkkS5Jm0boD73naDc/TFPnNLnNrYZWCvbFoj5Tk1wtpCsmyoSt4CLSkp6UkuNhJ7T1Ro8UYlPQL6guOUzjsPJxYYtuBr4ueODmBB9HKmx0Fvi89OGjF8Zag2vpHFjw5UoeDWeUT1W1Q9mqYM1QljJg6ImwhLMm36CFgTzOlv3jZ0Fqx3hHEISgy6Q65juCVLRJb8q1xbIgRUqYiYdswerq9RH2nSKVe5Zym6xcd4/iHrXvVJxWsl5ghJBL8gjPxb77kK0OjM+7lhSR4M9I1olOfwBl/1xyoMWdOhwfl94NKwnEyxmTqPDtsnZ/wAbHmlIJnH2uDoS5Blj5Gm9bJThTWGI3wFZVVCUKokNHi83F4WIzDmue2Fhdew4WQ1n2QdTtgsd6KOzXchQ71oNvyxht8YI46rsPn8Y3v0UoypVA5QqCLKfYOuZ1ZRd/lqvTHN5AqGNgvjVe7Wnaxwre6K0CGtZfRNmCN57RwSab/7HqP+tbKAeJPAsMrsys20sbacFr0a3OqSjZKPx9cJgEU+A1wGhj+Mzq9XYyJpNSyAJ97n7rdMB18RHlxDYmeCPQ1i+FhQfGKdrLrOMvNhHUB3u5gwQCfqhdwihtQFEJd63QPKyLdN1JRqWLSY9/sTjcXnESLyi0T6aqgifOs4lpEc94uIuVQPjHAtJvi1zPr+DU9lIcFh1gPztce/hO8mTSwnvgl/FZLVOatjnGerc7tCGbJAwLkpHaBcJqBeg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4930.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(66476007)(83380400001)(508600001)(76116006)(6506007)(8936002)(66946007)(86362001)(966005)(5660300002)(2906002)(186003)(26005)(53546011)(8676002)(64756008)(66446008)(33656002)(9686003)(4326008)(110136005)(71200400001)(38100700002)(38070700005)(122000001)(107886003)(52536014)(7696005)(55016002)(316002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?aVew6MBVhk66H1kn+hpOi+b017eSacycYUoClxXXNi9ktZdwgQAWDoW2JOfx?= =?us-ascii?Q?oc3HE1XGpvqGXgSRsxCQcB0K9g4p7XONRsqrul8WsRZndszKrpLjjoyJ34IE?= =?us-ascii?Q?ddxDhfbLA9msWHUVyzADcwWuTVHyO8VijQCF4CZy46U3z8mBBkw3UCkxs3J3?= =?us-ascii?Q?7jSyw66EA2dgFupxPdNZlbfbIlnTmji4+0L18T0G5kiCb0hE06q/menDyLwE?= =?us-ascii?Q?GmZ1yVoRm1HgBoFy73PktKbv7sn1ssXNm1n7leiBCjE99dh86SXmgDA8H1em?= =?us-ascii?Q?eE0t6l7E+XVbi9IgTCroJFlOn7rFNMVyR3VLVd1LycDCQtg1VMec/g3TCVko?= =?us-ascii?Q?HvOgyjM1ikUztXca+kikYysIUnIWeT/NXrf64aloJOn8VqYCjhvS6/5dQ3gf?= =?us-ascii?Q?nUEd41XaKBQcZIF/1z1hSLYdySy7ELbKOh1B1NSSIAa3lpuQ/Ua/7wXica6n?= =?us-ascii?Q?nKtgFGFze2xBd3a5il6h36g6ktpvKKSd2NfG9ogCXJkI2X207mM5A/pm+KOZ?= =?us-ascii?Q?9vXoYO3/sWGHKUBjTwtxqbDZxm7xEKLctN5pEYx+qB6Z+rcrZHrfPADu3VOa?= =?us-ascii?Q?PCpvPu4yV30M/cX0zVVd8Jk5lQCMipzvJYX7i2MlkMvFAKwihh8UACnjTlBx?= =?us-ascii?Q?gOHPBdnuKxB908aQauhkpkKNJqF3LxG7lRv+xx4iaHprtUE6+LVUT7BhHBIu?= =?us-ascii?Q?4iNsqdL90QMhxs7UBa1EZynt0kLFT0vMeyBrWTkfijw+5HMVEaBysvYSrRuY?= =?us-ascii?Q?5XaAhFOJy2mvI1pTExcIqdujeyelpCxg0V16VwI1q4b+DcSNKVQOT/QaLyV6?= =?us-ascii?Q?gWEGyZFwi68qhXOBRsrrfC+dSb6Za4xtSY2u8wswJOVaqBxeLIkBSoxP3tjx?= =?us-ascii?Q?M8brmy6913wk1G8X1qQ2nup1Drq4V77tprLs0REfE2IcB+uwYL6hfoG2hcjm?= =?us-ascii?Q?yDi/kHthETWCNvskGRUDbT0+EbxRNzRZPfZZU6rTyXlMHJXDBulLhvBuxskz?= =?us-ascii?Q?fixgOB0/5tc1xZ/kBGah1wSM6y6IMVOgaNRRKw0yLhxMq+XOdlQJipwKApaq?= =?us-ascii?Q?JLU9OjwYIYtsFVbzYPdopH+qC6VazPB26Dv1xEurn1bPQwFSp3UOUohtqr+N?= =?us-ascii?Q?9gj+fMavcSlfnJ2eumghD1ZHzUgrJp+Xv2++ZLhTsAIraYSJkLuf9dqA97Pw?= =?us-ascii?Q?Oxru9AtkTWeu9Y79jCydHazgHFDpQbKKbGJFJ4ho6lMPsYi1oBhiNnKzoS8Z?= =?us-ascii?Q?C1lhEBKZqlzsP2FaFtBU9LvmyhPxciksMjCexeBTPclLhpmexaP4p5TTypep?= =?us-ascii?Q?DvRk83uOhNNSzQ98TMm8fLII?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4930.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8e1e5c0-746b-4a63-ac48-08d968baad7d X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2021 17:55:23.2221 (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: jm3U7hdY7DOUp/H1ZfoCAgUt3+AqmRrzkYSuyaLSlSi5CtEghEeHvT9a7F6f0PN38dE69k0EP4UeQZeov6FvzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1327 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Though CopyMem() copies nothing when Length equals to 0, I agree this patch= to totally skip the CopyMem() call. Reviewed-by: Ray Ni > -----Original Message----- > From: Mark Wilson > Sent: Friday, November 13, 2020 8:05 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray > Subject: [PATCH v3 1/1] UefiCpuPkg: Clean up save state boundary checks a= nd comments. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2956 >=20 > In functions ReadSaveStateRegisterByIndex and WriteSaveStateRegister: > * check width > 4 instead of >=3D 4 when writing upper 32 bytes. > - This improves the code but will not affect functionality. >=20 > Cc: Eric Dong > Cc: Ray Ni > Signed-off-by: Mark Wilson > --- > UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSm= mCpuDxeSmm/SmramSaveState.c > index 661cc51f361a..0ab5e1ba0f14 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > @@ -315,12 +315,12 @@ ReadSaveStateRegisterByIndex ( > } >=20 >=20 >=20 > // >=20 > - // Write lower 32-bits of return buffer >=20 > + // Write at most 4 of the lower bytes of the return buffer >=20 > // >=20 > CopyMem(Buffer, (UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterI= ndex].Offset64Lo, MIN(4, Width)); >=20 > - if (Width >=3D 4) { >=20 > + if (Width > 4) { >=20 > // >=20 > - // Write upper 32-bits of return buffer >=20 > + // Write at most 4 of the upper bytes of the return buffer >=20 > // >=20 > CopyMem((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + mSmmCpuWidthO= ffset[RegisterIndex].Offset64Hi, Width - 4); >=20 > } >=20 > @@ -539,12 +539,12 @@ WriteSaveStateRegister ( > } >=20 >=20 >=20 > // >=20 > - // Write lower 32-bits of SMM State register >=20 > + // Write at most 4 of the lower bytes of SMM State register >=20 > // >=20 > CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].Of= fset64Lo, Buffer, MIN (4, Width)); >=20 > - if (Width >=3D 4) { >=20 > + if (Width > 4) { >=20 > // >=20 > - // Write upper 32-bits of SMM State register >=20 > + // Write at most 4 of the upper bytes of SMM State register >=20 > // >=20 > CopyMem((UINT8 *)CpuSaveState + mSmmCpuWidthOffset[RegisterIndex].= Offset64Hi, (UINT8 *)Buffer + 4, Width - 4); >=20 > } >=20 > -- > 2.28.0.windows.1