From nobody Sun May 5 02:30:24 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+86066+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+86066+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139557; cv=none; d=zohomail.com; s=zohoarc; b=AVxc3xjrC3p1aQ3NptKLHK+OL+y4hAI8d3+D8WV3+JwSoJ6gWQGcveDQLd5X0FQ4topgT2ujY4H6gaAQlGA5sOBOnsM2t33KQz+wNzhVKI/DMSU/PDjZCDUnsDjw0owPva8ezykV3A5gzWD1/+j5Jt29XJaU+575wX8HDkGVKlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139557; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qEf7qrFzjpap+B0hSXcZ+jn0R+uGytm4jB/0MuOAc1E=; b=CcIgg+GUo9i8pNSVoo6VOBNFioKUSZ1KYoEIx1ippY/tQPkgAFlVZNEpv2zw5wvVgpbG9/ZW2P1fxTbKwiV26ILVopH2Gb+jhQlGV52U2WG7lGq5vsLtxRD/AzAVtOtBr4wR/pEepO3yx+E0xWeApDJUajhSjv/FTiP622suZ5U= 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+86066+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 164313955748830.291287444507248; Tue, 25 Jan 2022 11:39:17 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id n2meYY1788612x75SH6SRk3X; Tue, 25 Jan 2022 11:39:17 -0800 X-Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mx.groups.io with SMTP id smtpd.web11.2065.1643139556106848812 for ; Tue, 25 Jan 2022 11:39:16 -0800 X-Received: by mail-pg1-f169.google.com with SMTP id p125so19142850pga.2 for ; Tue, 25 Jan 2022 11:39:16 -0800 (PST) X-Gm-Message-State: WAFPVH3qbG3g8SKTR2Mgeuthx1787277AA= X-Google-Smtp-Source: ABdhPJzEi4mm1++9OK9wLlfxJ7te64bHuMKLdUeDd3SvkN8rXN3/9j5XO0Zv+bh8+4zG7uH1Ugs7MA== X-Received: by 2002:a05:6a00:1946:b0:492:64f1:61b5 with SMTP id s6-20020a056a00194600b0049264f161b5mr19828667pfk.52.1643139555437; Tue, 25 Jan 2022 11:39:15 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:15 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Hao A Wu , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v3 1/6] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Date: Tue, 25 Jan 2022 11:39:04 -0800 Message-Id: <20220125193909.491-2-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139557; bh=TMESwzPBi3/vbndn6l8e5zSTkMpETb2Kv8ZBM+b22vQ=; h=Cc:Date:From:Reply-To:Subject:To; b=DWASbdtGIOe36yL6xnTmBv2m0HGTGsmXP/GCNa4Z3OrahOez3DQQsE/lQzIedvaP/YF HG3jXnCY6q3exi3lc648bua91WIQD1lixM5147RRMwSBrlo5m66nbovdhYp3ZXe4T2o+P orTnGTlGDfXKtOOikeZoPBr0+xmHY+s+hQw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139559858100005 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3709 In EDKII implementation of variable policy, the DXE runtime agent would communicate to MM to disable, register or query policies. However, these operations populate the value of MessageLength that includes communicate header to include MM communicate header, which mismatches with the description of PI specification. This fix will correct the MessageLength field calculation to exclude the size of MM_COMMUNICATE_HEADER. Cc: Jian J Wang Cc: Liming Gao Cc: Hao A Wu Cc: Bret Barkelew Cc: Michael Kubacki Signed-off-by: Kun Qin Reviewed-by: Liming Gao --- Notes: v2: - No review, no updates =20 v3: - Added reviewed-by tag [Liming] MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c | 10 +++= ++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDx= e.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c index 672a2293bcb1..b2094fbcd6ea 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c @@ -89,7 +89,7 @@ ProtocolDisableVariablePolicy ( CommHeader =3D mMmCommunicationBuffer; PolicyHeader =3D (VAR_CHECK_POLICY_COMM_HEADER *)&CommHeader->Data; CopyGuid (&CommHeader->HeaderGuid, &gVarCheckPolicyLibMmiHandlerGuid); - CommHeader->MessageLength =3D BufferSize; + CommHeader->MessageLength =3D BufferSize - OFFSET_OF (EFI_MM_COMMUNICATE= _HEADER, Data); PolicyHeader->Signature =3D VAR_CHECK_POLICY_COMM_SIG; PolicyHeader->Revision =3D VAR_CHECK_POLICY_COMM_REVISION; PolicyHeader->Command =3D VAR_CHECK_POLICY_COMMAND_DISABLE; @@ -138,7 +138,7 @@ ProtocolIsVariablePolicyEnabled ( PolicyHeader =3D (VAR_CHECK_POLICY_COMM_HEADER *)&CommHeader->Data; CommandParams =3D (VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS *)(PolicyHead= er + 1); CopyGuid (&CommHeader->HeaderGuid, &gVarCheckPolicyLibMmiHandlerGuid); - CommHeader->MessageLength =3D BufferSize; + CommHeader->MessageLength =3D BufferSize - OFFSET_OF (EFI_MM_COMMUNICATE= _HEADER, Data); PolicyHeader->Signature =3D VAR_CHECK_POLICY_COMM_SIG; PolicyHeader->Revision =3D VAR_CHECK_POLICY_COMM_REVISION; PolicyHeader->Command =3D VAR_CHECK_POLICY_COMMAND_IS_ENABLED; @@ -213,7 +213,7 @@ ProtocolRegisterVariablePolicy ( PolicyHeader =3D (VAR_CHECK_POLICY_COMM_HEADER *)&CommHeader->Data; PolicyBuffer =3D (VOID *)(PolicyHeader + 1); CopyGuid (&CommHeader->HeaderGuid, &gVarCheckPolicyLibMmiHandlerGuid); - CommHeader->MessageLength =3D BufferSize; + CommHeader->MessageLength =3D BufferSize - OFFSET_OF (EFI_MM_COMMUNICATE= _HEADER, Data); PolicyHeader->Signature =3D VAR_CHECK_POLICY_COMM_SIG; PolicyHeader->Revision =3D VAR_CHECK_POLICY_COMM_REVISION; PolicyHeader->Command =3D VAR_CHECK_POLICY_COMMAND_REGISTER; @@ -270,7 +270,7 @@ DumpVariablePolicyHelper ( PolicyHeader =3D (VAR_CHECK_POLICY_COMM_HEADER *)&CommHeader->Data; CommandParams =3D (VAR_CHECK_POLICY_COMM_DUMP_PARAMS *)(PolicyHeader + 1= ); CopyGuid (&CommHeader->HeaderGuid, &gVarCheckPolicyLibMmiHandlerGuid); - CommHeader->MessageLength =3D BufferSize; + CommHeader->MessageLength =3D BufferSize - OFFSET_OF (EFI_MM_COMMUNICATE= _HEADER, Data); PolicyHeader->Signature =3D VAR_CHECK_POLICY_COMM_SIG; PolicyHeader->Revision =3D VAR_CHECK_POLICY_COMM_REVISION; PolicyHeader->Command =3D VAR_CHECK_POLICY_COMMAND_DUMP; @@ -397,7 +397,7 @@ ProtocolLockVariablePolicy ( CommHeader =3D mMmCommunicationBuffer; PolicyHeader =3D (VAR_CHECK_POLICY_COMM_HEADER *)&CommHeader->Data; CopyGuid (&CommHeader->HeaderGuid, &gVarCheckPolicyLibMmiHandlerGuid); - CommHeader->MessageLength =3D BufferSize; + CommHeader->MessageLength =3D BufferSize - OFFSET_OF (EFI_MM_COMMUNICATE= _HEADER, Data); PolicyHeader->Signature =3D VAR_CHECK_POLICY_COMM_SIG; PolicyHeader->Revision =3D VAR_CHECK_POLICY_COMM_REVISION; PolicyHeader->Command =3D VAR_CHECK_POLICY_COMMAND_LOCK; --=20 2.34.1.windows.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 (#86066): https://edk2.groups.io/g/devel/message/86066 Mute This Topic: https://groups.io/mt/88680220/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 Sun May 5 02:30:24 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+86067+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+86067+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139558; cv=none; d=zohomail.com; s=zohoarc; b=YIsB09pjLJ70KMWrm1hSpzimEYGn5FgOREY8be4vcjg+WL5EDJskTdc72xzYLwXzOCItxs/ux3remmumXaVI5QC5QQXiugpGCRTOYjDfAxngl/oNrDNt7mxx3XuzROeAg3RQcrWEUWOrplRuA859GOuiUxWmeWy4me6vk87xrXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139558; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=riT0AncFp6xcz10i7def+sn8FN97hBztMC1qOPXB82g=; b=ZI7Y21mJzBztzbip93iRC53QJMSNAH02yIYrwBktB/FwK5xtVIEh8l1jDWimcUWfxNA3iMI+MgRZ276qlXCZPUoyeMuV/0kgaTYrcMaSJPbIFpXPojuTnac+BR2WHl/kH7jjnduX0WzAgeCKIvj73n3+aGpkgZ0VQPHmG8v9V9U= 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+86067+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 1643139558222700.2021785648521; Tue, 25 Jan 2022 11:39:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3Nh3YY1788612xDXL19zQKY0; Tue, 25 Jan 2022 11:39:17 -0800 X-Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mx.groups.io with SMTP id smtpd.web08.2063.1643139556609473630 for ; Tue, 25 Jan 2022 11:39:16 -0800 X-Received: by mail-pl1-f178.google.com with SMTP id d18so7657550plg.2 for ; Tue, 25 Jan 2022 11:39:16 -0800 (PST) X-Gm-Message-State: P1ERlHdaY0fWvx7JYTRmocL7x1787277AA= X-Google-Smtp-Source: ABdhPJzVE0itNt0sxHIhq1xzeTvMW1OC+KKxJ4bC/iXTJPeWpAUPkja0ytAgLpycIj4I2yvInq0vLQ== X-Received: by 2002:a17:902:e74c:b0:14b:409e:400e with SMTP id p12-20020a170902e74c00b0014b409e400emr12903799plf.61.1643139556066; Tue, 25 Jan 2022 11:39:16 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:15 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v3 2/6] MdePkg: MmCommunication2: Update MM communicate2 function description Date: Tue, 25 Jan 2022 11:39:05 -0800 Message-Id: <20220125193909.491-3-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139557; bh=EHMudm1f3ZjFW2jYAJIOy4CPjPMU2V0rct2Z8bT9Olk=; h=Cc:Date:From:Reply-To:Subject:To; b=ca5l/s8AqPv6Q/7az1L5spDD/g89gTFkdRNDdcQNbudrK2+03k9C6LzskMJTERjgf90 jw40RASde/9c9zL4tBgri7A0GsOSDscN0Xld5rSgKiCpPYjBL4rq4WE9Jt+Qwaj5Gkr1v +QKtOfld27qrXP3SbcsnX1YeUzDYsPkOyVw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139559925100006 Content-Type: text/plain; charset="utf-8" Current MM communicate2 function definition described input arguments `CommBufferPhysical`, `CommBufferVirtual` and `CommSize` as input only, which mismatches with the "input and output type" as in PI specification. This change updated function descriptions of MM communite2 definition to match input argument types. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Kun Qin Reviewed-by: Liming Gao --- Notes: v2: - Newly added =20 v3: - Added reviewed-by tag [Liming] MdePkg/Include/Protocol/MmCommunication2.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MdePkg/Include/Protocol/MmCommunication2.h b/MdePkg/Include/Pr= otocol/MmCommunication2.h index 3495a7327f76..1b56320c7fff 100644 --- a/MdePkg/Include/Protocol/MmCommunication2.h +++ b/MdePkg/Include/Protocol/MmCommunication2.h @@ -27,12 +27,13 @@ typedef struct _EFI_MM_COMMUNICATION2_PROTOCOL EFI_MM_C= OMMUNICATION2_PROTOCOL; =20 This function provides a service to send and receive messages from a reg= istered UEFI service. =20 - @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instanc= e. - @param[in] CommBufferPhysical Physical address of the MM communication = buffer - @param[in] CommBufferVirtual Virtual address of the MM communication b= uffer - @param[in] CommSize The size of the data buffer being passed = in. On exit, the size of data - being returned. Zero if the handler does = not wish to reply with any data. - This parameter is optional and may be NUL= L. + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL in= stance. + @param[in, out] CommBufferPhysical Physical address of the MM communica= tion buffer + @param[in, out] CommBufferVirtual Virtual address of the MM communicat= ion buffer + @param[in, out] CommSize The size of the data buffer being pa= ssed in. On exit, the + size of data being returned. Zero if= the handler does not + wish to reply with any data. This pa= rameter is optional + and may be NULL. =20 @retval EFI_SUCCESS The message was successfully posted. @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBuffer= Virtual was NULL. --=20 2.34.1.windows.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 (#86067): https://edk2.groups.io/g/devel/message/86067 Mute This Topic: https://groups.io/mt/88680221/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 Sun May 5 02:30:24 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+86068+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+86068+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139558; cv=none; d=zohomail.com; s=zohoarc; b=Vm0n7hVNJLSfsdGA1eXCgTA930oFVe9tqbGmHYFq0D4q7wtc9X0mvbFX2VciLeB+oafmiXqMGrmk/vV/e77dyAy7/OhMhaPcrYZlKYjkCYFFAIkvjp/ZJqfLcATxUfpTmN1g/siSwgcxABbTKPexo7iUHBXvgCVdVGjsRWotDQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139558; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nVcwcScXY+C5nY208wol0wFUlmtaEzWz1+DV4ejxP5s=; b=TjHRDSzgSa7u+8D/yqnH8sgyMEYzuC76jjyu6BvC4NayV+IrnYEaGcYHZ+kGor2wdcX+tP0BLswY1gu/XoSgek3YBy/CmllKHeip3+8sKc/Y8nPL/vXb6BK/HZVKl00lZDrt/p1ewJSiOHhZ2BCERH5ItodN3QNVqu8P+reqSg0= 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+86068+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 1643139558883847.0493487744534; Tue, 25 Jan 2022 11:39:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DvFAYY1788612xs0RFYFr0I7; Tue, 25 Jan 2022 11:39:18 -0800 X-Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mx.groups.io with SMTP id smtpd.web09.2044.1643139557605453788 for ; Tue, 25 Jan 2022 11:39:17 -0800 X-Received: by mail-pj1-f43.google.com with SMTP id h12so20951502pjq.3 for ; Tue, 25 Jan 2022 11:39:17 -0800 (PST) X-Gm-Message-State: GJ6ODmKqQSUsaYqDdgP2XcUtx1787277AA= X-Google-Smtp-Source: ABdhPJwHbrwQ5SKkfkyil7ACFwC4VvEr/8/z1p5062TV/l6abSca0JKNw8laZU5t1GMyED8VkW1q0w== X-Received: by 2002:a17:902:a50f:b0:149:bc1a:2c98 with SMTP id s15-20020a170902a50f00b00149bc1a2c98mr20047348plq.35.1643139556877; Tue, 25 Jan 2022 11:39:16 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:16 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki , Sami Mujawar Subject: [edk2-devel] [PATCH v3 3/6] ArmPkg: MmCommunicationDxe: MM communicate function argument attributes Date: Tue, 25 Jan 2022 11:39:06 -0800 Message-Id: <20220125193909.491-4-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139558; bh=OEr0gj5OdFFNasXQFC5xP1j4pcQge6oi5ZEP3i8jWVI=; h=Cc:Date:From:Reply-To:Subject:To; b=eAEspu4iKSFeYr8fq1Ck4J5IzzUKzyJYX/6Kb2Vstya5239b3MTbX9lCFNxF4hXGBkW qFUepxjU2+lj0zRRT7UvbUlPw9N/xdT32UE9ZMz5/iOxgGKoDnzOlt4m1tNDwIpFefl2g tG0wAmv8Lt5hDw1ooCgxfKezFfQt6OQtJrQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139560093100012 Content-Type: text/plain; charset="utf-8" Current MM communicate2 function from ArmPkg described input arguments `CommBufferPhysical`, `CommBufferVirtual` and `CommSize` as input only, which mismatches with the "input and output type" as in PI specification. This change updated function descriptions of MM communite2 to match input argument types. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Cc: Sami Mujawar Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 1 of 4 [Ard] =20 v3: - Added cc entry and reviewed-by tag [Sami] ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 7c8284104d87..7f756a32d4e0 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -41,12 +41,13 @@ STATIC EFI_HANDLE mMmCommunicateHandle; =20 This function provides a service to send and receive messages from a reg= istered UEFI service. =20 - @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL instanc= e. - @param[in] CommBufferPhysical Physical address of the MM communication = buffer - @param[in] CommBufferVirtual Virtual address of the MM communication b= uffer - @param[in] CommSize The size of the data buffer being passed = in. On exit, the size of data - being returned. Zero if the handler does = not wish to reply with any data. - This parameter is optional and may be NUL= L. + @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL in= stance. + @param[in, out] CommBufferPhysical Physical address of the MM communica= tion buffer + @param[in, out] CommBufferVirtual Virtual address of the MM communicat= ion buffer + @param[in, out] CommSize The size of the data buffer being pa= ssed in. On exit, the + size of data being returned. Zero if= the handler does not + wish to reply with any data. This pa= rameter is optional + and may be NULL. =20 @retval EFI_SUCCESS The message was successfully posted. @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBuffer= Virtual was NULL. --=20 2.34.1.windows.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 (#86068): https://edk2.groups.io/g/devel/message/86068 Mute This Topic: https://groups.io/mt/88680222/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 Sun May 5 02:30:24 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+86069+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+86069+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139559; cv=none; d=zohomail.com; s=zohoarc; b=HTo+Dqqto/bKf61FsvZ/c3TtyJm1Av48bfGLa5gzICNbNGJdaW2qF7SovzZDZhqRli2PMKOZU44IdBTYpFFZVfkulA7Ry4pfe+xF95tXpqRWwya28Z26RLQn1LSNnl0oPN1vvaGdI+lD9t4L/WRfNOzujdF6Lw0w2dN1Y3Qizg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139559; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=IlMgdgbN0bK1xkBuG9082YKLmjwQdXhaAJ7rFeGq0N8=; b=WFX9mqyEx3ItY9nAgr478WKUVzum/js6HcS0QE4VQbTHo72kacPIJeS0CsRhdQwu8uOL/GiB4+i3RYG/QQJU+5/Q1GvNDMkMuitjF6YoFHS9n7ohqJxWaTF2fCPNIpIoOPKsl6S7BTZv6ESTEx2ITONsSPT1wBqLF5bJ2UoldrQ= 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+86069+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 1643139559429142.0049391707929; Tue, 25 Jan 2022 11:39:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id RfxjYY1788612x2n0bVydEpO; Tue, 25 Jan 2022 11:39:18 -0800 X-Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mx.groups.io with SMTP id smtpd.web12.1943.1643139558271877052 for ; Tue, 25 Jan 2022 11:39:18 -0800 X-Received: by mail-pj1-f52.google.com with SMTP id d5so18542460pjk.5 for ; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-Gm-Message-State: SbwLtrhuo8ITW4CvFhe7Ob4Zx1787277AA= X-Google-Smtp-Source: ABdhPJwtgrxXBgkzK9vNRT2sBrS2O2dTlB4iZtMvJqIFy7kUjXUOxXppwKHK+Pm0NkJd0CH/GbsvJQ== X-Received: by 2002:a17:902:704a:b0:14a:b62b:f41b with SMTP id h10-20020a170902704a00b0014ab62bf41bmr20140833plt.93.1643139557593; Tue, 25 Jan 2022 11:39:17 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:17 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki , Sami Mujawar Subject: [edk2-devel] [PATCH v3 4/6] ArmPkg: MmCommunicationDxe: Update MM communicate `CommBuffer**` checks Date: Tue, 25 Jan 2022 11:39:07 -0800 Message-Id: <20220125193909.491-5-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139558; bh=xIdmPl3g/TobV5mlWleVpZ1vLfbbtYUblv7IaajSddM=; h=Cc:Date:From:Reply-To:Subject:To; b=h1ANQEmuALu2R9V05ZRfZtoUfz4vg+oQMfRh/DEKmzLaZ8ty4fJqd/P/OuhlEW2AVfI fqrcz8JNbC5o+RJUaIl47aZoKBdqplIMXjoc2RK5pc81Ecud9vrvtsZUzDJReV1HDtyT6 zqwquo38mcz0dFGZ1A8ycpLsNps05R7UIiA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139560191100014 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3751 Current MM communicate routine from ArmPkg would conduct few checks prior to proceeding with SMC calls. However, the inspection step is different from PI specification. This patch updated MM communicate input argument inspection routine to assure that return code `EFI_INVALID_PARAMETER` represents "the `CommBuffer**` parameters do not refer to the same location in memory", as described by `EFI_MM_COMMUNICATION2_PROTOCOL.Communicate()` section in PI specification. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Cc: Sami Mujawar Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 2 of 4 [Ard] - Uncrustify style update =20 v3: - Added cc entry and reviewed-by tag [Sami] ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 7f756a32d4e0..0283be430dff 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -83,7 +83,7 @@ MmCommunication2Communicate ( // // Check parameters // - if (CommBufferVirtual =3D=3D NULL) { + if ((CommBufferVirtual =3D=3D NULL) || (CommBufferPhysical =3D=3D NULL))= { return EFI_INVALID_PARAMETER; } =20 --=20 2.34.1.windows.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 (#86069): https://edk2.groups.io/g/devel/message/86069 Mute This Topic: https://groups.io/mt/88680223/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 Sun May 5 02:30:24 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+86070+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+86070+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139560; cv=none; d=zohomail.com; s=zohoarc; b=J0XZ3ny7faYegjN7L+YO+DQRUfkJfbQNHPMffq6Vk0FIP+eudRL/vHIQfydZvnSNyK4DiS052nsKRl2Lz3kmcyTb7VxU6ToySv/UDB0BQdFVP3VUAHZmlfSvUdu768DSpQUCzDQ/xX8JgY6DOAcZlNqJkpYoP/73C8MQClt5PhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139560; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NogAdV23qsbJdwVjEhm7qjhX6HkdoMTc1d9sxPjKDsI=; b=dLV1PWfOUWaVAWmZ4tLfjYkRgDWcFrWd45JkISdLPclx11+Wwk6zIiDOszzfFi7LrnHJhhSy90JBn/FKp22G60w7nF6Ts/OGkMCuk2O2spPbrRHrbyBUQ2aS6s7Zb7M/ZoOni3SyrGDFPuAURoG1EAOctEnAS/0lkQOblydfgLk= 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+86070+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 164313956003895.83867015363148; Tue, 25 Jan 2022 11:39:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id IZ1aYY1788612xhfFuIjXEvD; Tue, 25 Jan 2022 11:39:19 -0800 X-Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mx.groups.io with SMTP id smtpd.web12.1944.1643139558840333274 for ; Tue, 25 Jan 2022 11:39:18 -0800 X-Received: by mail-pg1-f180.google.com with SMTP id v3so13831585pgc.1 for ; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-Gm-Message-State: ywcZYyZgijqs2SgesRuUcxWPx1787277AA= X-Google-Smtp-Source: ABdhPJwAA/0PJdc+VvqM9RL1Pys7alRUwHFSGUq2UBxEI+8OmglQOvlvjLkhqRm7fDCJQhjng7Os/g== X-Received: by 2002:a62:33c7:0:b0:4bd:5aa4:1220 with SMTP id z190-20020a6233c7000000b004bd5aa41220mr19561934pfz.55.1643139558292; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:18 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki , Sami Mujawar Subject: [edk2-devel] [PATCH v3 5/6] ArmPkg: MmCommunicationDxe: Update MM communicate `CommSize` check Date: Tue, 25 Jan 2022 11:39:08 -0800 Message-Id: <20220125193909.491-6-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139559; bh=9UoJGRwPyq/+Ty+mFJS5bzxUHM7biya9d0KByKhvtc0=; h=Cc:Date:From:Reply-To:Subject:To; b=wOeN1MFt1bWCG/ubhlv8iXFqaLTWULeNcq6arHnxCQa92peDCn40JAQudReCdVPHvwJ UkOBzQar63gAw+fOwSm6FKy8lLX/UEuO2ysji6QrykkiFo9E52Ym2Zro+xMdmxqNeDDmM qpdVQQ85B0teFK9JzVvLw7HkAt6OWhPjXmU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139562329100022 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3751 Current MM communicate routine from ArmPkg would conduct few checks prior to proceeding with SMC calls. However, the inspection step is different from PI specification. This patch updated MM communicate input argument inspection routine to assure `CommSize` represents "the size of the data buffer being passed in" instead of the size of the data being used from data buffer, as described by section `EFI_MM_COMMUNICATION2_PROTOCOL.Communicate()` in PI specification. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Cc: Sami Mujawar Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 3 of 4 [Ard] =20 v3: - Added cc entry and reviewed-by tag [Sami] ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 19 ++++++++++++-----= -- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 0283be430dff..2f89b7c5b6c4 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -44,13 +44,18 @@ STATIC EFI_HANDLE mMmCommunicateHandle; @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL in= stance. @param[in, out] CommBufferPhysical Physical address of the MM communica= tion buffer @param[in, out] CommBufferVirtual Virtual address of the MM communicat= ion buffer - @param[in, out] CommSize The size of the data buffer being pa= ssed in. On exit, the - size of data being returned. Zero if= the handler does not + @param[in, out] CommSize The size of the data buffer being pa= ssed in. On input, + when not omitted, the buffer should = cover EFI_MM_COMMUNICATE_HEADER + and the value of MessageLength field= . On exit, the size + of data being returned. Zero if the = handler does not wish to reply with any data. This pa= rameter is optional and may be NULL. =20 @retval EFI_SUCCESS The message was successfully posted. - @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBuffer= Virtual was NULL. + @retval EFI_INVALID_PARAMETER CommBufferPhysical or CommBufferVirtual w= as NULL, or + integer value pointed by CommSize does no= t cover + EFI_MM_COMMUNICATE_HEADER and the value o= f MessageLength + field. @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implem= entation. If this error is returned, the MessageLen= gth field in the CommBuffer header or the integer p= ointed by @@ -96,8 +101,8 @@ MmCommunication2Communicate ( sizeof (CommunicateHeader->HeaderGuid) + sizeof (CommunicateHeader->MessageLength); =20 - // If the length of the CommBuffer is 0 then return the expected length. - if (CommSize !=3D 0) { + // If CommSize is not omitted, perform size inspection before proceeding. + if (CommSize !=3D NULL) { // This case can be used by the consumer of this driver to find out the // max size that can be used for allocating CommBuffer. if ((*CommSize =3D=3D 0) || @@ -108,9 +113,9 @@ MmCommunication2Communicate ( } =20 // - // CommSize must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEAD= ER); + // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMU= NICATE_HEADER); // - if (*CommSize !=3D BufferSize) { + if (*CommSize < BufferSize) { return EFI_INVALID_PARAMETER; } } --=20 2.34.1.windows.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 (#86070): https://edk2.groups.io/g/devel/message/86070 Mute This Topic: https://groups.io/mt/88680224/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 Sun May 5 02:30:24 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+86071+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+86071+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139560; cv=none; d=zohomail.com; s=zohoarc; b=cMMJ+RiRctvoS6EzZ0O7NFDUBjYvTAZQJQUtgEp3MThxpLsyB/EiGOATRkrEL28CvGMdtu35knagi90/ONtI3GG3rBWzGmJWPGtgJOzDEqNaeNaSBUbf7XS8cRHVhnCaoHZFx82nlemknkRbnxb3zYml84cWGNK/MhitZUb6tFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139560; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qxFobrFgyqoRbGczfbg/yZkIfYzc3tp27VlwvhTflAk=; b=X25E4JS+/T6SlYJozGDem0NmxI1G1IQfkLn/PKkT9+oO/+yfSKu5xVLJNXcRpXi4Tszae/PUW88z6+t61VrHknnpX9boxrki55OtflohfiO8oAGwuVXMi14Ymwv+GtTN0BaFXXwV7RSofQEuimj4jfksHFk0rJl9humKMcaapFs= 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+86071+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 1643139560709654.2468990434907; Tue, 25 Jan 2022 11:39:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Q4P3YY1788612xdVarOq8M51; Tue, 25 Jan 2022 11:39:20 -0800 X-Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mx.groups.io with SMTP id smtpd.web12.1945.1643139559444445864 for ; Tue, 25 Jan 2022 11:39:19 -0800 X-Received: by mail-pl1-f173.google.com with SMTP id x11so14574553plg.6 for ; Tue, 25 Jan 2022 11:39:19 -0800 (PST) X-Gm-Message-State: WpEBTOd6ZxwEXj2OHXLFzf3Ex1787277AA= X-Google-Smtp-Source: ABdhPJysYZ7RKSd6QbTD20rDghcHfwBSo2MIxuw4WIS5GzgLzyfNZqWyGhm90YfDOuBh1d9Gaj9goQ== X-Received: by 2002:a17:902:dad1:b0:14b:5094:9076 with SMTP id q17-20020a170902dad100b0014b50949076mr10538008plx.22.1643139558944; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:18 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki , Sami Mujawar Subject: [edk2-devel] [PATCH v3 6/6] ArmPkg: MmCommunicationDxe: Update MM communicate `MessageLength` check Date: Tue, 25 Jan 2022 11:39:09 -0800 Message-Id: <20220125193909.491-7-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139560; bh=CYWAnssUrK76S4sCQYccL/63VwvDvv+JuX6AcJRBUdg=; h=Cc:Date:From:Reply-To:Subject:To; b=PZiVBgvH3ddtoR2/cDZY36/AN17Wsby6vx3McaFa8YcrF14pAl9YKjyoqFzfbbFP4Kl 0MEsoEDr2njDonIoKQ1Ozoys/Y/jlm6Pu/g/5dL41dCgT86+vSXcSu3YYYR6B0d5++DON fk7Wfeny5SE6JZemz8yplOamNI6b4pCNGBk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139562402100026 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3751 Current MM communicate routine from ArmPkg would conduct few checks prior to proceeding with SMC calls. However, the inspection step is different from PI specification. This patch updated MM communicate input argument inspection routine to assure that "if the `MessageLength` is zero, or too large for the MM implementation to manage, the MM implementation must update the `MessageLength` to reflect the size of the `Data` buffer that it can tolerate", as described by `EFI_MM_COMMUNICATION_PROTOCOL.Communicate()` section in PI specification. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Cc: Sami Mujawar Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 4 of 4 [Ard] - Uncrustify style update =20 v3: - Added cc entry and reviewed-by tag [Sami] ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 2f89b7c5b6c4..85d9034555f0 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -92,6 +92,7 @@ MmCommunication2Communicate ( return EFI_INVALID_PARAMETER; } =20 + Status =3D EFI_SUCCESS; CommunicateHeader =3D CommBufferVirtual; // CommBuffer is a mandatory parameter. Hence, Rely on // MessageLength + Header to ascertain the @@ -109,28 +110,33 @@ MmCommunication2Communicate ( (*CommSize > mNsCommBuffMemRegion.Length)) { *CommSize =3D mNsCommBuffMemRegion.Length; - return EFI_BAD_BUFFER_SIZE; + Status =3D EFI_BAD_BUFFER_SIZE; } =20 // // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMU= NICATE_HEADER); // if (*CommSize < BufferSize) { - return EFI_INVALID_PARAMETER; + Status =3D EFI_INVALID_PARAMETER; } } =20 // - // If the buffer size is 0 or greater than what can be tolerated by the = MM + // If the message length is 0 or greater than what can be tolerated by t= he MM // environment then return the expected size. // - if ((BufferSize =3D=3D 0) || + if ((CommunicateHeader->MessageLength =3D=3D 0) || (BufferSize > mNsCommBuffMemRegion.Length)) { CommunicateHeader->MessageLength =3D mNsCommBuffMemRegion.Length - sizeof (CommunicateHeader->HeaderGu= id) - sizeof (CommunicateHeader->MessageL= ength); - return EFI_BAD_BUFFER_SIZE; + Status =3D EFI_BAD_BUFFER_SIZE; + } + + // MessageLength or CommSize check has failed, return here. + if (EFI_ERROR (Status)) { + return Status; } =20 // SMC Function ID --=20 2.34.1.windows.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 (#86071): https://edk2.groups.io/g/devel/message/86071 Mute This Topic: https://groups.io/mt/88680225/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-