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.web11.19483.1639441565837246594 for ; Mon, 13 Dec 2021 16:26:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.com header.s=intel header.b=chObf+D1; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: nathaniel.l.desimone@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639441565; x=1670977565; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=SsMdoMXcF4PU7kqy/yXV+WowlI9C29piOVvkW8ZShcg=; b=chObf+D1v09UL9ab1p24J7rCAg0ic0NiQodGb7MWwiVfdTjKFhmB0b+L OLNxdcpgOSHPcqejGRBdo3cND0tORBa2A15OfZFxOt3XYbdQrFz50biYI RXsrfVNFpfRpja/mdZ/K7me2JxadeINavFQMmEWUkGivlRlCOjnr0VBhG pPPdKJYT6WzbO3TbyBa40NkB95CGOjaEwETO24zG2xWoxVkiDb52trhZF 13TG53SMNgqbr1pCrEp4M+v+y9VXsxLWD9YGrdRKMSbYjI+msBvyhELco kr/50cJjFZQz2WQ1opwWZzCbovU8pfUdEfowZsih89ipGMASR0gBzI5ES Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10197"; a="236392957" X-IronPort-AV: E=Sophos;i="5.88,203,1635231600"; d="scan'208";a="236392957" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2021 16:26:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,203,1635231600"; d="scan'208";a="505138198" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga007.jf.intel.com with ESMTP; 13 Dec 2021 16:26:04 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 13 Dec 2021 16:26:04 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Mon, 13 Dec 2021 16:26:04 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Mon, 13 Dec 2021 16:26:04 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iC/55pzsq6Nczb5incAjkpxKal9akZthyHZ5uW39SftKt9V7NnzSQq+91c6knXOus/9NKKDG0DruI43P89Kd8ml8Ul48q2rwPK7uAklwNXBqP/2hsKNS0ZAQef1AX9A6hky++iBI/HGs5RSIg5zUS6Iy5VBGcw0oALTjIrPE64EuZrMd/sgH/cZ1Svoq6aUiR0Q+ZghL8WQAMjGQr0eyMbYBeXGZLeL1N0Nlh9wnARRjfacZef0BbQQm+pUR4vpIvSEmuBwjWzo7zyiwLDCxB7p9ttapQ8FOIIQlvNwVuXDn8SEcQYTRCGTUUcS/yJPrNSwiBnGh6Q8Ws4wvWhSoDw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=naJZobbxnRzOh6V9y3GtHESVOUNdiooy3BJoCc+e0HY=; b=EJ4DiZ3ncCk/43uFTnkTQLUHVBPrufEQ9rdaRqUqdHfMDsJcsh2QZY2M0rfkwzrSDtD8rmzTmMuBYv51DvzsbPNqAHlH4xaWjhifRrW4kDeI8+tO88ozMLL4/vk3E+UwXkZIYNK2szfG/53a0oLSCcLZXhAATjQ0I2EpiOaHVmMiDGXUsapeALrNJyl2ZjK622eSYABXDM3dQkSTUWr3p2nDCn87WHmuJP4C5xsAGjWXaREmosiuUKz4JhEGnceJGGYL8g07xDqWW2lGcOnjvEsNeXcKXkX6muLwmJsLujNsqxNPgrBmkKX5tmJ/EKiT9Si7mnxxbEOJR1eh8LPcnA== 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=naJZobbxnRzOh6V9y3GtHESVOUNdiooy3BJoCc+e0HY=; b=EKka4Sc+WvTY1MpsMQi+WWRkNwFal4yb0Z6VNHVK8GCmfTTprHzBBH/h9SwiJviTl98wPEQknH+Imm5WW64GMGy2HmZNZfDjGxSy0effXPV0WPHXKiF5ePRL3ZQN7AVb610sym4e6W8k6na+nz5iHxO+j5S4d4bRbCen0OCUIWA= Received: from MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) by MWHPR11MB1248.namprd11.prod.outlook.com (2603:10b6:300:27::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Tue, 14 Dec 2021 00:26:02 +0000 Received: from MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::6920:39b9:e18c:9dc5]) by MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::6920:39b9:e18c:9dc5%8]) with mapi id 15.20.4778.017; Tue, 14 Dec 2021 00:26:02 +0000 From: "Nate DeSimone" To: "mikuback@linux.microsoft.com" , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "Gao, Liming" , "Dong, Eric" Subject: Re: [edk2-platforms][PATCH v2 1/1] MinPlatformPkg/TestPointCheckLib: Fix DMAR structure length calculation Thread-Topic: [edk2-platforms][PATCH v2 1/1] MinPlatformPkg/TestPointCheckLib: Fix DMAR structure length calculation Thread-Index: AQHX7iVBrmJuxvZxUE20CY2q8waO9KwxJdgQ Date: Tue, 14 Dec 2021 00:26:02 +0000 Message-ID: References: <20211211002216.4464-1-mikuback@linux.microsoft.com> In-Reply-To: <20211211002216.4464-1-mikuback@linux.microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 742cb603-ca59-4594-fc2d-08d9be984f7b x-ms-traffictypediagnostic: MWHPR11MB1248:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:972; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6/2iJfm+Rp3v3PAGpbgR4XGEsiZySouZG7bt5nuh0A2FTA/dLv0BJgV5KHr+ovxs4ya5vjAd8XzhLeLGFct/RhzItHxUbQF1IlSDyXaECIpD9IJFMW5noaH9sWilrQ2nW4TyxOqoSUNfY+73D4hq5LNAJxfWcD51gYCmeLPtdJ+W1dGSAhyntYg5FzDhZvVVQfL7PZ8w5rxEodsD1gmTQNXbifZ3dDOSfm5CDg4glDT74zCK/mproa/qVyhzxv603X3CVfNq7O9TBKx6GRYaNUzFoy6rfqGV19sinNqb6SqmpIG4iE+w1lDO9/qHA9lHTCz5MEmQ5csjJaFYFjto7JqySd5o5LSnsfGVNWrgBovpzrTYJ8SFqBNFRhqTLTlevo9tcQrm+F3gbOGaN2Im4sEBk/+UA8vJ7WG8ALHzSqKzQ4Cme1rC9hO6e3hc2WYDld4tSUwfVJhykmGg1BusM0Z+2P1IqQlSvvJwmhfX5u5cYUAkM77ssvL7YUVC5OGahaVLT5g/XRNLzYQR2DMjDrnwqpz7RJl2oeF18DHREKcfC4epaA4G4mdhF0ITJoS/waI3Ln0+7dQjBFkExtPcUA5mxn3JT/M4xLYw+p2e4MS2JvxMwt+9uuLfjYa2ZXtQAa7/uxmFV2KA3IULA4VBwttdUIw0KulTI9qr9PtYEBHRmkpfOdol2UakABoUk+MsTA4bqFgQyxrWOw1EctOJMqihlqWw18HZ5DDJtO2DLueZtSLPJI0el53b95KVElLPsgW4tHQg39MQW7PLzhqwIa19yJ5KVx8t9G0YPcOK67vGhA4gQWMhYjobFfM55gRm5dOJb3cwPG//U3A6enOpdg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5821.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52536014)(66446008)(66556008)(186003)(122000001)(53546011)(26005)(7696005)(86362001)(55016003)(38100700002)(6506007)(2906002)(8936002)(64756008)(83380400001)(66476007)(508600001)(966005)(9686003)(5660300002)(33656002)(38070700005)(54906003)(71200400001)(4326008)(66946007)(82960400001)(107886003)(316002)(8676002)(110136005)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?aR495whbfSdA8qDvLtPGCzNTm1r0pwhkrRNL1S+0fFLK0ntSgDWXRIq9su0v?= =?us-ascii?Q?RR2bjQ/Ai3kKuVK15owdDJYLyY5g8HP4o+S3K4kLODdEYlHvm+UYGi1nAF69?= =?us-ascii?Q?gtygzmSEqQPHJ8VPr7B0AOAR3CBkUQ6OQmk56BXPBK/cH47CUU/RMrFQbldn?= =?us-ascii?Q?l9OD1ZzhLA8L7L6mwGdGXIjE2T+U9lLsY0a8dDbh24nAEmX5Kiw6gziA7L+e?= =?us-ascii?Q?gzs8+moRqbAw1Aai5UYj7X9jNbk0mIbRnB0TC/8plUzcxEBfrhwunIETbSKK?= =?us-ascii?Q?0LvgUpWicCY4R1JdBDW8X6o9m1UhzGV54k5gZB3dnT4aQk+xL1HW9UGAhExS?= =?us-ascii?Q?UKdVu6dzHTA1cPCXoWyLiUKBLhU7ttIdJ7RWFQ3/YE0JhM4Hd1kidQzDB/36?= =?us-ascii?Q?1CGwaM6MceciuTRo+2N3NMs5/GqYXZrEXeScSWAF8ivDWMTsNplni27xIffm?= =?us-ascii?Q?Wny3yjyOVkWG8IIr4vLE1OXZ5/cxA1ael3jsiDVr1eRTO1ObU3yL9oQJrXXk?= =?us-ascii?Q?4r3k4lbeBeZZusWsrZ0bCutX7oTG55ggPkqg4AboyrWncW6NqxtEWxk6Anwh?= =?us-ascii?Q?YjVFiimtw2QkVWONVs2ld+Mp4iTtdWqibawpBl74SynI5grtzFWS/RpWVJcJ?= =?us-ascii?Q?CsaNXnB29hbC8W03Y2/Iu7KiGbzBzxTxYz3R0uyPtbQR5vEj/Hc3iORucU5D?= =?us-ascii?Q?8fAN+sIWQeInhNS0Fu1PQC/uD950fADcG/FX7MBS43dx2jvBVJkFktA/AREA?= =?us-ascii?Q?ELPR7XabgDgLRbatF25k8n7ZMtrqCj86LI7mw+6o3x09SEoQoQ+zij/tiM3L?= =?us-ascii?Q?PbyhPoNL/Gm+2gRrWgDKTxsZDHs5bFLuMdRHl4NQJLn6neCu0UWEM5DDa5cb?= =?us-ascii?Q?2kdEQFyNedqpoFsNTyaSaZHZ1a0WzOSX0TDR21hp8oj5lW8qE6Y+625CvnnX?= =?us-ascii?Q?4eCHpmL8vW92kiIFGszW77uaDm+TosTOVRJIUXl8bfadofpRuBPGdUVqqA43?= =?us-ascii?Q?5E5JEz9LcEdVIjTeFgEjBLPo6yZfjLAgKmmQoCI+gv8cHDUdNRyZTtmU2lNa?= =?us-ascii?Q?lKh7g1uEcWr4fRvKuwxSSoV5m2c/3wW3JOL9gtvO3UGTqllI+0G0TqjgQEqb?= =?us-ascii?Q?Jfq/qrqiGOuNF1uQ6yRQ0yFBtkiyzftU75GulEe6I039UGKn7gALZ9z68fjd?= =?us-ascii?Q?pINkcvSAtTddCT7qTmXqO3b27u39vS9TKibozPIeRht4tU0yhEY4Z4QXqrHK?= =?us-ascii?Q?EG0TevAjcZzlPB/dNVvVx7J4ScGSkht7cHpkn6uqRcRI54X5jV19BM477f4M?= =?us-ascii?Q?3hI1EcQM9/usDsUN2jJbKl7CifAUqqWYVOOQN3J7vBBJcVyndlPNFulcK1II?= =?us-ascii?Q?S3neUWDRcSlNPvfOJpy+/XO2BuQjXf0Y+ShG8GfmBbgR2LvChaoW8eleXAOY?= =?us-ascii?Q?ZpgE/rPivX8imAmpTpvzD0+uL87nN/C66nPnxwDw4MgxEUx9Qyp8CXvUlyNP?= =?us-ascii?Q?iLOjfEfYxeEw8VPH3C+j7fB3EEx3w0hYhCMg1/Iyayte4X1vEgCTu/fbhWah?= =?us-ascii?Q?sOoIBIyTuZWeS1X4kHQPrWbqu2kbplJQl+0Vnz2AcO76gpdKFbG5kvcjxfIQ?= =?us-ascii?Q?/lh+5W0E1uSVISZicvNLki0rHIH8DZaf7ZWG3pg8u2i7vlavcStaA35KZ6Tl?= =?us-ascii?Q?GMcyyg=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 742cb603-ca59-4594-fc2d-08d9be984f7b X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2021 00:26:02.6217 (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: mBpkyBL8YDh7o2rabe0NJAuCVR1Wn18J+TeYiwHneAqZsEOdCZFaizphVX+s8ObTtBPQ9gpbKz+rvwuIKsw+wp5eCU6xgkAvCLrQY69XfH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1248 Return-Path: nathaniel.l.desimone@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Pushed: https://github.com/tianocore/edk2-platforms/commit/871ce77 -----Original Message----- From: mikuback@linux.microsoft.com =20 Sent: Friday, December 10, 2021 4:22 PM To: devel@edk2.groups.io Cc: Chiu, Chasel ; Desimone, Nathaniel L ; Liming Gao ; Dong, Eric Subject: [edk2-platforms][PATCH v2 1/1] MinPlatformPkg/TestPointCheckLib: F= ix DMAR structure length calculation From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3768 When processing DMAR structures of type EFI_ACPI_DMAR_STRUCTURE_HEADER within the ACPI DMAR table, the code determi= nes the structure length by subtracting the DMAR structure headers present = from the overall DMAR ACPI table size. The terminating condition is that the remaining total DMAR length is greate= r than zero. However, the current DMAR structure length is subtracted after= the DMAR structure pointer has already been assigned to the next structure= . This change subtracts the current DMAR structure length before transitionin= g to the next structure. The terminating condition is also updated to ensure the remaining size is a= t least as large as the expected structure header size. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Michael Kubacki --- Notes: V2 Changes: =20 - Updated the terminating condition to ensure the remaining size is at least as large as the expected structure size. Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiD= mar.c | 8 ++++---- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDmaPr= otection.c | 4 ++-- Platform/Intel/MinPlatformPkg/Test/Library/TestPointCh= eckLib/PeiCheckDmaProtection.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeCheckAcpiDmar.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointChe= ckLib/DxeCheckAcpiDmar.c index b2279966d8ed..e0b7aaa48527 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= AcpiDmar.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh +++ eckAcpiDmar.c @@ -133,7 +133,7 @@ DumpAcpiDmar ( // DmarLen =3D Dmar->Header.Length - sizeof(EFI_ACPI_DMAR_HEADER); DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)(Dmar + 1); - while (DmarLen > 0) { + while (DmarLen >=3D sizeof (*DmarStructHeader)) { switch (DmarStructHeader->Type) { case EFI_ACPI_DMAR_TYPE_DRHD: Drhd =3D (EFI_ACPI_DMAR_DRHD_HEADER *)DmarStructHeader; @@ -204,8 +2= 04,8 @@ DumpAcpiDmar ( DEBUG ((DEBUG_INFO, "\n")); break; } - DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8 *)DmarS= tructHeader + DmarStructHeader->Length); DmarLen -=3D DmarStructHeader->Length; + DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8=20 + *)DmarStructHeader + DmarStructHeader->Length); } } =20 @@ -220,7 +220,7 @@ CheckAcpiDmar ( =20 DmarLen =3D Dmar->Header.Length - sizeof(EFI_ACPI_DMAR_HEADER); DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)(Dmar + 1); - while (DmarLen > 0) { + while (DmarLen >=3D sizeof (*DmarStructHeader)) { switch (DmarStructHeader->Type) { case EFI_ACPI_DMAR_TYPE_DRHD: Drhd =3D (EFI_ACPI_DMAR_DRHD_HEADER *)DmarStructHeader; @@ -232,8 +2= 32,8 @@ CheckAcpiDmar ( default: break; } - DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8 *)DmarS= tructHeader + DmarStructHeader->Length); DmarLen -=3D DmarStructHeader->Length; + DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8=20 + *)DmarStructHeader + DmarStructHeader->Length); } return EFI_SUCCESS; } \ No newline at end of file diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeCheckDmaProtection.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPoi= ntCheckLib/DxeCheckDmaProtection.c index 10b44fe8b9b8..aba0985956f2 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= DmaProtection.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh +++ eckDmaProtection.c @@ -38,7 +38,7 @@ CheckDrhd ( // DmarLen =3D Dmar->Header.Length - sizeof(EFI_ACPI_DMAR_HEADER); DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)(Dmar + 1); - while (DmarLen > 0) { + while (DmarLen >=3D sizeof (*DmarStructHeader)) { switch (DmarStructHeader->Type) { case EFI_ACPI_DMAR_TYPE_DRHD: Drhd =3D (EFI_ACPI_DMAR_DRHD_HEADER *)DmarStructHeader; @@ -56,8 +56= ,8 @@ CheckDrhd ( default: break; } - DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8 *)DmarS= tructHeader + DmarStructHeader->Length); DmarLen -=3D DmarStructHeader->Length; + DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8=20 + *)DmarStructHeader + DmarStructHeader->Length); } =20 return EFI_SUCCESS; diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/P= eiCheckDmaProtection.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPoi= ntCheckLib/PeiCheckDmaProtection.c index cb764b3633ef..5a18235eddf4 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheck= DmaProtection.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCh +++ eckDmaProtection.c @@ -36,7 +36,7 @@ CheckDrhd ( // DmarLen =3D Dmar->Header.Length - sizeof(EFI_ACPI_DMAR_HEADER); DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)(Dmar + 1); - while (DmarLen > 0) { + while (DmarLen >=3D sizeof (*DmarStructHeader)) { switch (DmarStructHeader->Type) { case EFI_ACPI_DMAR_TYPE_DRHD: Drhd =3D (EFI_ACPI_DMAR_DRHD_HEADER *)DmarStructHeader; @@ -61,8 +61= ,8 @@ CheckDrhd ( default: break; } - DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8 *)DmarS= tructHeader + DmarStructHeader->Length); DmarLen -=3D DmarStructHeader->Length; + DmarStructHeader =3D (EFI_ACPI_DMAR_STRUCTURE_HEADER *)((UINT8=20 + *)DmarStructHeader + DmarStructHeader->Length); } =20 return EFI_SUCCESS; -- 2.28.0.windows.1