From nobody Fri May 17 07:55: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+109060+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+109060+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710407; cv=none; d=zohomail.com; s=zohoarc; b=OH8d/xbbhSpDbrqGVLw7Mmw9Fz3XyeRDu/08VgHTYPeSDaZQPSyaNhfd6nOsg51+hxW6Sp5eq87JI+glKicc4Vkxq2qIL26Dv8lacDvKP+62Ooo/hWYxiP5Gq8yF0VFb1lzrac3MIQ7GTJgn2CxJGcDlj2Tg0HfPga0b+t90g40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710407; 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=z/oPNgpidMCQRF2HFwADtclL9rpW5oMY9Hvlec+iinE=; b=Eqb9hW96DOre9F6yn2faS/3Zcgs90rGa9Q1nlO0zFHjxmVGSrjwEFkr0ka1IN5c/92NNYoS4rJseGnEaswsWkwfnDy1LJqY8F1cZqxSuR4wNKG2htgUh0+fsYJ+qCVUmrgi28CM+Y+HgA3w/DXOqLzaIG2yR5hhJ1N/vVei7sJE= 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+109060+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710407845174.8631021071377; Mon, 25 Sep 2023 23:40:07 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=r9ufVog68/SCNkNXJaBLuupacmRzwDX9p6G2veE/ua8=; 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=1695710407; v=1; b=RLNSwq/kVe0j64KbShvAT7XMFQiuJ8Pf5Rt3qwX1rJWbe1+GHc3ntFn0jOv5kSN494c8VQFW iOujWBOTUmNhDcY01e55WRAHBpPso6hnexWHzhmLjv5o+1Z/F0RawapySTqmX3qsUgW6ZJNtjcU qlTM6LI69b4ZWO6blJgt+7DM= X-Received: by 127.0.0.2 with SMTP id xmtjYY1788612xA3hLte4WdT; Mon, 25 Sep 2023 23:40:07 -0700 X-Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by mx.groups.io with SMTP id smtpd.web11.13052.1695710406914798972 for ; Mon, 25 Sep 2023 23:40:07 -0700 X-Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6bf298ef1f5so5113838a34.0 for ; Mon, 25 Sep 2023 23:40:06 -0700 (PDT) X-Gm-Message-State: AwVijOSjKQWM7vGM0R4Z4TLQx1787277AA= X-Google-Smtp-Source: AGHT+IESx6I0g0wQy59Sk+OaSgBHu/s1Ihv+ylPMICZyJSmzBJcxy7TXxYxCdH/U6afagfMrFjHZmw== X-Received: by 2002:a05:6358:341a:b0:134:c859:d32a with SMTP id h26-20020a056358341a00b00134c859d32amr11301541rwd.25.1695710405900; Mon, 25 Sep 2023 23:40:05 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:05 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 1/5] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues Date: Tue, 26 Sep 2023 12:09:54 +0530 Message-Id: <20230926063958.313858-2-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710408292100003 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 (#109060): https://edk2.groups.io/g/devel/message/109060 Mute This Topic: https://groups.io/mt/101590754/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 07:55: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+109061+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+109061+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710410; cv=none; d=zohomail.com; s=zohoarc; b=K/NFTb/1OsqsEQoQHIJCs+S/iOvQHDeLGYac4lIkIXiT2VDcUJ4aHFdeb8UnVTQyEPX50OZ5ZToi58rz9kKbLVKexusHWxkTcxCQkqtPp2K4dTNZnqutKeIw/MyMGzS7t2OtIOq4Z+u1rSsLttmSOHSYn3NXwFrCIbxtyBtem1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710410; 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=sVcbcWGgphH11CCrnbFE2ZLTr7U49q9yvytoFtxnIr4=; b=a6d8W+O5r02gWntNj0oQ/mwLz+1gY3SPnCGcEG4IyLautvwlnU6iwFk9nyOrNlv6Et46Ui97b+XFGhYYFngEuOSX+UBbgMApgpEwDZVJx+XrlTb1w9byUT8pu3td+CD9hTb20uXqS7v/rS9Ij7jPcuHC3c9WN4E8lcdIwuw6oYs= 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+109061+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710410317732.4322100369766; Mon, 25 Sep 2023 23:40:10 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=2IjeFMgrQrRbiyqCi8FCG5ZBIK65tkvBbF1qseWSugg=; 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=1695710409; v=1; b=FVaoX4iFxYjtnwFvXYxZYO2hHo4POJ0VLQgHIaSsMEgAFHUif/vqCOhIk9HhQTDk3DQVYam+ bx95r4ZxBrax3vdbszr1c3kltGWSXoHGC+Nd1SmigQy/LxDNZ6nuh+Jlt+cHTkqRzrhNbld8GB2 x1mVkNWqCFdJUELoQ/dgEcOU= X-Received: by 127.0.0.2 with SMTP id 35SXYY1788612x9m6laTX56T; Mon, 25 Sep 2023 23:40:09 -0700 X-Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by mx.groups.io with SMTP id smtpd.web11.13055.1695710409312160888 for ; Mon, 25 Sep 2023 23:40:09 -0700 X-Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-57bca5b9b0aso1618371eaf.3 for ; Mon, 25 Sep 2023 23:40:09 -0700 (PDT) X-Gm-Message-State: vsORAwm061paEybsRyeYpGZHx1787277AA= X-Google-Smtp-Source: AGHT+IGoIIwy0EIJ7TTAmuojVQZcWyvhlkoyfYjNXesFEBYFZ4/5Fr3P+QHgWOYsEIOM0xXOGc2ACA== X-Received: by 2002:a05:6358:4287:b0:134:c650:cc0a with SMTP id s7-20020a056358428700b00134c650cc0amr11473173rwc.15.1695710408278; Mon, 25 Sep 2023 23:40:08 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:07 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 2/5] MdeModulePkg/Core/Dxe: Fix MISSING_BREAK Coverity issue Date: Tue, 26 Sep 2023 12:09:55 +0530 Message-Id: <20230926063958.313858-3-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710411476100009 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 (#109061): https://edk2.groups.io/g/devel/message/109061 Mute This Topic: https://groups.io/mt/101590755/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 07:55: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+109062+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+109062+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710412; cv=none; d=zohomail.com; s=zohoarc; b=dks0Y9nbS1l8ydXSQM4gF0449sQqUi0WDL1mxt5iK0PnvJbTrW92OqVsu7uv3FkGevoVL+JLtxxzUXFFqL5BqGLwcUSU8MQo6br7qIaj9jKk//pz7BTqGEjh9eCCQKJqfQ7Om0C8n6mnBwn3m8LRwHI6JWuuXkvkXE3zHCE7iR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710412; 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=XtU9N/IhFM2R3pnred7pmApm87R7fwn2zsi3MVZWHn8=; b=du/Zc2bWgUA+itAxn3WwHtJSvhK8tRokA30SUkUpfCZWJdOQkJ9twcH9x5nBSuEKTbvLg73/KVEst8SGV/hj/sIxbS+REVCpRQgErdIN2LaAN2kPDs+eMz3KUru+LC/+Xj5nL3N8zEWYTRiFZ5ks4tXiNDSYqQ+z0t5/Xp+JgFE= 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+109062+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710412581666.19153122624; Mon, 25 Sep 2023 23:40:12 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=X2vHKh011PBMv8L2D+4shUUyabsam49oOLcr2VJCPnk=; 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=1695710412; v=1; b=YVK+SBcDFHYlHzo/W6qxYNzAyEabcXQNDT+vHaZcjYQooQgnndFieZef/KlLKviMglbYP++3 abEZUEfy4JBFKoTYEStapgjfDyU7TZWC0fTNdPQrMYuHx3NYrXl5tWAAVeYw6ce+B9bHIRKjr+S cpiYrwrTSNSWFgAFw3qG7daU= X-Received: by 127.0.0.2 with SMTP id KtteYY1788612xLGzGGRg9cA; Mon, 25 Sep 2023 23:40:12 -0700 X-Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by mx.groups.io with SMTP id smtpd.web10.13233.1695710411740657607 for ; Mon, 25 Sep 2023 23:40:11 -0700 X-Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6c4e7951dddso2008334a34.1 for ; Mon, 25 Sep 2023 23:40:11 -0700 (PDT) X-Gm-Message-State: eziy5tDKjEN76OoUJXIgRuFXx1787277AA= X-Google-Smtp-Source: AGHT+IEeGIwiy3LxEIrY+pIoP1YKYqkKWNzYQiTfj/8oXsLyuizqgC0l/baD23fvK+TkBSTZRcErYQ== X-Received: by 2002:a05:6358:e49c:b0:143:9b25:c029 with SMTP id by28-20020a056358e49c00b001439b25c029mr14102153rwb.2.1695710410720; Mon, 25 Sep 2023 23:40:10 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:10 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue Date: Tue, 26 Sep 2023 12:09:56 +0530 Message-Id: <20230926063958.313858-4-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710413473100013 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 (#109062): https://edk2.groups.io/g/devel/message/109062 Mute This Topic: https://groups.io/mt/101590756/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 07:55: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+109063+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+109063+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710415; cv=none; d=zohomail.com; s=zohoarc; b=Q7LM9K6xvge9aOJuile8W4+RTZqf2I5i39ezPAgR0FqKmuyBC8DWdbhEmgnViGP3nSsPrsYuFsvOYB7NN1pEK4l3OAee2bq962HxaQGl0MVgSDT1VxgyZ6YEu4CC46xq9rIPADL2/nW3vtCy3YceTXzVsa7yRO6+oqHWCBHo62s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710415; 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=KTD0S3nOA9+GmZ0X/UYqPPlfHnDGkKW4qS7P6lvNOxA=; b=FL/QaW1dgxuw7SCL2zaul0kVy7W+B2AP1kxKiXFaYU/98f6oGlqdpRcttiqc62iqXIhauc9A19XSQBBas2WCBd4agx9odbCpnvPr+ETlkZAFeuTYHzYB2oSWMzaRO6ATBxlvEfEX+PKn4pGNcktBOMctRMSFOUl6poHBQHkuL6s= 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+109063+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710415571265.9376919984172; Mon, 25 Sep 2023 23:40:15 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=2uwRhCWiR8YF17eRmEd8wEbc4wtAFOnddhVpE4am9LM=; 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=1695710415; v=1; b=u43H5WFNLf7OcrkJaZ0LwGbBrzyZ3I4Kesvaq4si+j3Zd43bU7kDSFp5SCPZ6a0b/lQ8ubHQ KLVzvxeEmrWpgymJzZH+juGQH7HxvdBPZgqxI3QXhQkWjqPSNOAQFNdMkjao8BxiINgGwT2cL7V 6UMqIqReJpgQdu6kWOCEK8A0= X-Received: by 127.0.0.2 with SMTP id xFQDYY1788612xW2X8HEDs0N; Mon, 25 Sep 2023 23:40:15 -0700 X-Received: from mail-ua1-f54.google.com (mail-ua1-f54.google.com [209.85.222.54]) by mx.groups.io with SMTP id smtpd.web11.13056.1695710414559456584 for ; Mon, 25 Sep 2023 23:40:14 -0700 X-Received: by mail-ua1-f54.google.com with SMTP id a1e0cc1a2514c-76d846a4b85so2693975241.1 for ; Mon, 25 Sep 2023 23:40:14 -0700 (PDT) X-Gm-Message-State: dhrQXbw65pLrb2QdJ2MCdRpzx1787277AA= X-Google-Smtp-Source: AGHT+IF4X92aI7IJJkIZkF7FtEcCUUaXRyzcrCpQpC6apRYvzEd4pPx7MOJaREih7efdT9+uo/9ueA== X-Received: by 2002:a67:de81:0:b0:452:7748:4700 with SMTP id r1-20020a67de81000000b0045277484700mr6242122vsk.2.1695710413165; Mon, 25 Sep 2023 23:40:13 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:12 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 4/5] MdeModulePkg/Core/Dxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issues Date: Tue, 26 Sep 2023 12:09:57 +0530 Message-Id: <20230926063958.313858-5-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710416712100019 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 (#109063): https://edk2.groups.io/g/devel/message/109063 Mute This Topic: https://groups.io/mt/101590757/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 07:55: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+109064+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+109064+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710417; cv=none; d=zohomail.com; s=zohoarc; b=XO3FJ4AX8vW50eo+fXtH8z/Rx3mF3FCbpn4oCf85WBn4GEsZa80rZk51EkZdiNf39zSssb+FXqjdttVHNs1s1KjZz+IslupDY6tCY8VLNpu/uleqobCoadon1UN/nZIMYkYnJpizIwJlTU3oholShi9tGXrqDwfZAnotdn2x9cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710417; 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=V7oO8buj7Xf5RPUU+L0wdfvdJBEwbGUHj1Y+nkphR9w=; b=JxRuocUDgMl0w+HvQ/Z6xEOJ0iZlvGlbQngF2G77d3n5AXU9TCKeSnfJpYtpX46tOB+rw6C4kbzdfRZQxhgHhrHD+koDlSWgYWLhs4EJbj+baoq+83c9SaEBM6aLi6mnZWAkgGpqtjrNggG59QRKe/0H1Vim/SJUx73YVo0LdLs= 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+109064+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710417891908.549102633956; Mon, 25 Sep 2023 23:40:17 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=sMEv9wQgSRlYN2nk07s1Qp6it8eXK8mcLWyx7UVM5Qo=; 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=1695710417; v=1; b=pkJDVh/HJ82Qhp24HIUxNy09QQ99V4mABdJ9U68t/B228RbQTopJ1ZcYPnMqHBUjycYaSvil oa/N2mgNbNyhZAqe5uehWBW0PY5E/kR4m1pYkFMQ15zoilpSNPoKow5ut6qrp5jBnzxLEPmmh25 y27v7jN9UL65vW8J3bMiSRk8= X-Received: by 127.0.0.2 with SMTP id ol6HYY1788612xYNmvXCYMI3; Mon, 25 Sep 2023 23:40:17 -0700 X-Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) by mx.groups.io with SMTP id smtpd.web11.13059.1695710417015843020 for ; Mon, 25 Sep 2023 23:40:17 -0700 X-Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-49a319c9e17so1338980e0c.1 for ; Mon, 25 Sep 2023 23:40:16 -0700 (PDT) X-Gm-Message-State: TePysvIST0U2x7fdYFHuUFKdx1787277AA= X-Google-Smtp-Source: AGHT+IHjJKGnNiF22WhNDQVrOWVw3TL7wSefBu+6fsxFSUbqdjCxhUtX+mVeMdHXPPAI8+NTZGAEqA== X-Received: by 2002:a05:6102:3bd5:b0:452:988d:b1c9 with SMTP id a21-20020a0561023bd500b00452988db1c9mr4440015vsv.16.1695710415647; Mon, 25 Sep 2023 23:40:15 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:15 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 5/5] MdeModulePkg/Core/Dxe: Fix UNUSED_VALUE Coverity issues Date: Tue, 26 Sep 2023 12:09:58 +0530 Message-Id: <20230926063958.313858-6-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710418786100021 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. One option assuming this is deliberate, would be to remove the return value storage in Status. Otherwise, simply add appropriate debug messages conditionally. 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/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 (#109064): https://edk2.groups.io/g/devel/message/109064 Mute This Topic: https://groups.io/mt/101590758/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-