From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D95D574004E for ; Fri, 8 Mar 2024 07:22:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=x3sDa3ZNDfRSiindbrZUSFuZE7aneCL9SeNyg7U88ds=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1709882559; v=1; b=cAjw/YbO2tSIetixCN97tchvHdG8BDvHMz8Jh1c/eLmhGje25JbNp9hx9tb+hMkrY2Q3Uqh8 c9jiW1MitUbBCEx1X0JAG+yXo+d2nyuhgp7DUCoQKltpqsBxQuE40LzFMC5pNNaEZTw4P6I3f+k I87dBSsR+bqwt6/PLXF4EmX1+2KuW1vcaVNFpDYa/MzuQrijof3VmJ/DhWzIdFnZhsZ74/62yqG D1M94/snLWcFsWX6WVBdmNObs0Lih39k+ZNddD/i4Gct/L7rySrypONaofIdJ60S1izUx2l6HaH 9ISPehiZEUjXFX8DzAu1MwKI2tld5FXad9KJ/fvQOqTcQ== X-Received: by 127.0.0.2 with SMTP id lSKrYY7687511xDRjDmbrCzI; Thu, 07 Mar 2024 23:22:39 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.85]) by mx.groups.io with SMTP id smtpd.web11.16500.1709882558899521430 for ; Thu, 07 Mar 2024 23:22:39 -0800 X-Received: from BN9PR03CA0198.namprd03.prod.outlook.com (2603:10b6:408:f9::23) by BL1PR12MB5729.namprd12.prod.outlook.com (2603:10b6:208:384::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Fri, 8 Mar 2024 07:22:34 +0000 X-Received: from BN2PEPF000044AB.namprd04.prod.outlook.com (2603:10b6:408:f9:cafe::9a) by BN9PR03CA0198.outlook.office365.com (2603:10b6:408:f9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39 via Frontend Transport; Fri, 8 Mar 2024 07:22:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000044AB.mail.protection.outlook.com (10.167.243.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 07:22:34 +0000 X-Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 8 Mar 2024 01:22:34 -0600 X-Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 7 Mar 2024 23:22:33 -0800 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 8 Mar 2024 01:22:32 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Zhichao Gao , Pierre Gondois Subject: [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse Date: Thu, 07 Mar 2024 23:22:39 -0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AB:EE_|BL1PR12MB5729:EE_ X-MS-Office365-Filtering-Correlation-Id: 21d43044-ccf3-4764-1ed0-08dc3f40866d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: /pEYckv8HZElvOcc2eJgYJnc2wPL6UsJKeFKV0pKOkKCYo7dQA71/2GjeCfXWGNmgfMCf7/wCfPMsf5AtoHEguV5HtHEwOzuiiRCmZ8wdAfNC6I12WPSzNrN8YUWkNoYviA0x//ARPFdJ6cmidcdlv5twZh68kIKcDV/L3SAEROtvZCRGwxSXlIweln00XndF84zQVTwcQ5wKF0CiGn6jV17bPxyoW6enoaPWtWm8xtNSqcWvx0o9Z5eBPm9WJcW1Mmb1FywEijroK7ri6BAt3jWXqdIK/aDwin8gAN1j0Q4gC3dXwS/MLjzqRWVZPZ9W3U7pb+jb2eOno7WdT75q7Js5pDO7xN2ET9VKF3HNkufYtB5DxqPg2uDKFCfu4JizODTcaK1LTYhzldBTm2538UqxuN4LKHw5PYK7Vv6ml1i89SDizVXTS327O9Pp9/WtxNcWqmPQ6/TF4cbIAJQfBDDtWlTW3YFBEwGESOLDTIJwE/DQOZZ4siJg0wdGCnLmkT6Jtuy1gCdjstKS/b2wrRuwoXQIWg6Tev8D5vroV0oiapGoXQJ+Y6D0snWE81xy4TD/zsxUb22eUfLZ2mdSx9jNeB9Q0vTFMcfF57lGGTPuCBTWWqY57Z8YagbfaTbkrKF95R4f7YPplgxU7dDGcXovx9VNHrvRhH+/TBB4SPFjZBgmH5HC92DD3CQMFhhSDaYlLIgZo0PeGo5UNx5TZv4RQK/cTVJKR+o2/8JsS2lBBWdhWSGntasXwZA0OWs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 07:22:34.5054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21d43044-ccf3-4764-1ed0-08dc3f40866d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5729 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zoTNyZSKEtFCkhZqlZvXX2kgx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="cAjw/YbO"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Abdul Lateef Attar Adds WSMT parse to the UefiShellAcpiViewCommandLib library. Cc: Zhichao Gao Cc: Pierre Gondois Signed-off-by: Abdul Lateef Attar Reviewed-by: Pierre Gondois --- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 17 ++ .../Parsers/Wsmt/WsmtParser.c | 147 ++++++++++++++++++ .../UefiShellAcpiViewCommandLib.c | 1 + .../UefiShellAcpiViewCommandLib.inf | 1 + 4 files changed, 166 insertions(+) create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ws= mt/WsmtParser.c diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index ba3364f2c2..6468fe5d8c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -985,6 +985,23 @@ ParseAcpiSsdt ( IN UINT8 AcpiTableRevision ); =20 +/** + This function parses the ACPI WSMT table. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiWsmt ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + /** This function parses the ACPI XSDT table and optionally traces the ACPI table fields. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/Wsmt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtPa= rser.c new file mode 100644 index 0000000000..3c7252b0bf --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParser.= c @@ -0,0 +1,147 @@ +/** @file + WSMT table parser + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - Windows SMM Security Mitigation Table spec, version 1.0 +**/ + +#include +#include +#include "AcpiParser.h" + +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + This function validates the WSMT Protection flag. + + @param [in] Ptr Pointer to the start of the buffer. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. + +**/ +STATIC +VOID +EFIAPI +ValidateWsmtProtectionFlag ( + IN UINT8 *Ptr, + IN VOID *Context + ) +{ + UINT32 ProtectionFlag; + + ProtectionFlag =3D *(UINT32 *)Ptr; + + if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_P= ROTECTION) \ + =3D=3D EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION) + { + if ((ProtectionFlag & EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) \ + !=3D EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) + { + IncrementErrorCount (); + Print (L"ERROR: COMM_BUFFER_NESTED_PTR_PROTECTION is set but FIXED_C= OMM_BUFFERS is not set.\n"); + } + } +} + +/** + This function validates the reserved bits in the WSMT Protection flag. + + @param [in] Ptr Pointer to the start of the buffer. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateReserved ( + IN UINT8 *Ptr, + IN VOID *Context + ) +{ + UINT32 ProtectionFlag; + + ProtectionFlag =3D *(UINT32 *)Ptr; + + if ((ProtectionFlag & 0xFFFFFFF8) !=3D 0) { + IncrementErrorCount (); + Print (L"ERROR: Reserved bits are not zero.\n"); + } +} + +/** + An ACPI_PARSER array describing the WSMT Protection flag . +**/ +STATIC CONST ACPI_PARSER WsmtProtectionFlagParser[] =3D { + { L"FIXED_COMM_BUFFERS ", 1, 0, L"0x%x", NULL, NULL, NUL= L, NULL }, + { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, NUL= L, NULL }, + { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, NUL= L, NULL }, + { L"Reserved ", 29, 3, L"0x%x", NULL, NULL, Val= idateReserved, NULL }, +}; + +/** + This function prints WSMT Protection flag. + 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 +DumpWsmtProtectionFlag ( + IN CONST CHAR16 *Format OPTIONAL, + IN UINT8 *Ptr + ) +{ + if (Format !=3D NULL) { + Print (Format, *(UINT32 *)Ptr); + return; + } + + Print (L"0x%X\n", *(UINT32 *)Ptr); + ParseAcpiBitFields ( + TRUE, + 2, + NULL, + Ptr, + 4, + PARSER_PARAMS (WsmtProtectionFlagParser) + ); +} + +/** + An ACPI_PARSER array describing the ACPI WSMT Table. +**/ +STATIC CONST ACPI_PARSER WsmtParser[] =3D { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + { L"Protection Flag", 4,36, NULL, DumpWsmtProtectionFlag, NUL= L, ValidateWsmtProtectionFlag, NULL } +}; + +/** + This function parses the ACPI WSMT table. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiWsmt ( + IN BOOLEAN Trace, + IN UINT8 *Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + ParseAcpi ( + Trace, + 0, + "WSMT", + Ptr, + AcpiTableLength, + PARSER_PARAMS (WsmtParser) + ); +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index 9e15979ea2..0bdf068fe0 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -73,6 +73,7 @@ ACPI_TABLE_PARSER ParserList[] =3D { { EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, = ParseAcpiSpcr }, { EFI_ACPI_6_2_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE, = ParseAcpiSrat }, { EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, = ParseAcpiSsdt }, + { EFI_ACPI_6_5_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE, = ParseAcpiWsmt }, { EFI_ACPI_6_2_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, = ParseAcpiXsdt } }; =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index 3338e04379..e62366116c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -52,6 +52,7 @@ Parsers/Spcr/SpcrParser.c Parsers/Srat/SratParser.c Parsers/Ssdt/SsdtParser.c + Parsers/Wsmt/WsmtParser.c Parsers/Xsdt/XsdtParser.c UefiShellAcpiViewCommandLib.c UefiShellAcpiViewCommandLib.uni --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116490): https://edk2.groups.io/g/devel/message/116490 Mute This Topic: https://groups.io/mt/104804849/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-