[edk2-devel] [PATCH v1 5/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix UNUSED_VALUE Coverity issues

2023-09-26 Thread Ranbir Singh
The return value after calls to functions gBS->UninstallMultipleProtocolInterfaces, StartPciDevicesOnBridge, PciPciDeviceInfoCollector, BarExisted, PciRootBridgeIo->Pci.Write, gPciHotPlugInit->InitializeRootHpc and PciRootBridgeP2CProcess is stored in Status, but it is not made of any use and later

[edk2-devel] [PATCH v1 4/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue

2023-09-26 Thread Ranbir Singh
From: Ranbir Singh The function StartPciDevices has a check ASSERT (RootBridge != NULL); but this comes into play only in DEBUG mode. In Release mode, there is no handling if the RootBridge value is NULL and the code proceeds to unconditionally dereference "RootBridge" which will lead to CR

[edk2-devel] [PATCH v1 3/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix ARRAY_VS_SINGLETON Coverity issues

2023-09-26 Thread Ranbir Singh
From: Ranbir Singh The function PciHostBridgeResourceAllocator is not making use of the generic approach as is used in one of the other function namely - DumpResourceMap. As a result, the following warnings can be seen as reported by Coverity e.g. (30) Event address_of: Taking address with "&Io

[edk2-devel] [PATCH v1 2/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix MISSING_BREAK Coverity issues

2023-09-26 Thread Ranbir Singh
From: Ranbir Singh The function UpdatePciInfo has switch-case code in which there are fall through from case 32: to case 64:. While this is seeemingly intentional, it is not evident to any static analyzer tool. Just adding // No break; here as this is an intentional fallthrough. as explicit

[edk2-devel] [PATCH v1 1/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix DEADCODE Coverity issue

2023-09-26 Thread Ranbir Singh
From: Ranbir Singh The function PciHotPlugRequestNotify has two if blocks towards the end of function both containing return. Due to the parameter checks ensured at the beginning of the function, one of the two if blocks is bound to come in execution flow. Hence, the return EFI_SUCCESS; at line 2

[edk2-devel] [PATCH v1 0/5] BZ 4239: Fix PciBusDxe issues pointed by

2023-09-26 Thread Ranbir Singh
Ranbir Singh (5): MdeModulePkg/Bus/Pci/PciBusDxe: Fix DEADCODE Coverity issue MdeModulePkg/Bus/Pci/PciBusDxe: Fix MISSING_BREAK Coverity issues MdeModulePkg/Bus/Pci/PciBusDxe: Fix ARRAY_VS_SINGLETON Coverity issues MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue MdeModuleP

[edk2-devel] [PATCH v2 5/5] MdeModulePkg/Core/Dxe: Fix UNUSED_VALUE Coverity issues

2023-09-26 Thread Ranbir Singh
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 op

[edk2-devel] [PATCH v2 4/5] MdeModulePkg/Core/Dxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issues

2023-09-26 Thread Ranbir Singh
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

[edk2-devel] [PATCH v2 1/5] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues

2023-09-26 Thread Ranbir Singh
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

[edk2-devel] [PATCH v2 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue

2023-09-26 Thread Ranbir Singh
From: Ranbir Singh In the function PromoteGuardedFreePages(), the value of AvailablePages cannot be ZERO at the condition check point if (AvailablePages != 0) { as the code can come out of the while loop above only when AvailablePages is non-ZERO. Hence, remove the redundant condition check

[edk2-devel] [PATCH v2 2/5] MdeModulePkg/Core/Dxe: Fix MISSING_BREAK Coverity issue

2023-09-26 Thread Ranbir Singh
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 D

[edk2-devel] [PATCH v2 0/5] BZ 4219: MdeModulePkg/Core/Dxe: Fix issues

2023-09-26 Thread Ranbir Singh
v1 -> v2: - Rebased - Commit message update wrt Fix UNUSED_VALUE Coverity issues Ranbir Singh (5): MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues MdeModulePkg/Core/Dxe: Fix MISSING_BREAK Coverity issue MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue MdeModulePkg/Core/Dxe: F

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Ni, Ray
Nate, Thanks for the great patch! Minor comments: 1. Regarding the DllEntryPoint, what's the difference between below line in your patch and the original code that calls GetProcAddress()? * DllEntryPoint = (VOID *) ((UINTN)Library + (UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPo

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Nate DeSimone
Thanks for the reminder/education on the coding style. I knew my habit of putting variables at the top of functions came from somewhere. Pushed: https://github.com/tianocore/edk2/commit/ad1c039 -Original Message- From: Kinney, Michael D Sent: Tuesday, September 26, 2023 2:43 PM To: Des

[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, September 26, 2023 #cal-reminder

2023-09-26 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO* *When:* Tuesday, September 26, 2023 6:30pm to 7:30pm (UTC-07:00) America/Los Angeles *Where:* https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e34

Re: [edk2-devel] [PATCH v2] MdeModulePkg/Xhci: Skip size round up for TRB during address translation

2023-09-26 Thread Wu, Hao A
Reviewed-by: Hao A Wu Best Regards, Hao Wu > -Original Message- > From: Cheng, Gao > Sent: Tuesday, September 26, 2023 4:25 PM > To: devel@edk2.groups.io > Cc: Cheng, Gao ; Wu, Hao A ; > Ni, Ray ; Wang, Jian J ; Gao, > Liming > Subject: [PATCH v2] MdeModulePkg/Xhci: Skip size round up

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Michael D Kinney
Hi Nate, Reviewed-by: Michael D Kinney That makes complete sense now on the use case when building drivers or apps outside EmulatorPkg DSC file and wanting to support source level debug. In the past, I have had to add components to EmulatorPkg DSC file. Thank you for adding feature to support

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Nate DeSimone
Hi Mike, Yes, we can delete those lines now 😊. I have those lines commented out in my copy of EmulatorPkg. I found this because I have been trying to use EmulatorPkg to source level debug drivers that I built separately via one of the edk2-platform builds. Thanks, Nate -Original Message--

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Michael D Kinney
Hi Nate, Declaring all the local variables at the top of the function is really a coding style recommendation documented in the EDK II C Coding Style Specification. End of Section 5.4.1.1. Declaring local in other scopes is strongly discouraged. https://tianocore-docs.github.io/edk2-CCodingSta

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Michael D Kinney
I have VS Code on Windows working today using the PDB based symbol file. The following lines in the EmulatorPkg DSC file force 4KB alignment and the DLL export of the InitializeDriver symbol https://github.com/tianocore/edk2/blob/bf0bdacdd6f6cdd2e9ac5db14b6daf19a5a5bd57/EmulatorPkg/EmulatorPkg.d

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Nate DeSimone
Looks like it compiles fine in VS2015, and we just removed the tools_def entries for every VC++ version older than that. And C99 has been in gcc for a very long time and clang forever. So perhaps we can start using C99 style variable declarations finally? Thanks, Nate -Original Message

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Nate DeSimone
Oh, never mind, I see you are suggesting a C99 style variable declaration. Do we need to worry about old compiler that want all variable declarations at the top still? Thanks, Nate -Original Message- From: Desimone, Nathaniel L Sent: Tuesday, September 26, 2023 1:38 PM To: Kinney, Mich

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Nate DeSimone
Hi Mike, Unfortunately, that change will generate the following warning on GCC4.6+ warning: variable "Success" set but not used [-Wunused-but-set-variable] Hence why I wrote it that way. Let me know if you would like me to make a different change before committing. Thanks, Nate -Original

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Nate DeSimone
Hi Mike, Source level debug with VS Code does indeed work today with gdb or lldb. This change makes the Visual Studio Windows debugger work as well. You are correct that if the same DLL is loaded more than once that this method cannot perform source level debug on the second instance; but this

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Source Level Debug on Windows

2023-09-26 Thread Michael D Kinney
Hi Nate, I am able to do source level debug of EmulatorPkg using VS Code today. What scenarios are broken? I do know that the DLL based approach would only allow a single instance of the module to be loaded and debugged. If, for example, a driver is loaded more than once from the UEFI Shell in

Re: [edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Michael D Kinney
Thanks Nate! I have noticed this issue for a while. One comment below. With that update: Reviewed-by: Michael D Kinney Mike > -Original Message- > From: Desimone, Nathaniel L > Sent: Tuesday, September 26, 2023 11:36 AM > To: devel@edk2.groups.io > Cc: Andrew Fish ; Ni, Ray ; Kinney

[edk2-devel] [PATCH v1 5/5] .github/workflows/codeql.yml: Add CodeQL workflow

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki Adds a workflow to run CodeQL against all packages built in .pytool/CISettings.py. The following is done: 1. Determine which packages to build against. Those that support are managed by .pytool/CISettings.py will be selected. For each package: 2. Determine how to inter

[edk2-devel] [PATCH v1 4/5] .pytool/CISettings.py: Integrate CodeQL

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki Adds the `--codeql` parameter to `stuart_update` and `stuart_ci_build`. - `stuart_update --codeql` - Downloads the CodeQL CLI locally. The command will pull the appropriate binary for the host OS. - `stuart_ci_build --codeql` - Runs CodeQL during the build resulting in

[edk2-devel] [PATCH v1 1/5] Remove existing CodeQL infrastructure

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki CodeQL currently runs via the codeql-analysis.yml GitHub workflow which uses the `github/codeql-action/init@v2` action (pre-build) and the `github/codeql-action/analyze@v2` action (post-build) to setup the CodeQL environment and extract results. This infrastructure is remov

[edk2-devel] [PATCH v1 3/5] BaseTools/Plugin/CodeQL: Add integration helpers

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki Adds a Python module to the CodeQL plugin directory that exports functions commonly needed for Stuart-based platforms to easily enable CodeQL in their platform build. This functionality has already moved to edk2-pytool-extensions https://github.com/tianocore/edk2-pytool-ext

[edk2-devel] [PATCH v1 2/5] BaseTools/Plugin/CodeQL: Add CodeQL build plugin

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki Adds a CodeQL plugin that supports CodeQL in the build system. 1. CodeQlBuildPlugin - Generates a CodeQL database for a given build. 2. CodeQlAnalyzePlugin - Analyzes a CodeQL database and interprets results. 3. External dependencies - Assist with downloading the CodeQL

[edk2-devel] [PATCH v1 0/5] Use CodeQL CLI

2023-09-26 Thread Michael Kubacki
From: Michael Kubacki CodeQL currently runs via the codeql-analysis.yml GitHub workflow which uses the github/codeql-action/init@v2 action (pre-build) and the github/codeql-action/analyze@v2 action (post-build) to setup the CodeQL environment and extract results. This infrastructure is removed i

[edk2-devel] [PATCH v1] EmulatorPkg: Fix Terminal Issues

2023-09-26 Thread Nate DeSimone
After running EmulatorPkg, one will notice that their terminal acts strangely. This is caused by the EmulatorPkg Host changing the terminal mode and not restoring the original mode, which is now fixed. Cc: Andrew Fish Cc: Ray Ni Cc: Michael D Kinney Cc: Chasel Chiu Signed-off-by: Nate DeSimone

[edk2-devel] [PATCH v2 5/5] MdePkg/BaseLib: ensure ARM LongJump never returns 0

2023-09-26 Thread Leif Lindholm
The ARM implementation of of InternalLongJump always returned the value Value - but it is not supposed to ever return 0. Add the test to prevent that, and return 1 if Value is 0 - as is already present in AArch64. Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar --- MdePkg/Libr

[edk2-devel] [PATCH v2 3/5] MdePkg/BaseLib: use normal register init in ARM SetJump implementations

2023-09-26 Thread Leif Lindholm
There may be architectures on which there are benefits to eor r0, r0(, r0) but ARM was never one of them. Change to more readable mov r0, #0 instead. Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar --- MdePkg/Library/BaseLib/Arm/SetJumpLongJump.S | 2 +- MdePkg/Library/B

[edk2-devel] [PATCH v2 4/5] MdePkg/BaseLib: correct register sizes in AArch64 SetJump/LongJump

2023-09-26 Thread Leif Lindholm
Both in SetJump and in InternalLongJump, 32-bit w register views were used for the UINTN return value. In SetJump, this did not cause errors; it was only counterintuitive. But in InternalLongJump, it meant the top 32 bits of Value were stripped off. Change all of these to use the 64-bit x register

[edk2-devel] [PATCH v2 2/5] MdePkg/BaseLib: add ASSERT in ARM* SetJump implementations

2023-09-26 Thread Leif Lindholm
The SetJump comment header states that: If JumpBuffer is NULL, then ASSERT(). However, this was not currently done. Add a call to InternalAssertJumpBuffer. Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar --- MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S | 8 M

[edk2-devel] [PATCH v2 1/5] MdePkg/BaseLib: fix comments in ARM* SetJump/LongJump implementations

2023-09-26 Thread Leif Lindholm
Drop redundant comment about IPF (clearly copied across from now deleted code). Also change "Instead is resumes execution" -> "Instead it resumes execution" Signed-off-by: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar --- MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S | 3 +-- MdePkg/

[edk2-devel] [PATCH v2 0/5] MdePkg: various fixes to ARM/AArch64 SetJump/LongJump

2023-09-26 Thread Leif Lindholm
Back in the mists of time (January 2020) I submitted a set to clean up and fix a few bugs in ARM/AArch64 BaseLib SetJump/LongJump implementations: https://edk2.groups.io/g/devel/message/65812 Then hubris struck and I meant to refactor the code for all architectures, and since this was in my first

Re: [edk2-devel] [PATCH v2 0/2] StandaloneMmPkg: Make StandaloneMmCpu platform

2023-09-26 Thread Tuan Phan
Hi Sami/Yeo Do you have any comments on this series? Regards, On Thu, Sep 14, 2023 at 4:10 PM Tuan Phan wrote: > This series makes StandaloneMmCpu platform independent so that > other platforms besides ARM/AARCH64 can use it without creating > new driver. > > There are two parts in this series:

Re: [edk2-devel] [PATCH v4 00/14] Add ImagePropertiesRecordLib and Fix MAT Bugs

2023-09-26 Thread Taylor Beebe
Reviews on this patch series would be much appreciated :) On 8/28/23 9:38 AM, Ard Biesheuvel wrote: I was hoping to get around to this before the end of the week (but I am not a MdeModulePkg maintainer) On Mon, 28 Aug 2023 at 18:27, Taylor Beebe wrote: Can I please get reviews/feedback on th

[edk2-devel] [PATCH 1/1] MdePkg/UefiDevicePathLib: Fix AcpiEx print logic

2023-09-26 Thread Albecki, Mateusz
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4555 Add logic that checks if the code doesn't overflow ACPI_EXTENDED_HID_DEVICE_PATH node when searching for optional strings. If the string is not provided in the device path node default value of "\0" is used. Cc: Michael D Kinney Cc: Liming

[edk2-devel] [PATCH 0/1] MdePkg/UefiDevicePathLib: Fix buffer overflows in DevPathToTextAcpiEx

2023-09-26 Thread Albecki, Mateusz
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4555 Github PR: https://github.com/tianocore/edk2/pull/4865 Fix for buffer overlows that arise in DevPathToTextAcpiEx when device path node producer doesn't specify all of the optional strings. Tests: - Booted the platform and confirmed that pla

[edk2-devel] Uploading to fd file flash chip

2023-09-26 Thread Alireza Banejad
Hi everybody, I have built the Whisky Lake platform and I got the fd file but now I want to upload it into my motherboard's flash chip but I haven't found the right way of doing so. it seems I need to translate it into a *.rom file but I don't know how to do that. I have already built a coreboot fi

[edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reduce the times of BSP and AP sync for exit

2023-09-26 Thread Wu, Jiaxin
After review, there are unnecessary steps for BSP and AP sync for exit. This patch is to reduce one round BSP and AP sync for exit so as to improve SMM performance: WaitForAllAPs <- ReleaseBsp ReleaseAllAPs -> WaitForBsp Cc: Eric Dong Cc: Ray Ni Cc: Zeng Star Cc: Rahul Kumar Cc: Gerd Hoffmann

[edk2-devel] [PATCH v1 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Optimize semaphore sync between BSP and AP

2023-09-26 Thread Wu, Jiaxin
This patch is to: 1. Define 2 new functions (WaitForBsp & ReleaseBsp) used for the semaphore sync between BSP & AP. 2. Add ReleaseOneAp(), used for BSP to release one AP. With the change, BSP & AP Sync flow will be easy understand: BSP to Release All APs ---> AP to Wait BSP ReleaseAllAPs ()

[edk2-devel] [PATCH v1 0/2] Optimize semaphore sync between BSP and AP

2023-09-26 Thread Wu, Jiaxin
The series patches are to optimize semaphore sync between BSP and AP: Patch 1: Define 3 functions (WaitForBsp & ReleaseBsp & ReleaseOneAp) specific for BSP & AP sync, which will make the flow easy to understand. Patch 2: Reduce one round BSP and AP sync for exit so as to improve SMM performance Ji

[edk2-devel] [PATCH v2] MdeModulePkg/Xhci: Skip size round up for TRB during address translation

2023-09-26 Thread Gao
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4560 TRB Template is 16 bytes. When boundary checking is 64 bytes for xHCI device/host memory address, it may exceed xHCI host memory pool and cause unwanted DXE_ASSERT. Introduce a new input parameter to indicate whether to enforce 64byte size al