From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109909+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109909+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066320; cv=none; d=zohomail.com; s=zohoarc; b=lmfgKQvH/Fo+OYqlP8zc0SgL3avFF4ub5jkHEsjCMOFkq+8WGD0vXqGdChq/5JwWvT8+OAUSAmOeF2HawHtg4WhyTrfNrK2n4v2R4XfeVjIoKNVYTxSU3rRN8pZ4SrzRCumlO/UgOX99SM029U3kkr+e009keuSl33IbCd+Vj5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066320; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=uqgYQldTxAUY1NpC4PFIM3ImQPXijoSBryR58V9j9rw=; b=B3sJURXYFed17sOJJZJOxTEF72K90vqvh0QD9qyDfR2TCEKp4PXyE1z0Dq9w8erTmyYyOTYDy2N1QUFMiNcngBg/Gp+mCxUqOUnJZzrlaqB2Mh96x3jxhZuVh3ap+iBAMFgttW0kegE4rBrgDGYADX1+xtYEFqGFiq+a8ei4rTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109909+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169806632045773.62401167121686; Mon, 23 Oct 2023 06:05:20 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=8kvTkXJMVgHjWzqAdnK8Yh339FxOTAkiKWS6IDcgHaw=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066320; v=1; b=Jn/rA8CgSDSFQ9+OhvvlGHXM3FBnOwb+joPQiGfMklgkh1J348LD4HLHP0GKtGOtcZXmOUfn w3Wo95f0U5EJE9/sja1uXoO0hABw9P/hfJvYhspRI191DRd/x5sdopADH4WpMyQKvdPbD9ng+zf D2LmoFi7CwtzAENRE4Icw9rY= X-Received: by 127.0.0.2 with SMTP id kEvLYY1788612xcE6L0v5D7X; Mon, 23 Oct 2023 06:05:20 -0700 X-Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mx.groups.io with SMTP id smtpd.web10.119841.1698066318779968361 for ; Mon, 23 Oct 2023 06:05:19 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c51f5a1ecdso48699301fa.0 for ; Mon, 23 Oct 2023 06:05:18 -0700 (PDT) X-Gm-Message-State: c3ZJPfeR2B3bTSzG1UUoZVRPx1787277AA= X-Google-Smtp-Source: AGHT+IHeDX/0YqDtJg9LZ1ejvWNItMsC0VD+sofvNTifYlahLCfCYARiKTjXqasDsEaxwH+dHCK/TQ== X-Received: by 2002:a2e:a7ca:0:b0:2c0:1b06:c2c7 with SMTP id x10-20020a2ea7ca000000b002c01b06c2c7mr3874614ljp.20.1698066316459; Mon, 23 Oct 2023 06:05:16 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:16 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 01/16] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure Date: Mon, 23 Oct 2023 16:04:56 +0300 Message-Id: <20231023130511.4521-2-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066320770100003 Content-Type: text/plain; charset="utf-8" Currently there is only a definition for the MCTP KCS HEADER structure. Add definition for the MCTP KCS TRAILER structure as well. Signed-off-by: Konstantin Aladyshev Signed-off-by: Abner Chang Reviewed-by: Abner Chang Reviewed-by: Attar, AbdulLateef (Abdul Lateef) --- .../Library/ManageabilityTransportMctpLib.h | 5 +++++ .../MctpProtocol/Common/MctpProtocolCommon.c | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtMctpLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransp= ortMctpLib.h index 43bd142f4c..462e7436e6 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpL= ib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpL= ib.h @@ -39,6 +39,11 @@ typedef struct { UINT8 DefiningBody; ///< Message type. UINT8 ByteCount; ///< Byte count of payload. } MANAGEABILITY_MCTP_KCS_HEADER; + +typedef struct { + UINT8 Pec; ///< MCTP over KCS Packet Error Code. +} MANAGEABILITY_MCTP_KCS_TRAILER; + #define MCTP_KCS_NETFN_LUN 0xb0 #define DEFINING_BODY_DMTF_PRE_OS_WORKING_GROUP 0x01 =20 diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index 1ad48efdc7..7576007f77 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -132,7 +132,7 @@ SetupMctpRequestTransportPacket ( MANAGEABILITY_MCTP_KCS_HEADER *MctpKcsHeader; MCTP_TRANSPORT_HEADER *MctpTransportHeader; MCTP_MESSAGE_HEADER *MctpMessageHeader; - UINT8 *Pec; + MANAGEABILITY_MCTP_KCS_TRAILER *MctpKcsTrailer; UINT8 *ThisPackage; =20 if ((PacketHeader =3D=3D NULL) || (PacketHeaderSize =3D=3D NULL) || @@ -151,8 +151,8 @@ SetupMctpRequestTransportPacket ( return EFI_OUT_OF_RESOURCES; } =20 - Pec =3D (UINT8 *)AllocateZeroPool (sizeof (UINT8)); - if (Pec =3D=3D NULL) { + MctpKcsTrailer =3D (MANAGEABILITY_MCTP_KCS_TRAILER *)AllocateZeroPool = (sizeof (MANAGEABILITY_MCTP_KCS_TRAILER)); + if (MctpKcsTrailer =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a: Not enough resource for PEC.\n", __func__)= ); FreePool (MctpKcsHeader); return EFI_OUT_OF_RESOURCES; @@ -167,7 +167,7 @@ SetupMctpRequestTransportPacket ( if (ThisPackage =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a: Not enough resource for package.\n", __fun= c__)); FreePool (MctpKcsHeader); - FreePool (Pec); + FreePool (MctpKcsTrailer); return EFI_OUT_OF_RESOURCES; } =20 @@ -193,14 +193,14 @@ SetupMctpRequestTransportPacket ( =20 // // Generate PEC follow SMBUS 2.0 specification. - *Pec =3D HelperManageabilityGenerateCrc8 (MCTP_KCS_PACKET_ERROR_CODE_P= OLY, 0, ThisPackage, MctpKcsHeader->ByteCount); + MctpKcsTrailer->Pec =3D HelperManageabilityGenerateCrc8 (MCTP_KCS_PACK= ET_ERROR_CODE_POLY, 0, ThisPackage, MctpKcsHeader->ByteCount); =20 *PacketBody =3D (UINT8 *)ThisPackage; *PacketBodySize =3D MctpKcsHeader->ByteCount; - *PacketTrailer =3D (MANAGEABILITY_TRANSPORT_TRAILER)Pec; + *PacketTrailer =3D (MANAGEABILITY_TRANSPORT_TRAILER)MctpKcsTrailer; *PacketHeader =3D (MANAGEABILITY_TRANSPORT_HEADER)MctpKcsHeader; *PacketHeaderSize =3D sizeof (MANAGEABILITY_MCTP_KCS_HEADER); - *PacketTrailerSize =3D 1; + *PacketTrailerSize =3D sizeof (MANAGEABILITY_MCTP_KCS_TRAILER); return EFI_SUCCESS; } else { DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.", _= _func__)); --=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 (#109909): https://edk2.groups.io/g/devel/message/109909 Mute This Topic: https://groups.io/mt/102134647/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109910+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109910+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066321; cv=none; d=zohomail.com; s=zohoarc; b=My6v5lI59rsK0wJEwd7Us2jFswh8XWbd0beRlhJT2X9AoCslLLPGXwR+RqzeX7LcvketGIAOCNc8BI/meY1WXS8+Dqyn+8RLZWgVmOr8BbqDMJ2VIIAb2VVk8/39GG4qSBLX7zEqOuiIiztRSMPC6aJzoO1w8xNkYgtmsk4qSEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066321; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=VckpKJBpbZEyHmj2ubeZwR0ZjKDU74WMId9CDVPOUz8=; b=G7Hzb0r4EHxeFk/YXK8vdqB2LHYUsxqlNXEvwfE7ORyTHYaGCkCSYfo7LvB69mLonpEgCnM/h26iifmlqz5lDKIPDtmCTRTFMBcce6iQdREu8km/I0xYQn9HxeSnSa3s5pPDJMXQsoQqHaelffjhYBil7XLCyAnU6lxX8mi+qro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109910+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066321266802.5314976341763; Mon, 23 Oct 2023 06:05:21 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pkpNLZ0dJZoP+m2ADLyzCf0u48yz4msxOaDin37Gp2o=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066320; v=1; b=KCvbov7jJKJSgOr3qf4rLDXVU6b/IGUh4OpNFfOg8+be1mIXnJJ/E3cmdBiRxE5uLudnwUaW op/9PuxUTHQMMR2V2LEV8bKlNYZ2LDs5iL34Eofy1AJwg1Uyepq3SoN3jbgeIpvCOc+pS3LrEV3 7KPpRsXzylfLG74I0leLNBPg= X-Received: by 127.0.0.2 with SMTP id jg7SYY1788612xVJJo9hpTg5; Mon, 23 Oct 2023 06:05:20 -0700 X-Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by mx.groups.io with SMTP id smtpd.web10.119842.1698066319386766690 for ; Mon, 23 Oct 2023 06:05:19 -0700 X-Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2c5028e5b88so46300251fa.3 for ; Mon, 23 Oct 2023 06:05:19 -0700 (PDT) X-Gm-Message-State: ISolZ9kf0RlhX7sfkeLMMI7Tx1787277AA= X-Google-Smtp-Source: AGHT+IGu80jxTMGGCddaFXONM/2yfegFtERBU6gcdFTr+beC8hCtIybfF94TIHBuLVmbFYw6P7ZbSw== X-Received: by 2002:a2e:9b06:0:b0:2bc:c4af:36b9 with SMTP id u6-20020a2e9b06000000b002bcc4af36b9mr6380863lji.52.1698066317164; Mon, 23 Oct 2023 06:05:17 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:16 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 02/16] ManageabilityPkg: Check MCTP EIDs for reserved values Date: Mon, 23 Oct 2023 16:04:57 +0300 Message-Id: <20231023130511.4521-3-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066322818100013 Content-Type: text/plain; charset="utf-8" MTCP base specification marks EIDs 1-7 as reserved. Therefore return EFI_INVALID_PARAMETER if such EIDs were provided to the MctpSubmitMessage function. Signed-off-by: Konstantin Aladyshev Signed-off-by: Abner Chang Reviewed-by: Abner Chang Reviewed-by: Attar, AbdulLateef (Abdul Lateef) ; --- .../Universal/MctpProtocol/Dxe/MctpProtocol.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProto= col.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c index 88bfd9b7e7..d0f49a1abb 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c @@ -78,6 +78,23 @@ MctpSubmitMessage ( return EFI_INVALID_PARAMETER; } =20 + // + // Check source EID and destination EID + // + if ((MctpSourceEndpointId >=3D MCTP_RESERVED_ENDPOINT_START_ID) && + (MctpSourceEndpointId <=3D MCTP_RESERVED_ENDPOINT_END_ID) + ) { + DEBUG ((DEBUG_ERROR, "%a: The value of MCTP source EID (%x) is reserve= d.\n", __func__, MctpSourceEndpointId)); + return EFI_INVALID_PARAMETER; + } + + if ((MctpDestinationEndpointId >=3D MCTP_RESERVED_ENDPOINT_START_ID) && + (MctpDestinationEndpointId <=3D MCTP_RESERVED_ENDPOINT_END_ID) + ) { + DEBUG ((DEBUG_ERROR, "%a: The value of MCTP destination EID (%x) is re= served.\n", __func__, MctpDestinationEndpointId)); + return EFI_INVALID_PARAMETER; + } + Status =3D CommonMctpSubmitMessage ( mTransportToken, MctpType, --=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 (#109910): https://edk2.groups.io/g/devel/message/109910 Mute This Topic: https://groups.io/mt/102134648/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109911+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109911+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066321; cv=none; d=zohomail.com; s=zohoarc; b=bR1/wslYOZHIp7RCG67PC8ijyUzXa1agWzG930+UqFR00hucz0tmQ4Y2xosd/dsvyNyJpI5Umyfp55KadVQz5WG50/n/LPaj2nq3uXOzhHyxJhLWMk6hBiXOaAqFCyegUcMwQBK4HvCaxu73rwoPtUy9GDl9ZCKyFTC4OzBIC+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066321; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=q6K+QwyoCJY9AS/Mw7Go/ilpK1HnRxzW4L063yKpWqU=; b=ATZr8xcciEMUZX40lRtnkCMbMMccQbYumi9acA31KirrtUq3QzqrqblrZ1iaSK0MgqOAHGKEakthoyeKLW8y0cRn9WBBOFXt7LpPIbpcHuiKScBpvfRlvfZF6I509bW0iC1/w/r2ZMNzNRkYQOQqnjYMS0AlpneMlz9scVcrwRs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109911+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066321587916.2986038956499; Mon, 23 Oct 2023 06:05:21 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Vh/efiAlvb756VksALrtEo6z2ZsbKJ9FeMVOqPNbXy8=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066321; v=1; b=kcBErc//9qKIwGAViTsDfI1c/ogprPjbGyK2IDGO1pGk5dA+hH/0Je8ORE4qygVkntzvNuyu s92vEtRZztvcvMPGn76PzUXAN8ETpfW7o9L4JGeaJ2qO/sAzA+9pFq1DTV4BFkzWYsHA5vEi7CF b9GjroQGMEcXrEDQTFRC7iGo= X-Received: by 127.0.0.2 with SMTP id W6SHYY1788612xKnSdUBItM9; Mon, 23 Oct 2023 06:05:21 -0700 X-Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mx.groups.io with SMTP id smtpd.web11.120282.1698066320314374691 for ; Mon, 23 Oct 2023 06:05:20 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c509f2c46cso46554411fa.1 for ; Mon, 23 Oct 2023 06:05:20 -0700 (PDT) X-Gm-Message-State: mCjglnrcxsF3kHxWb6Pv2qDJx1787277AA= X-Google-Smtp-Source: AGHT+IFjGmp/YW1ffCb1Bgtku/G1q7odyFKFjKqkd+lArdn2xJ3ZbHg0qpLmqZT0fxeLL26zTqbAlg== X-Received: by 2002:a05:651c:11d3:b0:2c5:16c0:623b with SMTP id z19-20020a05651c11d300b002c516c0623bmr5557067ljo.34.1698066317863; Mon, 23 Oct 2023 06:05:17 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:17 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 03/16] ManageabilityPkg: Support both MCTP and IPMI in KCS tranport library Date: Mon, 23 Oct 2023 16:04:58 +0300 Message-Id: <20231023130511.4521-4-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066322875100014 Content-Type: text/plain; charset="utf-8" The Manageability KCS transport library needs to support requests both from MCTP and IPMI transports. Currently the code only handles IPMI case correctly. In the MCTP case the communication should be based on the MCTP-over-KCS specification (DSP0254). This specification defines a special KCS binding header and trailer structures that need to be present in every MCTP message. The header structure contains a length field, therefore response packet size is not needed to be known beforehand. The trailer structure contains a PEC checksum that can be used to check itegrity of the response message. Modify Manageability KCS transport library code to check which message is processed (IPMI or MCTP) and handle each case correctly based on its own specification. Tested: - The IPMI KCS communication is tested by Abner Chang, - The MCTP KCS communication is tested by Konstantin Aladyshev on the AMD EthanolX CRB. Signed-off-by: Konstantin Aladyshev Signed-off-by: Abner Chang Reviewed-by: Abner Chang --- .../Common/KcsCommon.c | 284 +++++++++++++++--- .../MctpProtocol/Common/MctpProtocolCommon.c | 14 +- 2 files changed, 260 insertions(+), 38 deletions(-) diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Common/KcsCommon.c b/Features/ManageabilityPkg/Library/ManageabilityTransp= ortKcsLib/Common/KcsCommon.c index d5b54c04be..4f7e7d450f 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /KcsCommon.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /KcsCommon.c @@ -8,16 +8,19 @@ **/ #include #include +#include #include #include #include #include +#include #include #include =20 #include "ManageabilityTransportKcs.h" =20 extern MANAGEABILITY_TRANSPORT_KCS_HARDWARE_INFO mKcsHardwareInfo; +extern MANAGEABILITY_TRANSPORT_KCS *mSingleSessionToken; =20 /** This function waits for parameter Flag to set. @@ -379,6 +382,218 @@ KcsTransportRead ( return EFI_SUCCESS; } =20 +/** + This funciton checks the KCS response data according to + manageability protocol. + + @param[in] ResponseData Pointer to response data. + @param[in] ResponseDataSize Size of response data. + @param[out] AdditionalStatus Pointer to receive the additional st= atus. + + @retval EFI_SUCCESS KCS response header is checked witho= ut error + @retval EFI_DEVICE_ERROR KCS response header has problem. +**/ +EFI_STATUS +KcsCheckResponseData ( + IN UINT8 *ResponseData, + IN UINT32 ResponseDataSize, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus + ) +{ + EFI_STATUS Status; + MANAGEABILITY_MCTP_KCS_TRAILER MctpKcsPec; + UINT32 PecSize; + UINT8 CalculatedPec; + CHAR16 *CompletionCodeStr; + + Status =3D EFI_SUCCESS; + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERROR= S; + if (CompareGuid (&gManageabilityProtocolMctpGuid, mSingleSessionToken->T= oken.ManageabilityProtocolSpecification)) { + // + // For MCTP over KCS, check PEC + // + PecSize =3D sizeof (MANAGEABILITY_MCTP_KCS_TRAILER) + 1; // +1 to rea= d last dummy byte that finishes KCS transfer + Status =3D KcsTransportRead (&MctpKcsPec.Pec, &PecSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Failed to read PEC with Status(%r)\n", + __func__, + Status + )); + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERRO= R; + return Status; + } + + if (PecSize !=3D sizeof (MctpKcsPec)) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Received PEC size is %d instead of %d\n", + __func__, + PecSize, + sizeof (MctpKcsPec) + )); + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERRO= R; + return EFI_DEVICE_ERROR; + } + + HelperManageabilityDebugPrint ((VOID *)&MctpKcsPec.Pec, PecSize - 1, "= MCTP over KCS Response PEC:\n"); + CalculatedPec =3D HelperManageabilityGenerateCrc8 (MCTP_KCS_PACKET_ERR= OR_CODE_POLY, 0, ResponseData, ResponseDataSize); + if (CalculatedPec !=3D MctpKcsPec.Pec) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Received PEC is 0x%02x instead of 0x%02x\n", + __func__, + MctpKcsPec.Pec, + CalculatedPec + )); + Status =3D EFI_DEVICE_ERROR; + } + } else if (CompareGuid (&gManageabilityProtocolIpmiGuid, mSingleSessionT= oken->Token.ManageabilityProtocolSpecification)) { + // + // For IPMI over KCS + // Check and print Completion Code + // + Status =3D IpmiHelperCheckCompletionCode (*ResponseData, &CompletionCo= deStr, AdditionalStatus); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_MANAGEABILITY_INFO, "Cc: %02x %s.\n", *((UINT8 *)Respo= nseData), CompletionCodeStr)); + } else if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((DEBUG_ERROR, "Cc: %02x not defined in IpmiCompletionCodeMapp= ing or invalid.\n", *((UINT8 *)ResponseData))); + } + } + + return Status; +} + +/** + This funciton reads the KCS response header according to + manageability protocol. Caller has to free the memory + allocated for response header. + + @param[in] ResponseHeader Pointer to receive the response h= eader. + @param[out] AdditionalStatus Pointer to receive the additional= status. + + @retval EFI_SUCCESS KCS response header is checked an= d returned + to caller. + @retval EFI_INVALID_PARAMETER One of the given parameter is inc= orrect. + @retval EFI_OUT_OF_RESOURCE Memory allocation is failed for R= esponseHeader. + @retval EFI_DEVICE_ERROR Incorrect response header. +**/ +EFI_STATUS +KcsReadResponseHeader ( + IN UINT8 **ResponseHeader, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus + ) +{ + EFI_STATUS Status; + UINT32 RspHeaderSize; + UINT32 ExpectedHeaderSize; + UINT8 *RspHeader; + + if ((ResponseHeader =3D=3D NULL) || (AdditionalStatus =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + *ResponseHeader =3D NULL; + if (CompareGuid (&gManageabilityProtocolMctpGuid, mSingleSessionToken->T= oken.ManageabilityProtocolSpecification)) { + + // For MCTP over KCS + ExpectedHeaderSize =3D sizeof (MANAGEABILITY_MCTP_KCS_HEADER); + DEBUG (( + DEBUG_MANAGEABILITY_INFO, + "%a: Reading MCTP over KCS response header.\n", + __func__ + )); + } else if (CompareGuid (&gManageabilityProtocolIpmiGuid, mSingleSessionT= oken->Token.ManageabilityProtocolSpecification)) { + // For IPMI over KCS + + ExpectedHeaderSize =3D sizeof (IPMI_KCS_RESPONSE_HEADER); + DEBUG (( + DEBUG_MANAGEABILITY_INFO, + "%a: Reading IPMI over KCS response header.\n", + __func__ + )); + } else { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Unsupportted manageability protocol over KCS: %g.\n", + __func__, + mSingleSessionToken->Token.ManageabilityProtocolSpecification + )); + return EFI_INVALID_PARAMETER; + } + + RspHeader =3D (UINT8 *)AllocateZeroPool (ExpectedHeaderSize); + if (RspHeader =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Memory allocation failed for KCS response header= !\n")); + return EFI_OUT_OF_RESOURCES; + } + + RspHeaderSize =3D ExpectedHeaderSize; + Status =3D KcsTransportRead (RspHeader, &RspHeaderSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Failed to read KCS response header Status(%r)\n", + __func__, + Status + )); + FreePool (RspHeader); + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERROR; + return Status; + } + + if (RspHeaderSize !=3D 0) { + HelperManageabilityDebugPrint ((VOID *)RspHeader, RspHeaderSize, "KCS = Response Header:\n"); + } + + if (ExpectedHeaderSize !=3D RspHeaderSize) { + DEBUG (( + DEBUG_ERROR, + "The size (%d bytes) of returned resposne header is not the same as = expection (%d bytes)!\n", + RspHeaderSize, + ExpectedHeaderSize + )); + FreePool (RspHeader); + return EFI_DEVICE_ERROR; + } + + if (CompareGuid (&gManageabilityProtocolMctpGuid, mSingleSessionToken->T= oken.ManageabilityProtocolSpecification)) { + // + // MCTP over KCS + // + if (((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->NetFunc !=3D MCTP_KC= S_NETFN_LUN) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! MANAGEABILITY_MCTP_KCS_HEADER.NetFunc is equal 0x%02x = instead of 0x%02x\n", + __func__, + ((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->NetFunc, + MCTP_KCS_NETFN_LUN + )); + FreePool (RspHeader); + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERRO= R; + return EFI_DEVICE_ERROR; + } + + if (((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->DefiningBody !=3D DE= FINING_BODY_DMTF_PRE_OS_WORKING_GROUP) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! MANAGEABILITY_MCTP_KCS_HEADER.DefiningBody is equal 0x= %02x instead of 0x%02x\n", + __func__, + ((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->DefiningBody, + DEFINING_BODY_DMTF_PRE_OS_WORKING_GROUP + )); + FreePool (RspHeader); + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_ERRO= R; + return EFI_DEVICE_ERROR; + } + } + + *ResponseHeader =3D RspHeader; + *AdditionalStatus =3D MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS_NO_ERROR= S; + return EFI_SUCCESS; +} + /** This service communicates with BMC using KCS protocol. =20 @@ -423,11 +638,9 @@ KcsTransportSendCommand ( OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus ) { - EFI_STATUS Status; - UINT32 RspHeaderSize; - IPMI_KCS_RESPONSE_HEADER RspHeader; - UINT32 ExpectedResponseDataSize; - CHAR16 *CompletionCodeStr; + EFI_STATUS Status; + UINT8 *RspHeader; + UINT32 ExpectedResponseDataSize; =20 if ((RequestData !=3D NULL) && (RequestDataSize =3D=3D 0)) { DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData and Request= DataSize\n", __func__)); @@ -467,56 +680,59 @@ KcsTransportSendCommand ( RequestDataSize ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "KCS Write Failed with Status(%r)", Status)); + DEBUG ((DEBUG_ERROR, "KCS Write Failed with Status(%r)\n", Status)); return Status; } + } =20 + if ((ResponseData !=3D NULL) && (ResponseDataSize !=3D NULL) && (*Respon= seDataSize !=3D 0)) { // // Read the response header - RspHeaderSize =3D sizeof (IPMI_KCS_RESPONSE_HEADER); - Status =3D KcsTransportRead ((UINT8 *)&RspHeader, &RspHeaderSiz= e); + // + Status =3D KcsReadResponseHeader (&RspHeader, AdditionalStatus); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "KCS read response header failed Status(%r), " \ - "RspNetFunctionLun =3D 0x%x, " \ - "Comamnd =3D 0x%x \n", - Status, - RspHeader.NetFunc, - RspHeader.Command - )); return (Status); } =20 // - // Print out the response payloads. - HelperManageabilityDebugPrint ((VOID *)&RspHeader, RspHeaderSize, "KCS= Response Header:\n"); - } + // Override ResposeDataSize if the manageability protocol is MCTP. + // + if (CompareGuid (&gManageabilityProtocolMctpGuid, mSingleSessionToken-= >Token.ManageabilityProtocolSpecification)) { + if (*ResponseDataSize < ((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)= ->ByteCount) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! MANAGEABILITY_MCTP_KCS_HEADER.ByteCount (0x%02x) is = bigger than provided buffer (0x%02x)\n", + __func__, + ((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->ByteCount, + *ResponseDataSize + )); + return EFI_INVALID_PARAMETER; + } + + *ResponseDataSize =3D ((MANAGEABILITY_MCTP_KCS_HEADER *)RspHeader)->= ByteCount; + } + FreePool (RspHeader); =20 - if ((ResponseData !=3D NULL) && (ResponseDataSize !=3D NULL) && (*Respon= seDataSize !=3D 0)) { ExpectedResponseDataSize =3D *ResponseDataSize; - Status =3D KcsTransportRead ((UINT8 *)ResponseData, = ResponseDataSize); + Status =3D KcsTransportRead (ResponseData, ResponseD= ataSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "KCS response read Failed with Status(%r)", Sta= tus)); + DEBUG ((DEBUG_ERROR, "KCS response read Failed with Status(%r)\n", S= tatus)); } =20 - // // Print out the response payloads. if (*ResponseDataSize !=3D 0) { if (ExpectedResponseDataSize !=3D *ResponseDataSize) { - DEBUG ((DEBUG_ERROR, "Expected KCS response size : %d is not match= ed to returned size : %d.\n", ExpectedResponseDataSize, *ResponseDataSize)); - Status =3D EFI_DEVICE_ERROR; + DEBUG (( + DEBUG_ERROR, + "Expected KCS response size : %d is not matched to returned size= : %d.\n", + ExpectedResponseDataSize, + *ResponseDataSize + )); + return EFI_DEVICE_ERROR; } =20 HelperManageabilityDebugPrint ((VOID *)ResponseData, (UINT32)*Respon= seDataSize, "KCS Response Data:\n"); - - // Print Completion Code - Status =3D IpmiHelperCheckCompletionCode (*((UINT8 *)ResponseData), = &CompletionCodeStr, AdditionalStatus); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_MANAGEABILITY_INFO, "Cc: %02x %s.\n", *((UINT8 *)Res= ponseData), CompletionCodeStr)); - } else if (Status =3D=3D EFI_NOT_FOUND) { - DEBUG ((DEBUG_MANAGEABILITY_INFO, "Cc: %02x not defined in IpmiCom= pletionCodeMapping or invalid.\n", *((UINT8 *)ResponseData))); - } + Status =3D KcsCheckResponseData (ResponseData, *ResponseDataSize, Ad= ditionalStatus); } else { DEBUG ((DEBUG_ERROR, "No response, can't determine Completion Code.\= n")); } diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index 7576007f77..e560c638d5 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -267,6 +267,9 @@ CommonMctpSubmitMessage ( MANAGEABILITY_TRANSPORT_TRAILER MctpTransportTrailer; MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES *MultiPackages; MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR *ThisPackage; + UINT8 *ResponseBuffer; + MCTP_TRANSPORT_HEADER *MctpTransportResponseHeader; + MCTP_MESSAGE_HEADER *MctpMessageResponseHeader; =20 if (TransportToken =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a: No transport toke for MCTP\n", __func__)); @@ -435,11 +438,12 @@ CommonMctpSubmitMessage ( ThisPackage++; } =20 + ResponseBuffer =3D (UINT8 *)AllocatePool (*ResponseDataSize + sizeof (MC= TP_TRANSPORT_HEADER) + sizeof (MCTP_MESSAGE_HEADER)); // Receive packet. TransferToken.TransmitPackage.TransmitPayload =3D NULL; TransferToken.TransmitPackage.TransmitSizeInByte =3D 0; - TransferToken.ReceivePackage.ReceiveBuffer =3D ResponseDa= ta; - TransferToken.ReceivePackage.ReceiveSizeInByte =3D *ResponseD= ataSize; + TransferToken.ReceivePackage.ReceiveBuffer =3D ResponseBu= ffer; + TransferToken.ReceivePackage.ReceiveSizeInByte =3D *ResponseD= ataSize + sizeof (MCTP_TRANSPORT_HEADER) + sizeof (MCTP_MESSAGE_HEADER); TransferToken.TransmitHeader =3D NULL; TransferToken.TransmitHeaderSize =3D 0; TransferToken.TransmitTrailer =3D NULL; @@ -461,8 +465,10 @@ CommonMctpSubmitMessage ( // Return transfer status. // *AdditionalTransferError =3D TransferToken.TransportAdditionalStatus; - *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInB= yte; - Status =3D TransferToken.TransferStatus; + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInB= yte - sizeof (MCTP_TRANSPORT_HEADER) - sizeof (MCTP_MESSAGE_HEADER); + CopyMem (ResponseData, ResponseBuffer + sizeof (MCTP_TRANSPORT_HEADER) += sizeof (MCTP_MESSAGE_HEADER), *ResponseDataSize); + FreePool (ResponseBuffer); + Status =3D TransferToken.TransferStatus; if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Failed to send MCTP command over %s: %r\n", = __func__, mTransportName, Status)); return Status; --=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 (#109911): https://edk2.groups.io/g/devel/message/109911 Mute This Topic: https://groups.io/mt/102134651/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109912+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109912+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066322; cv=none; d=zohomail.com; s=zohoarc; b=PdNgeL2N337DxWFrUvXEp3sG5Cn7TlN8gBRANwqBext3fpu4TZqLp/UoqQadUn31g/h3RQa7G0mllM9cbE0y5WAv8SxfGJ78xSO7usiDtS6vKgtUQj6N3ib5usFk7pjCnqGVGAqmjeK+0j9eqeXbXF8V4EntkDlNxbqcOsassFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066322; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=HPbfe3tR1m+quf2ZA+MK44ROky+jQcDP5zMmg/QeO0E=; b=iV15+UhMspB0KEtIER3OKIB1UB+FQwfZBMjPqgJWgz7+k4op60ODocWC3/VqoziNdm1tSTUCeaCJJC2Em5Nq8/weDke9W9jOd+1vkCJUyOY+YKKCWF3B01k891UZ9yIYuRLEm68wwvLSPc8i/dHy6ttgnYbZUV/rhPGKTWb1BZE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109912+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066322564829.7992106468517; Mon, 23 Oct 2023 06:05:22 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=elYrdlvSi/25VP0y7g602Dc3cOQ6zm/poRAiquudj20=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066321; v=1; b=shIQqUGY3pIuL2dqPiHZ4mkUGJKvpQWHO/tnb1asOJ/EIkG9t6pZekuDKleAOZH3HD0/y0Cc g9KG2JKDFJcuEy9BZC+ymdnYism2d5YpNPY3XQWSqGWBdnH0WfY9MLpjjgbgPnPtaKryxHL8xbW kVo82KRlZNEhggHOmep39x20= X-Received: by 127.0.0.2 with SMTP id 92WVYY1788612x76IjSeiRyV; Mon, 23 Oct 2023 06:05:21 -0700 X-Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web11.120283.1698066321141455304 for ; Mon, 23 Oct 2023 06:05:21 -0700 X-Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-507a55302e0so4412857e87.0 for ; Mon, 23 Oct 2023 06:05:20 -0700 (PDT) X-Gm-Message-State: KGFW1z6HrNBFvwpZOq1f3zMIx1787277AA= X-Google-Smtp-Source: AGHT+IEgPPoiRqFEPj/TI1uLxDDfwJv3rRtJgP3oxFhJMc+8qHodLq9L6znLRsP3xnc5G82bGLGY1Q== X-Received: by 2002:a2e:8718:0:b0:2c1:9a8b:f67 with SMTP id m24-20020a2e8718000000b002c19a8b0f67mr6996096lji.1.1698066318949; Mon, 23 Oct 2023 06:05:18 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:18 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 04/16] ManageabilityPkg: Check header fields in the MCTP response Date: Mon, 23 Oct 2023 16:04:59 +0300 Message-Id: <20231023130511.4521-5-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066324839100023 Content-Type: text/plain; charset="utf-8" Add checks for the MCTP header fields in the MCTP response. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../MctpProtocol/Common/MctpProtocolCommon.c | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index e560c638d5..5844d54eb2 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -461,6 +461,88 @@ CommonMctpSubmitMessage ( &TransferToken ); =20 + MctpTransportResponseHeader =3D (MCTP_TRANSPORT_HEADER *)ResponseBuffer; + if (MctpTransportResponseHeader->Bits.HeaderVersion !=3D MCTP_KCS_HEADER= _VERSION) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response HeaderVersion (0x%02x) doesn't match MCTP_KCS_H= EADER_VERSION (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.HeaderVersion, + MCTP_KCS_HEADER_VERSION + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.MessageTag !=3D MCTP_MESSAGE_TAG) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response MessageTag (0x%02x) doesn't match MCTP_MESSAGE_= TAG (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.MessageTag, + MCTP_MESSAGE_TAG + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.TagOwner !=3D MCTP_MESSAGE_TAG_OWN= ER_RESPONSE) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response TagOwner (0x%02x) doesn't match MCTP_MESSAGE_TA= G_OWNER_RESPONSE (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.TagOwner, + MCTP_MESSAGE_TAG_OWNER_RESPONSE + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.SourceEndpointId !=3D MctpDestinat= ionEndpointId) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response SrcEID (0x%02x) doesn't match sent EID (0x%02x)= \n", + __func__, + MctpTransportResponseHeader->Bits.SourceEndpointId, + MctpDestinationEndpointId + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.DestinationEndpointId !=3D MctpSou= rceEndpointId) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response DestEID (0x%02x) doesn't match local EID (0x%02= x)\n", + __func__, + MctpTransportResponseHeader->Bits.DestinationEndpointId, + MctpSourceEndpointId + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + + MctpMessageResponseHeader =3D (MCTP_MESSAGE_HEADER *)(MctpTransportRespo= nseHeader + 1); + if (MctpMessageResponseHeader->Bits.MessageType !=3D MctpType) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response MessageType (0x%02x) doesn't match sent Message= Type (0x%02x)\n", + __func__, + MctpMessageResponseHeader->Bits.MessageType, + MctpType + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + + if (MctpMessageResponseHeader->Bits.IntegrityCheck !=3D (UINT8)RequestDa= taIntegrityCheck) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response IntegrityCheck (%d) doesn't match sent Integrit= yCheck (%d)\n", + __func__, + MctpMessageResponseHeader->Bits.IntegrityCheck, + (UINT8)RequestDataIntegrityCheck + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + // // Return transfer status. // --=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 (#109912): https://edk2.groups.io/g/devel/message/109912 Mute This Topic: https://groups.io/mt/102134652/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109913+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109913+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066323; cv=none; d=zohomail.com; s=zohoarc; b=ciFaGMLFxJOBL7AGVtpIWlEOd024PmMkYqDpmM9FMmsL4LhCRFpPY2vEL28UjXOvVN+hQBffQ0bvhhezN/aLit3NpIqR7gJ4CoY0W+uXhFHh+ho0KCJuz8SU+aKwwYMtA/fe+7COBnAkPwa/WTe++jLgTtwuF2iVmusVOSLLFiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066323; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=USloFysXOFtemU10KW7n1rz6GA+OUFgBRNpWQSAV4wA=; b=B2MJ6MxsEes3SPH794sDOxGf7MbeFqriJy6OE/v5NZ9e9I+WEgiQnZQbOiWR93vkuFzjqujfZz37/zySgfTuryr42D9HMTpr5rsua56Nn9vQWMuCS2RuuEqxoKYXNownRdiKZuTwp3rxF2BBz7Xv48q2ri2dxAA2HUmXt2g1LTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109913+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066323136173.37991328211604; Mon, 23 Oct 2023 06:05:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Dyk7KTZ+PHIcerMerYvnoU2Ubqxtl9VVdI3+GLIWMq8=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066322; v=1; b=UuVo2OQONhoEFTQtPCQZNfQcNma6lGJeTqvqiRFJVPt48TeR01dd37P+mihpgeYJQKWhf8bg AE4M2jV2VhwLaPi9Vm/55YeMNHcIibWDH/VOofugECzLsluope/hTmy+FIuIYKGyfbXVuYGVL8m wT2IvbOsQJWXSNVh+ptsrFqg= X-Received: by 127.0.0.2 with SMTP id 11n7YY1788612xuV5UAJjdeC; Mon, 23 Oct 2023 06:05:22 -0700 X-Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mx.groups.io with SMTP id smtpd.web11.120284.1698066321943536459 for ; Mon, 23 Oct 2023 06:05:22 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c5087d19a6so48735901fa.0 for ; Mon, 23 Oct 2023 06:05:21 -0700 (PDT) X-Gm-Message-State: xSS9pEB7JxhceixSNRyhrsTnx1787277AA= X-Google-Smtp-Source: AGHT+IHjL13PM/MC6x29OozJi4iTFUh8584qQVtdrcVk2RYFzRcor0UIBmPzX2PJIcdQruDxYXEauw== X-Received: by 2002:a2e:b042:0:b0:2c0:1c32:b4df with SMTP id d2-20020a2eb042000000b002c01c32b4dfmr5769614ljl.15.1698066319602; Mon, 23 Oct 2023 06:05:19 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:19 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 05/16] ManageabilityPkg: Correct typo in MCTP destination EID field Date: Mon, 23 Oct 2023 16:05:00 +0300 Message-Id: <20231023130511.4521-6-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066324844100024 Content-Type: text/plain; charset="utf-8" Correct wrong structure member used for MCTP destination EID. Signed-off-by: Abner Chang Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Universal/PldmProtocol/Common/PldmProtocolCommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index ce1e2cba95..1c4506d87f 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -119,7 +119,7 @@ SetupPldmRequestTransportPacket ( } =20 MctpHeader->SourceEndpointId =3D PcdGet8 (PcdMctpSourceEnd= pointId); - MctpHeader->SourceEndpointId =3D PcdGet8 (PcdMctpDestinati= onEndpointId); + MctpHeader->DestinationEndpointId =3D PcdGet8 (PcdMctpDestinati= onEndpointId); MctpHeader->MessageHeader.IntegrityCheck =3D FALSE; MctpHeader->MessageHeader.MessageType =3D MCTP_MESSAGE_TYPE_PLDM; *PacketHeader =3D (MANAGEABILITY_TRANSPORT_= HEADER *)MctpHeader; --=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 (#109913): https://edk2.groups.io/g/devel/message/109913 Mute This Topic: https://groups.io/mt/102134653/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109914+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109914+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066325; cv=none; d=zohomail.com; s=zohoarc; b=ZzntFJJ94/Tthchu8jsIxPcdcXdhYbVW+jFUwW3oBIiRJTxVeFyDs35Eb1YQpqmgTzriv1RMnxc30bs144cA9cPBcxoAcmFxID8ME0/OSrFobgh/KpXpR8eOJ+YMPeNChW+qETGMhq5bEvMugh056JcMyjQ6wA2111jS7r3tI6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066325; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=dbhqHtHSNKqz+iG3TiVr9PMte1wqq8QC71E6uN3WPyc=; b=T3bxCW5/EHiJSDYB1VQEbpGHi21+CuTetSg9AhKOgJy6o9n7aCZQm4/NWdihV51TtwF0shAVNftGRjK2waGH0Wtxe+9LAXKOglko6QTUsDan8jhXdULeW5t5WuEmafVOxUUXSnWIokkyZPsGd0uz4wipttNQvoWgCjPrBzacQoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109914+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066325784113.91059812808066; Mon, 23 Oct 2023 06:05:25 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=v6VEOjaOdhVUjxZVfpGztWdtzkG4NZZk2Pqf2AbYD8k=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066323; v=1; b=Q+r8l8eXXoFmWQyWrAZyOetCwBVcf2P2jfCzB3gKqVgMX/qYVvpX98HixKx7KJoacS4AZE0t y+rXHXU4H4RPRDuj2BDmcWCzmNy0wCbH6ug8Zdqi3ttUwV8ZfmGhOrB3Qm0jCWz8pOIJEek2MN0 nsmXgTytVFk/ygXiZ9ISBtJA= X-Received: by 127.0.0.2 with SMTP id NaFKYY1788612xuykW6cJBct; Mon, 23 Oct 2023 06:05:23 -0700 X-Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mx.groups.io with SMTP id smtpd.web11.120286.1698066322578027551 for ; Mon, 23 Oct 2023 06:05:22 -0700 X-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2b9c907bc68so48482941fa.2 for ; Mon, 23 Oct 2023 06:05:22 -0700 (PDT) X-Gm-Message-State: HcwAPGQ5A65lZPl4wkQx1XoNx1787277AA= X-Google-Smtp-Source: AGHT+IF6615VQCXS1Yx/KmakSOWa3bZ+Jpw7Czuvr4lMoFFybS2Zq6bF9LTWe4mpLZQOfV/nj/Fhuw== X-Received: by 2002:a05:651c:22a:b0:2b6:df71:cff1 with SMTP id z10-20020a05651c022a00b002b6df71cff1mr6414922ljn.52.1698066320382; Mon, 23 Oct 2023 06:05:20 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:20 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 06/16] ManageabilityPkg: Update the algorithm of using MCTP endpoint ID PCD Date: Mon, 23 Oct 2023 16:05:01 +0300 Message-Id: <20231023130511.4521-7-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066326926100032 Content-Type: text/plain; charset="utf-8" Although MtcpSubmit function receives source and destination MCTP EID arguments these value are not used in any way currently. Instead the code always uses EID values from the PCDs. To correct this issue modify function interface to receive source and destination MCTP EIDs via pointers and use PCD values only if the pointers are NULL. Signed-off-by: Konstantin Aladyshev Signed-off-by: Abner Chang Reviewed-by: Abner Chang --- .../Include/Protocol/MctpProtocol.h | 12 ++++-- .../Dxe/ManageabilityTransportMctp.c | 4 +- .../MctpProtocol/Common/MctpProtocolCommon.c | 4 +- .../Universal/MctpProtocol/Dxe/MctpProtocol.c | 42 ++++++++++++++----- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h b/Fe= atures/ManageabilityPkg/Include/Protocol/MctpProtocol.h index 85e42f157d..c96b986c44 100644 --- a/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h +++ b/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h @@ -28,8 +28,12 @@ typedef struct _EDKII_MCTP_PROTOCOL EDKII_MCTP_PROTOCOL; =20 @param[in] This EDKII_MCTP_PROTOCOL instan= ce. @param[in] MctpType MCTP message type. - @param[in] MctpSourceEndpointId MCTP source endpoint ID. - @param[in] MctpDestinationEndpointId MCTP source endpoint ID. + @param[in] MctpSourceEndpointId Pointer of MCTP source end= point ID. + Set to NULL means use plat= form PCD value + (PcdMctpSourceEndpointId). + @param[in] MctpDestinationEndpointId Pointer of MCTP destinatio= n endpoint ID. + Set to NULL means use plat= form PCD value + (PcdMctpDestinationEndpoin= tId). @param[in] RequestDataIntegrityCheck Indicates whether MCTP mes= sage has integrity check byte. @param[in] RequestData Message Data. @@ -58,8 +62,8 @@ EFI_STATUS (EFIAPI *MCTP_SUBMIT_COMMAND)( IN EDKII_MCTP_PROTOCOL *This, IN UINT8 MctpType, - IN UINT8 MctpSourceEndpointId, - IN UINT8 MctpDestinationEndpointId, + IN UINT8 *MctpSourceEndpointId, + IN UINT8 *MctpDestinationEndpointId, IN BOOLEAN RequestDataIntegrityCheck, IN UINT8 *RequestData, IN UINT32 RequestDataSize, diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLi= b/Dxe/ManageabilityTransportMctp.c b/Features/ManageabilityPkg/Library/Mana= geabilityTransportMctpLib/Dxe/ManageabilityTransportMctp.c index c520e2302d..249104c873 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/M= anageabilityTransportMctp.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/M= anageabilityTransportMctp.c @@ -205,8 +205,8 @@ MctpTransportTransmitReceive ( Status =3D mMctpProtocol->Functions.Version1_0->MctpSubmitCommand ( mMctpProtocol, TransmitHeader->MessageH= eader.MessageType, - TransmitHeader->SourceEn= dpointId, - TransmitHeader->Destinat= ionEndpointId, + &TransmitHeader->SourceE= ndpointId, + &TransmitHeader->Destina= tionEndpointId, (BOOLEAN)TransmitHeader-= >MessageHeader.IntegrityCheck, TransferToken->TransmitP= ackage.TransmitPayload, TransferToken->TransmitP= ackage.TransmitSizeInByte, diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index 5844d54eb2..3128aadd15 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -175,8 +175,8 @@ SetupMctpRequestTransportPacket ( MctpTransportHeader =3D (MCTP_TRANSPORT_HE= ADER *)ThisPackage; MctpTransportHeader->Bits.Reserved =3D 0; MctpTransportHeader->Bits.HeaderVersion =3D MCTP_KCS_HEADER_VE= RSION; - MctpTransportHeader->Bits.DestinationEndpointId =3D PcdGet8 (PcdMctpDe= stinationEndpointId); - MctpTransportHeader->Bits.SourceEndpointIdId =3D PcdGet8 (PcdMctpSo= urceEndpointId); + MctpTransportHeader->Bits.DestinationEndpointId =3D MctpDestinationEnd= pointId; + MctpTransportHeader->Bits.SourceEndpointId =3D MctpSourceEndpoint= Id; MctpTransportHeader->Bits.MessageTag =3D MCTP_MESSAGE_TAG; MctpTransportHeader->Bits.TagOwner =3D MCTP_MESSAGE_TAG_O= WNER_REQUEST; MctpTransportHeader->Bits.PacketSequence =3D mMctpPacketSequenc= e & MCTP_PACKET_SEQUENCE_MASK; diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProto= col.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c index d0f49a1abb..73445bf816 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c @@ -29,8 +29,12 @@ UINT32 mTransportMaximumPayload; =20 @param[in] This EDKII_MCTP_PROTOCOL instan= ce. @param[in] MctpType MCTP message type. - @param[in] MctpSourceEndpointId MCTP source endpoint ID. - @param[in] MctpDestinationEndpointId MCTP source endpoint ID. + @param[in] MctpSourceEndpointId Pointer of MCTP source end= point ID. + Set to NULL means use plat= form PCD value + (PcdMctpSourceEndpointId). + @param[in] MctpDestinationEndpointId Pointer of MCTP destinatio= n endpoint ID. + Set to NULL means use plat= form PCD value + (PcdMctpDestinationEndpoin= tId). @param[in] RequestDataIntegrityCheck Indicates whether MCTP mes= sage has integrity check byte. @param[in] RequestData Message Data. @@ -59,8 +63,8 @@ EFIAPI MctpSubmitMessage ( IN EDKII_MCTP_PROTOCOL *This, IN UINT8 MctpType, - IN UINT8 MctpSourceEndpointId, - IN UINT8 MctpDestinationEndpoin= tId, + IN UINT8 *MctpSourceEndpointId, + IN UINT8 *MctpDestinationEndpoi= ntId, IN BOOLEAN RequestDataIntegrityCh= eck, IN UINT8 *RequestData, IN UINT32 RequestDataSize, @@ -72,24 +76,42 @@ MctpSubmitMessage ( ) { EFI_STATUS Status; + UINT8 SourceEid; + UINT8 DestinationEid; =20 if ((RequestData =3D=3D NULL) && (ResponseData =3D=3D NULL)) { DEBUG ((DEBUG_ERROR, "%a: Both RequestData and ResponseData are NULL\n= ", __func__)); return EFI_INVALID_PARAMETER; } =20 + if (MctpSourceEndpointId =3D=3D NULL) { + SourceEid =3D PcdGet8 (PcdMctpSourceEndpointId); + DEBUG ((DEBUG_MANAGEABILITY, "%a: Use PcdMctpSourceEndpointId for MCTP= source EID: %x\n", __func__, SourceEid)); + } else { + SourceEid =3D *MctpSourceEndpointId; + DEBUG ((DEBUG_MANAGEABILITY, "%a: MCTP source EID: %x\n", __func__, So= urceEid)); + } + + if (MctpDestinationEndpointId =3D=3D NULL) { + DestinationEid =3D PcdGet8 (PcdMctpDestinationEndpointId); + DEBUG ((DEBUG_MANAGEABILITY, "%a: Use PcdMctpDestinationEndpointId for= MCTP destination EID: %x\n", __func__, DestinationEid)); + } else { + DestinationEid =3D *MctpDestinationEndpointId; + DEBUG ((DEBUG_MANAGEABILITY, "%a: MCTP destination EID: %x\n", __func_= _, DestinationEid)); + } + // // Check source EID and destination EID // - if ((MctpSourceEndpointId >=3D MCTP_RESERVED_ENDPOINT_START_ID) && - (MctpSourceEndpointId <=3D MCTP_RESERVED_ENDPOINT_END_ID) + if ((SourceEid >=3D MCTP_RESERVED_ENDPOINT_START_ID) && + (SourceEid <=3D MCTP_RESERVED_ENDPOINT_END_ID) ) { DEBUG ((DEBUG_ERROR, "%a: The value of MCTP source EID (%x) is reserve= d.\n", __func__, MctpSourceEndpointId)); return EFI_INVALID_PARAMETER; } =20 - if ((MctpDestinationEndpointId >=3D MCTP_RESERVED_ENDPOINT_START_ID) && - (MctpDestinationEndpointId <=3D MCTP_RESERVED_ENDPOINT_END_ID) + if ((DestinationEid >=3D MCTP_RESERVED_ENDPOINT_START_ID) && + (DestinationEid <=3D MCTP_RESERVED_ENDPOINT_END_ID) ) { DEBUG ((DEBUG_ERROR, "%a: The value of MCTP destination EID (%x) is re= served.\n", __func__, MctpDestinationEndpointId)); return EFI_INVALID_PARAMETER; @@ -98,8 +120,8 @@ MctpSubmitMessage ( Status =3D CommonMctpSubmitMessage ( mTransportToken, MctpType, - MctpSourceEndpointId, - MctpDestinationEndpointId, + SourceEid, + DestinationEid, RequestDataIntegrityCheck, RequestData, RequestDataSize, --=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 (#109914): https://edk2.groups.io/g/devel/message/109914 Mute This Topic: https://groups.io/mt/102134654/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109915+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109915+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066324; cv=none; d=zohomail.com; s=zohoarc; b=YJv3xUFgbNlcezxFS3xcm+pOu8/+zPNKAIu0oJrZzP0YoERVQvPESi3zhXqcvYdr5hzQx4optbuPYJ3X5PEJF5JbHvLG0Ny+UAEKfUHh2AKyTxGjNFYxypA14NKBwrsQo4ZqKZnJBrPInJYwLJcSXpUL8GDukdkoPSI/z6M2F8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066324; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=qSBuDGH4SgLORBiZzdCmjS3xMRTyIGaeBrpVop55z18=; b=WHz996AUkwtGBawFVHjQtWqxTFcf/k3SuiyjiJTU96co+1W1783xtba6KVbrYEsgfUsMdpKBWMZOqBnbdkI1mKcORyIPjB8ZSV6X70LlTfJuhOg0czAEBKpP3AyzlJRLUJs6P0YwfImCKoay5q7a2rva381Sh5Sg3NHsjtnxmSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109915+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066324845912.0452614899104; Mon, 23 Oct 2023 06:05:24 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xJb/MpHrcg4p5QBmR0ERuqc43+YmfEumuqt72mGyrks=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066324; v=1; b=rvBEDC4alcNxQuYd+wFVfFvoNpknMirVFwb8ZzSW3XpP2xcawmYzX0E92q/8AGXHoUOgh+dp WfauurVI6FV2AMB2Ph11OcnMFq4XZ22xhEqgqpguUC1fsdGNwmSVSMu38vspT6CaJc4vRDLMxbA U6pF9fvDnK/GCgq7z6bHhg84= X-Received: by 127.0.0.2 with SMTP id kC53YY1788612xC195LRfeBW; Mon, 23 Oct 2023 06:05:24 -0700 X-Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mx.groups.io with SMTP id smtpd.web10.119846.1698066323289932092 for ; Mon, 23 Oct 2023 06:05:23 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c5056059e0so49518691fa.3 for ; Mon, 23 Oct 2023 06:05:23 -0700 (PDT) X-Gm-Message-State: 3IBsehvEAzeRFlxNlTvEyrEmx1787277AA= X-Google-Smtp-Source: AGHT+IGSfsWY5jIljmVs7MsrSlvIDkcYNQOlcLCM8uak25AItsGfDUm3DtXUMeW3rq0TBD1uRirKtw== X-Received: by 2002:a05:651c:1409:b0:2c5:1d11:5688 with SMTP id u9-20020a05651c140900b002c51d115688mr6044569lje.14.1698066321049; Mon, 23 Oct 2023 06:05:21 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:20 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 07/16] ManageabilityPkg: Correct value for the MCTP TAG_OWNER response bit Date: Mon, 23 Oct 2023 16:05:02 +0300 Message-Id: <20231023130511.4521-8-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066326877100031 Content-Type: text/plain; charset="utf-8" Currently the MCTP TAG_OWNER bit is checked against 1 both in MTCP request and response. According to the MTCP Base specification in case of the MCTP response the TAG_OWNER bit should be equal to 0. Correct MCTP_MESSAGE_TAG_OWNER_RESPONSE flag value to fix the issue. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Include/Library/ManageabilityTransportMctpLib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtMctpLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransp= ortMctpLib.h index 462e7436e6..a8dc8a8519 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpL= ib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpL= ib.h @@ -51,8 +51,8 @@ typedef struct { // is not defined by the specification. #define MCTP_MESSAGE_TAG 0x1 =20 -#define MCTP_MESSAGE_TAG_OWNER_REQUEST 0x01 -#define MCTP_MESSAGE_TAG_OWNER_RESPONSE 0x01 +#define MCTP_MESSAGE_TAG_OWNER_REQUEST 1 +#define MCTP_MESSAGE_TAG_OWNER_RESPONSE 0 =20 #define MCTP_PACKET_SEQUENCE_MASK 0x3 =20 --=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 (#109915): https://edk2.groups.io/g/devel/message/109915 Mute This Topic: https://groups.io/mt/102134655/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109916+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109916+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066327; cv=none; d=zohomail.com; s=zohoarc; b=leVN0rFggwDG4zOXBUm4cA8fUaO2Lt6LomNCA2MajLuJY9K0O+eQrbk47k48s+hLnKe09cG/K6HI5eSloJQOODBeObX/kL9YcgJxLJHDkfS6pJjetZmz6xiWJPYw+mtdciD3PRdG/YwJafcdJkuXOU+elZCzcQvjWh6+AglEXGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066327; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=SoxQyMjLtKiz2Kkdc/KCFJ/KrBneG8CDCojxdwFOk6Q=; b=CIdjeADqoUf+ikOH/M6OfiuEV4epRzEO3vc1MS4w/GyL3c857dh56Fa01oYnjEF4ybA0dCSTA+Lz6Uhr/Iq1H1ipbZOm2bVk7nADMsW7hKyAIUmQpZdGeimmE6/84ZR6BpnYdD6uz82cBLAN2BtcxS7Urrmk0Y/vcFQgf+LBIvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109916+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066327031438.0859771150218; Mon, 23 Oct 2023 06:05:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=3NJdXTAw2fh8SsvHpQgn6hzfB4kUTfccYIzD466GhKM=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066325; v=1; b=wM2nj4YoNzKjGWBOuCTztuO0LVNB2AEAyXKxDAEe68he8tFOpEENzOS7d6Jh3pwioovuEDwV AQR0Qz+7n1jUn19+en0GzY/0HuOJx4zPO1FH4MnSfG/H/8Uoalsd3f5LYEtkAJy4fq6sgz1pPCs L0NuMbxv321WriL82UmU9EAc= X-Received: by 127.0.0.2 with SMTP id k21zYY1788612xFUpHN9oI7q; Mon, 23 Oct 2023 06:05:25 -0700 X-Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by mx.groups.io with SMTP id smtpd.web11.120287.1698066323806373312 for ; Mon, 23 Oct 2023 06:05:24 -0700 X-Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2c51388ccebso48332221fa.3 for ; Mon, 23 Oct 2023 06:05:23 -0700 (PDT) X-Gm-Message-State: BTqlDYReSbytuysDPdoW12Vnx1787277AA= X-Google-Smtp-Source: AGHT+IEZH1E+Oq/uw83/t1vS49ccI8EpB9pLwC74ZurpW2eK2LSBLXZ7ZHbbnIh27PWoEhhstyuOKQ== X-Received: by 2002:a2e:b042:0:b0:2c0:1c32:b4df with SMTP id d2-20020a2eb042000000b002c01c32b4dfmr5769756ljl.15.1698066321706; Mon, 23 Oct 2023 06:05:21 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:21 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 08/16] ManageabilityPkg: Don't check MCTP header fields if transfer has failed Date: Mon, 23 Oct 2023 16:05:03 +0300 Message-Id: <20231023130511.4521-9-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066328817100043 Content-Type: text/plain; charset="utf-8" If MCTP KCS communication has failed we need to abort MCTP transfer function before checking any MCTP header data. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../MctpProtocol/Common/MctpProtocolCommon.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index 3128aadd15..4aae4fcba9 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -461,6 +461,13 @@ CommonMctpSubmitMessage ( &TransferToken ); =20 + *AdditionalTransferError =3D TransferToken.TransportAdditionalStatus; + Status =3D TransferToken.TransferStatus; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to send MCTP command over %s: %r\n", = __func__, mTransportName, Status)); + return Status; + } + MctpTransportResponseHeader =3D (MCTP_TRANSPORT_HEADER *)ResponseBuffer; if (MctpTransportResponseHeader->Bits.HeaderVersion !=3D MCTP_KCS_HEADER= _VERSION) { DEBUG (( @@ -543,18 +550,9 @@ CommonMctpSubmitMessage ( return EFI_DEVICE_ERROR; } =20 - // - // Return transfer status. - // - *AdditionalTransferError =3D TransferToken.TransportAdditionalStatus; *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInB= yte - sizeof (MCTP_TRANSPORT_HEADER) - sizeof (MCTP_MESSAGE_HEADER); CopyMem (ResponseData, ResponseBuffer + sizeof (MCTP_TRANSPORT_HEADER) += sizeof (MCTP_MESSAGE_HEADER), *ResponseDataSize); FreePool (ResponseBuffer); - Status =3D TransferToken.TransferStatus; - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: Failed to send MCTP command over %s: %r\n", = __func__, mTransportName, Status)); - return Status; - } =20 return Status; } --=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 (#109916): https://edk2.groups.io/g/devel/message/109916 Mute This Topic: https://groups.io/mt/102134656/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109917+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109917+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066327; cv=none; d=zohomail.com; s=zohoarc; b=YhPAksBz5HR+FDsRYd+bWyreJLclM6mjc3bLfqcMfb0ogCgXU52Opl+gcOjkkSzvQoEfQVirwPUiUeZfhqTzaDpAhvWGOlGghdqZ0lgtuNL0ba21PDc9jygKTX2wuvUAFNihbWMkG5q2lFArMv7C4pFV5QPs4QInb5jjcZfWCNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066327; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Ry01A0+rcWOvfmu+CXqMHA8aZ2NPwluOtytTIouMCkE=; b=JAg75xDOBEeR29e+cmi05oxAsqhSmHeb+Q2bi7aU3yE0IgxMP8qthWzcoHuXASM5wAippR1nAk3jkGrUcazKHpJPeEmbDiYnAmmp4aKCs6xgjAbc9UaPyub5dpdvf8/cKTNR1PT/Qr6xbkx19YdSxdpP7AmZ/dEcHzMYSELI50s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109917+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066327005752.727801258706; Mon, 23 Oct 2023 06:05:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=gaeFRaurOFht+fX2akrplusng8bBEsZ2Gd9iqj59FzY=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066326; v=1; b=M0BNLJj49f3Q0oDuubyfEtsSUL73lbZOOv6rzQsZLTNo0DjelvjQgF2uVJ1mFRgNdpJHEiY5 wgkEFWZReO6Q8WpsM6FkWEbwaB0Xjz5D0VGnUJpnkp0RcpC/fUI6ky+bnQGb0b8k7/fPQoSElqf ynnBJhA9nFV0g/YhUwfRKyi8= X-Received: by 127.0.0.2 with SMTP id yRBmYY1788612x6cOvSGjl1g; Mon, 23 Oct 2023 06:05:26 -0700 X-Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by mx.groups.io with SMTP id smtpd.web11.120288.1698066324651358385 for ; Mon, 23 Oct 2023 06:05:25 -0700 X-Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2bfed7c4e6dso48588971fa.1 for ; Mon, 23 Oct 2023 06:05:24 -0700 (PDT) X-Gm-Message-State: HMbuZsII95rpAxe2DMu7jQI4x1787277AA= X-Google-Smtp-Source: AGHT+IHOVsIRYeKaSek0uvhFIDDzkTdQNI4UgdMegUeQoTsgCNuGyfDmMgeHmCiD51BD1kFMc0XZYA== X-Received: by 2002:a2e:b911:0:b0:2c5:2132:24f5 with SMTP id b17-20020a2eb911000000b002c5213224f5mr5769107ljb.53.1698066322561; Mon, 23 Oct 2023 06:05:22 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:22 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 09/16] ManageabilityPkg: Use correct constants for PLDM header checks Date: Mon, 23 Oct 2023 16:05:04 +0300 Message-Id: <20231023130511.4521-10-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066328825100044 Content-Type: text/plain; charset="utf-8" Currently PldmProtocol code uses magic numbers in the PLDM header checks. Since PLDM headers have all the necessary definitions replace magic numbers with the appropriate defines. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Universal/PldmProtocol/Common/PldmProtocolCommon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index 1c4506d87f..4edfe05955 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -321,15 +321,15 @@ CommonPldmSubmitCommand ( // // Check the integrity of response. data. ResponseHeader =3D (PLDM_RESPONSE_HEADER *)FullPacketResponseData; - if ((ResponseHeader->PldmHeader.DatagramBit !=3D 0) || - (ResponseHeader->PldmHeader.RequestBit !=3D 0) || + if ((ResponseHeader->PldmHeader.DatagramBit !=3D (!PLDM_MESSAGE_HEADER_I= S_DATAGRAM)) || + (ResponseHeader->PldmHeader.RequestBit !=3D PLDM_MESSAGE_HEADER_IS_R= ESPONSE) || (ResponseHeader->PldmHeader.InstanceId !=3D mPldmRequestInstanceId) = || (ResponseHeader->PldmHeader.PldmType !=3D PldmType) || (ResponseHeader->PldmHeader.PldmTypeCommandCode !=3D PldmCommand)) { DEBUG ((DEBUG_ERROR, "PLDM integrity check of response data is failed.= \n")); - DEBUG ((DEBUG_ERROR, " Request bit =3D %d (Expected value: 0)\n")); - DEBUG ((DEBUG_ERROR, " Datagram =3D %d (Expected value: 0)\n")); + DEBUG ((DEBUG_ERROR, " Datagram =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.DatagramBit, (!PLDM_MESSAGE_HEADER_IS_DATAGRAM)= )); + DEBUG ((DEBUG_ERROR, " Request bit =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.RequestBit, PLDM_MESSAGE_HEADER_IS_RESPONSE)); DEBUG ((DEBUG_ERROR, " Instance ID =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.InstanceId, mPldmRequestInstanceId)); DEBUG ((DEBUG_ERROR, " Pldm Type =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.PldmType, PldmType)); DEBUG ((DEBUG_ERROR, " Pldm Command =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.PldmTypeCommandCode, PldmCommand)); --=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 (#109917): https://edk2.groups.io/g/devel/message/109917 Mute This Topic: https://groups.io/mt/102134657/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109918+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109918+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066327; cv=none; d=zohomail.com; s=zohoarc; b=aBb6Jje6WKlA43YHjlU4Egs8J+u5I98y71WxHelBvM0MTD2dZnBZJygW8gdjxK65FWvkqZv1l2ozR1LKNErJS9sXoTDKysqg37/CecTbGyJPaijcLiqO12z0yuBc45jJuFHeFJA1worstlHf364pBGBUNJNviRLbn83dmzn4kF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066327; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=DEfuRL33HwVoNytnbcBZ8OzL+QHUL+J2PVYPFPOdrmM=; b=ORHflAIWUoiWCvB48F58+XbJd+8es2Pr50LojPEO0/Njy5Yz3MmYo8vtMtTo+tH88ZHVVepmZaw3QK03I9LgwlhwDCNAJ/j7emBEcQWik0N/gXo7wS8mI0GnMyb3o8lyMZ58mEZIwhp/L2WtrXwLFNI5EawPLsJJ9bkk9LfECgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109918+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066327549425.2216107433287; Mon, 23 Oct 2023 06:05:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=40mJXTPR82mTH8+6m/MqaI/29UMBSCTB7tDROT7nzqk=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066327; v=1; b=Z4EqJtzyelVMp/vhPK2aVQTN8tq/cwJMSHCWSERlxiL3QnBnD7jxd6zrPqcf2UTcU6cWJRSQ Hk+GA/O8//8vgl3iBRz3jm3h9hBc+zbyc97UPJuWZRyEBmvuxatrmOHIESm378VQUKhDWvGjvxP fJ67OD6Ab1UFhcnmYwHSiyjk= X-Received: by 127.0.0.2 with SMTP id c1E6YY1788612xuhOXOSFwKb; Mon, 23 Oct 2023 06:05:27 -0700 X-Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by mx.groups.io with SMTP id smtpd.web10.119848.1698066325594501203 for ; Mon, 23 Oct 2023 06:05:25 -0700 X-Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-507ac66a969so4388711e87.3 for ; Mon, 23 Oct 2023 06:05:25 -0700 (PDT) X-Gm-Message-State: AEsTFyT9qX0vpc5ik5Nj1DAwx1787277AA= X-Google-Smtp-Source: AGHT+IHrZDN4tzl37I+5cNtOa12a9Prdx2/rRp6PgUR6ecjD+O2Ru8O2+FPoKBlt9SC8FkhqhjH0qg== X-Received: by 2002:a2e:3a03:0:b0:2c5:84c:62d3 with SMTP id h3-20020a2e3a03000000b002c5084c62d3mr6010175lja.5.1698066323402; Mon, 23 Oct 2023 06:05:23 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:22 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 10/16] ManageabilityPkg: Return error on multiple-packet MCTP responses Date: Mon, 23 Oct 2023 16:05:05 +0300 Message-Id: <20231023130511.4521-11-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066328811100041 Content-Type: text/plain; charset="utf-8" Since the current driver doesn't yet support handling of multiple-packet MCTP responses, return EFI_UNSUPPORTED error in such cases. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../MctpProtocol/Common/MctpProtocolCommon.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index 4aae4fcba9..3709ab16eb 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -524,6 +524,17 @@ CommonMctpSubmitMessage ( FreePool (ResponseBuffer); return EFI_DEVICE_ERROR; } + if ((MctpTransportResponseHeader->Bits.StartOfMessage !=3D 1) || + (MctpTransportResponseHeader->Bits.EndOfMessage !=3D 1) || + (MctpTransportResponseHeader->Bits.PacketSequence !=3D 0)) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Multiple-packet MCTP responses are not supported by the = current driver\n", + __func__ + )); + FreePool (ResponseBuffer); + return EFI_UNSUPPORTED; + } =20 MctpMessageResponseHeader =3D (MCTP_MESSAGE_HEADER *)(MctpTransportRespo= nseHeader + 1); if (MctpMessageResponseHeader->Bits.MessageType !=3D MctpType) { --=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 (#109918): https://edk2.groups.io/g/devel/message/109918 Mute This Topic: https://groups.io/mt/102134658/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109919+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109919+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066328; cv=none; d=zohomail.com; s=zohoarc; b=ZwP05M2VNP5IOYEIWawRKtpZUsZwqqiaTVV5Pc5ctPVy66qvvMF77vG7ibDku6GssoAmzvwqkXBGGN9SRmApAlr6AvMErc5FTxNyyL1THEeUDnpgi/C4wcJ65OB1APJG3td/m2kwZooHh5D7Wq0ZstnSAFslKCER4xxBRC6T2kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066328; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=7gfFq6LtiItzIrhERkgIj4Qy40aaiH4dn9zRcsap/L8=; b=maCzuz8KceoIxgOH2oqsOAQ3RiTnUDAhtEuMRSg8SMoVPB3W8QPWNY8iu5UxNFhxZ8BDxpvbK9rf5KS+Gr1WLV1Z3/S0zaHth/YmNp8cp0ISZbN+BnC547QNvAtoTxd77OkhRNLYAijt37fFSBxQ8OvBeFH26wkrKwlvooFhLBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109919+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066328070958.0912584494774; Mon, 23 Oct 2023 06:05:28 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=PKrp0Gs4vLrOgKHJT5kSwSz7YdguBAELBzqnGmcSjYg=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066327; v=1; b=gclBecT/ykpJEAGASC5kcxk0YiV3Uzib0qK/i1b1yI1u2GtJ9PjCPHbh7hOCZ60Deb4Mr//x fOkNXhzvGYSqGWMgx7b7EHW+jmsHqqiAaoM/nbZTlezb1EmgHmvHqNerT5YHvnRV8NAsvkbw7Me vvkSMpWB87UYyTiPGrjGfrrM= X-Received: by 127.0.0.2 with SMTP id YoWlYY1788612xkrEGK9JgeN; Mon, 23 Oct 2023 06:05:27 -0700 X-Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mx.groups.io with SMTP id smtpd.web11.120292.1698066326741189498 for ; Mon, 23 Oct 2023 06:05:27 -0700 X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c503dbe50dso49172981fa.1 for ; Mon, 23 Oct 2023 06:05:26 -0700 (PDT) X-Gm-Message-State: K7LBcCwkLrUnFSGnxT9lqSjsx1787277AA= X-Google-Smtp-Source: AGHT+IGfl3oAjONwEHr7+7DWdq18IVhRTgA9a5TQpkusZeF/2f2hnpjmpwcyMRqRAd14axz6C8hCWg== X-Received: by 2002:a2e:9189:0:b0:2c5:23ac:3672 with SMTP id f9-20020a2e9189000000b002c523ac3672mr6268731ljg.45.1698066324567; Mon, 23 Oct 2023 06:05:24 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:23 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 11/16] ManageabilityPkg: Add PLDM terminus PCDs Date: Mon, 23 Oct 2023 16:05:06 +0300 Message-Id: <20231023130511.4521-12-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066328815100042 Content-Type: text/plain; charset="utf-8" From: Abner Chang Add PLDM source and destination terminus IDs for transmiting PLDM message. Signed-off-by: Abner Chang Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- Features/ManageabilityPkg/ManageabilityPkg.dec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/Mana= geabilityPkg/ManageabilityPkg.dec index 14fe0fd2e0..eb0ee67cba 100644 --- a/Features/ManageabilityPkg/ManageabilityPkg.dec +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec @@ -72,6 +72,12 @@ # @Prompt MCTP KCS (Memory mapped) I/O base address gManageabilityPkgTokenSpaceGuid.PcdMctpKcsBaseAddress|0xca2|UINT32|0x000= 00004 =20 + ## This value is the PLDM source and destination terminus ID for transmi= ting PLDM message. + # @Prompt PLDM source terminus ID + gManageabilityPkgTokenSpaceGuid.PcdPldmSourceTerminusId|0|UINT8|0x000000= 40 + # @Prompt PLDM destination terminus ID + gManageabilityPkgTokenSpaceGuid.PcdPldmDestinationEndpointId|0|UINT8|0x0= 0000041 + ## This is the value of SOL channels supported on platform. # @Prompt SOL channel number gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels|3|UINT8|0x00000100 --=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 (#109919): https://edk2.groups.io/g/devel/message/109919 Mute This Topic: https://groups.io/mt/102134661/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109920+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109920+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066329; cv=none; d=zohomail.com; s=zohoarc; b=CqafiUNa4a6w7Y6OP7znBQRnNhq7YfpKSJ8EPYIAXvkBqS5kvglrT4AkEkc881vp2HRXowJgltTmshZ+P3Dx3YBtpV8MfWfgzQzf5VEDd62r1WnWd2ddmvp2lDjDFdppMIRQ6eO37uixRDuGKnjsqb8CdRpL/v9qkWJ/aUs3XM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066329; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=rm0BbwcA/8gbXcHbZ6OW0MFJNll3/moVZXgNAPlgBHg=; b=SnOTNt7fJTLrEDkYcUKh7bxS6dRDL7On03oTwRgrHsfBTiJJfVqv9IMpMACL4SoqapsGLfB9uo77uSDpipFnqjEKrjMvUw6F2s26Oexqw8+IPUSnseUshuXA3B7HgY2y1Z4cV4kGF1gdBqxTiJEnUHCeacynZFGoMX8sjFiIcG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109920+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066329097874.123931735027; Mon, 23 Oct 2023 06:05:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=4UgB4NlJmjJT6RNZZw6sGA39tMie2KIVohszToCy8ic=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066328; v=1; b=V3UD7UqhSoeXrO0kMIb6UN9jaCXPFNHKsjZdVAAku8xNDkX9gDTE+JIL3i/4KOmn9XvFLiB4 KxpjjiqSuDevkB9My6cfY+L9kGIwPa8OAIawQ5iv0m1W3IbHf8xOyUkhRQV6DgiXu+MS+bEYfxV o/gaI7MsQNT6b0Imdm9CBhSA= X-Received: by 127.0.0.2 with SMTP id 3gQuYY1788612xwiz52SA9fA; Mon, 23 Oct 2023 06:05:28 -0700 X-Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mx.groups.io with SMTP id smtpd.web11.120294.1698066327719147732 for ; Mon, 23 Oct 2023 06:05:28 -0700 X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c501bd6ff1so44832191fa.3 for ; Mon, 23 Oct 2023 06:05:27 -0700 (PDT) X-Gm-Message-State: JPV0SLij7M5BYTn5Y04uILZrx1787277AA= X-Google-Smtp-Source: AGHT+IFyzZsBcqJf/WDhRv6TktiPYuCLfWxDWur67aJNIJL6Xeiz2XzwjnKmXt8JKS4rf0BU01NOBQ== X-Received: by 2002:a2e:9797:0:b0:2bc:db99:1775 with SMTP id y23-20020a2e9797000000b002bcdb991775mr6198533lji.26.1698066325420; Mon, 23 Oct 2023 06:05:25 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:24 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 12/16] PldmProtocolDxe: Correct TID argument usage Date: Mon, 23 Oct 2023 16:05:07 +0300 Message-Id: <20231023130511.4521-13-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066330966100054 Content-Type: text/plain; charset="utf-8" From: Abner Chang Currently the PLDM source/destination TID arguments for the PldmSubmit function are not actually used in any way in the underlying MCTP communication. The code just uses MCTP source/destination EID PCDs. So we have to restructure code to actually use provided PLDM TIDs. On the other case the PldmSubmitCommand function from the PldmProtocolLib doesn't even accept the source/destination TID arguments. To address both these facts correct TID argument usage in the following way: - by default the TID values are taken from the built-time PCDs, - user have an ability to provide custom TIDs either via PldmSubmit function arguments or by calling PldmSetTerminus API. Signed-off-by: Abner Chang Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Include/Library/BasePldmProtocolLib.h | 16 ++++++ .../Include/Protocol/PldmProtocol.h | 18 +++--- .../PldmProtocolLibrary/Dxe/PldmProtocolLib.c | 49 +++++++++++++++- .../Dxe/PldmProtocolLib.inf | 6 +- .../PldmProtocol/Common/PldmProtocolCommon.c | 28 +++++++--- .../PldmProtocol/Common/PldmProtocolCommon.h | 22 +++++--- .../Universal/PldmProtocol/Dxe/PldmProtocol.c | 56 ++++++++++++++++--- .../PldmProtocol/Dxe/PldmProtocolDxe.inf | 4 -- 8 files changed, 162 insertions(+), 37 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.= h b/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h index 5523ac3a4d..a698197263 100644 --- a/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h +++ b/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h @@ -9,6 +9,22 @@ #ifndef EDKII_PLDM_PROTOCOL_LIB_H_ #define EDKII_PLDM_PROTOCOL_LIB_H_ =20 +/** + This function sets the PLDM source termius and destination terminus + ID for SMBIOS PLDM transfer. + + @param[in] SourceId PLDM source teminus ID. + @param[in] DestinationId PLDM destination teminus ID. + + @retval EFI_SUCCESS The terminus is set successfully. + @retval EFI_INVALID_PARAMETER The terminus is set unsuccessfully. +**/ +EFI_STATUS +PldmSetTerminus ( + IN UINT8 SourceId, + IN UINT8 DestinationId +); + /** This service enables submitting commands via EDKII PLDM protocol. =20 diff --git a/Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h b/Fe= atures/ManageabilityPkg/Include/Protocol/PldmProtocol.h index 651997e1ad..02efb3015a 100644 --- a/Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h +++ b/Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h @@ -26,13 +26,15 @@ typedef struct _EDKII_PLDM_PROTOCOL EDKII_PLDM_PROTOCO= L; /** This service enables submitting commands via EDKII PLDM protocol. =20 - @param[in] This EDKII_PLDM_PROTOCOL instance. - @param[in] PldmType PLDM message type. - @param[in] Command PLDM Command of PLDM message type. - @param[in] RequestData Command Request Data. - @param[in] RequestDataSize Size of Command Request Data. - @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. - @param[in, out] ResponseDataSize Size of Command Response Data. + @param[in] This EDKII_PLDM_PROTOCOL instan= ce. + @param[in] PldmType PLDM message type. + @param[in] Command PLDM Command of PLDM messa= ge type. + @param[in] PldmTerminusSourceId PLDM source teminus ID. + @param[in] PldmTerminusDestinationId PLDM destination teminus I= D. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Da= ta. + @param[out] ResponseData Command Response Data. The= completion code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response D= ata. =20 @retval EFI_SUCCESS The command byte stream was successfully = submit to the device and a response was successfully received. @retval EFI_NOT_FOUND The command was not successfully sent to = the device or a response was not successfully received from the device. @@ -49,6 +51,8 @@ EFI_STATUS IN EDKII_PLDM_PROTOCOL *This, IN UINT8 PldmType, IN UINT8 Command, + IN UINT8 PldmTerminusSourceId, + IN UINT8 PldmTerminusDestinationId, IN UINT8 *RequestData, IN UINT32 RequestDataSize, OUT UINT8 *ResponseData, diff --git a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/Pldm= ProtocolLib.c b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/P= ldmProtocolLib.c index 267bd8fbc1..37231b0756 100644 --- a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.c +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.c @@ -9,10 +9,34 @@ #include #include #include +#include #include #include =20 -EDKII_PLDM_PROTOCOL *mEdkiiPldmProtocol =3D NULL; +EDKII_PLDM_PROTOCOL *mEdkiiPldmProtocol =3D NULL; +UINT8 mSourcePldmTerminusId =3D 0; +UINT8 mDestinationPldmTerminusId =3D 0; + +/** + This function sets the PLDM source termius and destination terminus + ID for SMBIOS PLDM transfer. + + @param[in] SourceId PLDM source teminus ID. + @param[in] DestinationId PLDM destination teminus ID. + + @retval EFI_SUCCESS The terminus is set successfully. + @retval EFI_INVALID_PARAMETER The terminus is set unsuccessfully. +**/ +EFI_STATUS +PldmSetTerminus ( + IN UINT8 SourceId, + IN UINT8 DestinationId +) +{ + mSourcePldmTerminusId =3D SourceId; + mDestinationPldmTerminusId =3D DestinationId; + return EFI_SUCCESS; +} =20 /** This service enables submitting commands via EDKII PLDM protocol. @@ -69,6 +93,8 @@ PldmSubmitCommand ( mEdkiiPldmProtocol, PldmType, Command, + mSourcePldmTerminus= Id, + mDestinationPldmTer= minusId, RequestData, RequestDataSize, ResponseData, @@ -85,3 +111,24 @@ PldmSubmitCommand ( =20 return Status; } +/** + + Initialize mSourcePldmTerminusId and mDestinationPldmTerminusId. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCCESS Protocol listener is registered successfully. + +**/ +EFI_STATUS +EFIAPI +PldmProtocolLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + PldmSetTerminus (PcdGet8(PcdPldmSourceTerminusId), PcdGet8(PcdPldmDestin= ationEndpointId)); + return EFI_SUCCESS; +} diff --git a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/Pldm= ProtocolLib.inf b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe= /PldmProtocolLib.inf index 1233d76726..19c84840b6 100644 --- a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.inf +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.inf @@ -16,7 +16,7 @@ MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D PldmProtocolLib|DXE_RUNTIME_DRIVER DX= E_DRIVER DXE_CORE UEFI_DRIVER UEFI_APPLICATION - + CONSTRUCTOR =3D PldmProtocolLibConstructor # # VALID_ARCHITECTURES =3D IA32 X64 # @@ -40,3 +40,7 @@ [Protocols] gEdkiiPldmProtocolGuid ## ALWAYS_CONSUMES =20 +[FixedPcd] + gManageabilityPkgTokenSpaceGuid.PcdPldmSourceTerminusId + gManageabilityPkgTokenSpaceGuid.PcdPldmDestinationEndpointId + diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index 4edfe05955..ea3d4a22b2 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -64,6 +64,8 @@ GetFullPacketResponseSize ( @param[in] TransportToken The transport interface. @param[in] PldmType PLDM message type. @param[in] PldmCommand PLDM command of this PLDM type. + @param[in] SourceId PLDM source teminus ID. + @param[in] DestinationId PLDM destination teminus ID. @param[out] PacketHeader The pointer to receive header of r= equest. @param[out] PacketHeaderSize Packet header size in bytes. @param[in, out] PacketBody The request body. @@ -88,6 +90,8 @@ SetupPldmRequestTransportPacket ( IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, IN UINT8 PldmType, IN UINT8 PldmCommand, + IN UINT8 SourceId, + IN UINT8 DestinationId, OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, OUT UINT16 *PacketHeaderSize, IN OUT UINT8 **PacketBody, @@ -118,8 +122,8 @@ SetupPldmRequestTransportPacket ( return EFI_OUT_OF_RESOURCES; } =20 - MctpHeader->SourceEndpointId =3D PcdGet8 (PcdMctpSourceEnd= pointId); - MctpHeader->DestinationEndpointId =3D PcdGet8 (PcdMctpDestinati= onEndpointId); + MctpHeader->SourceEndpointId =3D SourceId; + MctpHeader->DestinationEndpointId =3D DestinationId; MctpHeader->MessageHeader.IntegrityCheck =3D FALSE; MctpHeader->MessageHeader.MessageType =3D MCTP_MESSAGE_TYPE_PLDM; *PacketHeader =3D (MANAGEABILITY_TRANSPORT_= HEADER *)MctpHeader; @@ -161,13 +165,15 @@ SetupPldmRequestTransportPacket ( /** Common code to submit PLDM commands =20 - @param[in] TransportToken Transport token. - @param[in] PldmType PLDM message type. - @param[in] PldmCommand PLDM command of this PLDM type. - @param[in] RequestData Command Request Data. - @param[in] RequestDataSize Size of Command Request Data. - @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. - @param[in, out] ResponseDataSize Size of Command Response Data. + @param[in] TransportToken Transport token. + @param[in] PldmType PLDM message type. + @param[in] PldmCommand PLDM command of this PLDM = type. + @param[in] PldmTerminusSourceId PLDM source teminus ID. + @param[in] PldmTerminusDestinationId PLDM destination teminus I= D. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Da= ta. + @param[out] ResponseData Command Response Data. The= completion code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response D= ata. =20 @retval EFI_SUCCESS The command byte stream was successfully = submit to the device and a response was successfully received. @retval EFI_NOT_FOUND The command was not successfully sent to = the device or a response was not successfully received from the device. @@ -182,6 +188,8 @@ CommonPldmSubmitCommand ( IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, IN UINT8 PldmType, IN UINT8 PldmCommand, + IN UINT8 PldmTerminusSourceId, + IN UINT8 PldmTerminusDestinationId, IN UINT8 *RequestData OPTIONAL, IN UINT32 RequestDataSize, OUT UINT8 *ResponseData OPTIONAL, @@ -225,6 +233,8 @@ CommonPldmSubmitCommand ( TransportToken, PldmType, PldmCommand, + PldmTerminusSourceId, + PldmTerminusDestinationId, &PldmTransportHeader, &HeaderSize, &ThisRequestData, diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.h b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.h index 231d6e802e..79431dd3b1 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.h +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.h @@ -44,6 +44,8 @@ SetupPldmTransportHardwareInformation ( @param[in] TransportToken The transport interface. @param[in] PldmType PLDM message type. @param[in] PldmCommand PLDM command of this PLDM type. + @param[in] SourceId PLDM source teminus ID. + @param[in] DestinationId PLDM destination teminus ID. @param[out] PacketHeader The pointer to receive header of r= equest. @param[out] PacketHeaderSize Packet header size in bytes. @param[in, out] PacketBody The request body. @@ -68,6 +70,8 @@ SetupPldmRequestTransportPacket ( IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, IN UINT8 PldmType, IN UINT8 PldmCommand, + IN UINT8 SourceId, + IN UINT8 DestinationId, OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, OUT UINT16 *PacketHeaderSize, IN OUT UINT8 **PacketBody, @@ -79,13 +83,15 @@ SetupPldmRequestTransportPacket ( /** Common code to submit PLDM commands =20 - @param[in] TransportToken Transport token. - @param[in] PldmType PLDM message type. - @param[in] PldmCommand PLDM command of this PLDM type. - @param[in] RequestData Command Request Data. - @param[in] RequestDataSize Size of Command Request Data. - @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. - @param[in, out] ResponseDataSize Size of Command Response Data. + @param[in] TransportToken Transport token. + @param[in] PldmType PLDM message type. + @param[in] PldmCommand PLDM command of this PLDM = type. + @param[in] PldmTerminusSourceId PLDM source teminus ID. + @param[in] PldmTerminusDestinationId PLDM destination teminus I= D. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Da= ta. + @param[out] ResponseData Command Response Data. The= completion code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response D= ata. =20 @retval EFI_SUCCESS The command byte stream was successfully = submit to the device and a response was successfully received. @retval EFI_NOT_FOUND The command was not successfully sent to = the device or a response was not successfully received from the device. @@ -100,6 +106,8 @@ CommonPldmSubmitCommand ( IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, IN UINT8 PldmType, IN UINT8 PldmCommand, + IN UINT8 PldmTerminusSourceId, + IN UINT8 PldmTerminusDestinationId, IN UINT8 *RequestData OPTIONAL, IN UINT32 RequestDataSize, OUT UINT8 *ResponseData OPTIONAL, diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProto= col.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c index b2ca69b05f..726747416c 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c @@ -25,13 +25,15 @@ UINT32 TransportMaximumPayload; /** This service enables submitting commands via EDKII PLDM protocol. =20 - @param[in] This EDKII_PLDM_PROTOCOL instance. - @param[in] PldmType PLDM message type. - @param[in] Command PLDM Command of PLDM message type. - @param[in] RequestData Command Request Data. - @param[in] RequestDataSize Size of Command Request Data. - @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. - @param[in, out] ResponseDataSize Size of Command Response Data. + @param[in] This EDKII_PLDM_PROTOCOL instan= ce. + @param[in] PldmType PLDM message type. + @param[in] Command PLDM Command of PLDM messa= ge type. + @param[in] PldmTerminusSourceId PLDM source teminus ID. + @param[in] PldmTerminusDestinationId PLDM destination teminus I= D. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Da= ta. + @param[out] ResponseData Command Response Data. The= completion code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response D= ata. =20 @retval EFI_SUCCESS The command byte stream was successfully = submit to the device and a response was successfully received. @retval EFI_NOT_FOUND The command was not successfully sent to = the device or a response was not successfully received from the device. @@ -39,7 +41,7 @@ UINT32 TransportMaximumPayload; @retval EFI_DEVICE_ERROR PLDM transport interface Device hardware = error. @retval EFI_TIMEOUT The command time out. @retval EFI_UNSUPPORTED The command was not successfully sent to = the device. - @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resourc= e or data size error. + @retval EFI_OUT_OF_RESOURCES The resource allcation is out of resource= or data size error. @retval EFI_INVALID_PARAMETER Both RequestData and ResponseData are NULL **/ EFI_STATUS @@ -48,6 +50,8 @@ PldmSubmitCommand ( IN EDKII_PLDM_PROTOCOL *This, IN UINT8 PldmType, IN UINT8 Command, + IN UINT8 PldmTerminusSourceId, + IN UINT8 PldmTerminusDestinationId, IN UINT8 *RequestData, IN UINT32 RequestDataSize, OUT UINT8 *ResponseData, @@ -61,10 +65,46 @@ PldmSubmitCommand ( return EFI_INVALID_PARAMETER; } =20 + if (RequestData !=3D NULL && RequestDataSize =3D=3D 0) { + DEBUG (( + DEBUG_ERROR, + "%a: RequestDataSize =3D=3D 0, however RequestData is not NULL for P= LDM type: 0x%x, Command: 0x%x.\n", + __func__, + PldmType, + Command + )); + return EFI_INVALID_PARAMETER; + } + + if (ResponseData =3D=3D NULL && *ResponseDataSize !=3D 0) { + DEBUG (( + DEBUG_ERROR, + "%a: *ResponseDataSize !=3D 0, however ResponseData is NULL for PLDM= type: 0x%x, Command: 0x%x.\n", + __func__, + PldmType, + Command + )); + return EFI_INVALID_PARAMETER; + } + + if (ResponseData !=3D NULL && *ResponseDataSize =3D=3D 0) { + DEBUG (( + DEBUG_ERROR, + "%a: *ResponseDataSize =3D=3D 0, however ResponseData is not NULL fo= r PLDM type: 0x%x, Command: 0x%x.\n", + __func__, + PldmType, + Command + )); + return EFI_INVALID_PARAMETER; + } + + DEBUG ((DEBUG_MANAGEABILITY, "%a: Source terminus ID: 0x%x, Destination = terminus ID: 0x%x.\n")); Status =3D CommonPldmSubmitCommand ( mTransportToken, PldmType, Command, + PldmTerminusSourceId, + PldmTerminusDestinationId, RequestData, RequestDataSize, ResponseData, diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProto= colDxe.inf b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProto= colDxe.inf index 006f77b09a..aef25f6438 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.= inf +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.= inf @@ -42,9 +42,5 @@ [Protocols] gEdkiiPldmProtocolGuid =20 -[FixedPcd] - gManageabilityPkgTokenSpaceGuid.PcdMctpSourceEndpointId - gManageabilityPkgTokenSpaceGuid.PcdMctpDestinationEndpointId - [Depex] TRUE --=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 (#109920): https://edk2.groups.io/g/devel/message/109920 Mute This Topic: https://groups.io/mt/102134662/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109921+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109921+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066329; cv=none; d=zohomail.com; s=zohoarc; b=iB0AgcHFRxCjgmNzWGzrAwutrBxLxCHHc3lzfzixgqiBtop1cpxMmfot0uyn6yoPqK/lrzmp7Vvo6Db1y78hqvjSkkCXgr0SDtIb5HFD82WS3rFqTAmMUh17dZfCb6n32pMx2OLy5/2nq05rf6fzmXz6wLtKx0CvB173wfJQnP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066329; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=HWDSH2h8JlWNc5QVvWhE8QPOC9ugC1zHnIHXyP64NC0=; b=Zf3uMrhEBAaQ65o8C8pddqiOa/XlAcwgO/Pp6bVXvcasDwJPx4IR2Uy2mbYlwMrsl+nXLRPjEzDuITt/ZB7tm6iqgd/9H1Zd2noqMgeGmzeF33BX2+B1U5y1/5k34EzX9ZQFIgUvOO5S336RCGzvyP1NvPminJ1MSA2WVxpPDEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109921+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066329753153.39062952361303; Mon, 23 Oct 2023 06:05:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=zEJapWRqAGN3O1Gmam843rkiN6Xv5O/PjfXLgENHTGI=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066329; v=1; b=TLsFLNjDEMk1lPR310JQ7Eo9zmm59pHg+6BeSRnWe2vDXRzAF4FcZnOjifhyrMmmD9JlnMlj mgM/Phquh/2fXE9UHhRAkHMBlWSDAMU9/wwKmL2fXfH3T3B5yW/gSoJxm3M/cOwFF6CnLEpPOtj JOZOxhuSyqIrl8Skjor3ixaY= X-Received: by 127.0.0.2 with SMTP id ZR6YYY1788612x9X3VeTvSiq; Mon, 23 Oct 2023 06:05:29 -0700 X-Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mx.groups.io with SMTP id smtpd.web11.120296.1698066328513631540 for ; Mon, 23 Oct 2023 06:05:28 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c4fdf94666so42875641fa.2 for ; Mon, 23 Oct 2023 06:05:28 -0700 (PDT) X-Gm-Message-State: VccksvrGz6m3Fgpd45myagpax1787277AA= X-Google-Smtp-Source: AGHT+IGMgHzk2tRBnFSHEqoC3oZlcLrDkFutlYb2UsEmFe//ojy8UZFEwbMX8sVNwU2eJiksI1UCcg== X-Received: by 2002:a2e:9b0b:0:b0:2b9:36d5:729c with SMTP id u11-20020a2e9b0b000000b002b936d5729cmr6426089lji.47.1698066326257; Mon, 23 Oct 2023 06:05:26 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:25 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 13/16] ManageabilityPkg/PldmProtocol: Remove PLDM command table Date: Mon, 23 Oct 2023 16:05:08 +0300 Message-Id: <20231023130511.4521-14-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066330959100053 Content-Type: text/plain; charset="utf-8" From: Abner Chang In case of the PLDM/MCTP communication response size doesn't have to be known beforehand, the caller just need to provide the buffer big enough to accomodate the response. Remove PLDM command table for retrieving the response payload size and correct the code to fix the response buffer size handling. Also update the message for error conditions. Signed-off-by: Abner Chang Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../PldmProtocol/Common/PldmProtocolCommon.c | 100 +++--------------- .../PldmProtocol/Common/PldmProtocolCommon.h | 3 + .../Universal/PldmProtocol/Dxe/PldmProtocol.c | 13 ++- 3 files changed, 31 insertions(+), 85 deletions(-) diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index ea3d4a22b2..bc72ce07b3 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -21,42 +21,6 @@ extern CHAR16 *mTransportName; extern UINT8 mPldmRequestInstanceId; =20 -PLDM_MESSAGE_PACKET_MAPPING PldmMessagePacketMappingTable[] =3D { - { PLDM_TYPE_SMBIOS, PLDM_GET_SMBIOS_STRUCTURE_TABLE_METADATA_COMMAND_COD= E, sizeof (PLDM_GET_SMBIOS_STRUCTURE_TABLE_METADATA_RESPONSE_FORMAT) }, - { PLDM_TYPE_SMBIOS, PLDM_SET_SMBIOS_STRUCTURE_TABLE_METADATA_COMMAND_COD= E, sizeof (PLDM_SET_SMBIOS_STRUCTURE_TABLE_METADATA_RESPONSE_FORMAT) }, - { PLDM_TYPE_SMBIOS, PLDM_SET_SMBIOS_STRUCTURE_TABLE_COMMAND_CODE, = sizeof (PLDM_SET_SMBIOS_STRUCTURE_TABLE_REQUEST_FORMAT) } -}; - -/** - This function returns the expected full size of PLDM response message. - - @param[in] PldmType PLDM message type. - @param[in] PldmCommand PLDM command of this PLDM type. - - @retval Zero No matched entry for this PldmType/PldmCommand. - @retval None-zero Size of full packet is returned. -**/ -UINT32 -GetFullPacketResponseSize ( - IN UINT8 PldmType, - IN UINT8 PldmCommand - ) -{ - INT16 Index; - PLDM_MESSAGE_PACKET_MAPPING *ThisEntry; - - ThisEntry =3D PldmMessagePacketMappingTable; - for (Index =3D 0; Index < (sizeof (PldmMessagePacketMappingTable)/ sizeo= f (PLDM_MESSAGE_PACKET_MAPPING)); Index++) { - if ((PldmType =3D=3D ThisEntry->PldmType) && (PldmCommand =3D=3D ThisE= ntry->PldmCommand)) { - return ThisEntry->ResponseSize; - } - - ThisEntry++; - } - - return 0; -} - /** This functions setup the final header/body/trailer packets for the acquired transport interface. @@ -267,10 +231,10 @@ CommonPldmSubmitCommand ( TransferToken.TransmitPackage.TransmitTimeoutInMillisecond =3D MANAGEABI= LITY_TRANSPORT_NO_TIMEOUT; =20 // Set receive packet. - FullPacketResponseDataSize =3D GetFullPacketResponseSize (PldmType, Pldm= Command); - if (FullPacketResponseDataSize =3D=3D 0) { - DEBUG ((DEBUG_ERROR, " No mapping entry in PldmMessagePacketMappingTa= ble for PLDM Type:%d Command %d\n", PldmType, PldmCommand)); - ASSERT (FALSE); + if (ResponseData =3D=3D NULL && *ResponseDataSize =3D=3D 0) { + FullPacketResponseDataSize =3D sizeof (PLDM_RESPONSE_HEADER); + } else { + FullPacketResponseDataSize =3D *ResponseDataSize + sizeof (PLDM_RESPON= SE_HEADER); } =20 FullPacketResponseData =3D (UINT8 *)AllocateZeroPool (FullPacketResponse= DataSize); @@ -306,6 +270,7 @@ CommonPldmSubmitCommand ( ); // // Check the response size. + // if (TransferToken.ReceivePackage.ReceiveSizeInByte < sizeof (PLDM_RESPON= SE_HEADER)) { DEBUG (( DEBUG_MANAGEABILITY_INFO, @@ -315,21 +280,13 @@ CommonPldmSubmitCommand ( TransferToken.ReceivePackage.ReceiveSizeInByte, FullPacketResponseDataSize )); - if (ResponseDataSize !=3D NULL) { - if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeInBy= te) { - *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInBy= te; - } - } - - if (ResponseData !=3D NULL) { - CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, *Resp= onseDataSize); - } - + HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); goto ErrorExit; } =20 // // Check the integrity of response. data. + // ResponseHeader =3D (PLDM_RESPONSE_HEADER *)FullPacketResponseData; if ((ResponseHeader->PldmHeader.DatagramBit !=3D (!PLDM_MESSAGE_HEADER_I= S_DATAGRAM)) || (ResponseHeader->PldmHeader.RequestBit !=3D PLDM_MESSAGE_HEADER_IS_R= ESPONSE) || @@ -343,22 +300,16 @@ CommonPldmSubmitCommand ( DEBUG ((DEBUG_ERROR, " Instance ID =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.InstanceId, mPldmRequestInstanceId)); DEBUG ((DEBUG_ERROR, " Pldm Type =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.PldmType, PldmType)); DEBUG ((DEBUG_ERROR, " Pldm Command =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.PldmTypeCommandCode, PldmCommand)); - if (ResponseDataSize !=3D NULL) { - if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeInBy= te) { - *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInBy= te; - } - } - - if (ResponseData !=3D NULL) { - CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, *Resp= onseDataSize); - } + DEBUG ((DEBUG_ERROR, " Pldm Completion Code =3D 0x%x\n", ResponseHe= ader->PldmCompletionCode)); =20 + HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); goto ErrorExit; } =20 // // Check the response size - if (TransferToken.ReceivePackage.ReceiveSizeInByte !=3D FullPacketRespon= seDataSize) { + // + if (TransferToken.ReceivePackage.ReceiveSizeInByte > FullPacketResponseD= ataSize) { DEBUG (( DEBUG_ERROR, "The response size is incorrect: Response size %d (Expected %d), Com= pletion code %d.\n", @@ -366,38 +317,21 @@ CommonPldmSubmitCommand ( FullPacketResponseDataSize, ResponseHeader->PldmCompletionCode )); - if (ResponseDataSize !=3D NULL) { - if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeInBy= te) { - *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInBy= te; - } - } - - if (ResponseData !=3D NULL) { - CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, *Resp= onseDataSize); - } =20 + HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); goto ErrorExit; } =20 - if (*ResponseDataSize !=3D (TransferToken.ReceivePackage.ReceiveSizeInBy= te - sizeof (PLDM_RESPONSE_HEADER))) { + if (*ResponseDataSize < GET_PLDM_MESSAGE_PAYLOAD_SIZE(TransferToken.Rece= ivePackage.ReceiveSizeInByte)) { DEBUG ((DEBUG_ERROR, " The size of response is not matched to Request= DataSize assigned by caller.\n")); DEBUG (( DEBUG_ERROR, "Caller expects %d, the response size minus PLDM_RESPONSE_HEADER siz= e is %d, Completion Code %d.\n", *ResponseDataSize, - TransferToken.ReceivePackage.ReceiveSizeInByte - sizeof (PLDM_RESPON= SE_HEADER), + GET_PLDM_MESSAGE_PAYLOAD_SIZE(TransferToken.ReceivePackage.ReceiveSi= zeInByte), ResponseHeader->PldmCompletionCode )); - if (ResponseDataSize !=3D NULL) { - if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeInBy= te) { - *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInBy= te; - } - } - - if (ResponseData !=3D NULL) { - CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, *Resp= onseDataSize); - } - + HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, GET_PLD= M_MESSAGE_PAYLOAD_SIZE(TransferToken.ReceivePackage.ReceiveSizeInByte), "Fa= iled response payload\n"); goto ErrorExit; } =20 @@ -406,10 +340,10 @@ CommonPldmSubmitCommand ( =20 // Copy response data (without header) to caller's buffer. if ((ResponseData !=3D NULL) && (*ResponseDataSize !=3D 0)) { - *ResponseDataSize =3D FullPacketResponseDataSize - sizeof (PLDM_RESPON= SE_HEADER); + *ResponseDataSize =3D GET_PLDM_MESSAGE_PAYLOAD_SIZE(TransferToken.Rece= ivePackage.ReceiveSizeInByte); CopyMem ( (VOID *)ResponseData, - (VOID *)(FullPacketResponseData + sizeof (PLDM_RESPONSE_HEADER)), + GET_PLDM_MESSAGE_PAYLOAD_PTR(FullPacketResponseData), *ResponseDataSize ); } diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.h b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.h index 79431dd3b1..eb273c4f46 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.h +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.h @@ -12,6 +12,9 @@ #include #include =20 +#define GET_PLDM_MESSAGE_PAYLOAD_SIZE(PayloadSize) (PayloadSize - sizeof (= PLDM_RESPONSE_HEADER)) +#define GET_PLDM_MESSAGE_PAYLOAD_PTR(PayloadPtr) ((UINT8 *)PayloadPtr + si= zeof (PLDM_RESPONSE_HEADER)) + typedef struct { UINT8 PldmType; UINT8 PldmCommand; diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProto= col.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c index 726747416c..058f98e677 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c @@ -60,8 +60,17 @@ PldmSubmitCommand ( { EFI_STATUS Status; =20 - if ((RequestData =3D=3D NULL) && (ResponseData =3D=3D NULL)) { - DEBUG ((DEBUG_ERROR, "%a: Both RequestData and ResponseData are NULL\n= ", __func__)); + // + // Check the given input parameters. + // + if (RequestData =3D=3D NULL && RequestDataSize !=3D 0) { + DEBUG (( + DEBUG_ERROR, + "%a: RequestDataSize !=3D 0, however RequestData is NULL for PLDM ty= pe: 0x%x, Command: 0x%x.\n", + __func__, + PldmType, + Command + )); return EFI_INVALID_PARAMETER; } =20 --=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 (#109921): https://edk2.groups.io/g/devel/message/109921 Mute This Topic: https://groups.io/mt/102134663/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109922+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109922+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066335; cv=none; d=zohomail.com; s=zohoarc; b=FLXrqnN+HyvryHmAwHxMqQKUscaD4Pmr6ZKnEp7cNMmMZMfHmOCbeWxBmOr1eb9hOt6xjUDu44/yKRuMFIS2E+PTEKHr0IH6ShfpkkD82DQFiKUvYEEKej0kBfNMJ5zJzAgLhhFoW/2QDjQdREbjx1dq4e9fsiw0Ssq/4h2nQIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066335; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=INNAcRWm/eO1m3zMD2gYA2wqdLVi55Zdtbi2/uIb7kA=; b=PD6G290CUEbWDXCC9w6Lgb00abT8uKiHBmIBXWnQIlAYA9tGJ2Br5fnTz+4ixg+Lgk6HJhsuEsXmmsx5PMH9+SwCitlHFf+l/mVxT/5/hJmo28KyBgLe6XylQlhBhAJ+VpHMwPDNHd/lM0q4DviXKmQ3c0gOGAPe4wpwj+D0Zio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109922+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066335693982.1522145145709; Mon, 23 Oct 2023 06:05:35 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=F91jisq3LNNHGomzkxFoFK6uc78rHWjVytsud1tncDc=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066335; v=1; b=FrZ0AyHV79Ie4GXWxG+8YZ8Qv68XOZe8HwMuH7QBZS6GXtJlJxlpvzjhtCQ3HeNVyS3dzooA tON2ipcsPrerLFzfGT4/8c0uFBBaywEErxTrjIIYcz5jSEf5z6Dze+bFSUPkgKXRCtBic961Ze6 AtSbMBtOkOOJGIWVEahsKNyU= X-Received: by 127.0.0.2 with SMTP id e38JYY1788612xLM4mQWWxd0; Mon, 23 Oct 2023 06:05:35 -0700 X-Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by mx.groups.io with SMTP id smtpd.web11.120298.1698066329258157547 for ; Mon, 23 Oct 2023 06:05:29 -0700 X-Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2c50305c5c4so49585041fa.1 for ; Mon, 23 Oct 2023 06:05:28 -0700 (PDT) X-Gm-Message-State: cPNDgtl3WtZ8Ab7DU9qnZUk3x1787277AA= X-Google-Smtp-Source: AGHT+IFxVYRLMNP+I8+KylD7smD/6CjisGUBYH3WF+nx31e0Invd7UJ3qVOdxAlw2W8zR85rnOPB+w== X-Received: by 2002:a05:651c:1a29:b0:2bc:f5a0:cc25 with SMTP id by41-20020a05651c1a2900b002bcf5a0cc25mr7084478ljb.2.1698066326918; Mon, 23 Oct 2023 06:05:26 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:26 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 14/16] ManageabilityPkg: Return error on PLDM header check fails Date: Mon, 23 Oct 2023 16:05:09 +0300 Message-Id: <20231023130511.4521-15-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066336846100003 Content-Type: text/plain; charset="utf-8" Currently PldmSubmit command returns EFI_SUCCESS even if the response header checks have failed. Correct the code to return errors in such cases. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Universal/PldmProtocol/Common/PldmProtocolCommon.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index bc72ce07b3..04f250e57c 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -241,7 +241,7 @@ CommonPldmSubmitCommand ( if (FullPacketResponseData =3D=3D NULL) { DEBUG ((DEBUG_ERROR, " Not enough memory for FullPacketResponseDataSi= ze.\n")); Status =3D EFI_OUT_OF_RESOURCES; - goto ErrorExit2; + goto ErrorExit; } =20 // Print out PLDM packet. @@ -281,6 +281,7 @@ CommonPldmSubmitCommand ( FullPacketResponseDataSize )); HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); + Status =3D EFI_DEVICE_ERROR; goto ErrorExit; } =20 @@ -303,6 +304,7 @@ CommonPldmSubmitCommand ( DEBUG ((DEBUG_ERROR, " Pldm Completion Code =3D 0x%x\n", ResponseHe= ader->PldmCompletionCode)); =20 HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); + Status =3D EFI_DEVICE_ERROR; goto ErrorExit; } =20 @@ -319,6 +321,7 @@ CommonPldmSubmitCommand ( )); =20 HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, Transfe= rToken.ReceivePackage.ReceiveSizeInByte, "Failed response payload\n"); + Status =3D EFI_DEVICE_ERROR; goto ErrorExit; } =20 @@ -332,6 +335,7 @@ CommonPldmSubmitCommand ( ResponseHeader->PldmCompletionCode )); HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, GET_PLD= M_MESSAGE_PAYLOAD_SIZE(TransferToken.ReceivePackage.ReceiveSizeInByte), "Fa= iled response payload\n"); + Status =3D EFI_DEVICE_ERROR; goto ErrorExit; } =20 @@ -350,13 +354,12 @@ CommonPldmSubmitCommand ( =20 // Return transfer status. // -ErrorExit: Status =3D TransferToken.TransferStatus; if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Failed to send PLDM command over %s\n", __fu= nc__, mTransportName)); } =20 -ErrorExit2: +ErrorExit: if (PldmTransportHeader !=3D NULL) { FreePool ((VOID *)PldmTransportHeader); } --=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 (#109922): https://edk2.groups.io/g/devel/message/109922 Mute This Topic: https://groups.io/mt/102134664/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109923+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109923+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066330; cv=none; d=zohomail.com; s=zohoarc; b=PejbtUjezs9RuEUNJHVeJP/Kd1EJ7M5QOYFvSxXaAtalGKDGnKh9WLwq0E1I5TqEUTfJvUIkAJ+WPwJk1/iX+l8XCMc19XRTjlO8E4yuJvwKkE06qtgW9GndCdVuAj3EZSBaO3u7YUMIkz1OT1JPJJOSTYZ7y7WH/oNJD80WI00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066330; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=PP5RadBUdU8qtXfVFCHhS236MdltRNIYYF4w5P2rIn4=; b=mzeTFKMvS8pz8OrgiTEYvSXopEcZSlmjTgyqoxtKbpNKLlTT/NPtnNpaxKVdjCDLwVrs+ijZeiwe6lDOtUYnbnJtUel910p3oyaDdrv+/dDdyAPP6QV4c7mDRH2NQ++imJ9+ai5mWiHKdT9gEqK52YlCkO+9GWBmsgCgWg2PoYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109923+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066330913350.97644633746415; Mon, 23 Oct 2023 06:05:30 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=V78VJ4qjZPwSpCKfunLyWkOmAm9yg0BLrBfMUYHqJFM=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066330; v=1; b=XlweTAI2mpK29YrzW459hLQ5S6SfYzQmybYLX0cF+8XMpzOoBQjyiLXA4A5oeiCLBRnO6oIY LiEe+26mF3XQU93EAY+Oq8iOQf+Dn7PjpcomqIKVWGqqc2fRNlhT2ARKjDMRsHKD0I4LBiU8wuC wDtIaPHYQtyrbLsHYkr2ag3s= X-Received: by 127.0.0.2 with SMTP id F1MIYY1788612xmvAdjuJ30L; Mon, 23 Oct 2023 06:05:30 -0700 X-Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by mx.groups.io with SMTP id smtpd.web10.119851.1698066329757117715 for ; Mon, 23 Oct 2023 06:05:30 -0700 X-Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2c5028e5b88so46303811fa.3 for ; Mon, 23 Oct 2023 06:05:29 -0700 (PDT) X-Gm-Message-State: gxLLTKKEFDx5hvj1ByCmabCbx1787277AA= X-Google-Smtp-Source: AGHT+IGwmOVGomnLEFQcKBwbMC839bbCzcBBv4h66jb9qWF0d37k8sQnxjgcoqM+BCoYFU8EJeTnoQ== X-Received: by 2002:a05:651c:4cc:b0:2c5:191a:47fd with SMTP id e12-20020a05651c04cc00b002c5191a47fdmr8165209lji.1.1698066327660; Mon, 23 Oct 2023 06:05:27 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:27 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 15/16] PldmSmbiosTransferDxe: Implement Set PLDM terminus ID API Date: Mon, 23 Oct 2023 16:05:10 +0300 Message-Id: <20231023130511.4521-16-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066332939100062 Content-Type: text/plain; charset="utf-8" From: Abner Chang Currently all PLDM functions inside the PLDM_SMBIOS_TRANSFER_PROTOCOL use PLDM terminus PCDs for the MCTP addressing. Add additional function to the protocol API to provide user a way to use custom TIDs. Signed-off-by: Abner Chang Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Protocol/PldmSmbiosTransferProtocol.h | 26 +++++++++++++++++ .../PldmSmbiosTransferDxe.c | 28 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/Features/ManageabilityPkg/Include/Protocol/PldmSmbiosTransferP= rotocol.h b/Features/ManageabilityPkg/Include/Protocol/PldmSmbiosTransferPr= otocol.h index 7903e12726..8b23d39682 100644 --- a/Features/ManageabilityPkg/Include/Protocol/PldmSmbiosTransferProtocol= .h +++ b/Features/ManageabilityPkg/Include/Protocol/PldmSmbiosTransferProtocol= .h @@ -23,6 +23,31 @@ typedef struct _EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL EDK= II_PLDM_SMBIOS_TRANSFER_ #define EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL_VERSION ((EDKII_PLDM_SM= BIOS_TRANSFER_PROTOCOL_VERSION_MAJOR << 8) |\ EDKII_PLDM_SMBIOS_T= RANSFER_PROTOCOL_VERSION_MINOR) =20 +/** + This function sets PLDM SMBIOS transfer source and destination + PLDM terminus ID. + + @param [in] This EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL instanc= e. + @param [in] SourceId PLDM source teminus ID. + Set to PLDM_TERMINUS_ID_UNASSIGNED means use + platform default PLDM terminus ID. + (gManageabilityPkgTokenSpaceGuid.PcdPldmSou= rceTerminusId) + @param [in] DestinationId PLDM destination teminus ID. + Set to PLDM_TERMINUS_ID_UNASSIGNED means use + platform default PLDM terminus ID. + (gManageabilityPkgTokenSpaceGuid.PcdPldmDes= tinationEndpointId) + + @retval EFI_SUCCESS Get SMBIOS table metadata Successfu= lly. + @retval EFI_INVALID_PARAMETER Invalid value of source or destinat= ion + PLDM terminus ID. +**/ +typedef +EFI_STATUS +(EFIAPI *PLDM_GET_SMBIOS_TRANSFER_TERMINUS_ID)( + IN UINT8 SourceId, + IN UINT8 DestinationId + ); + /** This function gets SMBIOS table metadata. =20 @@ -151,6 +176,7 @@ EFI_STATUS // EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL // typedef struct { + PLDM_GET_SMBIOS_TRANSFER_TERMINUS_ID SetPldmSmbiosTransferTerminu= sId; PLDM_GET_SMBIOS_STRUCTURE_TABLE_METADATA GetSmbiosStructureTableMetaD= ata; PLDM_SET_SMBIOS_STRUCTURE_TABLE_METADATA SetSmbiosStructureTableMetaD= ata; PLDM_GET_SMBIOS_STRUCTURE_TABLE GetSmbiosStructureTable; diff --git a/Features/ManageabilityPkg/Universal/PldmSmbiosTransferDxe/Pldm= SmbiosTransferDxe.c b/Features/ManageabilityPkg/Universal/PldmSmbiosTransfe= rDxe/PldmSmbiosTransferDxe.c index fdf033f0b1..357a7d49e4 100644 --- a/Features/ManageabilityPkg/Universal/PldmSmbiosTransferDxe/PldmSmbiosT= ransferDxe.c +++ b/Features/ManageabilityPkg/Universal/PldmSmbiosTransferDxe/PldmSmbiosT= ransferDxe.c @@ -25,6 +25,33 @@ =20 UINT32 SetSmbiosStructureTableHandle; =20 +/** + This function sets PLDM SMBIOS transfer source and destination + PLDM terminus ID. + + @param [in] This EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL instanc= e. + @param [in] SourceId PLDM source teminus ID. + Set to PLDM_TERMINUS_ID_UNASSIGNED means use + platform default PLDM terminus ID. + (gManageabilityPkgTokenSpaceGuid.PcdPldmSou= rceTerminusId) + @param [in] DestinationId PLDM destination teminus ID. + Set to PLDM_TERMINUS_ID_UNASSIGNED means use + platform default PLDM terminus ID. + (gManageabilityPkgTokenSpaceGuid.PcdPldmDes= tinationEndpointId) + + @retval EFI_SUCCESS Get SMBIOS table metadata Successfu= lly. + @retval EFI_INVALID_PARAMETER Invalid value of source or destinat= ion + PLDM terminus ID. +**/ +EFI_STATUS +SetPldmSmbiosTransferTerminusId ( + IN UINT8 SourceId, + IN UINT8 DestinationId + ) +{ + return PldmSetTerminus(SourceId, DestinationId); +} + /** Get the full size of SMBIOS structure including optional strings that fo= llow the formatted structure. =20 @@ -457,6 +484,7 @@ GetSmbiosStructureByHandle ( } =20 EDKII_PLDM_SMBIOS_TRANSFER_PROTOCOL_V1_0 mPldmSmbiosTransferProtocolV10 = =3D { + SetPldmSmbiosTransferTerminusId, GetSmbiosStructureTableMetaData, SetSmbiosStructureTableMetaData, GetSmbiosStructureTable, --=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 (#109923): https://edk2.groups.io/g/devel/message/109923 Mute This Topic: https://groups.io/mt/102134665/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 16 00:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109924+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109924+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066331; cv=none; d=zohomail.com; s=zohoarc; b=TAYLKVp+qaOdDHNB2joPDFoR3zvnjS3Qg5i+wP0dnLUxTaGJpHVhRZJICIQMuVrW5I814co+in1wJk/alU7P+oxeOx6gMZSnW00wII08TPiu2N2dMWfoxD/Li2BE4+KlAfexggeAXzwMwTKKTbCIn7hj4LHk2KtubE+1L9qsUs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066331; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=AJYiw0/QrYVj6ZDPdZVN3EwgNlN1pXQaCMHYy1Y9rV8=; b=itF5BeoZkkLCIBpEDrqvYUszFEHVYQXc6usAThHuCnTUzKpyAh4/tKu3NeiVukkCWr9tVlUXIY+Rl6qgAn5ft0ZHaVbTfngP5ggYcCk99WGTAIo9VrcW9TLZeXqGGR/XLfAYBdRrtguNNmTIY8aSa4oHjVn9qw78gT8H47IHK88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109924+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698066331875754.3893458349054; Mon, 23 Oct 2023 06:05:31 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=HLI4EI9KEBjT0gU9NJUo0QYdLkMiPRABLHN01aWvzYY=; c=relaxed/simple; d=groups.io; h=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; s=20140610; t=1698066331; v=1; b=OanNtVkMoaz49OCf85PRywgae1jfFPcwS/SHACPIvt7jU8u/joX6BhmhGv99+wu8XgNBTXaG sCdnuD2axp2VYKqTz2iszVKxMSPp1RdK55EoBSEulVHJNPdNeGHvrvzRNZnRs5u33twbkc0WRNT PUH4gnqVxYASSwOBWYspq/BQ= X-Received: by 127.0.0.2 with SMTP id jpnEYY1788612xhIlpbK4qVU; Mon, 23 Oct 2023 06:05:31 -0700 X-Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by mx.groups.io with SMTP id smtpd.web11.120299.1698066330723625316 for ; Mon, 23 Oct 2023 06:05:31 -0700 X-Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-507a62d4788so5143252e87.0 for ; Mon, 23 Oct 2023 06:05:30 -0700 (PDT) X-Gm-Message-State: saNQTUq928ERykKT1NyICbINx1787277AA= X-Google-Smtp-Source: AGHT+IGZr8tBncdj4usfAL6iF7PkBv59tg+Pcncj4jwX4jOVv1gn5tHP8LSVtPXXvsiSmVSFWnwdjw== X-Received: by 2002:a2e:b953:0:b0:2bd:1fee:aacf with SMTP id 19-20020a2eb953000000b002bd1feeaacfmr5755684ljs.24.1698066328611; Mon, 23 Oct 2023 06:05:28 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:28 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 16/16] ManageabilityPkg: Check PLDM completion code Date: Mon, 23 Oct 2023 16:05:11 +0300 Message-Id: <20231023130511.4521-17-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066332929100061 Content-Type: text/plain; charset="utf-8" Every PLDM response contains 1 byte Completion code which is needed to be checked against SUCCESS value which means that the PLDM command was accepted and completed normally. If it is not equal to that value it is necessary to return error status so the caller would know that Response buffer is invalid. Signed-off-by: Konstantin Aladyshev Reviewed-by: Abner Chang --- .../Universal/PldmProtocol/Common/PldmProtocolCommon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/Pl= dmProtocolCommon.c index 04f250e57c..2f2f76603e 100644 --- a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC= ommon.c @@ -293,7 +293,8 @@ CommonPldmSubmitCommand ( (ResponseHeader->PldmHeader.RequestBit !=3D PLDM_MESSAGE_HEADER_IS_R= ESPONSE) || (ResponseHeader->PldmHeader.InstanceId !=3D mPldmRequestInstanceId) = || (ResponseHeader->PldmHeader.PldmType !=3D PldmType) || - (ResponseHeader->PldmHeader.PldmTypeCommandCode !=3D PldmCommand)) + (ResponseHeader->PldmHeader.PldmTypeCommandCode !=3D PldmCommand) || + (ResponseHeader->PldmCompletionCode !=3D PLDM_COMPLETION_CODE_SUCCES= S)) { DEBUG ((DEBUG_ERROR, "PLDM integrity check of response data is failed.= \n")); DEBUG ((DEBUG_ERROR, " Datagram =3D %d (Expected value: %d)\n",= ResponseHeader->PldmHeader.DatagramBit, (!PLDM_MESSAGE_HEADER_IS_DATAGRAM)= )); --=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 (#109924): https://edk2.groups.io/g/devel/message/109924 Mute This Topic: https://groups.io/mt/102134666/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-