From nobody Sat May 18 15:08:14 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+109634+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+109634+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462303; cv=none; d=zohomail.com; s=zohoarc; b=B+lpc8UQYXN/wI8agFz+daG0H50mscZfEIDabrLZV4OsQBxN/VvHzcY3hLnc0VcAY8zqpMMJLs7JQGtcY/+exy7c5CBvyZVtot3Dd19WLE/m0a/W+4CuUHkNaWAUaVHR8tXVIs8nCQ9+mU/ec17zJnn1UntjxNszjsypdU0Bop4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462303; 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=BxqfCj051QpGkecq1EzhSmLfBBsFgav5GuwFjuyXr5Q=; b=QyDG7pRyFZOxp+s51s1m1tuwQ9fH4eqT3jyMe+ARFvXUj3VbwQ98kojEunbvvGKXGnp8f7Q/dkppRiveY/pZxaSDH7a20SmkIyacGu3aVuxuuTb/oYm7fJTTGcBGRd1xvsoEeIcvEiee6piN6Yv382Lc2F5OStXTKd2okwEVZ3c= 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+109634+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 1697462303069211.94043718965224; Mon, 16 Oct 2023 06:18:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=/1NWdoBJEi20sKQ/hMSKghppHwWyWNd3IoDpJzGV+dA=; 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=1697462302; v=1; b=lmG+bJdXBLQav2zdFAWkGxqwx34MhmvSnrJ2kxaV1grO18/hNqQ1lNB9VIBxsMj0vSz8zHRm 8XoujZftJ6ucq+v5eS4dPh8JTno1L8S3tzvaiUexhtmfCL5gosNFKAlbrRK4OoChmcL5h52rE68 El7zgecIaBB9HKtBMUkJgn+0= X-Received: by 127.0.0.2 with SMTP id AgViYY1788612x6YRPnOazJJ; Mon, 16 Oct 2023 06:18:22 -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.123859.1697462301971103828 for ; Mon, 16 Oct 2023 06:18:22 -0700 X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c50d1b9f22so29883821fa.0 for ; Mon, 16 Oct 2023 06:18:21 -0700 (PDT) X-Gm-Message-State: UMQ4IcquROZgWCZQlCNTzWVAx1787277AA= X-Google-Smtp-Source: AGHT+IHnQmKy1vQLkjkkVfheA0+a++mkMpJFxf4GoDCDwARxBnWSu0J6GoalI4KJKnj0Xsjoa8J58w== X-Received: by 2002:a05:651c:154a:b0:2c5:1eb6:bd1e with SMTP id y10-20020a05651c154a00b002c51eb6bd1emr4446685ljp.43.1697462299768; Mon, 16 Oct 2023 06:18:19 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:19 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 01/10] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure Date: Mon, 16 Oct 2023 16:18:07 +0300 Message-Id: <20231016131816.6634-2-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462303484100001 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 --- .../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 (#109634): https://edk2.groups.io/g/devel/message/109634 Mute This Topic: https://groups.io/mt/101994938/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 Sat May 18 15:08:14 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+109635+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+109635+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462303; cv=none; d=zohomail.com; s=zohoarc; b=ZgoYN3Z5evvwgShyPGiw0LPsDXvfn3RiojRgjxnqogxrAkdSPgTiW/rE+O6MIFAPdE6VoNIJy0MOGXSGJpmuw1WOASCMs6t5IOm3LQmWEI59AEtvh6mszoUlwqTiXYTTttgC9GtZRCW00/WTe09+qkCAIGf69UZF7oYzXKHrQE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462303; 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=V9vseWoAjcd0QapMowR1RsbUhJLRyp8P0Qo5+wBqE6Q=; b=Z1xhY3cvXftNN7hx4lsa3QemzcaIGxnu9BBCTU8IOy/eWcxlWwXFZaC6fT/1w/8FLlbLSDqrNBb49bxpjyVTip/9H3zeYNXhGNC1Kry+6pDnVKqTAZCj40EElraD7ZgQ0uLeXB3xOzHwXjur/woTOe3iRr4jHrl5WUtu8wTQGRI= 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+109635+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 1697462303695213.5331692550044; Mon, 16 Oct 2023 06:18:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=raq5l1Hv+Yzyz3aYYnPaoC9EnfB1uD/Z936S1pXoIA4=; 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=1697462303; v=1; b=IqJxcXGj6xHOhKRZjEmggc/93gt+D4ImDgxUtnpQKCNFYX2lZ1CWA0uqpQluUFTOPLt2oEYX suysIGZDMcFM1urAGVIPoFbPNC5iZVulJKaWr5UL8M+xRKOe91rCjzdf12T9q7RwKHs2UrORB3D /QV8QBZPJYwXwsc6jzuKYntY= X-Received: by 127.0.0.2 with SMTP id 0OZhYY1788612xNkz6hOBzAN; Mon, 16 Oct 2023 06:18: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.web10.123807.1697462302480388128 for ; Mon, 16 Oct 2023 06:18:22 -0700 X-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2c518a1d83fso23425441fa.3 for ; Mon, 16 Oct 2023 06:18:22 -0700 (PDT) X-Gm-Message-State: SjXwWoQ8IyQGc7sEd7bYrjFzx1787277AA= X-Google-Smtp-Source: AGHT+IGRGc+CNDfVZ6EF2FOzGlnNg+PGXM3WYEfuDJxZY3U+QxA3sCahzu4zG94ntsuG2wW5bHT5Fg== X-Received: by 2002:a2e:8e98:0:b0:2bf:f32a:1f68 with SMTP id z24-20020a2e8e98000000b002bff32a1f68mr30339110ljk.19.1697462300429; Mon, 16 Oct 2023 06:18:20 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:20 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 02/10] ManageabilityPkg: Check MCTP EIDs for reserved values Date: Mon, 16 Oct 2023 16:18:08 +0300 Message-Id: <20231016131816.6634-3-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462305511100009 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 --- .../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 (#109635): https://edk2.groups.io/g/devel/message/109635 Mute This Topic: https://groups.io/mt/101994939/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 Sat May 18 15:08:14 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+109636+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+109636+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462304; cv=none; d=zohomail.com; s=zohoarc; b=XYdVQwvURIr540iZoYSblk/I3O4q3DlllspXDxNg7d7Xr2yXftIrPkhE51mKLKFexdFpATny9+TLgmRHnsdsXbuD51Zy8YhFhmq31EzZl8ETU16rtM781y1sD5JhTvSmqvpzINInRaxE8yYoK9uN27nyADcN5+o3K5k/bIoW07w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462304; 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=33fheiNi6O449CSGMTS0Ny/fzmkaGP3+xkjmrFXwZ44=; b=b06G+zp1pZBfsC5NcPjF5mT5YfviMj8LI5zNklsWEMepeXySqrf69r9b9yuGLeDHR7RaPJMESfAkTeIzEkuJE4kURb67OSzVyGvHSbMn48MJEFuV2CGodRMAm+R5ZT/JBvz4O+DcQtTD/W9Is6zDMv7ym1e4SqrGocXR5lihg7g= 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+109636+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 1697462304751821.6343083100244; Mon, 16 Oct 2023 06:18:24 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Lv2sWk/Ft1WpnVOOUk7TLmO4QFfcb85nol8iSJOjxTQ=; 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=1697462304; v=1; b=rbfFwsrlfbRJ2b6MoirwRSkXKKANsL13tz+YnCdygOwzSGXNX0RGyfKXOtcRvYZuppPdUaHk l+FZUU+9aJTK37N5Fmk6hl/DWWQBPsjL9/dv+FjnBKSeCxdcd05uztU+sboIaPT1zfyIKluoYrn +hqBrPub+MYLbw34kkiPFqgo= X-Received: by 127.0.0.2 with SMTP id KUYdYY1788612xbQbSXPTfH7; Mon, 16 Oct 2023 06:18:24 -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.web10.123810.1697462303437929515 for ; Mon, 16 Oct 2023 06:18:23 -0700 X-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2c504a5e1deso45308821fa.2 for ; Mon, 16 Oct 2023 06:18:23 -0700 (PDT) X-Gm-Message-State: Z9EfWZqc1bN36Y62pxada9Yix1787277AA= X-Google-Smtp-Source: AGHT+IFCeqMbY1gFYSkXETlPJM5Elf2yeda/0zWhtn3JagNwOrfbrT+y9hmCOhpRZL4S7XNv0MClsQ== X-Received: by 2002:a2e:9c56:0:b0:2c0:122a:322b with SMTP id t22-20020a2e9c56000000b002c0122a322bmr24714909ljj.48.1697462301186; Mon, 16 Oct 2023 06:18:21 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:20 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 03/10] ManageabilityPkg: Support both MCTP and IPMI in KCS tranport library Date: Mon, 16 Oct 2023 16:18:09 +0300 Message-Id: <20231016131816.6634-4-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462305557100010 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 --- .../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 (#109636): https://edk2.groups.io/g/devel/message/109636 Mute This Topic: https://groups.io/mt/101994941/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 Sat May 18 15:08:14 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+109637+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+109637+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462305; cv=none; d=zohomail.com; s=zohoarc; b=ArztclR/c1gVBxmxm2yUexMU/8DrvY6KPXNM0jJSlThrpDLVVLgLDRtRkGCoLdYC+Uep3UdEC616HKBmG5vdLJ0Fn6SRr3Bs+6mhXaAgXi1sYJd5/VR7HNitAW5JbWFfBPA5w8QR2aPCPpAOiZHhR46c6ryP3qgtozCckn/Vh7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462305; 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=iNjCfzifc6kW7xlsdtc7T1G1O35thNUV/wr08x07PgY=; b=A7L/L/1E7OWXatH0c9hJElxRLrHnzk3DRdz2j6b5lA0J/U6wozk2UBp9OU0fdfwt7zRjl9po+yhP44puU+3kooA8V9tt7JeKLI0JsFG2LagnzD7duDBS5MD8jpKEtdWmAdOOhdpegMa+QYVg6zgOBs9SnAR4XgODOlrxKuWs0m8= 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+109637+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 1697462305329274.0704500692291; Mon, 16 Oct 2023 06:18:25 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=HZi1/wzbXqdS8Sb+51CiwwWctL8BqlEhAF4TfxMEgJU=; 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=1697462304; v=1; b=P2bjaTVleazzaU2XrfQoqLCXc6uoilSwZ0iSAFN042NRRfvNM1qYw6MBVhdNiG81wKenfj6+ ezETPGj/4y5jU/ftVjVTXLDJR6+Pvu3GrA5GKVKTvZT+sh532arli9EYGxitCnmpZibQ0yt3UMP DffvIT9kTVE+wtDir5x8XLrU= X-Received: by 127.0.0.2 with SMTP id 6LWsYY1788612xLE0eV4jno6; Mon, 16 Oct 2023 06:18:24 -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.web10.123811.1697462304097235177 for ; Mon, 16 Oct 2023 06:18:24 -0700 X-Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2b9338e4695so58223171fa.2 for ; Mon, 16 Oct 2023 06:18:23 -0700 (PDT) X-Gm-Message-State: B964IMKdK0fsw6iy2JJWWsPMx1787277AA= X-Google-Smtp-Source: AGHT+IEN9sFd32PzDeZ/z2YweOOKfPEMi0vrQ+VDWC8smmWq61LmxTO1LD2S24ZV7qBW6YGh5KFHWQ== X-Received: by 2002:a2e:2a46:0:b0:2c5:1ad0:e2ff with SMTP id q67-20020a2e2a46000000b002c51ad0e2ffmr3874781ljq.39.1697462301904; Mon, 16 Oct 2023 06:18:21 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:21 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 04/10] ManageabilityPkg: Check header fields in the MCTP response Date: Mon, 16 Oct 2023 16:18:10 +0300 Message-Id: <20231016131816.6634-5-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462307433100019 Content-Type: text/plain; charset="utf-8" Add checks for the MCTP header fields in the MCTP response. Signed-off-by: Konstantin Aladyshev --- .../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 (#109637): https://edk2.groups.io/g/devel/message/109637 Mute This Topic: https://groups.io/mt/101994942/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 Sat May 18 15:08:14 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+109638+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+109638+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462305; cv=none; d=zohomail.com; s=zohoarc; b=m6xeONGte+mQD+1jajOoRtBPHUGTD8s5f906qrxA6y9oSN0FCqG0DIpgEpPlkdjn8/VklI3XL/k7Ujx1kmQOejMpKIQ3M8xAnenICuETU9Er2CzwF58p/FvNSx5YdPleqHimziuOJCxedmgq3y/GsHK2arCD9oeHVGQtfWs/t/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462305; 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=XgVwsvPS/OGRmXBMY5Nh2Gke++Z+bhOfaKQzveRLkag=; b=YhIj0F7yjmQcERXp9ub19v3XFA4j/idvBpbBXcR8H86i66PA3mBmbH8loLkBrkAo5bDoTrSz961ort6tNYfwl6BjEa7vCNs1bc430agwEv3orD0F1lCNm2ydZgH0udHRitxQOUPSXaG8en+NjSzdAdN0BotsnxD5jjUK6awP0Co= 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+109638+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 1697462305968527.4882501905995; Mon, 16 Oct 2023 06:18:25 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Z/iWHhjM6GA3kdOucw8wGTtXtoDIfJQHvnxmZt+BZAk=; 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=1697462305; v=1; b=E0ISvDKt5tvR5Tz43Ny7x9UYAncbgxN1WgluoZB0pApUHR4oVHP1vz7X1+3Te6p0VobKQVR2 fB5FIDAB8Rgr9UayxMaGzGF7X4ulpXqNNtPQ8TcYERiv0wXVp+EJEif0/YZa5XtqSiL4iavIfqL cjXo89ri1LhZYEVfTM9bu1wM= X-Received: by 127.0.0.2 with SMTP id 2xbGYY1788612xt7Yv8kqSyh; Mon, 16 Oct 2023 06:18:25 -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.web10.123812.1697462304818843779 for ; Mon, 16 Oct 2023 06:18:25 -0700 X-Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2c5028e5b88so44647171fa.3 for ; Mon, 16 Oct 2023 06:18:24 -0700 (PDT) X-Gm-Message-State: Y9jPQfCxyNDsBvjaO1ctladlx1787277AA= X-Google-Smtp-Source: AGHT+IFs4qMWsGYHGrgRfY2HcvDmJ0WBcU6LX4vuWZzX5RHYmyapKNDVQurntXcQptcc4PeyHqCOfQ== X-Received: by 2002:a2e:861a:0:b0:2c5:1f70:a266 with SMTP id a26-20020a2e861a000000b002c51f70a266mr2925917lji.50.1697462302750; Mon, 16 Oct 2023 06:18:22 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:22 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 05/10] ManageabilityPkg: Correct typo in MCTP destination EID field Date: Mon, 16 Oct 2023 16:18:11 +0300 Message-Id: <20231016131816.6634-6-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462307451100020 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 --- .../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 (#109638): https://edk2.groups.io/g/devel/message/109638 Mute This Topic: https://groups.io/mt/101994943/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 Sat May 18 15:08:14 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+109639+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+109639+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462306; cv=none; d=zohomail.com; s=zohoarc; b=S3pLO+KzDUSIol/Nb8EEuCV3nDEZRSpXZF8aqgHNwUYfnQZEvaZYAZCeavzHncXL7Y6gfdXz2B118YSF7Fnjud9wuu5cJnQY7Xwd8Zwj2SIeZMTqI1VwzIFihajW2/RMAlCjxhpuf7C4+btryFdkOhl9CZUdprLkL5eqJLSof+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462306; 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=An2HmFzl36hp8P24/vq5ubaPbxNpBCT8xCdWND8MYOI=; b=eKM1WkgUgzzjgrAWmTkkuB+e/AcWmVm8KpiftyirHX3zQyt8jyiyxqXuJeLYO6yfYrQUtIkuwtf5aTsfdJ2XuvYq2w648l4PoryH55bImnVP+km38KUrDoMCS73Snqi03Y2Su7KMJKvHz2IJAS+CVj+B6P+PklK4HkBdg+O05Do= 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+109639+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 1697462306868505.80088604303796; Mon, 16 Oct 2023 06:18:26 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=U4A7AsRhYzZ/bVsnRXzhtZJ9U2i4Ib1tcr5GBtSt82Y=; 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=1697462306; v=1; b=NalJ3zhvtKBU5SykWW1Z1lO+n48EGMCnzN2Bjm/2Uw358/kxHWnRFSyfabuK/qrcEGbjCMEh qojf3W+1qGPj/YcGCXDDEhRJRUXasG4imL7ufsgZ5/kPH0ppVXlJQ61xcEBOiQ8Fw5q8yQXbFhM JNNoDuoXEWSzXCDM4Xg8RVm0= X-Received: by 127.0.0.2 with SMTP id U9vuYY1788612xwYlAz7ibrR; Mon, 16 Oct 2023 06:18:26 -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.web11.123862.1697462305591294158 for ; Mon, 16 Oct 2023 06:18:25 -0700 X-Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so41779721fa.1 for ; Mon, 16 Oct 2023 06:18:25 -0700 (PDT) X-Gm-Message-State: yQyJO6zmtxOnwZ3YTaL6Icgzx1787277AA= X-Google-Smtp-Source: AGHT+IEbpMG2D1uj75u89kvw43Ns6y2mPXeoIVyztazVztH/G6XEaxkm3hvx4SbZ2SKZ8uxmL47yDg== X-Received: by 2002:a05:651c:c9:b0:2b6:a3a0:5f7 with SMTP id 9-20020a05651c00c900b002b6a3a005f7mr31680334ljr.9.1697462303478; Mon, 16 Oct 2023 06:18:23 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:23 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 06/10] ManageabilityPkg: Update the algorithm of using MCTP endpoint ID PCD Date: Mon, 16 Oct 2023 16:18:12 +0300 Message-Id: <20231016131816.6634-7-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462307469100021 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 --- .../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 (#109639): https://edk2.groups.io/g/devel/message/109639 Mute This Topic: https://groups.io/mt/101994944/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 Sat May 18 15:08:14 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+109640+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+109640+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462307; cv=none; d=zohomail.com; s=zohoarc; b=hQU5aywhjPMIE4bSsU88rMsdhd6L+ZBLzQIuy7i1LngEDFmE0MzlkzVXHpuL9gfdL+hcTK6gjGqyGomcKiAfBhcXxKGcU5Ux+m23TDiiCdJZIUjh/1DaJksEOJS8AniPXXVD5O9KEjuopE2xjfQE6PTwTWKopnhEGqVtnQa0AHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462307; 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=T1eK13BanRqithX1Pagv+rZxpjLoyCsY0K/jn/ozXaQ=; b=QFHUjEVhhjY7aWlm3tVsEq/ZWMC1khQ2oAeijxK3VtxslHHWtsZunnqyW+Tpx871fi+gOIUMH8xz2BXVgKsd79sLNiku1r8hLZUyx6PWK7IK5IoEMDHnutXx8wvTGrRe4Ngz19udODLEL1k7xEwtCSceTbs8otMU2DDWgfBwhLQ= 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+109640+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 1697462307541147.17995696095875; Mon, 16 Oct 2023 06:18:27 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=XQIwBwSKl5JLcLgoAYnfVug8f4hHvNvfYY3EPq5RmOg=; 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=1697462307; v=1; b=Y8rA+UxGHtpdwkyoKOjijmbhD0c2ItSR6yZ2wPiIK88/Kcs3LuL9pp3NnThflVadjpTbGQ5L LGXDZeaUtIB5kgmlFELA0axfGoCinJJWgL7ej3V6vVHfrYlVKz/96hFQouDr6vCZai0NXj/qB2a +Z4QHe2QupP7nVfmNoJFWrGI= X-Received: by 127.0.0.2 with SMTP id 1DXMYY1788612xEZeszpIgqh; Mon, 16 Oct 2023 06:18:27 -0700 X-Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by mx.groups.io with SMTP id smtpd.web11.123863.1697462306336721080 for ; Mon, 16 Oct 2023 06:18:26 -0700 X-Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2c50cf61f6dso36192261fa.2 for ; Mon, 16 Oct 2023 06:18:26 -0700 (PDT) X-Gm-Message-State: bgqfBQoRrVrP12hkLJXz36RRx1787277AA= X-Google-Smtp-Source: AGHT+IGGlDNeLi+DB8BRjvBeJG6cgmfhb9t8uKUtccYtkyAmB1FFeWkKxMvaUbdZTrL5KvYVR1ecWw== X-Received: by 2002:a2e:a40d:0:b0:2c5:1b02:2d37 with SMTP id p13-20020a2ea40d000000b002c51b022d37mr2952521ljn.6.1697462304328; Mon, 16 Oct 2023 06:18:24 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:23 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 07/10] ManageabilityPkg: Correct value for the MCTP TAG_OWNER response bit Date: Mon, 16 Oct 2023 16:18:13 +0300 Message-Id: <20231016131816.6634-8-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462309457100032 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 --- .../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 (#109640): https://edk2.groups.io/g/devel/message/109640 Mute This Topic: https://groups.io/mt/101994945/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 Sat May 18 15:08:14 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+109641+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+109641+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462308; cv=none; d=zohomail.com; s=zohoarc; b=P4Sf9ARlRHZCxJ3c3/zvKk+gMamnVv8Fm6isjPNbIzVeoyvpUonGSBIe12n7jWBLx4cBaLzvFRKlanlCPu6s+Ueo7PUA/sqSQQr726ZFnpJKWwghdxxk4fdWdH1H6PFWtqOFPVSkpAhDzCFHC+dEnC5xBrmfSwK0hEU3orrEWuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462308; 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=S8j0gg6G/lTEPIklMJ07ZWEC/I/za31UR7SBa5lUE84=; b=j5OJcmjRdeivQqy0b+oW0yA9+6I1U0R43Xvtajlro4PCdP5uFtuBQp0Oi2Csyqjeo17t0tQ6Bs7Z+hX4X/Cs2AmiLAwSsTtq8BBocERJhbBKyNaMGqFheNdJSJxQWYKh1W609Ndkt3wOXS49YpfQhDoZMlwsxKR37hJbZUZWBtg= 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+109641+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 169746230856371.84764774778432; Mon, 16 Oct 2023 06:18:28 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=OOGFnZM68u5kYg/u62zJa+/HucId3U28b9/Gp9VHZYk=; 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=1697462308; v=1; b=wSXhEIwf1u/abs29kNJpcqiL6ARMdj6zlezxhQvM6Q6A6gYdOHzEJC8tu2mPrGV9xSstqpV5 45OPPg5pi6vCEzf9hI0wBi6aq9ROXESFO/XN5+X3TvfRKtH/olVFzFgAhlAvZ9krgxgHsYREbm8 2NZHPD2VfA7qEUkrzkLq1S7E= X-Received: by 127.0.0.2 with SMTP id PPaCYY1788612xXYsLgJNcfE; Mon, 16 Oct 2023 06:18:28 -0700 X-Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mx.groups.io with SMTP id smtpd.web11.123864.1697462307195172484 for ; Mon, 16 Oct 2023 06:18:27 -0700 X-Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2b9d07a8d84so53699481fa.3 for ; Mon, 16 Oct 2023 06:18:26 -0700 (PDT) X-Gm-Message-State: CgibiPic6Y3FMqrLUIdhacsEx1787277AA= X-Google-Smtp-Source: AGHT+IFyHVQyqa/H9WFBICUy2WwmRkNXe2xcpQ/4qVgQ8HriZt0wnH1VquJLPHMXyJyWVtD1MGKokQ== X-Received: by 2002:a05:651c:a12:b0:2c5:169f:ff03 with SMTP id k18-20020a05651c0a1200b002c5169fff03mr5630663ljq.5.1697462305090; Mon, 16 Oct 2023 06:18:25 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:24 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 08/10] ManageabilityPkg: Don't check MCTP header fields if transfer has failed Date: Mon, 16 Oct 2023 16:18:14 +0300 Message-Id: <20231016131816.6634-9-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462309452100031 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 --- .../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 (#109641): https://edk2.groups.io/g/devel/message/109641 Mute This Topic: https://groups.io/mt/101994946/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 Sat May 18 15:08:14 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+109642+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+109642+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462309; cv=none; d=zohomail.com; s=zohoarc; b=GRyPsEj18MDQN0ih2tRRHZhY/MeXI+oWhFxBGX9jcIdPN3Nw3IhysE1DCoC/thHpd14DctfVhiGiL9OvOvsugbgYs8gxQX1/Ox3RzhfLmQ1z06CC/D5kIKoPXZ5xGGGN3lxYv9T2OsFQuiDxKRADVRFTtKA4DoB5Re2ISEKCzsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462309; 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=+JDcPeQuZuJwlMPCK3XuiCEISGxl9sj183snD6qA3GM=; b=S93ztnFg2UGOgrpEsrQ1YpH3ea1bK70Zt1/Fme0jAcbVXymxHqkUP+lLt2iWpkPy/1VITNVdPn09PQLsfe2FZhVDFqHUe9pYUrcU7NBe4HvjNEqrqvrYhFmm7NIPNcdUFEba5RWGt6dUsAmMOYhYX0o+tfeZA7Ta7Q7/WmIXs1k= 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+109642+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 1697462309159431.07634139487186; Mon, 16 Oct 2023 06:18:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=sVvSvXl4PFlnnk06LxXe62ZQ5oRLFUgTVt7OLwSmh0g=; 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=1697462308; v=1; b=LaRmgQorPVabvVQ+/qPKvaAywwn8BMJ9xKUEKrLPC9idNYeWHmvUNx/luH8h48EqvtuMBdL3 lyAn2fvrUmUkrc2QqWbbwBxK/mP7cEG0+7OW2bq9SlhgHfKMBVf9+r4LwBM6yaE+FJBXtuPowP1 OD5//ZyumFnKYrbXfho/bvfI= X-Received: by 127.0.0.2 with SMTP id GRkIYY1788612x6Wmk07yQ7Q; Mon, 16 Oct 2023 06:18: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.web10.123816.1697462307983768733 for ; Mon, 16 Oct 2023 06:18:28 -0700 X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c51388ccebso23845471fa.3 for ; Mon, 16 Oct 2023 06:18:27 -0700 (PDT) X-Gm-Message-State: nDkaSLovg56pHMDEZmoNbka6x1787277AA= X-Google-Smtp-Source: AGHT+IEVlLJ662Dgs0XHlS0G1EXjIkUgO02TwqN+9DOtoabu6Uhu+9xFOy9easoYWWA5s4GXVBxp+Q== X-Received: by 2002:a2e:5109:0:b0:2c5:1a8e:e4c9 with SMTP id f9-20020a2e5109000000b002c51a8ee4c9mr3695169ljb.31.1697462305893; Mon, 16 Oct 2023 06:18:25 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:25 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 09/10] ManageabilityPkg: Use correct constants for PLDM header checks Date: Mon, 16 Oct 2023 16:18:15 +0300 Message-Id: <20231016131816.6634-10-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462309464100033 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 --- .../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..3deded541a 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_IS_= 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, " Request bit =3D %d (Expected value: %d)\n",= PLDM_MESSAGE_HEADER_IS_RESPONSE)); + DEBUG ((DEBUG_ERROR, " Datagram =3D %d (Expected value: %d)\n",= PLDM_MESSAGE_HEADER_IS_DATAGRAM)); 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 (#109642): https://edk2.groups.io/g/devel/message/109642 Mute This Topic: https://groups.io/mt/101994947/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 Sat May 18 15:08:14 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+109643+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+109643+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1697462310; cv=none; d=zohomail.com; s=zohoarc; b=fgD1yH4MugWnFx96UvL/xmQi/Y6MK4vb6cSXPtz5baVpH2dfEfwxITbPF5Cfs66gz4IcQy7ifE1Af5sNPWEYvLG8sQPLuEUwB5T6p/3UBE6KwH88usrOq0bmx4r8NweUQzDPYAGsrCPp3EJ0v4UmkKNmrrAAPNdLLi1frIhafA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697462310; 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=iyoa/jlPTEovl3hNLQ1dqZ7ntwnAMYbSTxrTCi6/Pr8=; b=I+9pEROQ4yDO6A+fAYXtAtjEk2DKGMhivuI66ywZ+uCwJHi0h+SYLBqS3zbp/KZAGliXKrM1xcs3P5qHXyvJwlJhxJboHPjpI7gMWJ4Y4K67fCBnq4xaNQ8PRRLWpVsYPf7JVxzgOOhFChL2vXP+JyTxZN0XXUlG7QaOkiqPrCs= 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+109643+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 169746231012859.893379174935035; Mon, 16 Oct 2023 06:18:30 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=WLB/EphbKJKqKF95fuXLvQh5Q5uu8Ld6iw/m1KIk7k4=; 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=1697462309; v=1; b=oCYXqq9qegaRyjS2F2iuGUmc+4g7wO5FCRFcoEnZAvonMrxTiYWlWtVzDsZRFCsEwfU9whXN rF3kaPf7Bzpj7zh4rvM11Y+qOTX2NHUGw1OJet9xGLbh6yv9GNWvkdl2JF5O+Gn3QFIyOQU7F9C mpSXYKyuST8u6BP7WNSoRj4s= X-Received: by 127.0.0.2 with SMTP id 5WQfYY1788612xsImbE9ty8Y; Mon, 16 Oct 2023 06:18: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.123866.1697462309013277007 for ; Mon, 16 Oct 2023 06:18:29 -0700 X-Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c17de836fbso53876031fa.1 for ; Mon, 16 Oct 2023 06:18:28 -0700 (PDT) X-Gm-Message-State: M2tMz1EbVcLtRynHJuEe5NVZx1787277AA= X-Google-Smtp-Source: AGHT+IHzvLVCvJ2cUZqR1c5Gig8UZqGYuNUfKPXgoyChuvH2JuERK+KfyTw2nEsXROdXUt9IZUF5pw== X-Received: by 2002:a2e:a552:0:b0:2c5:13e8:e6d5 with SMTP id e18-20020a2ea552000000b002c513e8e6d5mr4946518ljn.23.1697462306910; Mon, 16 Oct 2023 06:18:26 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id 9-20020a2e1449000000b002ba586d27a2sm1362545lju.26.2023.10.16.06.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:18:26 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms 10/10] ManageabilityPkg: Return error on multiple-packet MCTP responses Date: Mon, 16 Oct 2023 16:18:16 +0300 Message-Id: <20231016131816.6634-11-aladyshev22@gmail.com> In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com> References: <20231016131816.6634-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: 1697462311715100041 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 --- .../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..7cf2d916f4 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 (#109643): https://edk2.groups.io/g/devel/message/109643 Mute This Topic: https://groups.io/mt/101994949/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-