From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a01:111:f400:fe49::71a; helo=nam03-dm3-obe.outbound.protection.outlook.com; envelope-from=bret.barkelew@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on071a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::71a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 97B2022352291 for ; Tue, 27 Feb 2018 11:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BNyG/+DQ5bsufTNmacbOFffpiFph8/iiEIcs9oJ19Oo=; b=XVLoqEFxk68mx9EoXD+JlcyHF//pGcAKxfcVV6UDGtVbicLmvfLwnpdlC/g9hVagaQIYsGXrkI4dJuWRdkEQiBtxbVvf97FEF1ulUP16hr6bi8/jSYygM9KtviC/Hn/ESx0sMvmMgr4Ag6iwrbNNqYkEkfLCDtuYvQJBIy/1pho= Received: from MWHPR21MB0784.namprd21.prod.outlook.com (10.173.51.150) by MWHPR21MB0142.namprd21.prod.outlook.com (10.173.52.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Tue, 27 Feb 2018 19:32:18 +0000 Received: from MWHPR21MB0784.namprd21.prod.outlook.com ([fe80::7ca9:b5d0:a59:6379]) by MWHPR21MB0784.namprd21.prod.outlook.com ([fe80::7ca9:b5d0:a59:6379%3]) with mapi id 15.20.0567.002; Tue, 27 Feb 2018 19:32:18 +0000 From: Bret Barkelew To: Hao Wu , "edk2-devel@lists.01.org" CC: Hao Wu , Michael D Kinney , Jiewen Yao , Liming Gao Thread-Topic: [edk2] [PATCH] MdePkg/BaseSafeIntLib: Fix VS IA32 NOOPT target build failure Thread-Index: AQHTpG+hg++VQ0mQZEStQ4sc5DfmBaO4unIN Date: Tue, 27 Feb 2018 19:32:18 +0000 Message-ID: References: <20180213020856.11328-1-hao.a.wu@intel.com> In-Reply-To: <20180213020856.11328-1-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [131.107.32.41] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR21MB0142; 7:UndtWLDpIobW3QdNSHa4sTPA+Sh7HfwmDyk1xTAQnv2r5GY6ZIGeYrFpguF50o8ThePPjXSJGGxreN/lpcMhw1+Qv5lqqyJwW0SnwTYYm+oZtD1KWCMfDz4ctM2dqKk45FJ4WmsECVv7QpRtd9NBi6umHV1oE1MeBS0iU5VxpRuVRjBCou8fqiC18YzSJ5//pDe2m8EpAP3BKEskf/nxvgasVcEXihuvtanxML09SBJiM+xkx9nCM7YsId4vpKDF x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0e456acd-3d02-443d-7bdc-08d57e18d068 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020); SRVR:MWHPR21MB0142; x-ms-traffictypediagnostic: MWHPR21MB0142: x-o365ent-eop-header: Message processed by - O365_ENT: Allow from ranges (Engineering ONLY) x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(189930954265078)(162533806227266)(219752817060721)(21748063052155)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231220)(944501200)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR21MB0142; BCL:0; PCL:0; RULEID:; SRVR:MWHPR21MB0142; x-forefront-prvs: 05961EBAFC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(396003)(366004)(39860400002)(39380400002)(346002)(199004)(189003)(86612001)(3660700001)(2950100002)(53936002)(97736004)(9686003)(74316002)(5660300001)(236005)(2900100001)(25786009)(6306002)(7736002)(54896002)(4326008)(55016002)(14454004)(76176011)(5250100002)(229853002)(2501003)(6436002)(105586002)(8990500004)(6246003)(99286004)(72206003)(110136005)(66066001)(22452003)(106356001)(33656002)(7696005)(54906003)(316002)(606006)(102836004)(186003)(10290500003)(6506007)(81166006)(6116002)(53546011)(68736007)(3846002)(3280700002)(8936002)(86362001)(478600001)(10090500001)(6346003)(81156014)(2906002)(575784001)(8676002)(59450400001)(26005)(966005)(19627235001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR21MB0142; H:MWHPR21MB0784.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bret.Barkelew@microsoft.com; x-microsoft-antispam-message-info: T/xUQCKmiwd+WE+9mlpTba0qHs5fzKC0qiR7qX9v//N7+jodZZbvsOEQOam7HCNmrZTU0gTRyUnVcc7nwuoPIgAFa18nWpbxiv4OrHyHIPRdMDoX9HJBpXd07SoEtezEJuNPL/p7CKmaceXR+X0GKvfk/IyVFJQ3rob2JqBr8jE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e456acd-3d02-443d-7bdc-08d57e18d068 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2018 19:32:18.1174 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0142 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: Re: [PATCH] MdePkg/BaseSafeIntLib: Fix VS IA32 NOOPT target build failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Feb 2018 19:26:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com - Bret From: Hao Wu Sent: Monday, February 12, 2018 6:09 PM To: edk2-devel@lists.01.org Cc: Hao Wu; Michael D Kinney; Jiewen Yao; Liming Gao Subject: [edk2] [PATCH] MdePkg/BaseSafeIntLib: Fix VS IA32 NOOPT target bui= ld failure The commit resolve the VS IA32 NOOPT target build failure for modules that use the BaseSafeIntLib. More specifically, corresponding BaseLib APIs should be used when performing shift & mulitiplication operations with signed/unsigned 64-bit operands. Cc: Michael D Kinney Cc: Sean Brogan Cc: Jiewen Yao Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu --- MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 3 +++ MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 13 +++++++++---- MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 ++- MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Libr= ary/BaseSafeIntLib/BaseSafeIntLib.inf index 20a83ed97b..8fbdafe748 100644 --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf @@ -56,3 +56,6 @@ [Packages] MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/Ba= seSafeIntLib/SafeIntLib.c index d846160ba0..64b8bc4ad8 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c @@ -28,6 +28,7 @@ #include #include +#include // @@ -3373,8 +3374,8 @@ SafeUint64Mult ( // b * c must be less than 2^32 or there would be bits in the high 64-bi= ts // then there must be no overflow of the resulting values summed up. // - DwordA =3D (UINT32)(Multiplicand >> 32); - DwordC =3D (UINT32)(Multiplier >> 32); + DwordA =3D (UINT32)RShiftU64 (Multiplicand, 32); + DwordC =3D (UINT32)RShiftU64 (Multiplier, 32); // // common case -- if high dwords are both zero, no chance for overflow @@ -3409,7 +3410,11 @@ SafeUint64Mult ( // now sum them all up checking for overflow. // shifting is safe because we already checked for overflow abov= e // - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << = 32, &UnsignedResult))) { + if (!RETURN_ERROR (SafeUint64Add ( + LShiftU64 (ProductBC, 32), + LShiftU64 (ProductAD, 32), + &UnsignedResult + ))) { // // b * d // @@ -4011,7 +4016,7 @@ SafeInt32Mult ( OUT INT32 *Result ) { - return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Res= ult); + return SafeInt64ToInt32 (MultS64x64 ((INT64)Multiplicand, (INT64)Multipl= ier), Result); } /** diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/= BaseSafeIntLib/SafeIntLib32.c index 18bfb9e413..b3b7b802a1 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c @@ -28,6 +28,7 @@ #include #include +#include /** INT32 -> UINTN conversion @@ -549,6 +550,6 @@ SafeIntnMult ( OUT INTN *Result ) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Resu= lt); + return SafeInt64ToIntn (MultS64x64 ((INT64)Multiplicand, (INT64)Multipli= er), Result); } diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c b/MdePkg/Library= /BaseSafeIntLib/SafeIntLibEbc.c index 4478957b7e..e810ba59ef 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c @@ -28,6 +28,7 @@ #include #include +#include /** INT32 -> UINTN conversion @@ -607,7 +608,7 @@ SafeIntnMult ( ) { if (sizeof (UINTN) =3D=3D sizeof (UINT32)) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Re= sult); + return SafeInt64ToIntn (MultS64x64 ((INT64)Multiplicand, (INT64)Multip= lier), Result); } return SafeInt64Mult ((INT64)Multiplicand, (INT64)Multiplier, (INT64 *)R= esult); } -- 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flists.01= .org%2Fmailman%2Flistinfo%2Fedk2-devel&data=3D04%7C01%7CBret.Barkelew%40mic= rosoft.com%7Cd8ac84da07d848841ffe08d57286c19b%7Cee3303d7fb734b0c8589bcd847f= 1c277%7C1%7C0%7C636540845483912177%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw= MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1&sdata=3Db5dnMPDn1LjKQ19GW= Qdr8c4aAbrCWcp%2BjLPmbYApkG8%3D&reserved=3D0