From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=E//shpDE; spf=pass (domain: arm.com, ip: 40.107.8.48, mailfrom: krzysztof.koch@arm.com) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.48]) by groups.io with SMTP; Sun, 18 Aug 2019 23:28:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JwbwEHWRgp1hprNXorxByjjSffJZcphHQg1fIkJTmMY=; b=E//shpDE2P2F80bm5gFBDOJLwa2rCCYozABfmuMtfp9p+UApC6QutVW0yktiV2pR85rPevdlh4Doa5LNdY4zYT50nD1TwFYYvakC8S7gGv5NSZkvwwGRx7r4+XmCHtGR6EmhHpd0j1kFkKfip/JAgpN69+RD5c8fc41S5KVma20= Received: from HE1PR08CA0047.eurprd08.prod.outlook.com (2603:10a6:7:2a::18) by AM5PR0802MB2594.eurprd08.prod.outlook.com (2603:10a6:203:99::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 06:28:17 +0000 Received: from DB5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by HE1PR08CA0047.outlook.office365.com (2603:10a6:7:2a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Mon, 19 Aug 2019 06:28:17 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT046.mail.protection.outlook.com (10.152.21.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Mon, 19 Aug 2019 06:28:15 +0000 Received: ("Tessian outbound 71602e13cd49:v26"); Mon, 19 Aug 2019 06:28:12 +0000 X-CR-MTA-TID: 64aa7808 Received: from 916f52c0bde3.2 (cr-mta-lb-1.cr-mta-net [104.47.5.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 74C8E8B0-1425-4423-82ED-B32A08285921.1; Mon, 19 Aug 2019 06:28:07 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02lp2057.outbound.protection.outlook.com [104.47.5.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 916f52c0bde3.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Mon, 19 Aug 2019 06:28:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z4VFubGk/fNsCrN5sM/tDMlbEtud5yo5g18LeS+tF20UDo1lhHCknUSVi/1EiF46pPAgdvwCe0nc4oeXz4QZHYanU7NlGXs5O8k0qmI8oG5XaPl07wQobHWmWbZ+yDQ1olgheZC1o4gbcDQQmVHhlJBe6AEdiUxv4txwra6Xdo/Ofx8KGZEDSWYjDobIRfhm11yOBg2p8cvhEWAICST9ZPtjUIUQS6a/kavScIiaZTcdelMZJKKsPJOKF2FY/DH6MqnFbs2BTkA0/6bSTNoKjHlfBBnjPF+36+//tidhEI5t/qEiwM/IQlNpY04d2g3TL9k5VWgP74kkTiSPWrKlFQ== 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=JwbwEHWRgp1hprNXorxByjjSffJZcphHQg1fIkJTmMY=; b=A0RWIPZxOrri0GlU9/EIL0/3VUmorYeFJhnQfSE8Z3CW6M+2JZkZ6Fcp+/1IukDS9NbfzlXzMuDbrKbBj23EY4nqXOx8BE2JAtecToJJR1bPHIC/sqm/U6JhX/7LyLDeTGNTWXCtG51GUxGcfZ/zLUSEfAX2yqyZRyFG7tiESrRORYlUDu9sOpdZjjk/LZG3dZnYQF3AH+UiRsxA+xQ96/+v66QAnuoV4Fq/P6AGp4lPRWKgwy+w/xaO+FD3A+aRHqpU9zPTGKMJaT/0KgjOqfJIHqnRsr1l9HHECN7JZSdYZ4XaoHVo1OE7M2dIbCI9ubFJ9CMB2ceg7csxUl0TjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JwbwEHWRgp1hprNXorxByjjSffJZcphHQg1fIkJTmMY=; b=E//shpDE2P2F80bm5gFBDOJLwa2rCCYozABfmuMtfp9p+UApC6QutVW0yktiV2pR85rPevdlh4Doa5LNdY4zYT50nD1TwFYYvakC8S7gGv5NSZkvwwGRx7r4+XmCHtGR6EmhHpd0j1kFkKfip/JAgpN69+RD5c8fc41S5KVma20= Received: from VE1PR08MB4783.eurprd08.prod.outlook.com (10.255.114.16) by VE1PR08MB4813.eurprd08.prod.outlook.com (10.255.112.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Mon, 19 Aug 2019 06:28:04 +0000 Received: from VE1PR08MB4783.eurprd08.prod.outlook.com ([fe80::c0c1:9dbc:4681:6b5c]) by VE1PR08MB4783.eurprd08.prod.outlook.com ([fe80::c0c1:9dbc:4681:6b5c%7]) with mapi id 15.20.2178.018; Mon, 19 Aug 2019 06:28:04 +0000 From: "Krzysztof Koch" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Carsey, Jaben" , "Ni, Ray" , Sami Mujawar , Matteo Carlini , nd Subject: Re: [edk2-devel] [PATCH v1 05/11] ShellPkg: acpiview: SLIT: Validate System Locality count Thread-Topic: [edk2-devel] [PATCH v1 05/11] ShellPkg: acpiview: SLIT: Validate System Locality count Thread-Index: AQHVViwCC8fTdh1LjU2xbT5sKDbvUqcB+c8A Date: Mon, 19 Aug 2019 06:28:04 +0000 Message-ID: References: <20190815131121.52644-1-krzysztof.koch@arm.com> <20190815131121.52644-6-krzysztof.koch@arm.com> <3CE959C139B4C44DBEA1810E3AA6F9000B82386D@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B82386D@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: b79c720a-3319-4825-8ed8-763655620b5b.1 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Krzysztof.Koch@arm.com; x-originating-ip: [217.140.96.140] x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 2b16f323-1ca8-43df-4ef1-08d7246e6ab5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:VE1PR08MB4813; X-MS-TrafficTypeDiagnostic: VE1PR08MB4813:|AM5PR0802MB2594: X-MS-Exchange-PUrlCount: 3 x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2150;OLM:2150; x-forefront-prvs: 0134AD334F X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4636009)(366004)(136003)(39850400004)(396003)(346002)(376002)(189003)(199004)(13464003)(11346002)(186003)(53936002)(102836004)(2906002)(9686003)(71200400001)(7696005)(14454004)(53546011)(99286004)(446003)(305945005)(316002)(478600001)(6506007)(15650500001)(66066001)(486006)(2501003)(86362001)(966005)(25786009)(110136005)(74316002)(8676002)(4326008)(81166006)(81156014)(6436002)(6306002)(5660300002)(14444005)(256004)(7736002)(8936002)(229853002)(66446008)(64756008)(66476007)(54906003)(76116006)(66556008)(66946007)(33656002)(76176011)(26005)(476003)(3846002)(6116002)(52536014)(6246003)(55016002)(71190400001);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR08MB4813;H:VE1PR08MB4783.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: Qq4aDQ4NHhEUHjmeNYZtRG5OwKsHCTJq+SsHLIW50guYM08ZCfJeZIX8vzjNRUoFlXIrcyEIlWml+PBMlkEoHGp0xKbCkEwFK/T/PqU/Bag4zlhqtm6k/skhWH9G02YdXXbTGW8R6a1pmpgs3i8PbXuhDioQs52Jf5tEaSyQ4N+A9FSQGVVUyfA15gH+ECwBSkdubvGIaGmevmWDpjbLvxlYigUNmHdCl6D2k7h7mK0Qk/82PgVadO0eyaZo1YmZhaEG35ze8DDrPimUc/lrJURweSnRgDRQSloKD2tLuib7L99TiZ3iA8Qx58XfIt3NLOeXM0tox7YhzTUBc6hYz28E0tm+bcn6gfnmnwrv0lpGPd24lRKyYumZbVQhOYE1ydpWDxVCVu/LCSMjiijPu31+2ENIAeRZvVYezNixZi0= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4813 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Krzysztof.Koch@arm.com; Return-Path: Krzysztof.Koch@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT046.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(136003)(346002)(39850400004)(376002)(396003)(2980300002)(189003)(199004)(13464003)(2906002)(446003)(15650500001)(356004)(26826003)(52536014)(22756006)(476003)(81156014)(99286004)(316002)(14444005)(5660300002)(54906003)(66066001)(81166006)(8676002)(7696005)(76176011)(6506007)(6246003)(53546011)(8746002)(4326008)(102836004)(8936002)(97756001)(70206006)(70586007)(14454004)(50466002)(186003)(305945005)(25786009)(6306002)(11346002)(2501003)(47776003)(74316002)(110136005)(229853002)(76130400001)(63350400001)(63370400001)(26005)(336012)(9686003)(486006)(6116002)(3846002)(478600001)(126002)(23726003)(966005)(7736002)(86362001)(55016002)(33656002)(46406003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0802MB2594;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:TempError;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4ca83779-e060-416f-d9c5-08d7246e6461 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM5PR0802MB2594; NoDisclaimer: True X-Forefront-PRVS: 0134AD334F X-Microsoft-Antispam-Message-Info: lzM61Iqsi2qJ7WFm69WcNdzJ7X8KGJ3ax8I7vtWLqhrroEczCs2PAdRS7ymMWoNbLeXnFlMO2/Vr1L2+7cMJsiA9EWFf8k/EcEUjF4twgpANz5Bzs9Hct8ftDoH7AbHj6aS/nPVcxTmsNQaWQjRhWRuVlfYtoin7wyq2x7QuSpXUCekPf1bQtCA6ZoFpoL1KvvJwmmoQOjSqy2xBx6xspnHMCK7Gbn8p4hKRggA4LQhWtSTXLvw8nBv3vV1aWY6OyR9ScbjD8Gi63Kd3hNx5u2G1D622JXKolawIlvB1CjBimJ2SjxSBfRx2p0wTIvAUSOEunkahb5ZE9qdahakTkaxlxllKheC+OcMD7zXyxT54Q2H61LDlTMciITktQkHkavRxKdKEYCF+a4ftlVtdHeqPN0SCXfvMbLOEqRoiNBw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2019 06:28:15.0923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b16f323-1ca8-43df-4ef1-08d7246e6ab5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2594 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Zhichao, Please find my comments inline marked as [Krzysztof]. Kind regards, Krzysztof -----Original Message----- From: Gao, Zhichao =20 Sent: Monday, August 19, 2019 2:19 To: devel@edk2.groups.io; Krzysztof Koch Cc: Carsey, Jaben ; Ni, Ray ; Sa= mi Mujawar ; Matteo Carlini ;= nd Subject: RE: [edk2-devel] [PATCH v1 05/11] ShellPkg: acpiview: SLIT: Valid= ate System Locality count > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of=20 > Krzysztof Koch > Sent: Thursday, August 15, 2019 9:11 PM > To: devel@edk2.groups.io > Cc: Carsey, Jaben ; Ni, Ray=20 > ; Gao, Zhichao ;=20 > Sami.Mujawar@arm.com; Matteo.Carlini@arm.com; nd@arm.com > Subject: [edk2-devel] [PATCH v1 05/11] ShellPkg: acpiview: SLIT:=20 > Validate System Locality count >=20 > 1. Check if the 'Number of System Localities' provided can be=20 > represented in the SLIT table. The table 'Length' field is a 32-bit=20 > value while the 'Number of System Localities' field is 64-bit long. >=20 > 2. Check if the SLIT matrix fits in the table buffer. If N is the SLIT= =20 > locality count, then the matrix used to represent the localities is=20 > N*N bytes long. The ACPI table length must be big enough to fit the matr= ix. >=20 > 3. Remove (now) redundant 64x64 bit multiplication. Why removing? This change is added to fixed the issue build error with IA3= 2 multiplication of two 64 bits data. The change of #3 should be removed from the patch. Keeping the variable size as UINT64 wouldn't affect the result. Thanks, Zhichao [Krzysztof] If you look closely, in this patch I have removed the need to = 64x64 bit multiplication. As I explain in the commit message, the specifica= tion of the SLIT table has an error. The System Locality Count is a 64-bit = value while the ACPI table length field is 32-bit long.=20 Consequently, after the right checks are implemented (in this patch), it i= s possible to operate on 32-bit values only. I believe that now MultU64x64(= ) is no longer needed so I reverted back to the '*' multiplication operator= . Please let me know what you think. >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > Notes: > v1: > - Validate the 'Number of System Localities' Field [Krzysztof] > - Remove redundant 64x64 bit multiplication [Krzysztof] >=20 > > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c= =20 > | > 47 +++++++++++++++++--- > 1 file changed, 42 insertions(+), 5 deletions(-) >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser > .c > index > 17e2166a09d8615b714e0c51d4d93d293fcdf601..e4625ee8b13907893a9b6990 > ecb956baf91cc3b9 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPa > +++ rs > +++ er.c > @@ -30,7 +30,7 @@ STATIC CONST ACPI_PARSER SlitParser[] =3D { > /** > Macro to get the value of a System Locality **/ -#define=20 > SLIT_ELEMENT(Ptr, i, j) *(Ptr + (MultU64x64 (i, LocalityCount)) + j) > +#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j) >=20 > /** > This function parses the ACPI SLIT table. > @@ -57,9 +57,9 @@ ParseAcpiSlit ( > ) > { > UINT32 Offset; > - UINT64 Count; > - UINT64 Index; > - UINT64 LocalityCount; > + UINT32 Count; > + UINT32 Index; > + UINT32 LocalityCount; > UINT8* LocalityPtr; > CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi >=20 > @@ -87,8 +87,45 @@ ParseAcpiSlit ( > return; > } >=20 > + /* > + Despite the 'Number of System Localities' being a 64-bit field in S= LIT, > + the maximum number of localities that can be represented in SLIT=20 > + is > limited > + by the 'Length' field of the ACPI table. > + > + Since the ACPI table length field is 32-bit wide. The maximum numbe= r of > + localities that can be represented in SLIT can be calculated as: > + > + MaxLocality =3D sqrt (MAX_UINT32 - sizeof > (EFI_ACPI_6_3_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEAD > ER)) > + =3D 65535 > + =3D MAX_UINT16 > + */ > + if (*SlitSystemLocalityCount > MAX_UINT16) { > + IncrementErrorCount (); > + Print ( > + L"ERROR: The Number of System Localities provided can't be > represented " \ > + L"in the SLIT table. SlitSystemLocalityCount =3D %ld. " \ > + L"MaxLocalityCountAllowed =3D %d.\n", > + *SlitSystemLocalityCount, > + MAX_UINT16 > + ); > + return; > + } > + > + LocalityCount =3D (UINT32)*SlitSystemLocalityCount; > + > + // Make sure system localities fit in the table buffer provided if= =20 > + (Offset + (LocalityCount * LocalityCount) > AcpiTableLength) { > + IncrementErrorCount (); > + Print ( > + L"ERROR: Invalid Number of System Localities. " \ > + L"SlitSystemLocalityCount =3D %ld. AcpiTableLength =3D %d.\n", > + *SlitSystemLocalityCount, > + AcpiTableLength > + ); > + return; > + } > + > LocalityPtr =3D Ptr + Offset; > - LocalityCount =3D *SlitSystemLocalityCount; >=20 > // We only print the Localities if the count is less than 16 > // If the locality count is more than 16 then refer to the > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >=20 >=20 >=20 >=20