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=edQUgIrI; spf=pass (domain: arm.com, ip: 40.107.15.71, mailfrom: sami.mujawar@arm.com) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.71]) by groups.io with SMTP; Wed, 12 Jun 2019 14:31:08 -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=KAAgPhzyTsdnvXfyF9sCc4upqYKAiUuDuH+B+pIIg0o=; b=edQUgIrIhN1y0Zd3N58Mh/XR1tesTK0+aulFlsecTJFsd7BiZeSSe+RRyk6F5muGMMSVcX/0KxCeEP3/EPsY/TzX9UFwOULCI4meNC26aZ9Cry/ZgydRWvKbEJqIkRw2XUT4Qe36q6HyzZ72vWi4rUGe4oIGhaYscbSwh6bSUVA= Received: from DB6PR0802MB2375.eurprd08.prod.outlook.com (10.172.228.142) by DB6PR0802MB2517.eurprd08.prod.outlook.com (10.172.251.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.14; Wed, 12 Jun 2019 21:31:05 +0000 Received: from DB6PR0802MB2375.eurprd08.prod.outlook.com ([fe80::a46c:aa3a:17bf:7909]) by DB6PR0802MB2375.eurprd08.prod.outlook.com ([fe80::a46c:aa3a:17bf:7909%3]) with mapi id 15.20.1987.010; Wed, 12 Jun 2019 21:31:05 +0000 From: "Sami Mujawar" To: Krzysztof Koch , "devel@edk2.groups.io" CC: "jaben.carsey@intel.com" , "ray.ni@intel.com" , "zhichao.gao@intel.com" , "michael.d.kinney@intel.com" , "liming.gao@intel.com" , Matteo Carlini , Stephanie Hughes-Fitt , nd Subject: Re: [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Topic: [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Index: AQHVIT8mTQk0WWQy60S/MnfTALyFc6aYibEw Date: Wed, 12 Jun 2019 21:31:05 +0000 Message-ID: References: <20190612141046.30168-1-krzysztof.koch@arm.com> <20190612141046.30168-3-krzysztof.koch@arm.com> In-Reply-To: <20190612141046.30168-3-krzysztof.koch@arm.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: fc25bcff-c772-4917-9376-8069aed550f7.1 x-checkrecipientchecked: true authentication-results: spf=none (sender IP is ) smtp.mailfrom=Sami.Mujawar@arm.com; x-originating-ip: [2a00:23c6:5485:a200:d878:de60:dcf3:89c4] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2bc21309-e846-4c86-6e14-08d6ef7d46a1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DB6PR0802MB2517; x-ms-traffictypediagnostic: DB6PR0802MB2517: x-ms-exchange-purlcount: 1 nodisclaimer: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0066D63CE6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(376002)(136003)(366004)(396003)(39860400002)(199004)(189003)(13464003)(66446008)(99286004)(73956011)(66476007)(102836004)(15650500001)(86362001)(19627235002)(2906002)(64756008)(9686003)(76116006)(66556008)(256004)(53546011)(8936002)(7696005)(55016002)(6306002)(6506007)(110136005)(54906003)(46003)(76176011)(186003)(316002)(30864003)(53936002)(66946007)(52536014)(229853002)(72206003)(2501003)(68736007)(14444005)(6246003)(6436002)(14454004)(11346002)(446003)(305945005)(71190400001)(74316002)(81156014)(8676002)(71200400001)(81166006)(7736002)(476003)(33656002)(25786009)(486006)(966005)(6116002)(4326008)(478600001)(5660300002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0802MB2517;H:DB6PR0802MB2375.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: cOT5e4RMiDR6egzjWrMvtPRIVS01Z31suT2tbNc6gGFqB/ENMGty2FC2A1qN8vM7K+rnYdrzlNzsjIUW1brthut2bIaAxjL5NKC2/qiUCgPcxmZizPcf2L3LUNzWzy+0+0glLu3cBisxaE00GAu609SfImCmLdZlfSfSzyU7XNuiDMoZ9265tN0ZCRW5OZt8whBiZD5WGP1cvTucFrnp2KzcJLxVxRsuVMCPX4Vhf7GOzvHIg5rhSWdulTkpYUe9EQ07AAbCNgpa7bj7uayneDx2rkEOPetEbKOhNvQ2Tl6daKpSi5tEqYsph2zSvqp/PRfIOIy+uv9BdYA/dMF3wj3d280kLdvZJKQGrh0Odido4KVxO3P38csEzAXcl0vCg1A9FXYQxGxdRmwncoPLkcgx5BxCu2sOjRSYuDpcvNc= MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bc21309-e846-4c86-6e14-08d6ef7d46a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2019 21:31:05.3758 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2517 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Sami Mujawar -----Original Message----- From: Krzysztof Koch =20 Sent: 12 June 2019 03:11 PM To: devel@edk2.groups.io Cc: jaben.carsey@intel.com; ray.ni@intel.com; zhichao.gao@intel.com; michae= l.d.kinney@intel.com; liming.gao@intel.com; Sami Mujawar ; Matteo Carlini ; Stephanie Hughes-Fitt ; nd Subject: [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Add support for parsing revision 3 of System Resource Affinity Table (SRAT)= . Decode and dump the new Generic Initiator Affinity Structure. Validate the Device Handle Type field inside the Generic Initiator Affinity= Structure. Signed-off-by: Krzysztof Koch --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/582_acp= iview_6_3_srat_v1 Notes: v1: - dump and validate the Generic Initiator Affinity Struct [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | = 35 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | = 16 ++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 2= 56 +++++++++++++++++++- 3 files changed, 299 insertions(+), 8 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index b5965507b498b9fa9bc4d3124b2285f509004c4f..60523936732f901317ee93d03fe= 06df1403f3695 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -1,7 +1,7 @@ /** @file ACPI parser =20 - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -401,6 +401,39 @@ Dump8Chars ( ); } =20 +/** + This function traces 12 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +VOID +EFIAPI +Dump12Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format !=3D NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7], + Ptr[8], + Ptr[9], + Ptr[10], + Ptr[11] + ); +} + /** This function indents and prints the ACPI table Field Name. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 7657892d9fd2e2e14c6578611ff0cf1b6f6cd750..5b23ab6fa9bd2f87e0347287872= 685a2f74622f3 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -184,6 +184,22 @@ Dump8Chars ( IN UINT8* Ptr ); =20 +/** + This function traces 12 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +VOID +EFIAPI +Dump12Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ); + /** This function indents and prints the ACPI table Field Name. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Srat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa= rser.c index 075ff2a141a82b522e8aaedb7ad79249aaf5eaac..8c268a11454d13c9e278691d619= a580c4c14c08e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars +++ er.c @@ -1,11 +1,11 @@ /** @file SRAT table parser =20 - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Reference(s): - - ACPI 6.2 Specification - Errata A, September 2017 + - ACPI 6.3 Specification - January 2019 **/ =20 #include @@ -17,6 +17,7 @@ // Local Variables STATIC CONST UINT8* SratRAType; STATIC CONST UINT8* SratRALength; +STATIC CONST UINT8* SratDeviceHandleType; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; =20 /** @@ -34,6 +35,51 @@ ValidateSratReserved ( IN VOID* Context ); =20 +/** + This function validates the Device Handle Type field in the Generic=20 +Initiator + Affinity Structure. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateSratDeviceHandleType ( + IN UINT8* Ptr, + IN VOID* Context + ); + +/** + This function traces the Device Handle field inside Generic Initiator + Affinity Structure. + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratDeviceHandle ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ); + +/** + This function traces the PCI BDF Number field inside Device Handle -=20 +PCI + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratPciBdfNumber ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ); + /** This function traces the APIC Proximity Domain field. =20 @@ -90,6 +136,41 @@ STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] =3D= { {L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, }; =20 +/** + An ACPI_PARSER array describing the Generic Initiator Affinity=20 +Structure **/ STATIC CONST ACPI_PARSER=20 +SratGenericInitiatorAffinityParser[] =3D { + {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, + + {L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Device Handle Type", 1, 3, L"%d", NULL, (VOID**)&SratDeviceHandleType= , + ValidateSratDeviceHandleType, NULL}, + {L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL,=20 +NULL}, + {L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL} }; + +/** + An ACPI_PARSER array describing the Device Handle - ACPI **/ STATIC=20 +CONST ACPI_PARSER SratDeviceHandleAcpiParser[] =3D { + {L"ACPI_HID", 8, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"ACPI_UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} }; + +/** + An ACPI_PARSER array describing the Device Handle - PCI **/ STATIC=20 +CONST ACPI_PARSER SratDeviceHandlePciParser[] =3D { + {L"PCI Segment", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"PCI BDF Number", 2, 2, NULL, DumpSratPciBdfNumber, NULL, NULL,=20 +NULL}, + {L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12C= hars, + NULL, NULL, NULL} +}; + /** An ACPI_PARSER array describing the Memory Affinity structure. **/ @@ -159,6 +240,148 @@ ValidateSratReserved ( } } =20 +/** + This function validates the Device Handle Type field in the Generic=20 +Initiator + Affinity Structure. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateSratDeviceHandleType ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + UINT8 DeviceHandleType; + + DeviceHandleType =3D *Ptr; + + if (DeviceHandleType > EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { + IncrementErrorCount (); + Print ( + L"\nERROR: Invalid Device Handle Type: %d. Must be between 0 and %d.= ", + DeviceHandleType, + EFI_ACPI_6_3_PCI_DEVICE_HANDLE + ); + } +} + +/** + This function traces the Device Handle field inside Generic Initiator + Affinity Structure. + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratDeviceHandle ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + if (SratDeviceHandleType =3D=3D NULL) { + IncrementErrorCount (); + Print (L"\nERROR: Device Handle Type read incorrectly.\n"); + return; + } + + Print (L"\n"); + + if (*SratDeviceHandleType =3D=3D EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) { + ParseAcpi ( + TRUE, + 2, + NULL, + Ptr, + sizeof (EFI_ACPI_6_3_DEVICE_HANDLE_ACPI), + PARSER_PARAMS (SratDeviceHandleAcpiParser) + ); + } else if (*SratDeviceHandleType =3D=3D EFI_ACPI_6_3_PCI_DEVICE_HANDLE) = { + ParseAcpi ( + TRUE, + 2, + NULL, + Ptr, + sizeof (EFI_ACPI_6_3_DEVICE_HANDLE_PCI), + PARSER_PARAMS (SratDeviceHandlePciParser) + ); + } +} + +/** + This function traces the PCI BDF Number field inside Device Handle -=20 +PCI + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratPciBdfNumber ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; + + Print (L"\n"); + + /* + The PCI BDF Number subfields are printed in the order specified in the= ACPI + specification. The format of the 16-bit PCI BDF Number field is as fol= lows: + + +-----+------+------+ + |DEV | FUNC | BUS | + +-----+------+------+ + |15:11| 10:8 | 7:0 | + +-----+------+------+ + */ + + // Print PCI Bus Number (Bits 7:0 of Byte 2) UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Bus Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + *Ptr + ); + + Ptr++; + + // Print PCI Device Number (Bits 7:3 of Byte 3) UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Device Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + (*Ptr & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3)) >> 3 + ); + + // PCI Function Number (Bits 2:0 of Byte 3) + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Function Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + *Ptr & (BIT2 | BIT1 | BIT0) + ); +} + /** This function traces the APIC Proximity Domain field. =20 @@ -211,6 +434,7 @@ ParseAcpiSrat ( UINT8* ResourcePtr; UINT32 GicCAffinityIndex; UINT32 GicITSAffinityIndex; + UINT32 GenericInitiatorAffinityIndex; UINT32 MemoryAffinityIndex; UINT32 ApicSapicAffinityIndex; UINT32 X2ApicAffinityIndex; @@ -218,6 +442,7 @@ ParseAcpiSrat ( =20 GicCAffinityIndex =3D 0; GicITSAffinityIndex =3D 0; + GenericInitiatorAffinityIndex =3D 0; MemoryAffinityIndex =3D 0; ApicSapicAffinityIndex =3D 0; X2ApicAffinityIndex =3D 0; @@ -247,7 +472,7 @@ ParseAcpiSrat ( ); =20 switch (*SratRAType) { - case EFI_ACPI_6_2_GICC_AFFINITY: + case EFI_ACPI_6_3_GICC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -264,7 +489,7 @@ ParseAcpiSrat ( ); break; =20 - case EFI_ACPI_6_2_GIC_ITS_AFFINITY: + case EFI_ACPI_6_3_GIC_ITS_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -281,7 +506,24 @@ ParseAcpiSrat ( ); break; =20 - case EFI_ACPI_6_2_MEMORY_AFFINITY: + case EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY: + AsciiSPrint ( + Buffer, + sizeof (Buffer), + "Generic Initiator Affinity Structure [%d]", + GenericInitiatorAffinityIndex++ + ); + ParseAcpi ( + TRUE, + 2, + Buffer, + ResourcePtr, + *SratRALength, + PARSER_PARAMS (SratGenericInitiatorAffinityParser) + ); + break; + + case EFI_ACPI_6_3_MEMORY_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -298,7 +540,7 @@ ParseAcpiSrat ( ); break; =20 - case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: + case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -315,7 +557,7 @@ ParseAcpiSrat ( ); break; =20 - case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY: + case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'