From nobody Fri May 17 08:39:22 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+109102+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+109102+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794771; cv=none; d=zohomail.com; s=zohoarc; b=JZPaQx2+1ch68MOtIkLLV5lfPgU1iBJtHT9psv+dS0D8ytcddJjV2IyV3yLzXpkEF7YZ3131wNJ1WpuD4jzUHx/668uzCj4cA/+LYrZ/yAy8StnH7D6RxeLuL6WnOTWulKwTQMEjNZIr+pOfOdIcfSTPApVRm9/2A5H17p/wZxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794771; 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=I+HYI9to3wuRX09tnplF2ScWHMjKGxxnn0LhuZKcpVM=; b=GVKu+wUeLvoQSBiuZHWbUzYD36ru+Mqr4I62adXQAkBRVm5/OleXlRYaxPtH2MMAcjj8AsvWPsyRhDHtSkx3tH3pgkhE3sIYjeX6THBRtwSG/G3ZvOaLf3t83ADNDVMZhXNQY14uLalt/VrCzVuMFr+WZOJFzAiQ5WypEZQD2RE= 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+109102+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695794771016908.1833929896978; Tue, 26 Sep 2023 23:06:11 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=/gGwruDnCPyiwmpXjl4IIQN83yU8kalRU2osix9FDLo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695794770; v=1; b=EXu418CgPSm2l+pwqhr7wu4uNivocefM4XEpT/rqnDKPWiOUhs/5XDt4+Y0sBgic3DYE9HaH h2eY5UGRJcjpXD6IZpXSLL49rd5mNocqYjLzCcFc6ZfGi2knAMuIKNg9qMU+fTjKpcKl8TqHI0d J17ABwXDkqi4+tqGYeg/vEc4= X-Received: by 127.0.0.2 with SMTP id egdLYY1788612xCVyMYp8Ja4; Tue, 26 Sep 2023 23:06:10 -0700 X-Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by mx.groups.io with SMTP id smtpd.web11.11800.1695794770022119417 for ; Tue, 26 Sep 2023 23:06:10 -0700 X-Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-79fe87cd74eso63749139f.3 for ; Tue, 26 Sep 2023 23:06:09 -0700 (PDT) X-Gm-Message-State: aD6zAehjCsR4utbdPQli63U8x1787277AA= X-Google-Smtp-Source: AGHT+IGUn7mU8L6JoMlRx76gqvgyEF7nF+Sw1QHruhs7BscmBQ918K/wnbCrS5fy3HR37qJboRO+4g== X-Received: by 2002:a05:6602:39a:b0:79f:da3d:c47f with SMTP id f26-20020a056602039a00b0079fda3dc47fmr1375767iov.13.1695794769060; Tue, 26 Sep 2023 23:06:09 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:08 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 1/5] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues Date: Wed, 27 Sep 2023 11:35:57 +0530 Message-Id: <20230927060601.443693-2-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794772430100007 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The functions CoreConvertSpace and CoreAllocateSpace in MdeModulePkg/Core/Dxe/Gcd/Gcd.c has ASSERT (FALSE); at lines 755 and 1155 which gets hit when Operation neither include GCD_MEMORY_SPACE_OPERATION nor include GCD_IO_SPACE_OPERATION but this comes into play only in DEBUG mode. In Release mode, the code continues to proceed in this undesirable case with Map variable still set to NULL and hence dereferencing "Map" will lead to CRASH. It is safer to add a debug message in this scenario and return from the function with EFI_INVALID_PARAMETER; The existing ASSERT may be retained or may be deleted whatever is deemed more appropriate. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 792cd2e0af23..39fa2adf9366 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -752,7 +752,9 @@ CoreConvertSpace ( CoreAcquireGcdIoLock (); Map =3D &mGcdIoSpaceMap; } else { + DEBUG ((DEBUG_GCD, " Status =3D %r\n", EFI_INVALID_PARAMETER)); ASSERT (FALSE); + return EFI_INVALID_PARAMETER; } =20 // @@ -1152,7 +1154,9 @@ CoreAllocateSpace ( CoreAcquireGcdIoLock (); Map =3D &mGcdIoSpaceMap; } else { + DEBUG ((DEBUG_GCD, " Status =3D %r\n", EFI_INVALID_PARAMETER)); ASSERT (FALSE); + return EFI_INVALID_PARAMETER; } =20 Found =3D FALSE; --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109102): https://edk2.groups.io/g/devel/message/109102 Mute This Topic: https://groups.io/mt/101612676/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 Fri May 17 08:39:22 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+109103+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+109103+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794773; cv=none; d=zohomail.com; s=zohoarc; b=SjZ43tgnR8Kr7AQjRa9jbXYXrHCiIbtDINglX668K+v/L4iuP0QyNpMEnx/4+4Lio4dN8oQAi+a3SSAIT9aRLb1FpqLK1ZXm+MMZKPlJzbJC4ySHskEfbz5SPAFZ6AsxiKqak+SbxZ+U731ijFwtcTb7Qd1PGnPl9PGd2YRVSDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794773; 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=UC/8hM5mugPcQRzRSuOAhlE1bfhFT5FnjQSL28wu5t0=; b=gBIfzuGT9nOOagx5PocN7FnA6klaUtQN2Q+F9OGaw0EuHv88fm4I+3B2/mOOiVf1s3Kpr1aC4PMi0402ej5ptThzgPCaSXbxErAvieJfcDBcxoJ865d6i33ErG/SEzo8IlbPZ120a4oacYyQAh/WhhPhYRq/6R1lbdnKB5PHJB0= 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+109103+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169579477330384.0749791792772; Tue, 26 Sep 2023 23:06:13 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=jrQ4k8PZ6y5t+266dUd5q2W32JUO/QP9tthQC/lDXEo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695794773; v=1; b=HdU34UoZ4w6+O8MMr0H7Qdyxvof//V0q6zGUQPMAXI1A0mCV3uF84R+uXxVYh4KD4DEshY/n XKvtmU0kPQu8pfIF3YZD9GloP5POCUaSBZGQ1/kMq4u0Lr0o7a1TamXbqhsUdk7h3Lwuhijx+qd foSFcUqf3CtOKXOFs+NFDms4= X-Received: by 127.0.0.2 with SMTP id WRxBYY1788612xsTe9f0hi5j; Tue, 26 Sep 2023 23:06:13 -0700 X-Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by mx.groups.io with SMTP id smtpd.web11.11801.1695794772448640883 for ; Tue, 26 Sep 2023 23:06:12 -0700 X-Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-79fa2dbd793so303654339f.2 for ; Tue, 26 Sep 2023 23:06:12 -0700 (PDT) X-Gm-Message-State: JJ9OXzCdMmHGUMl13kzgXRgQx1787277AA= X-Google-Smtp-Source: AGHT+IFMP8OiD5PlF0ZCH3xA85czSBHbLRa1cB/5TsGIjQ1McKUomQTdbfclDMcxN5ApWzmuTrZ1vQ== X-Received: by 2002:a05:6e02:1bc5:b0:34c:bc10:2573 with SMTP id x5-20020a056e021bc500b0034cbc102573mr1500692ilv.3.1695794771552; Tue, 26 Sep 2023 23:06:11 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:11 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 2/5] MdeModulePkg/Core/Dxe: Fix MISSING_BREAK Coverity issue Date: Wed, 27 Sep 2023 11:35:58 +0530 Message-Id: <20230927060601.443693-3-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794775161100011 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh The function CoreIsSchedulable has switch-case code in which case EFI_DEP_BEFORE: case EFI_DEP_AFTER: has a comment that // For a well-formed Dependency Expression, the code should never get here. It also has an ASSERT (FALSE); but this is applicable only in DEBUG mode. Seemingly, for RELEASE mode, code should not be allowed to fall through to case EFI_DEP_SOR: which is below the above two. Hence, add return FALSE at the end. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c b/MdeModulePkg/C= ore/Dxe/Dispatcher/Dependency.c index acbf68b700fb..9799ec9ca097 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c @@ -265,6 +265,8 @@ CoreIsSchedulable ( // DEBUG ((DEBUG_DISPATCH, " RESULT =3D FALSE (Unexpected BEFORE or = AFTER opcode)\n")); ASSERT (FALSE); + return FALSE; + case EFI_DEP_SOR: // // These opcodes can only appear once as the first opcode. If it = is found --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109103): https://edk2.groups.io/g/devel/message/109103 Mute This Topic: https://groups.io/mt/101612677/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 Fri May 17 08:39:22 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+109104+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+109104+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794775; cv=none; d=zohomail.com; s=zohoarc; b=IFnADV2VyIPvAQT38n6byvXmwsRIvjuwjkD5LqtNyhgsVUj3qEv/61qSjpg09lQXBtMwXUCzUn3eSH0UJuWjnBuLT63IzLpE1oC1u4b9uajqwOSdebdqok1J0HTeijlCatvMd/ZoXyBlvBh+shL0wIwjdzIa4kkXBjlE4cyDyLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794775; 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=G7HzzoE2WRuISDIn8VbTj/EIqyhGc6053KV4cM0kaKQ=; b=dAQTxmeKTaDo8v7iwCJXStk6KpKRkFLvdyPYZ+B/L62Z51ik/SyD4cVOLX3HWv3Z8rG9NnDFsSXzp1QPUUsMwzMIOOVlRxMsOaB5VNfYYzg4az55NaNs3ODiPr09EgzDKPYVY0ZRhCooO/M0Zgm3SzYj7H9bjBe4V2cQzf0Fpbk= 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+109104+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695794775939209.4762592449788; Tue, 26 Sep 2023 23:06:15 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xq7x4pg4JRDqoYeqiZbD9PFaWVdSlafyU3IdfJeuIwE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695794775; v=1; b=QMdwq+l6d1yWb3KiRhOUHMJgxkX1n8tFg0eRSOyT+/44/vfFxvFAXpP43ioA8LbfqtJI3vuu 6DsbEMG8AxnF+8AJizJLdmrqsCg1nDvGYW02nHjxCwVzn0NzG1m7mHCIX6OzFnZUo9TWALZ0kl9 3WqS3UyFU70H7LzycgUj0pfM= X-Received: by 127.0.0.2 with SMTP id j4ceYY1788612xUv3EmRf6dw; Tue, 26 Sep 2023 23:06:15 -0700 X-Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by mx.groups.io with SMTP id smtpd.web11.11802.1695794774952190888 for ; Tue, 26 Sep 2023 23:06:15 -0700 X-Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-79faf4210b2so260241939f.2 for ; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Gm-Message-State: qoteqvxEpOlBPf0NerHTZrr4x1787277AA= X-Google-Smtp-Source: AGHT+IEJlGPl7j1VNoGhI1HSPR0OE99SnuJFya0R53u5LNqGWFD37soMRH534dG0xh12OMqb/9GLQQ== X-Received: by 2002:a92:c5cd:0:b0:349:77c7:2ab6 with SMTP id s13-20020a92c5cd000000b0034977c72ab6mr1148907ilt.2.1695794774121; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:13 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue Date: Wed, 27 Sep 2023 11:35:59 +0530 Message-Id: <20230927060601.443693-4-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794777939100003 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh In the function PromoteGuardedFreePages(), the value of AvailablePages cannot be ZERO at the condition check point if (AvailablePages !=3D 0) { as the code can come out of the while loop above only when AvailablePages is non-ZERO. Hence, remove the redundant condition check and the return FALSE; DEADCODE statement at the end of the function. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 35 +++++++++----------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/= Mem/HeapGuard.c index 0c0ca61872b4..016791ee002b 100644 --- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c +++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c @@ -1568,28 +1568,25 @@ PromoteGuardedFreePages ( } } =20 - if (AvailablePages !=3D 0) { - DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Av= ailablePages)); - ClearGuardedMemoryBits (Start, AvailablePages); + DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Avai= lablePages)); + ClearGuardedMemoryBits (Start, AvailablePages); =20 - if (gCpu !=3D NULL) { - // - // Set flag to make sure allocating memory without GUARD for page ta= ble - // operation; otherwise infinite loops could be caused. - // - mOnGuarding =3D TRUE; - Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO= _SIZE (AvailablePages), 0); - ASSERT_EFI_ERROR (Status); - mOnGuarding =3D FALSE; - } - - mLastPromotedPage =3D Start; - *StartAddress =3D Start; - *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; - return TRUE; + if (gCpu !=3D NULL) { + // + // Set flag to make sure allocating memory without GUARD for page table + // operation; otherwise infinite loops could be caused. + // + mOnGuarding =3D TRUE; + Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_S= IZE (AvailablePages), 0); + ASSERT_EFI_ERROR (Status); + mOnGuarding =3D FALSE; } =20 - return FALSE; + mLastPromotedPage =3D Start; + *StartAddress =3D Start; + *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; + + return TRUE; } =20 /** --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109104): https://edk2.groups.io/g/devel/message/109104 Mute This Topic: https://groups.io/mt/101612679/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 Fri May 17 08:39:22 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+109105+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+109105+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794778; cv=none; d=zohomail.com; s=zohoarc; b=kqyv4o+t7fMHWZOhKpw+Fy9uWNar1JKvGAtzjQQAgrjQVndP03YHLzaBDWJSD/XVvMxcAbKQAK2A1ErkznZlGs8hMIGskRoOpSYG1lq5kGLciUpCnzZk7JZOo5h3yFAvGF7GG2ndRUwG3MV2DXAIahzLBhMx2ygNC8+PHOZAe3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794778; 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=570PKUL9qCOavNOg4DuyX/A+HnzbSVkYSNa+4zRiE0E=; b=kJqbEuqnTV3EKV7L2tPT4eCV0WkF7rvqf0QCjM/Eq2f923E+KwUd6IYmT9lc0K0AD7gk5gm/J18vzfo/aBlPiGV+8pSCIYNRW4z/DSG5IJc1rVuwzKNhdX58A1o+1CG0u9kK9J2rOBfm//Qwd9hFwSVzLK590++NMhiXXDYsE2s= 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+109105+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695794778484686.5086126751954; Tue, 26 Sep 2023 23:06:18 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=12XTOHxTU+1rj4KoThoICjAgk4OBT4w/AASmKTJxYMQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695794778; v=1; b=CO88QgDGmCsXqpT3ukUvJr+idRko6j+vaQyXr0/pC22fMe9zOuzv8t00WSlZe4NAmPKg9HjE ST9e39b1lsucpys4fxscGGfMGGxV02bWguA+htf4auGpQYlFh8/p4OnvziznEanx8Vi3CuLG4Eh +4ZNRJ8azUJlp2TwNsGs59M8= X-Received: by 127.0.0.2 with SMTP id 26k3YY1788612xQqA3BoXdma; Tue, 26 Sep 2023 23:06:18 -0700 X-Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by mx.groups.io with SMTP id smtpd.web11.11805.1695794777511756025 for ; Tue, 26 Sep 2023 23:06:17 -0700 X-Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-351574aca7bso7773805ab.3 for ; Tue, 26 Sep 2023 23:06:17 -0700 (PDT) X-Gm-Message-State: 8Z9AsZ252zHNzgTH8fWZJAr8x1787277AA= X-Google-Smtp-Source: AGHT+IHvULPm3mN02bJqco4Ja1vS7aGlKpz1myImqcgUrn+rrkodIVthlysO8ayTznXppDApuDVryw== X-Received: by 2002:a92:c543:0:b0:351:5b43:5ecd with SMTP id a3-20020a92c543000000b003515b435ecdmr1175559ilj.14.1695794776632; Tue, 26 Sep 2023 23:06:16 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:16 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 4/5] MdeModulePkg/Core/Dxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issues Date: Wed, 27 Sep 2023 11:36:00 +0530 Message-Id: <20230927060601.443693-5-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794780544100007 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh "1 << Priority" / "1 << Event->NotifyTpl" are potentially overflowing expressions with type "int" (32 bits, signed) evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "UINTN" (64 bits, unsigned). To avoid overflow, cast "1" to type "UINTN" before << operation. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Event/Event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/Ev= ent/Event.c index dc82abb02130..6cf93f7f562d 100644 --- a/MdeModulePkg/Core/Dxe/Event/Event.c +++ b/MdeModulePkg/Core/Dxe/Event/Event.c @@ -191,7 +191,7 @@ CoreDispatchEventNotifies ( CoreAcquireEventLock (); } =20 - gEventPending &=3D ~(UINTN)(1 << Priority); + gEventPending &=3D ~(UINTN)((UINTN)1 << Priority); CoreReleaseEventLock (); } =20 @@ -225,7 +225,7 @@ CoreNotifyEvent ( // =20 InsertTailList (&gEventQueue[Event->NotifyTpl], &Event->NotifyLink); - gEventPending |=3D (UINTN)(1 << Event->NotifyTpl); + gEventPending |=3D (UINTN)((UINTN)1 << Event->NotifyTpl); } =20 /** --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109105): https://edk2.groups.io/g/devel/message/109105 Mute This Topic: https://groups.io/mt/101612681/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 Fri May 17 08:39:22 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+109106+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+109106+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695794780; cv=none; d=zohomail.com; s=zohoarc; b=lDkItps0tFXcFV+Lx4dz2v1PpWJItEfFXqmwEN2LwRtlOWEgtRDzObMbh5r1tlugKlhAs5YzF8IiB6E2SMp984Md12AkBtggyUTRGJooEDlGMBkHIJKH0PWcK9J8xv0RyaaI31/lh5eCDFxEp/xejjAqZe/EjDR4979gcgm8VgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695794780; 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=IIa6YCVD8R/d7XpW22KsdD9druWeM8fPx/3RTDIa5J4=; b=aIfQnYXO9PAxCeIukRcxn6QMIOi/C0/ulJwmgQr3XIGKSH+3JXx4511W4cwyzSKUt40Oue4SW/l1NqloMNRkGQa3etCDsD0eEV85nNouMMsvJACZhg9w8wAOjqoJEQS3l25mPVoPSRQ7fBAsbiPgu1052WWFEM/8Vp8sibGid9Y= 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+109106+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695794780865415.5799445541637; Tue, 26 Sep 2023 23:06:20 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=7+0CVa/a3YgzRhWSvmeCg6KHDl5mzbGe+BGtk5Fdl5g=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695794780; v=1; b=CnSCpp/pfkdcaqmwqbw6ZBgc1Q5B9aUfzLVVmEgGFvWbfToZWR2cLeDc9Qg858o2pEXvY0dM bhoC+23AQ4IvENE8s3NZNlRda6l5AjA1iGX6zyAktAPscDeNVdLCm+AGxBpVlednRT/mkMwwak/ ScLIVO5HeTBhfhuXzOp89GUw= X-Received: by 127.0.0.2 with SMTP id 1J96YY1788612xs7grGDvthi; Tue, 26 Sep 2023 23:06:20 -0700 X-Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by mx.groups.io with SMTP id smtpd.web11.11807.1695794779862903277 for ; Tue, 26 Sep 2023 23:06:19 -0700 X-Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-79fe99a5f29so52484439f.1 for ; Tue, 26 Sep 2023 23:06:19 -0700 (PDT) X-Gm-Message-State: OT50wXhneKWxPVtnPrGMvc5Sx1787277AA= X-Google-Smtp-Source: AGHT+IHdgvRuErkyR0c7FEkNUiaQPK8iV/89qyquOwSHcE7ifLhvwaJdFrr79/rOeMgj/KborMsTbQ== X-Received: by 2002:a5e:8705:0:b0:79f:a25b:51c with SMTP id y5-20020a5e8705000000b0079fa25b051cmr1321229ioj.11.1695794778937; Tue, 26 Sep 2023 23:06:18 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:18 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao Subject: [edk2-devel] [PATCH v2 5/5] MdeModulePkg/Core/Dxe: Fix UNUSED_VALUE Coverity issues Date: Wed, 27 Sep 2023 11:36:01 +0530 Message-Id: <20230927060601.443693-6-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695794782585100009 Content-Type: text/plain; charset="utf-8" The return value after calls to functions CoreProcessFvImageFile, CoreStartImage, CoreGetDepexSectionAndPreProccess, CoreInternalAddMemorySpace, CoreAddIoSpace, CoreAllocateMemorySpace and CoreCloseProtocol is stored in Status, but it is not made of any use and later Status gets overridden. An option assuming this no Status check is deliberate, would be to remove the return value storage in Status. Otherwise, simply add Status check and appropriate debug messages (the patch does this). REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 15 +++++++++++++++ MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 15 +++++++++++++++ MdeModulePkg/Core/Dxe/Image/Image.c | 3 +++ 3 files changed, 33 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Dxe/Dispatcher/Dispatcher.c index cf9d55687766..f53a2513457a 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c @@ -506,6 +506,10 @@ CoreDispatcher ( // Produce a firmware volume block protocol for FvImage so it gets= dispatched from. // Status =3D CoreProcessFvImageFile (DriverEntry->Fv, DriverEntry->F= vHandle, &DriverEntry->FileName); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_DISPATCH, "Failed to produce a FVB protocol for Fv= %p FvHandle %p and FileName %g.\n", + DriverEntry->Fv, DriverEntry->FvHandle, &DriverEntry->FileName= )); + } } else { REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, @@ -516,6 +520,10 @@ CoreDispatcher ( ASSERT (DriverEntry->ImageHandle !=3D NULL); =20 Status =3D CoreStartImage (DriverEntry->ImageHandle, NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_DISPATCH, "Failed to transfer control to a loaded = image's entry point for ImageHandle %p.\n", + DriverEntry->ImageHandle)); + } =20 REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, @@ -549,6 +557,13 @@ CoreDispatcher ( // If Section Extraction Protocol did not let the Depex be read be= fore retry the read // Status =3D CoreGetDepexSectionAndPreProccess (DriverEntry); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_PROTOCOL_ERROR) { + DEBUG ((DEBUG_DISPATCH, "Section extraction protocol failure f= or DriverEntry %p.\n", DriverEntry)); + } else { + DEBUG ((DEBUG_DISPATCH, "No Depex, assume UEFI 2.0 driver mode= l for DriverEntry %p.\n", DriverEntry)); + } + } } =20 if (DriverEntry->Dependent) { diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 39fa2adf9366..384fee600d85 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -2638,6 +2638,9 @@ CoreInitializeGcdServices ( ResourceHob->ResourceLength, Capabilities ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_GCD, "Failed to add a segment of memory to GCD map= , Status =3D %r\n", Status)); + } } =20 if (GcdIoType !=3D EfiGcdIoTypeNonExistent) { @@ -2646,6 +2649,9 @@ CoreInitializeGcdServices ( ResourceHob->PhysicalStart, ResourceHob->ResourceLength ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_GCD, "Failed to add reserved I/O or I/O resources,= Status =3D %r\n", Status)); + } } } } @@ -2668,6 +2674,9 @@ CoreInitializeGcdServices ( gDxeCoreImageHandle, NULL ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status =3D %r\n= ", Status)); + } } =20 // @@ -2715,6 +2724,9 @@ CoreInitializeGcdServices ( gDxeCoreImageHandle, NULL ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status =3D %r= \n", Status)); + } } } =20 @@ -2763,6 +2775,9 @@ CoreInitializeGcdServices ( gDxeCoreImageHandle, NULL ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status =3D = %r\n", Status)); + } } } } diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 9dbfb2a1fad2..769e2d379051 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1010,6 +1010,9 @@ CoreUnloadAndCloseImage ( Image->Handle, OpenInfo[OpenInfoIndex].ControllerHandle ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Failed to close protocol on Handl= e %p\n", HandleBuffer[HandleIndex])); + } } } =20 --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109106): https://edk2.groups.io/g/devel/message/109106 Mute This Topic: https://groups.io/mt/101612682/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-