From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.70.105; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-oln040092070105.outbound.protection.outlook.com [40.92.70.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6E35921184ACB for ; Wed, 31 Oct 2018 12:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7FdWhuStfgdBNdEVKSB8UubkGlC5IZk2Io75rjvYfLI=; b=IfOH+pGF4RrGMzqTLgQmcX3CFe0uzsMmaQGgbaMyFsLO+Kp0VMlXaKn2YYi3Fjop1MV7Q5+hsN/p3rBRKNJU4xKCDFqT4k0Zx5VG8S0WGOUciaEmL10Y9xP3woq/s7tZHV6oMSCsUGdPEtX2OqmHOiXe2vK2xy+NkBPmY0XTFeSiPAUM054l4wfGhk3xgOyHaC68IkCFHctbjJPzZWAlt502BulcaUHFqxbxxM9PL93HIFJipRJt+zb2pMIQ9I4mTno4rL77IeaME9NQIpYXmIdqWdMfcqtLRLrZ5h3hzrinEZTwxS+cjIPpQKzefFxCVboGgdykmUIOsF3k2Pq73g== Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (10.152.20.60) by DB5EUR03HT210.eop-EUR03.prod.protection.outlook.com (10.152.21.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.14; Wed, 31 Oct 2018 19:55:49 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.20.52) by DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.14 via Frontend Transport; Wed, 31 Oct 2018 19:55:49 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::342c:bfb5:c08a:e4de]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::342c:bfb5:c08a:e4de%8]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 19:55:49 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: "lersek@redhat.com" Thread-Topic: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix ASSERT for success. Thread-Index: AQHUbptnvLzQubnneUOFpUp6QQY5eKU3EwHggAK15VA= Date: Wed, 31 Oct 2018 19:55:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:E1661EC5F8333E49F6973ACD901D934F8D77FA9069D41CE02F1507AE90AD8F69; UpperCasedChecksum:03FA2C3580C6A44DFD35BBEDF270F83B21E3D2BED520D3F87699B250898AA6FF; SizeAsReceived:7331; Count:46 x-tmn: [F5uu9alUuV/+H8HZyp9IsjR6e0JdowOg] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5EUR03HT210; 6:JmunOOxseyNHpugqukI6lKhGGUu0Vp8bs9wxHEyJjAjJ9pd6pdjbS8mQ++lT764rDJCMfXVaTFr37fAfvDF4ocXRU50fy8HHZ+twbbs3ye5qLWSbI1+5adEuU0rqB26U2Mk2lTu/XwFRMSHwfqyQ3IujL/7nc3SHLpRsZ4IgicxO2iCOQa5rcUWqvxN6SL7eMFGNm9PgQuDpuwoU07fniGkJBiZxXZWC7wUJ919kO4iDvma0OfKQIf2Odf5xFlXSLV4vG3tERcwDVf06Sgprznc33nFtbh+5fc6icSQz53QThahmKaL7Vq1IfOLdZ2tj6zliwKaR3xuryKvyP6l1ATlSSXuvSyzumZC0gGHEGuY9uL9LM0gbAmA3hN6wA9KBuPUYKduu7GrtEpJJDh5F/v4jdIywacmHydgZC8iDjk23aBaCC2GdvwAM+mDxDeqoH4uPbMjjZ22or6AGmErOSQ==; 5:ybMOPqKXZsVUM1RHbFWmN3uBr/RCcIHQEWsgBIeQOzygsnfhVtjlYcVL7aYMAog7V1mA4HkUXMXV+kBJlTfUdlb6nxZM11Hs847xA8bCTtR2IVC6bhKvZVqodQOfrZHDxJvzF32m+sljYheOd8IgkkgoQb40gJvnIdvSvRji/fY=; 7:WETPhUIcpargScPe5kr8wyr5/JEuh0xLnqDthV7MUeFlgmVY00KT7YLpcePzXAyQElMIkqpGEzmGXVG1gOnICqXLW3cLjibF0lvVlwxnyoqCi3w/wkHkHta2mIxYjM9maB+TzHoBOxjfqHYESc2SGQ== x-incomingheadercount: 46 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:DB5EUR03HT210; x-ms-traffictypediagnostic: DB5EUR03HT210: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:DB5EUR03HT210; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR03HT210; x-microsoft-antispam-message-info: CORd1rP6yW9agJliyUC31TXBCaperaTspfxCMMkZlvXnr9jKAggschHtY5egEaRk MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 0f20caa0-8eea-4e7d-397e-08d63f6adb28 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 19:55:49.5121 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT210 Subject: Re: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix ASSERT for success. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2018 19:55:52 -0000 Content-Language: de-DE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey Eric, I discovered it by accident, no tool was involved. Regards, Marvin > -----Original Message----- > From: Dong, Eric > Sent: Tuesday, October 30, 2018 3:30 AM > To: Marvin H=E4user ; edk2- > devel@lists.01.org > Cc: lersek@redhat.com > Subject: RE: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix ASSERT for > success. >=20 > Hi Marvin, >=20 > Thanks for your contribution. I have reviewed them and pushed to trunk. > SHA numbers are: > SHA-1: 4222e8e7e421e9c8d2c2f319a3860dd3332d6255 > SHA-1: 37fba7c2762e114a280e3b361b53ded034aac7e3 >=20 > One more question which just curious by me, how you find this issue? by t= ool > or code review? >=20 > Thanks, > Eric >=20 > > -----Original Message----- > > From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com] > > Sent: Sunday, October 28, 2018 4:51 PM > > To: edk2-devel@lists.01.org > > Cc: Dong, Eric ; lersek@redhat.com > > Subject: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix ASSERT for > > success. > > > > Index is initialized to MAX_UINT16 as default failure value, which is > > what the ASSERT is supposed to test for. The ASSERT condition however > > can never return FALSE for INT16 !=3D int, as due to Integer > > Promotion[1], Index is converted to int, which can never result in -1. > > > > Furthermore, Index is used as a for loop index variable inbetween its > > initialization and the ASSERT, so the value is unconditionally overwrit= ten > too. > > > > Fix the ASSERT check to compare Index to its upper boundary, which it > > will be equal to if the loop was not broken out of on success. > > > > [1] ISO/IEC 9899:2011, 6.5.9.4 > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Marvin Haeuser > > --- > > UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c > > b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c > > index b7c3ad31e82c..89b3f2b7257f 100644 > > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c > > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c > > @@ -110,7 +110,6 @@ GetProtectedModeCS ( > > UINTN GdtEntryCount; > > UINT16 Index; > > > > - Index =3D (UINT16) -1; > > AsmReadGdtr (&GdtrDesc); > > GdtEntryCount =3D (GdtrDesc.Limit + 1) / sizeof > > (IA32_SEGMENT_DESCRIPTOR); > > GdtEntry =3D (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base; @@ -122,7 > > +121,7 @@ GetProtectedModeCS ( > > } > > GdtEntry++; > > } > > - ASSERT (Index !=3D -1); > > + ASSERT (Index !=3D GdtEntryCount); > > return Index * 8; > > } > > > > -- > > 2.19.1.windows.1