From nobody Sat May 4 17:00:56 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+82128+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+82128+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1634288830; cv=none; d=zohomail.com; s=zohoarc; b=gpb5ZdPkjrzeBChvQH//A7GfE7raPXKJ8rq6j0QMSDGmQtQBgcXFRXSD1ENoUrL4vsqWeX89ZcWsjmSsg7zy71yov6QCVWkl9vXGq5qdhKpCJr6azqY7XvcnH2uaRomC2IvlYvoI3C3uFF4+h1DQW950KlBEBEUu6imB0XJqFKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634288830; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=A6gGEvDTVtsgrz8ohpTqkzZHr6URL0sFrUg/M6e4ZPc=; b=bxjVIVbC+zW0Z7N6a4Efdr8CzKn7lD/zCGmruSHPDMNTbp6zuMSog7L34VpDhd0Tp5kY/C+pLGyo08dJm7i6Osu+bw9mi699Rn1RZbqggkqqJuRZHveTu7e1fR3XVIzlQPv/ZyIwlp1P6TLOckdKitZX3/v+Tq3eAfeYexInL4k= 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+82128+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 1634288830919797.8539436091958; Fri, 15 Oct 2021 02:07:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id V4jYYY1788612xsGvQXyrZDi; Fri, 15 Oct 2021 02:07:10 -0700 X-Received: from out4436.biz.mail.alibaba.com (out4436.biz.mail.alibaba.com [47.88.44.36]) by mx.groups.io with SMTP id smtpd.web09.7035.1634288828981080073 for ; Fri, 15 Oct 2021 02:07:09 -0700 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=huangming@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Us71SiA_1634288787; X-Received: from 842effaa37a8.tbsite.net(mailfrom:huangming@linux.alibaba.com fp:SMTPD_---0Us71SiA_1634288787) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Oct 2021 17:06:55 +0800 From: "Ming Huang" To: devel@edk2.groups.io, sami.mujawar@arm.com, ardb+tianocore@kernel.org, jiewen.yao@intel.com, supreeth.venkatesh@arm.com Cc: ming.huang-@outlook.com, Ming Huang Subject: [edk2-devel] [PATCH edk2 v1 1/3] StandaloneMmPkg: Fix issue about SpPcpuSharedBufSize field Date: Fri, 15 Oct 2021 17:06:21 +0800 Message-Id: <20211015090623.52511-2-huangming@linux.alibaba.com> In-Reply-To: <20211015090623.52511-1-huangming@linux.alibaba.com> References: <20211015090623.52511-1-huangming@linux.alibaba.com> 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,huangming@linux.alibaba.com X-Gm-Message-State: WOooOgZ38mJOXLCsSrIKdzj0x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634288830; bh=f2wxP9e2fxgzjKrMyyF1+kXy1ckgyC2y7biUch9ui4w=; h=Cc:Date:From:Reply-To:Subject:To; b=YL8jKJexB2G1Zno/rSq/1bPYpTtINNLPszE5JfHCehx0t3od5dZgPloJ+MVlyIra+rT sWQy/GZJePK1j+Uie9T4jWKOY3fyHkWt2xvagnl1NbSmJshV/wstdUEr0PWxTfANEUdCl sO7ZrPh4vzKXMrWBtMP960Dj43FadSkKuJg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634288831305100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" TF-A: TrustedFirmware-A SPM: Secure Partition Manager(MM) In TF-A, the name of this field is sp_shared_buf_size. This field is the size of range for transmit data from TF-A to standaloneMM when SPM enable. SpPcpuSharedBufSize is pass from TF-A while StandaloneMM initialize. So, SpPcpuSharedBufSize should be rename to SpSharedBufSize and this field should no multiply by PayloadBootInfo->NumCpus; Signed-off-by: Ming Huang --- StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h = | 2 +- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c = | 2 +- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEnt= ryPoint.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint= .h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h index c44f7066c6..f1683ecb61 100644 --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h @@ -41,7 +41,7 @@ typedef struct { UINT64 SpPcpuStackSize; UINT64 SpHeapSize; UINT64 SpNsCommBufSize; - UINT64 SpPcpuSharedBufSize; + UINT64 SpSharedBufSize; UINT32 NumSpMemRegions; UINT32 NumCpus; EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateH= obList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHob= List.c index 85f8194687..93773c9fe8 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c @@ -173,7 +173,7 @@ CreateHobListFromBootInfo ( // Base and size of buffer shared with privileged Secure world software MmramRanges[1].PhysicalStart =3D PayloadBootInfo->SpSharedBufBase; MmramRanges[1].CpuStart =3D PayloadBootInfo->SpSharedBufBase; - MmramRanges[1].PhysicalSize =3D PayloadBootInfo->SpPcpuSharedBufSize * = PayloadBootInfo->NumCpus; + MmramRanges[1].PhysicalSize =3D PayloadBootInfo->SpSharedBufSize; MmramRanges[1].RegionState =3D EFI_CACHEABLE | EFI_ALLOCATED; =20 // Base and size of buffer used for synchronous communication with Normal diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standal= oneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/= Arm/StandaloneMmCoreEntryPoint.c index 49cf51a789..5db7019dda 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCo= reEntryPoint.c @@ -87,7 +87,7 @@ GetAndPrintBootinformation ( DEBUG ((DEBUG_INFO, "SpPcpuStackSize - 0x%x\n", PayloadBootInfo->SpPcpuS= tackSize)); DEBUG ((DEBUG_INFO, "SpHeapSize - 0x%x\n", PayloadBootInfo->SpHeapS= ize)); DEBUG ((DEBUG_INFO, "SpNsCommBufSize - 0x%x\n", PayloadBootInfo->SpNsCom= mBufSize)); - DEBUG ((DEBUG_INFO, "SpPcpuSharedBufSize - 0x%x\n", PayloadBootInfo->SpP= cpuSharedBufSize)); + DEBUG ((DEBUG_INFO, "SpSharedBufSize - 0x%x\n", PayloadBootInfo->SpShare= dBufSize)); =20 DEBUG ((DEBUG_INFO, "NumCpus - 0x%x\n", PayloadBootInfo->NumCpus= )); DEBUG ((DEBUG_INFO, "CpuInfo - 0x%p\n", PayloadBootInfo->CpuInfo= )); --=20 2.17.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 (#82128): https://edk2.groups.io/g/devel/message/82128 Mute This Topic: https://groups.io/mt/86334819/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 4 17:00:56 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+82126+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+82126+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1634288820; cv=none; d=zohomail.com; s=zohoarc; b=KpLhAcJY9rFfbmRfRCwu/cvMzWBakwNDQqE9W29W8eZKpzGrJGd18mVPD/ouacRa/QgiZJGHI+nXGA0uHDfYNWVhiXvz3UkHwLlfrywoWki1Xjc7T3JMFEtuYma4bBcszrMri4LGGHWJef8HL+zkjTwZKt/4YFUWri5wYFFqcQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634288820; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=LuNVTP8Grb2v/qGb+XRyLjpL2jMvWFMkD+ETiaRZADw=; b=lXTaCzbIX7YNrvFRsnUlQZac53d/lbpAI4qIpnZKS1tKKLxhoSI60MdHrMfOHIsXmw3LXUFLSO9c846f4P9qXP5Rxlwljx2zZbnfFPeUIlQRrKTmMbsqg/w0sp5RHjUg0Hidj8HyfElTE9onJEtyGGA/6/pXA305MvCwVwzP/iQ= 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+82126+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 1634288820216582.5038292463897; Fri, 15 Oct 2021 02:07:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id k1NsYY1788612xINsL6Hxnpd; Fri, 15 Oct 2021 02:06:59 -0700 X-Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by mx.groups.io with SMTP id smtpd.web08.7055.1634288818694755488 for ; Fri, 15 Oct 2021 02:06:59 -0700 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R671e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=huangming@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Us71SiA_1634288787; X-Received: from 842effaa37a8.tbsite.net(mailfrom:huangming@linux.alibaba.com fp:SMTPD_---0Us71SiA_1634288787) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Oct 2021 17:06:56 +0800 From: "Ming Huang" To: devel@edk2.groups.io, sami.mujawar@arm.com, ardb+tianocore@kernel.org, jiewen.yao@intel.com, supreeth.venkatesh@arm.com Cc: ming.huang-@outlook.com, Ming Huang Subject: [edk2-devel] [PATCH edk2 v1 2/3] StandaloneMmPkg: Replace DEBUG_INFO with DEBUG_ERROR Date: Fri, 15 Oct 2021 17:06:22 +0800 Message-Id: <20211015090623.52511-3-huangming@linux.alibaba.com> In-Reply-To: <20211015090623.52511-1-huangming@linux.alibaba.com> References: <20211015090623.52511-1-huangming@linux.alibaba.com> 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,huangming@linux.alibaba.com X-Gm-Message-State: oLCXQxGA5jctAFxIBhr0msxix1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634288819; bh=mAhKG6fyCt3ZGiuMz1LZXzbVJUTGMkaarlGsTxEFrfY=; h=Cc:Date:From:Reply-To:Subject:To; b=e7/P/iPti2mB9INcfbDfDfTAv5y/G7ulfbX1uyevhEtrRlRVWSALAoIpHEXII1NMzuz +7CjhcspPbk+FkEt1NyfxnXG09YcZli4bKitlf3poIHDN2TlOPvvpOREsjklGb2axf60w mPdddmbXGwPJuNLC6zAE1kWDAiH5hQ9CPG0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634288820519100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" DEBUG_ERROR should be used in error branch. Signed-off-by: Ming Huang --- StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c | 6 +++--- StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/Standa= loneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c index 165d696f99..5dfaf9d751 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c @@ -95,7 +95,7 @@ PiMmStandaloneArmTfCpuDriverEntry ( // if ((ARM_SMC_ID_MM_COMMUNICATE !=3D EventId) && (ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ !=3D EventId)) { - DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId)); + DEBUG ((DEBUG_ERROR, "UnRecognized Event - 0x%x\n", EventId)); return EFI_INVALID_PARAMETER; } =20 @@ -133,7 +133,7 @@ PiMmStandaloneArmTfCpuDriverEntry ( ); =20 if (Status !=3D EFI_SUCCESS) { - DEBUG ((DEBUG_INFO, "Mem alloc failed - 0x%x\n", EventId)); + DEBUG ((DEBUG_ERROR, "Mem alloc failed - 0x%x\n", EventId)); return EFI_OUT_OF_RESOURCES; } =20 @@ -156,7 +156,7 @@ PiMmStandaloneArmTfCpuDriverEntry ( mMmst->CpuSaveState =3D NULL; =20 if (mMmEntryPoint =3D=3D NULL) { - DEBUG ((DEBUG_INFO, "Mm Entry point Not Found\n")); + DEBUG ((DEBUG_ERROR, "Mm Entry point Not Found\n")); return EFI_UNSUPPORTED; } =20 diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/St= andaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c index 10097f792f..fd9c59b4da 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c @@ -143,7 +143,7 @@ StandaloneMmCpuInitialize ( =20 // Bail out if the Hoblist could not be found if (Index >=3D mMmst->NumberOfTableEntries) { - DEBUG ((DEBUG_INFO, "Hoblist not found - 0x%x\n", Index)); + DEBUG ((DEBUG_ERROR, "Hoblist not found - 0x%x\n", Index)); return EFI_OUT_OF_RESOURCES; } =20 @@ -158,7 +158,7 @@ StandaloneMmCpuInitialize ( (VOID **) &CpuDriverEntryPointDesc ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "ArmTfCpuDriverEpDesc HOB data extraction failed -= 0x%x\n", Status)); + DEBUG ((DEBUG_ERROR, "ArmTfCpuDriverEpDesc HOB data extraction failed = - 0x%x\n", Status)); return Status; } =20 @@ -176,7 +176,7 @@ StandaloneMmCpuInitialize ( (VOID **) &NsCommBufMmramRange ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "NsCommBufMmramRange HOB data extraction failed - = 0x%x\n", Status)); + DEBUG ((DEBUG_ERROR, "NsCommBufMmramRange HOB data extraction failed -= 0x%x\n", Status)); return Status; } =20 @@ -195,7 +195,7 @@ StandaloneMmCpuInitialize ( (VOID **) &MpInformationHobData ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "MpInformationHob extraction failed - 0x%x\n", Sta= tus)); + DEBUG ((DEBUG_ERROR, "MpInformationHob extraction failed - 0x%x\n", St= atus)); return Status; } =20 @@ -213,7 +213,7 @@ StandaloneMmCpuInitialize ( (VOID **) &mMpInformationHobData ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "mMpInformationHobData mem alloc failed - 0x%x\n",= Status)); + DEBUG ((DEBUG_ERROR, "mMpInformationHobData mem alloc failed - 0x%x\n"= , Status)); return Status; } =20 @@ -243,7 +243,7 @@ StandaloneMmCpuInitialize ( (VOID **) &PerCpuGuidedEventContext ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\= n", Status)); + DEBUG ((DEBUG_ERROR, "PerCpuGuidedEventContext mem alloc failed - 0x%x= \n", Status)); return Status; } return Status; --=20 2.17.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 (#82126): https://edk2.groups.io/g/devel/message/82126 Mute This Topic: https://groups.io/mt/86334814/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 4 17:00:56 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+82127+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+82127+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1634288821; cv=none; d=zohomail.com; s=zohoarc; b=eW9XCHkbJln3ZFTFxrg30uJUlMimFl9R5zuG+Pg6hq8mi+mVyTzWHTrE2X6mXOlvIe/NGLhmbYcmUwfaLq604xZOTCEOpJ1xpMN3CF66Y82l1dkwszWcdVA7iljKCYZaRLDn/T6jPnlfgIeaPtV+lfyCXwOMTXOjEilUcFmEdyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634288821; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=teK1KEcDkInZnL3yHtxylB+DHDw4yDpIJzs2cHQqIGA=; b=SdqnfE9w+vp67LbhCeT2Z5nCVCxNEWwpoHvj0cRep0eMyqcoIPnCoy/2rTXVnjJbawVG+Ds8PmWXdeUtySsGzMl5lcf4vVPFvZ9aw70GUDK2gRUVaWInLsbf6V6CW1nJOqXDB4bISINSAwhenBIjGUTZ+Nae/j7YO4kOLnpzn6Q= 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+82127+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 1634288821106468.92240363698966; Fri, 15 Oct 2021 02:07:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id miysYY1788612xWIKOd4BS7c; Fri, 15 Oct 2021 02:07:00 -0700 X-Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by mx.groups.io with SMTP id smtpd.web08.7056.1634288820132675548 for ; Fri, 15 Oct 2021 02:07:00 -0700 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=huangming@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Us71SiA_1634288787; X-Received: from 842effaa37a8.tbsite.net(mailfrom:huangming@linux.alibaba.com fp:SMTPD_---0Us71SiA_1634288787) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Oct 2021 17:06:57 +0800 From: "Ming Huang" To: devel@edk2.groups.io, sami.mujawar@arm.com, ardb+tianocore@kernel.org, jiewen.yao@intel.com, supreeth.venkatesh@arm.com Cc: ming.huang-@outlook.com, Ming Huang Subject: [edk2-devel] [PATCH edk2 v1 3/3] StandaloneMmPkg: Fix check buffer address failed issue from TF-A Date: Fri, 15 Oct 2021 17:06:23 +0800 Message-Id: <20211015090623.52511-4-huangming@linux.alibaba.com> In-Reply-To: <20211015090623.52511-1-huangming@linux.alibaba.com> References: <20211015090623.52511-1-huangming@linux.alibaba.com> 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,huangming@linux.alibaba.com X-Gm-Message-State: DLbCNlQeJEh3oQZRozI0dogTx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634288820; bh=UcYMJ7Upxs7IYuvJMwcuIR1EGBElu3new6PBA5vGSTo=; h=Cc:Date:From:Reply-To:Subject:To; b=TRCrEbbAxXZgOy0Jgrl0Cyw9erDTHZkb7Bk0Uf2ecg24dNCZfN3h+hBnTrABIunLZI8 JF2IIGMJf4tEmEzRMLmv7k3m9A1ZEKaE7V8iDNfAQvVsK+8uzUOXnFHRVq1vWj9iMQEHM k+GBkQ3oi95Kaksv02SEcCUsKP8N8mZddyA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634288822666100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are two scene communicate with StandaloneMm(MM): 1 edk2 -> TF-A -> MM, communicate MM use non-secure buffer which specify by EFI_SECURE_PARTITION_BOOT_INFO.SpNsCommBufBase; 2 RAS scene: fiq -> TF-A -> MM, use secure buffer which specify by EFI_SECURE_PARTITION_BOOT_INFO.SpShareBufBase; For now, the second scene will failed because check buffer address. This patch add CheckBufferAddr() to support check address for secure buffer. Signed-off-by: Ming Huang --- StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c | 70 +++++++++++= +++++---- StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c | 21 ++++++ StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h | 1 + 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/Standa= loneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c index 5dfaf9d751..63fab1bd78 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c @@ -50,6 +50,7 @@ EFI_MM_COMMUNICATE_HEADER **PerCpuGuidedEventContext =3D = NULL; =20 // Descriptor with whereabouts of memory used for communication with the n= ormal world EFI_MMRAM_DESCRIPTOR mNsCommBuffer; +EFI_MMRAM_DESCRIPTOR mSCommBuffer; =20 MP_INFORMATION_HOB_DATA *mMpInformationHobData; =20 @@ -60,6 +61,58 @@ EFI_MM_CONFIGURATION_PROTOCOL mMmConfig =3D { =20 STATIC EFI_MM_ENTRY_POINT mMmEntryPoint =3D NULL; =20 +STATIC +EFI_STATUS +CheckBufferAddr ( + IN UINTN CommBufferAddr + ) +{ + UINTN CommBufferSize; + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; + if (CommBufferAddr < mNsCommBuffer.PhysicalStart) { + Status =3D EFI_ACCESS_DENIED; + } + + if ((CommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=3D + (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) { + Status =3D EFI_INVALID_PARAMETER; + } + + // Find out the size of the buffer passed + CommBufferSize =3D ((EFI_MM_COMMUNICATE_HEADER *) CommBufferAddr)->Messa= geLength + + sizeof (EFI_MM_COMMUNICATE_HEADER); + + // perform bounds check. + if (CommBufferAddr + CommBufferSize >=3D + mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) { + Status =3D EFI_ACCESS_DENIED; + } + + if (!EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + + Status =3D EFI_SUCCESS; + if (CommBufferAddr < mSCommBuffer.PhysicalStart) { + Status =3D EFI_ACCESS_DENIED; + } + + if ((CommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=3D + (mSCommBuffer.PhysicalStart + mSCommBuffer.PhysicalSize)) { + Status =3D EFI_INVALID_PARAMETER; + } + + // perform bounds check. + if (CommBufferAddr + CommBufferSize >=3D + mSCommBuffer.PhysicalStart + mSCommBuffer.PhysicalSize) { + Status =3D EFI_ACCESS_DENIED; + } + + return Status; +} + /** The PI Standalone MM entry point for the TF-A CPU driver. =20 @@ -104,25 +157,16 @@ PiMmStandaloneArmTfCpuDriverEntry ( return EFI_INVALID_PARAMETER; } =20 - if (NsCommBufferAddr < mNsCommBuffer.PhysicalStart) { - return EFI_ACCESS_DENIED; - } - - if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=3D - (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) { - return EFI_INVALID_PARAMETER; + Status =3D CheckBufferAddr (NsCommBufferAddr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Check Buffer failed: %r\n", Status)); + return Status; } =20 // Find out the size of the buffer passed NsCommBufferSize =3D ((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->M= essageLength + sizeof (EFI_MM_COMMUNICATE_HEADER); =20 - // perform bounds check. - if (NsCommBufferAddr + NsCommBufferSize >=3D - mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) { - return EFI_ACCESS_DENIED; - } - GuidedEventContext =3D NULL; // Now that the secure world can see the normal world buffer, allocate // memory to copy the communication buffer to the secure world. diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/St= andaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c index fd9c59b4da..96dad20dd1 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c @@ -107,6 +107,7 @@ StandaloneMmCpuInitialize ( UINTN Index; UINTN ArraySize; VOID *HobStart; + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob; =20 ASSERT (SystemTable !=3D NULL); mMmst =3D SystemTable; @@ -186,6 +187,26 @@ StandaloneMmCpuInitialize ( CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof(EFI_MMRAM_DESCRIPTO= R)); DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.C= puStart, mNsCommBuffer.PhysicalSize)); =20 + Status =3D GetGuidedHobData ( + HobStart, + &gEfiMmPeiMmramMemoryReserveGuid, + (VOID **) &MmramRangesHob + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "MmramRangesHob data extraction failed - 0x%x\n",= Status)); + return Status; + } + + // + // As CreateHobListFromBootInfo(), the base and size of buffer shared wi= th + // privileged Secure world software is in second one. + // + CopyMem ( + &mSCommBuffer, + &MmramRangesHob->Descriptor[0] + 1, + sizeof(EFI_MMRAM_DESCRIPTOR) + ); + // // Extract the MP information from the Hoblist // diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h b/St= andaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h index 2c96439c15..2e03b20d85 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h @@ -30,6 +30,7 @@ extern EFI_MM_CPU_PROTOCOL mMmCpuState; // extern EFI_MM_COMMUNICATE_HEADER **PerCpuGuidedEventContext; extern EFI_MMRAM_DESCRIPTOR mNsCommBuffer; +extern EFI_MMRAM_DESCRIPTOR mSCommBuffer; extern MP_INFORMATION_HOB_DATA *mMpInformationHobData; extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig; =20 --=20 2.17.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 (#82127): https://edk2.groups.io/g/devel/message/82127 Mute This Topic: https://groups.io/mt/86334815/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-