From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.66.109; helo=eur01-ve1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066109.outbound.protection.outlook.com [40.92.66.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EF9492117B56F for ; Sun, 28 Oct 2018 01:51:25 -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=FyJP9J5Ovqi6zJfNn7D0JbyACIX9qQDAsTzH3ljANiM=; b=khVMQytsv1vJpXmjJ8XA4pU9YXiN/aezgfAUfZkKNhasOe2UN05MPkx7jpc3SYGbzbp4MsgsCe+TrFD8cYRgo3dxXa0e+dulgTc9n312eQUTQaKchJhqZ1wp2oq8ud0mQ2vXj7GWSyFkipik29CMLiqkrppZ58tMhgXTpgdfqtwCTTh3VUv+t6V7qiZtelA6VQ92OmsTpI0o89O11K18rMp5Nso7nSMKyqJK0OL1DF9TINAmWOIQqGKm01N/9KjLf6yN1+PhEBN8npMlSFmiL5YdSiB3HAW9zwulpl4oW2uqV6ngHFx2TeoM6DZN79Igygdpp1aYCnOa6owugZlZPw== Received: from VE1EUR01FT027.eop-EUR01.prod.protection.outlook.com (10.152.2.56) by VE1EUR01HT053.eop-EUR01.prod.protection.outlook.com (10.152.3.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.14; Sun, 28 Oct 2018 08:51:23 +0000 Received: from HE1PR0801MB1786.eurprd08.prod.outlook.com (10.152.2.53) by VE1EUR01FT027.mail.protection.outlook.com (10.152.2.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.14 via Frontend Transport; Sun, 28 Oct 2018 08:51:23 +0000 Received: from HE1PR0801MB1786.eurprd08.prod.outlook.com ([fe80::d077:4763:1d00:a054]) by HE1PR0801MB1786.eurprd08.prod.outlook.com ([fe80::d077:4763:1d00:a054%2]) with mapi id 15.20.1273.027; Sun, 28 Oct 2018 08:51:23 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: "eric.dong@intel.com" , "lersek@redhat.com" Thread-Topic: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix ASSERT for success. Thread-Index: AQHUbptnvLzQubnneUOFpUp6QQY5eA== Date: Sun, 28 Oct 2018 08:51:23 +0000 Message-ID: References: In-Reply-To: Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR07CA0021.eurprd07.prod.outlook.com (2603:10a6:209:2a::34) To HE1PR0801MB1786.eurprd08.prod.outlook.com (2603:10a6:3:88::17) x-incomingtopheadermarker: OriginalChecksum:5B92A817EFABD4373FF1B98C813D58423AA3FFDB98FB89A7DABC48F5A8885549; UpperCasedChecksum:5904F68EDE180BEAE29013E3BA5AA849DDEA1288A969A1CFBF90B3C64A84F545; SizeAsReceived:7593; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [EiyNd1SnRAFFWjNx0ZTfxzHVGOjZOT8e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR01HT053; 6:ZzQDCk9PAhNO+1WiT9Pd+lSDK+5iXgIkvEjbSUa9tHEECqBODxeZynrvOuQeAo4xsXd2kYl0+TGvC7IhHg+wUeAGzm5+cgHyp+a5grPzrn27IbcyZ1d/twyrNqlDK16YS0sx1QPdi+0CaVjobQnms23K3pK2n8N4F2+FAKJRG5HFTwN58qCUe/DsmdBdsVnzkBWqLAZPWwULt1qR4N9MVUxIxKtFoSDD0Dup/mGWb335ZJ312VlqjNkfB84YXQkVT9/6vGgrWwMJHRWfH65MSpkI/3jDAFsqZ8aeLgKvUX0bv7uIN7qUH7uIiHeDQov4ZS7aJQy0umcUsMfWraEgu+/kxmzVhPTOTLJukpo9UsVjRM0PmB4+UDW2VXN0yCNzpv9bpqWUIlxXi7ypeVk+iu9mx8WLZEJqOFAfS9s/KDGCE++Oo0p4cGQUohRtGttdP2nL7/qEF12sM13z42P6Vw==; 5:Wfq0HabwigNPWTAogiH77EcCVaibqAuavqpvKg/dgggextvLZpNAZn6wnQpnqu7v/fLydrT/XZEXhJrQ9MT8+jT4jMzyoV7nT0COTmAuTOihJtvMEtnkgeC65Y1illS1O3hSbbYHuboNID6PT6VxcBikSnNr1YOpfPewc/SmFpE=; 7:Ijgpak8VHzFf//K2GSh0k29yQ1wp4LFUrsh8A2tDgQ4iwLJnYi7NQFME1tF/mjK9d88VsKkEoWPF44ChXkFqhv6ScnDhHFzyWYza5FELo4Jsc02GtBtC94ymmcWABjhf7OPaZ/tBmowdeKBCImAFMQ== x-incomingheadercount: 50 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:VE1EUR01HT053; x-ms-traffictypediagnostic: VE1EUR01HT053: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:VE1EUR01HT053; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR01HT053; x-microsoft-antispam-message-info: Xs/nceU1LZXVrkRWkLGeYT3pHb9/arwehVrL1HcOE6ZRmnXslyyFRh1FDmZT6tY+ 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: 60a2377f-7661-47c1-9226-08d63cb28960 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2018 08:51:23.2401 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT053 Subject: [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: Sun, 28 Oct 2018 08:51:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 overwritten 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/PiSm= mCpuDxeSmm/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; =20 - 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; } =20 --=20 2.19.1.windows.1