Global: Fix the issue that Depex sections exist in the INF files of UEFI_DRIVER or UEFI_APPLICATION#12343
Global: Fix the issue that Depex sections exist in the INF files of UEFI_DRIVER or UEFI_APPLICATION#12343EricGao2015 wants to merge 5 commits intotianocore:masterfrom
Conversation
|
⚠ WARNING: Cannot add some reviewers: A user specified as a reviewer for this PR is not a collaborator of the repository. Please add them as a collaborator to the repository so they can be requested in the future. Non-collaborators requested: Attn Admins: Admin Instructions:
|
173e305 to
1cbe903
Compare
|
Since it's a breaking change, PR description should have Integration Instructions. |
NetworkPkg/TcpDxe/TcpDxe.inf
Outdated
| BASE_NAME = TcpDxe | ||
| FILE_GUID = 1A7E4468-2F55-4a56-903C-01265EB7622B | ||
| MODULE_TYPE = UEFI_DRIVER | ||
| MODULE_TYPE = DXE_DRIVER |
There was a problem hiding this comment.
I think the intent of all the network stack drivers is to be UEFI Drivers. Converting to DXE_DRIVER does not lool right. I think the bug may be that there is a depex for gEfiHash2ServiceBindingProtocolGuid. There are ways for a UEFI Driver to be notified when a dependent protocol is available or it can fail a driver binding start if its dependent services are not available.
| BASE_NAME = RedfishConfigHandlerDriver | ||
| FILE_GUID = 6e881000-5749-11e8-9bf0-8cdcd426c973 | ||
| MODULE_TYPE = UEFI_DRIVER | ||
| MODULE_TYPE = DXE_DRIVER |
There was a problem hiding this comment.
Same comment as TcpDxe. Need input from @AbnerChang to know if this is intended to be a UEFI Driver or if it should be a DXE Driver. If UEFI Driver, then Depex need to be removed and instead, the driver implementation needs to handle cases where dependent services are available or not.
There was a problem hiding this comment.
Same comment as TcpDxe. Need input from @AbnerChang to know if this is intended to be a UEFI Driver or if it should be a DXE Driver. If UEFI Driver, then Depex need to be removed and instead, the driver implementation needs to handle cases where dependent services are available or not.
@changab Hi Abner, please help to confirm this issue, thanks.
There was a problem hiding this comment.
This is an UEFI driver, we have to remove the DEPEX. Let me confirm this.
There was a problem hiding this comment.
This is an UEFI driver, we have to remove the DEPEX. Let me confirm this.
Hi Anber, I have removed Depex from RedfishConfigHandler driver and use notify function to handle the dependency. Please review it again. Thank you.
There was a problem hiding this comment.
@EricGao2015, I didn't know you were working on this. Please refer to #12395, I have tested my fix on AMD platform. We don't need the notification for this driver, because the Redfish credential driver is a DXE driver. The Redfish credential must be ready before the ConnectController(). You can update your PR, remove the changes for Redfish, and resend the PR once 12395 gets merged. Thanks.
Updated, please check again. It's my understand for Integration Instructions. |
|
I think it may cause combability issue as some downstream usages may already there. |
Yes, this is also the aspect that I conern about. This issue has persisted for more than a decade, the PR will cause breaking change to downstream. So I would like to know the opinions of all stewards and reviewers. |
|
I have 2 open comments above that need to be addressed before this PR can be completed. For the INFs that have a [Depex] of TRUE for module types that do not support [Depex]. I agree those are incorrect, but are effectively harmless. For example a UEFI Driver has an implied depex of all PI Arch Protocols. ANDing in an additional TRUE does not change the depex. I would like to see those cleaned up. So the patch to remove [Depex] TRUE for those cases looks correct. The BaseTools change to raise this to an error may be good long term. Short term, raising it to a WARNING so downstream consumers can have a chance to clean up the warnings is likely a better first step. The challenge is deciding when it can be promoted from a WARNING to an ERROR. |
1cbe903 to
4fa189b
Compare
I will handle the 2 comments after getting Anber's ack.
I agree with the gentle approach that raises warning instead of error. I have changed the print level form EdkLogger.error() to EdkLogger.warn(), so that the building will not be breaken. |
|
The PR does not produce warnings on transitive dependencies (UEF driver uses a library instance with [Depex]). Is this intentional? |
According to INF specification, UEFI_APPLICATION cannot have Depex section. So remove it. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
According to INF specification, UEFI_DRIVER and UEFI_APPLICATION cannot have Depex section. So remove it. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
According to INF specification, UEFI_DRIVER cannot have Depex section. RedfishConfigHandlerDriver is a UEFI_DRIVER, so the Depex section must be removed. But this driver really depends on gEdkIIRedfishCredentialProtocol. In order to handle the dependency, register a notify function once the protocol is failed to be located. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
According to INF specification, UEFI_DRIVER cannot have Depex section. So remove Depex section from TcpDxe driver INF file. The dependency has been guaranteed. In Tcp6DriverBindingStart() and Tcp4DriverBindingStart() function, gEfiHash2ServiceBindingProtocol has been checked if it is available by gBS->LocateProtocol(). Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
According to INF specification, if the module is not a library (no LIBRARY_CLASS in the [Defines] section) and the MODULE_TYPE is SEC, SMM_CORE, DXE_CORE, PEI_CORE, UEFI_DRIVER, UEFI_APPLICATION or HOST_APPLICATION a Depex section is not permitted. Thus, this patch adds a check when retrieving dependency expression. If the module has [Depex] section but it's not permitted by INF specification, just throw warning message to warn. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
4fa189b to
08e5d3b
Compare
Yes. This patch only handles the case that Depex in INF file which MODULE_TYPE is UEFI_DRIVER or UEFI_APPLICATION, because this constitutes a clear violation of the INF specification. One example is: |
Library INFs that support multiple module types and Depex need to make sure their [Depex] section is correct. The [Depex] section does allow syntax to provide a module type specific depex such as: The DxeNetLib lists the following module compatibiliy: But has a depex section that is applied to all module types the library supports So either DxeNetLib is listing extra module types that need to be removed or the [Depex] statement needs to be updated. I do not think that Also, the dependency on The RNG Protocol can be handled differently for DXE_DRIVER and UEFI_DRIVER and UEFI_APPLICATION. For UEFI_DRIVER and UEFI_APPLICATION, the depex must be empty and the constructor can look for the RNG Protocol or use a RegisterProtocolNotify(). Only DXE_DRIVER can use a direct [Depex] on RNG Protocol. The most compatible lib would be to remove the [Depex] all together and use RegisterProtocolNotify() and have services that do not work until the RNG Protocol is available. In general, the mix of UEFI_DRIVER and DXE_DRIVER in the network stack does not make sense. The network stack should be pure UEFI Drivers that can be loaded from Boot Manager or the Shell as well as embedded in platform FW. |
Thanks for your explanation, I understood your thought. The DxeNetLib issue is different with the subject of this PR, so I'll submit another PR to fix the issue later. |
@mdkinney - Hi. I'm not sure what should happen, but if not for your comment I would have said I am almost certain that DXE Drivers can be loaded from the Shell. A quick Google seems to confirm, though I haven't had a chance to retest what I thought I knew. |
Description
Fixes #12276
The INF specification said:
Thus, this series of patches does the following:
Remove improper Depex section in UEFI_DRIVER and UEFI_APPLICATION. If the driver really depends on certain protocol, use notify function to handle the dependency.
Adds a check when retrieving dependency expression in BaseTools. If the module has [Depex] section but it's not permitted by INF specification, just throw warning message t instead of break the building proccess.
Breaking change?
Impacts security?
Includes tests?
How This Was Tested
build -a X64 -t GCC -p RedfishPkg/RedfishPkg.dscbuild -a X64 -t GCC -p NetworkPkg/NetworkPkg.dscbuild -a X64 -t GCC -p MdeModulePkg/MdeModulePkg.dscbuild -a X64 -t GCC -p MdePkg/MdePkg.dscbuild -a X64 -t GCC -p ShellPkg/ShellPkg.dsc...[Depex] section is not permitted for UEFI_DRIVER/UEFI_APPLICATION moduleIntegration Instructions
Once the PR is merged, all UEFI drivers and uefi applications with [Depex] section will not be blocked by BaseTools when building but only warning message is throwed. If the driver is UEFI driver, remove Depex from INF file and check dependent protocol in driver binding Start() function or notify function if necessary.