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 4078DAC0C7F for ; Fri, 8 Mar 2024 09:20:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9Vu9ZRCGmE/o/RMaKnqIFQfhPqUK3ZdTCrH2iGtRtOk=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:From:Subject:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1709889638; v=1; b=17wu+XVLt2T3C/Tr1wz0va8Pe79xPumz+hBvGx9iCH5HElV4wi+qHN4BGeHPdcM+gjvecUrI qdPV6HnjsjmGP+tuIz87CMH+GEbeklVKnU8apn5dtxqI3/1sqKpdAruQpKxZOTbT7D1AEQApiBr T7SqOg0O8peJwX69fbQ80AgvfvKk/L6/BhUzhh5rLfHzhcmQp+MgXTsi56uB2I+Me4AsgSsPBLh 0pC9uz1NmfP3wvTDIDxN7YH0yNYL87bMMfXWFnrTPvBKh4dcKX6PJ3+hiEq/m/XWmzZn89tJsTx A8QhndPke0s2rLsmgXxrDLs5HKFW8zI8+oYk/Evx3jM4Q== X-Received: by 127.0.0.2 with SMTP id KTl6YY7687511xEoTpFl2kAh; Fri, 08 Mar 2024 01:20:38 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.17913.1709889637912640883 for ; Fri, 08 Mar 2024 01:20:38 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 26A88C15; Fri, 8 Mar 2024 01:21:14 -0800 (PST) X-Received: from [10.34.100.133] (e126645.nice.arm.com [10.34.100.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD89B3F762; Fri, 8 Mar 2024 01:20:36 -0800 (PST) Message-ID: <08f22224-cbcb-4df9-93e2-1dd634a54163@arm.com> Date: Fri, 08 Mar 2024 01:20:38 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: "PierreGondois" Subject: Re: [edk2-devel] [PATCH v2 2/2] ShellPkg/Acpiview: Adds ACPI WSMT Table parse To: Abdul Lateef Attar , devel@edk2.groups.io Cc: Abdul Lateef Attar , Zhichao Gao References: In-Reply-To: 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,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: BfnXtDUySK2JdKyNA3w1OZAmx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=17wu+XVL; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hello Abdul, On 3/8/24 08:22, Abdul Lateef Attar wrote: > From: Abdul Lateef Attar >=20 > Adds WSMT parse to the UefiShellAcpiViewCommandLib library. >=20 > 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= /Wsmt/WsmtParser.c >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/= ShellPkg/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/Ws= mtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/Wsmt= Parser.c > new file mode 100644 > index 0000000000..3c7252b0bf > --- /dev/null > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Wsmt/WsmtParse= r.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= _PROTECTION) \ > + =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= _COMM_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, N= ULL, NULL }, > + { L"COMM_BUFFER_NESTED_PTR_PROTECTION ", 1, 1, L"0x%x", NULL, NULL, N= ULL, NULL }, > + { L"SYSTEM_RESOURCE_PROTECTION ", 1, 2, L"0x%x", NULL, NULL, N= ULL, NULL }, > + { L"Reserved ", 29, 3, L"0x%x", NULL, NULL, V= alidateReserved, NULL }, I think we misunderstood each other here. We should check that if COMM_BUFFER_NESTED_PTR_PROTECTION, then FIXED_COMM_BUFFERS is also set. So I think we need to: - store the value of FIXED_COMM_BUFFERS (cf. ACPI_PARSER::ItemPtr in other = parsers) - add a validate to COMM_BUFFER_NESTED_PTR_PROTECTION to check the above I don't think it is necessary to check the reserved bits, Regards, Pierre -=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 (#116496): https://edk2.groups.io/g/devel/message/116496 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-