From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.12049.1574173429068227362 for ; Tue, 19 Nov 2019 06:23:49 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 06:23:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,324,1569308400"; d="scan'208";a="218263118" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 19 Nov 2019 06:23:47 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 19 Nov 2019 06:23:46 -0800 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 19 Nov 2019 06:23:46 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.225]) with mapi id 14.03.0439.000; Tue, 19 Nov 2019 22:23:44 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "sami.mujawar@arm.com" , Krzysztof Koch CC: "Ni, Ray" , "Gao, Zhichao" , Matteo Carlini , nd Subject: Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Topic: [edk2-devel] [PATCH v2 1/1] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Index: AQHVmWciRv0IR4PsIESMwkVtfZPlZaeQLWgAgAJpIjA= Date: Tue, 19 Nov 2019 14:23:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E5437A2@SHSMSX104.ccr.corp.intel.com> References: <20191112143937.68588-1-krzysztof.koch@arm.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWJhNjhhZDYtNGFlNS00NGMyLTk4MmQtOTMyNjZkMjM5ODUzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM0NTdUo5R2ZUZzkxa0t0dG8yRWZMUnJQbzZBdGNsTzFSaE4rbjM2dlwvM09Uam9BXC9ycktSNng1MGxMMlBVR2E2In0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Krzysztof: Does this patch plan to catch to edk2 201911 stable tag? This change is = like a feature support. But, it doesn't pass review before soft feature fre= eze.=20 Thanks Liming > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sami Muja= war > Sent: Monday, November 18, 2019 5:33 PM > To: Krzysztof Koch ; devel@edk2.groups.io > Cc: Ni, Ray ; Gao, Zhichao ; Ma= tteo Carlini ; nd > Subject: Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: acpiview: Update SRAT= parser to ACPI 6.3 >=20 > Reviewed-by: Sami Mujawar >=20 > Regards, >=20 > Sami Mujawar > -----Original Message----- > From: Krzysztof Koch > Sent: 12 November 2019 02:40 PM > To: devel@edk2.groups.io > Cc: ray.ni@intel.com; zhichao.gao@intel.com; Matteo Carlini ; Sami Mujawar ; > nd > Subject: [PATCH v2 1/1] ShellPkg: acpiview: Update SRAT parser to ACPI 6= .3 >=20 > Add support for parsing revision 3 of System Resource Affinity Table (SR= AT). >=20 > Decode and dump the new Generic Initiator Affinity Structure. >=20 > Validate the Device Handle Type field inside the Generic Initiator Affin= ity Structure. >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > The changes can be seen at https://github.com/KrzysztofKoch1/edk2/tree/5= 82_acpiview_6_3_srat_v2 >=20 > Notes: > v2: > - rebase on latest master [Krzysztof] >=20 > Readme.md = | 4 +- > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c = | 33 +++ > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h = | 16 + > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c = | 313 ++++++++++++++++++-- > 4 files changed, 343 insertions(+), 23 deletions(-) >=20 > diff --git a/Readme.md b/Readme.md > index acbcca88d3c62d392e6f94b1ad7de2d8627e3a38..594f16b20756ab78987fef4f= eac2e439743d5b4a 100644 > --- a/Readme.md > +++ b/Readme.md > @@ -17,7 +17,7 @@ for the UEFI and PI specifications from www.uefi.org. > > Windows > VS2019 > - edk2-ci > + master > > > src=3D"https://dev.azure.com/tianocore/edk2-ci/_apis/build/status/Window= s%20VS2019%20CI?branchName=3Dmaster"/> > @@ -34,7 +34,7 @@ for the UEFI and PI specifications from www.uefi.org. > > Ubuntu > GCC > - edk2-ci > + master > > > > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b= /ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > index a569c3c55406ab58536834e56ce9701f7edeffee..2b2ecb93cef9ee28b752e7bf= 2d920b059dbf7d6b 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > @@ -405,6 +405,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/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > index 20ca358bddfa5953bfb1d1bebaebbf3079eaba01..0dc721bd2cc59538432d4a9c= ab6c21728cc77d33 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/S= ratParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c > index a8aa420487bb6bf29fc38221d0b221573c64b8b3..d60476eb748e022f45d231e2= 4c32b2b53e29bbd7 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars > +++ er.c > @@ -5,7 +5,7 @@ > 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 > /** > @@ -32,13 +33,52 @@ EFIAPI > ValidateSratReserved ( > IN UINT8* Ptr, > IN VOID* Context > - ) > -{ > - if (*(UINT32*)Ptr !=3D 1) { > - IncrementErrorCount (); > - Print (L"\nERROR: Reserved should be 1 for backward compatibility.\= n"); > - } > -} > + ); > + > +/** > + This function validates the Device Handle Type field in the Generic > +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 - > +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 > + ); >=20 > /** > This function traces the APIC Proximity Domain field. > @@ -52,14 +92,7 @@ EFIAPI > DumpSratApicProximity ( > IN CONST CHAR16* Format, > IN UINT8* Ptr > - ) > -{ > - UINT32 ProximityDomain; > - > - ProximityDomain =3D Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); > - > - Print (Format, ProximityDomain); > -} > + ); >=20 > /** > An ACPI_PARSER array describing the SRAT Table. > @@ -103,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 > +Structure **/ STATIC CONST ACPI_PARSER > +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**)&SratDeviceHandleT= ype, > + ValidateSratDeviceHandleType, NULL}, > + {L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, > + {L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL, > +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 > +CONST ACPI_PARSER SratDeviceHandleAcpiParser[] =3D { > + {L"ACPI_HID", 8, 0, L"0x%lx", 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 > +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, > +NULL}, > + {L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump= 12Chars, > + NULL, NULL, NULL} > +}; > + > /** > An ACPI_PARSER array describing the Memory Affinity structure. > **/ > @@ -152,6 +220,190 @@ STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[= ] =3D { > {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL} }; >=20 > +/** > + This function validates the Reserved field in the SRAT table header. > + > + @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 > +ValidateSratReserved ( > + IN UINT8* Ptr, > + IN VOID* Context > + ) > +{ > + if (*(UINT32*)Ptr !=3D 1) { > + IncrementErrorCount (); > + Print (L"\nERROR: Reserved should be 1 for backward > +compatibility.\n"); > + } > +} > + > +/** > + This function validates the Device Handle Type field in the Generic > +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_HANDL= E) { > + 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 - > +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 = follows: > + > + +-----+------+------+ > + |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. > + > + @param [in] Format Format string for tracing the data. > + @param [in] Ptr Pointer to the start of the buffer. > +**/ > +STATIC > +VOID > +EFIAPI > +DumpSratApicProximity ( > + IN CONST CHAR16* Format, > + IN UINT8* Ptr > + ) > +{ > + UINT32 ProximityDomain; > + > + ProximityDomain =3D Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); > + > + Print (Format, ProximityDomain); > +} > + > /** > This function parses the ACPI SRAT table. > When trace is enabled this function parses the SRAT table and @@ -183= ,6 +435,7 @@ ParseAcpiSrat ( > UINT8* ResourcePtr; > UINT32 GicCAffinityIndex; > UINT32 GicITSAffinityIndex; > + UINT32 GenericInitiatorAffinityIndex; > UINT32 MemoryAffinityIndex; > UINT32 ApicSapicAffinityIndex; > UINT32 X2ApicAffinityIndex; > @@ -190,6 +443,7 @@ ParseAcpiSrat ( >=20 > GicCAffinityIndex =3D 0; > GicITSAffinityIndex =3D 0; > + GenericInitiatorAffinityIndex =3D 0; > MemoryAffinityIndex =3D 0; > ApicSapicAffinityIndex =3D 0; > X2ApicAffinityIndex =3D 0; > @@ -232,7 +486,7 @@ ParseAcpiSrat ( > } >=20 > switch (*SratRAType) { > - case EFI_ACPI_6_2_GICC_AFFINITY: > + case EFI_ACPI_6_3_GICC_AFFINITY: > AsciiSPrint ( > Buffer, > sizeof (Buffer), > @@ -249,7 +503,7 @@ ParseAcpiSrat ( > ); > break; >=20 > - case EFI_ACPI_6_2_GIC_ITS_AFFINITY: > + case EFI_ACPI_6_3_GIC_ITS_AFFINITY: > AsciiSPrint ( > Buffer, > sizeof (Buffer), > @@ -266,7 +520,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), > @@ -283,7 +554,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), > @@ -300,7 +571,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)' >=20 >=20 >=20 >=20