From nobody Mon May 6 15:34:06 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+85117+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+85117+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050453; cv=none; d=zohomail.com; s=zohoarc; b=A4I+pesHT5GN6yRkJdpm+wgyvoR7wh7Rje4IU/Z4o3nxCQcvhvCsvL6P76hvImXjwTba/39hEuHjhw/rRS8G264yJd8iBsL9YV2a93/g1j6VTDROOQt9vzcN2ZS9qfTubPfVlY7gqBp9R6uY6DEhEFKQMWRPGyuvO4zmJFyzT0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050453; 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=Q/ROYjSod+VsvaE5v1eGVGQUzmGxZ3Ki3/TxboOS07w=; b=QYmrzvExkKIzui3kZU5HmSp6f3BTikyNhYHJ+VxmcUl+E58LQd9KGSe8A9jgRn8E+6F0drAlqsyA+Z43osiFSgsjZwBKHc1ieS0pShG8J3RJvJyBL8Dpn/qWpD7Lp6FoVYyf4sKTZnbKhuF2U/fCwZCPdI3NvpdGWM9QxqqEzWM= 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+85117+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 1640050453778976.6113711690033; Mon, 20 Dec 2021 17:34:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id CgetYY1788612x6QkWRUSrLH; Mon, 20 Dec 2021 17:34:13 -0800 X-Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web09.706.1640050451790656732 for ; Mon, 20 Dec 2021 17:34:11 -0800 X-Received: by mail-pj1-f49.google.com with SMTP id n15-20020a17090a394f00b001b0f6d6468eso931342pjf.3 for ; Mon, 20 Dec 2021 17:34:11 -0800 (PST) X-Gm-Message-State: HiJ6RNH9rOoyZ3AphFhvQZqix1787277AA= X-Google-Smtp-Source: ABdhPJyEvY5EY+UIHIGHQ0/Q4EHFDJ8+J2igVaeLYEIu9NoKLDK6M4m8PjUo+zMfiOCO8IeXI102fQ== X-Received: by 2002:a17:90a:d195:: with SMTP id fu21mr1014915pjb.106.1640050451241; Mon, 20 Dec 2021 17:34:11 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:11 -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 v2 1/6] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Date: Mon, 20 Dec 2021 17:33:29 -0800 Message-Id: <20211221013334.1751-2-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050453; bh=PBMB68FiJChry8aAFcJhUwyfk5oLbUdpbOqdz7KWBeE=; h=Cc:Date:From:Reply-To:Subject:To; b=lTRg7YZlJUal2OSOhEObUMFoqny7ToQeiLU1ZMcSCcs00xwz/23rYxQGuCiP0aE888T +LwNRUhnW7FT5UD0nl0bga+4PQNrK16yVYX1A1Qn8vLqKhBZcWch4VtHeaVuHRquUnIsp mv0VD9GtfDHgSV2ol+2yi4VkG8TqCnXIFuo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050455244100011 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 Reviewed-by: Sami Mujawar --- Notes: v2: - No review, no updates 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.32.0.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 (#85117): https://edk2.groups.io/g/devel/message/85117 Mute This Topic: https://groups.io/mt/87869772/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 Mon May 6 15:34:06 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+85118+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+85118+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050453; cv=none; d=zohomail.com; s=zohoarc; b=mRwEx+NC07fbiYQvL64IB3ye7cONVOr5UIZGQW0ggb4Mhu/GQm/zjZV7T02/BYBHkn1BDSnvy+wnX1N3JpxBT7fWCAI/yCVPETMksq+krwl9xwnuZHDJ/+vsIyj5xRPhEAGV/W3Iz074DaA/PNlrU7WCFdWFahDeAwBhc9w3Ujw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050453; 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=8cC36n7tzeXb/CugWbD+tKx600JFCYT0r8ojijGKdc0=; b=GTBV4dc8hlfy5Bs2hNEGikBIQx3qKBcwp0sgOkO7s0LE9sGEwx6+ncVg6UhhKRPJ++bPwdT2buEkv70+BRMDjnflbrefhePnzXIy9fgyeOaxRPlkosULZ2en0m+mMFkYhqhZXpcn0IeJYEEmyUwmimeADdlTIMUu4MQ52y+3xSM= 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+85118+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 1640050453339246.46961888512703; Mon, 20 Dec 2021 17:34:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KpHOYY1788612xsSY3exUNgq; Mon, 20 Dec 2021 17:34:13 -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.web10.748.1640050452334723822 for ; Mon, 20 Dec 2021 17:34:12 -0800 X-Received: by mail-pj1-f43.google.com with SMTP id n15-20020a17090a394f00b001b0f6d6468eso931357pjf.3 for ; Mon, 20 Dec 2021 17:34:12 -0800 (PST) X-Gm-Message-State: nl2z9QsMOsxHLzIWqKCIregPx1787277AA= X-Google-Smtp-Source: ABdhPJzueoLSDibreL86uAa7rsBNP9yfAmAbJUMVNXxlkpFnaTjtf/YSxpQ6KGflMs5d3X/R/KixwQ== X-Received: by 2002:a17:90b:1bd2:: with SMTP id oa18mr1225646pjb.4.1640050451778; Mon, 20 Dec 2021 17:34:11 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:11 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v2 2/6] MdePkg: MmCommunication2: Update MM communicate2 function description Date: Mon, 20 Dec 2021 17:33:30 -0800 Message-Id: <20211221013334.1751-3-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050453; bh=mbcoMkAvLdIg0yU/KnbGSPp+8w17XUQOgpZF1IHy/U0=; h=Cc:Date:From:Reply-To:Subject:To; b=lClN07iD0qKPFzfcEMVBPheTxjf12IO96oGwHlffUCJvUAp2y6T+KtLBqNVwuA/mEkH m98yzJQjqdDK6oP/nBLdEE/v/ODS8dyy6V8786i7zGyR8QpBtTP5Es+Tf+2hnAGebObkX E3kyLTwOCSGhr63baaCpuQDkON6fGAiVOd4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050455163100007 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 Reviewed-by: Sami Mujawar --- Notes: v2: - Newly added 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.32.0.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 (#85118): https://edk2.groups.io/g/devel/message/85118 Mute This Topic: https://groups.io/mt/87869773/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 Mon May 6 15:34:06 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+85119+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+85119+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050454; cv=none; d=zohomail.com; s=zohoarc; b=AM2woHfX0ezKK+t1/NPl9zSfuvBSqXFEuZZbh8a0FZPwdY7KOwVttAblL/Y4zolBndoxXvUnh84/2MG4zNsuLw2whlrSJRufUKnt3jZT6eALegSaVq884b4TQbldH/0K0T1IHrVkjDoNMwLAAZd2BsfDQd2/v5iBSdqUZm2VlRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050454; 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=oBNE/o3cerp2S/sucJzLyrGGRXR2sy0ONFxWHeVdUUo=; b=E4FQBVZ6mplkgEawv9IfkaEqBkYn7Hyy13otY4bxBmySif+F1LkBvxw8EMqyW/57+kgeBj5eBhmPBfmmRgGIGZ+kdnIu/Twj16mo/ZvMS3GUdAMbt5ufRAAemHylcOc4mT7XlabnfeZSErmuVQpeUUz4frRiwCj4w9+COXqrULc= 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+85119+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 1640050454068520.6603685011863; Mon, 20 Dec 2021 17:34:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id udmwYY1788612xdYHjk88S27; Mon, 20 Dec 2021 17:34:13 -0800 X-Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mx.groups.io with SMTP id smtpd.web12.754.1640050452880002752 for ; Mon, 20 Dec 2021 17:34:12 -0800 X-Received: by mail-pl1-f179.google.com with SMTP id n16so8702486plc.2 for ; Mon, 20 Dec 2021 17:34:12 -0800 (PST) X-Gm-Message-State: OQMwA61j4cpFFb1CLekLNtkCx1787277AA= X-Google-Smtp-Source: ABdhPJxlUfNH+rYyi9LtaiUoLZJj4ZJcSpQU2P0SLXyd6afyNHZnF2n6fvZ9S37azRVzPouJKpoEMA== X-Received: by 2002:a17:90a:1bc1:: with SMTP id r1mr1021780pjr.66.1640050452365; Mon, 20 Dec 2021 17:34:12 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:12 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v2 3/6] ArmPkg: MmCommunicationDxe: MM communicate function argument attributes Date: Mon, 20 Dec 2021 17:33:31 -0800 Message-Id: <20211221013334.1751-4-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050453; bh=HWn9itgsPmnT1TuQVpS6Q5r+cWQkYOHDKuTpNpG3vA0=; h=Cc:Date:From:Reply-To:Subject:To; b=uBWfydqFyniuosyIuLdA+Wnp/9LoaR8wwNdTQzcD7eR5YPBH+Wut24KYYNf63wlLaQv 2tft36sdgvvrZDY7iLxRiOAtwTuo106h2RlmdEefJVFL7Rjz0WHFcCHlaBIL/FxwvvEu+ IzA8/fTJJ+1kih17MUptcQFhddK5p8r0+6A= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050455286100013 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 Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 1 of 4 [Ard] 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.32.0.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 (#85119): https://edk2.groups.io/g/devel/message/85119 Mute This Topic: https://groups.io/mt/87869775/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 Mon May 6 15:34:06 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+85120+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+85120+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050454; cv=none; d=zohomail.com; s=zohoarc; b=nHsb4bghHGbh36yw4LqxaL06Oo/isIrD8T4wJo+f3t1Jj/g3vpbjI1OA+Xr5jJ0RezWjaZ33cGi4fzijY9kPuC4G4Epiaf2K4Es7jDypV0gu+nAIGJV+/agkI6Xa/8MhWPoya1lJS8q9eIznoCYiL/KsL1S1OGi/Ppj4BnLYmmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050454; 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=N0bXoBYbKJjdHu8mRzg8X/ZvWQGoUpbifVX7d6ZTJLo=; b=AScXwwSYoJJ5KrO99BpTzbSfHTU4tZ2r0c503nHIV8UJRUT12c2P5UzKXUR1TLreaTh5ngoJB9rs+J5HMlcR8Uu1fv0cV3ODgQOaPXGWS5PBHIk37RHlcVD8vCw9WbjoJ08vhVjp0R4wL5Qh2eQjaTT+pc/Tr3E8f928Y1dsWQc= 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+85120+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 164005045450079.48822367378273; Mon, 20 Dec 2021 17:34:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9mD2YY1788612xvvjD4SP5Vl; Mon, 20 Dec 2021 17:34:14 -0800 X-Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mx.groups.io with SMTP id smtpd.web11.751.1640050453513536920 for ; Mon, 20 Dec 2021 17:34:13 -0800 X-Received: by mail-pj1-f41.google.com with SMTP id co15so11040141pjb.2 for ; Mon, 20 Dec 2021 17:34:13 -0800 (PST) X-Gm-Message-State: IpLpWT9HnCgCS3LhDBLy563kx1787277AA= X-Google-Smtp-Source: ABdhPJzqNHZHYTmx4E5rQZOIH4N51gPbIysjI7MoFxYWCXJNccu6PU3bz4CANTeht7ipacrr4YK4iw== X-Received: by 2002:a17:90a:db0f:: with SMTP id g15mr1213813pjv.76.1640050452986; Mon, 20 Dec 2021 17:34:12 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:12 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v2 4/6] ArmPkg: MmCommunicationDxe: Update MM communicate `CommBuffer**` checks Date: Mon, 20 Dec 2021 17:33:32 -0800 Message-Id: <20211221013334.1751-5-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050454; bh=dg1QSzCcHQAr6B2ez6nqQtVHHJ1J09dOBTVld2kSca8=; h=Cc:Date:From:Reply-To:Subject:To; b=JPkiJDfSC1+WGsDQdJwvwmEMoN4kGP0YeGNUVi7ZaIczkatfdP6aUjTDBcZMi5RZC5T +wcZsfS3IUHYe8kFX+TJitLoYKLr+rAouWlyEwtHvswKd65QKUjV582/uyartpFbugrYq qH8TnC3ptWEZnQpKeMgOL7nnaDc9L9rxAxo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050455370100018 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 Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 2 of 4 [Ard] - Uncrustify style update 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.32.0.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 (#85120): https://edk2.groups.io/g/devel/message/85120 Mute This Topic: https://groups.io/mt/87869776/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 Mon May 6 15:34:06 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+85121+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+85121+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050454; cv=none; d=zohomail.com; s=zohoarc; b=Gv5IPNwGK4o3SVfenph558yhF1ogUJZ9TglKvMemnoIz0q/ZYNoRQhjAP8aGlliJjAglXe72l40BQyvi+v6tO5vC6uPEabAwhwCWfnEL1TW53EwsWICfZbyTqif4i0LEXsykoumpdUW/aO2nxzNvWBL1kE+IzMt8U5Qb9xtrQkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050454; 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=vcMZJrNuZTEt1IfM76UJz0cKOHl1QHah+kH+jlzmPDQ=; b=jaxC/4Ox5qXDGfaRuNDzp2So5Pfv1cVGvz4vMDbKiNePS7UeXlJdduAbxzukX4gaOwOKQWBiWMG09U8e6kKDO7w4Wnfd8qJEjdrhGzOnPCD1bEG6TY8pX+LkGgM5L03tEDkUJmzVp2dbKCThUWS7frP2dZuG1Nc/2H/SKfVBY6M= 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+85121+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 1640050454954186.32779176376118; Mon, 20 Dec 2021 17:34:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tLUJYY1788612xIXTGzCrbOp; Mon, 20 Dec 2021 17:34:14 -0800 X-Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mx.groups.io with SMTP id smtpd.web10.749.1640050454139681830 for ; Mon, 20 Dec 2021 17:34:14 -0800 X-Received: by mail-pj1-f54.google.com with SMTP id f18-20020a17090aa79200b001ad9cb23022so1663334pjq.4 for ; Mon, 20 Dec 2021 17:34:14 -0800 (PST) X-Gm-Message-State: evCs0en6Wm6BDTm4j0TOvt30x1787277AA= X-Google-Smtp-Source: ABdhPJxTnBnkRVWtb1SF1HQcgpZcDiAzTjZ/kBcXVdpaKTsQeJj7xkEH9xfqmngJlpKOhkNyI1jHow== X-Received: by 2002:a17:90b:17cc:: with SMTP id me12mr989822pjb.179.1640050453593; Mon, 20 Dec 2021 17:34:13 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:13 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v2 5/6] ArmPkg: MmCommunicationDxe: Update MM communicate `CommSize` check Date: Mon, 20 Dec 2021 17:33:33 -0800 Message-Id: <20211221013334.1751-6-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050454; bh=pZNoa+tOeXqMm0gxMON38zDsdLE2rShFBTH2g2xNemc=; h=Cc:Date:From:Reply-To:Subject:To; b=fpaO3bb89ZhU2t8BxJkpwSwcWfPAwOYbKtRmSRY4VxUiR+ocEyITAdYrO5gh5wZPz7f KmGLNKp45YFxgLM4+8xior74PfeyCBfUHYzoF2MGVSDycgs00rR31mtRNOryzPj2jXPhK IUIKd29g6GyOOlozNXtiJU4lM3cIVlGbppU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050455427100021 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 Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 3 of 4 [Ard] 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.32.0.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 (#85121): https://edk2.groups.io/g/devel/message/85121 Mute This Topic: https://groups.io/mt/87869777/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 Mon May 6 15:34:06 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+85122+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+85122+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050456; cv=none; d=zohomail.com; s=zohoarc; b=iabZAloyfjsgj3keUIJflnEuzfxkw55+r/oV4KQOk8CDN7s9NiNS7W8gXeEN+lIRgdTfKV1wWTp7SAulinpNEwTB+BmniYzcNiesIcoYfGXbEnDskLJEbae41af5DzpKk5EFE7xw2xbMOSxBJ5bvjevwycypI4IQZScoy/cPwP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050456; 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=0gBqR0CgE6hyK8T/LRb+mFQS2FQm151SdGuRCdM/weo=; b=AyNKMjxBThINcb4nU2l1PuDyybisqZV1cegPBesXTidVdFDc4w/k19a44uglAEyCa04/KkuSLnPD6CiC7pETS911+QJqAnQ0BNIdaoP4mItW4kxFKM4jOLeXWerkX5ec9x5Xefh137N3hV6V5aSbLyCtIAJ7U0UtmGNEqUhzwwM= 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+85122+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 1640050456073156.89635114611656; Mon, 20 Dec 2021 17:34:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wM7iYY1788612xBtI6oQIy1g; Mon, 20 Dec 2021 17:34:15 -0800 X-Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mx.groups.io with SMTP id smtpd.web08.731.1640050454801596164 for ; Mon, 20 Dec 2021 17:34:14 -0800 X-Received: by mail-pj1-f53.google.com with SMTP id iy13so5610311pjb.5 for ; Mon, 20 Dec 2021 17:34:14 -0800 (PST) X-Gm-Message-State: z41Wqh9gmHkgWq70rt5B5rhOx1787277AA= X-Google-Smtp-Source: ABdhPJz6bWgTj9/98Id3II3c2m5nkLAs2GmBDTeBmdMK4NJZ4KnPvFtKTaczsfqfFi+TosC/KSQ5Ag== X-Received: by 2002:a17:90b:3d6:: with SMTP id go22mr966966pjb.221.1640050454263; Mon, 20 Dec 2021 17:34:14 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:14 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v2 6/6] ArmPkg: MmCommunicationDxe: Update MM communicate `MessageLength` check Date: Mon, 20 Dec 2021 17:33:34 -0800 Message-Id: <20211221013334.1751-7-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050455; bh=S47e+/T/cs9vkXhUWXctY0HUEyOQKkxb6F+bVTeYqmI=; h=Cc:Date:From:Reply-To:Subject:To; b=SPewd1nPoSxXZ09RhltECJCiR4XTBXXAz7YVq1D2krbOu3cYi1kP2E1GDapciUu/6fB mEJJpNCi10gMWLSmW9GsIRnHZ3Cu3HsLDUPzdGyygs1cpcEtSKMJyXrNO1cUsl+o1omcz Wsn+bPAAv5kwI5iGyRcxqXPtBYdpHZexc2c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050457535100028 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 Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 4 of 4 [Ard] - Uncrustify style update 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.32.0.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 (#85122): https://edk2.groups.io/g/devel/message/85122 Mute This Topic: https://groups.io/mt/87869778/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-