From fa542a1e770ac651b7a2f9e6650210465c824f7c Mon Sep 17 00:00:00 2001 From: mdkinney Date: Mon, 6 Dec 2010 21:55:14 +0000 Subject: [PATCH 1/1] 1) Change location of DEBUG() macro that prints the name of the FFS file being evaluated by the DXE Dispatcher to eliminate a duplicate print. 2) Change location of DEBUG() macro that prints the name of the FFS file being evaluated by the SMM Dispatcher to eliminate a duplicate print. 3) Remove all references and processing of SOR from the PiSmmCore. Treat use of SOR in the dependency expression of an SMM Driver as an invalid depex opcode. 4) Remove all references for an SMM Driver being in the "Untrusted" state from the PiSmmCore. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11127 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c | 4 +- MdeModulePkg/Core/PiSmmCore/Dependency.c | 22 +---- MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 96 +++---------------- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 5 +- 4 files changed, 18 insertions(+), 109 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c index 0ec9690890..1d8a57b879 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dependency.c @@ -220,8 +220,6 @@ CoreIsSchedulable ( EFI_GUID DriverGuid; VOID *Interface; - DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName)); - Operator = FALSE; Operator2 = FALSE; @@ -233,6 +231,8 @@ CoreIsSchedulable ( return FALSE; } + DEBUG ((DEBUG_DISPATCH, "Evaluate DXE DEPEX for FFS(%g)\n", &DriverEntry->FileName)); + if (DriverEntry->Depex == NULL) { // // A NULL Depex means treat the driver like an UEFI 2.0 thing. diff --git a/MdeModulePkg/Core/PiSmmCore/Dependency.c b/MdeModulePkg/Core/PiSmmCore/Dependency.c index 4bf8502cf8..44f693ac83 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dependency.c +++ b/MdeModulePkg/Core/PiSmmCore/Dependency.c @@ -161,8 +161,7 @@ PopBool ( /** This is the POSTFIX version of the dependency evaluator. This code does not need to handle Before or After, as it is not valid to call this - routine in this case. The SOR is just ignored and is a nop in the grammer. - POSTFIX means all the math is done on top of the stack. + routine in this case. POSTFIX means all the math is done on top of the stack. @param DriverEntry DriverEntry element to update. @@ -183,8 +182,6 @@ SmmIsSchedulable ( EFI_GUID DriverGuid; VOID *Interface; - DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName)); - Operator = FALSE; Operator2 = FALSE; @@ -196,6 +193,8 @@ SmmIsSchedulable ( return FALSE; } + DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName)); + if (DriverEntry->Depex == NULL) { // // A NULL Depex means that the SMM driver is not built correctly. @@ -239,21 +238,6 @@ SmmIsSchedulable ( // DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected BEFORE or AFTER opcode)\n")); ASSERT (FALSE); - case EFI_DEP_SOR: - // - // These opcodes can only appear once as the first opcode. If it is found - // at any other location, then the dependency expression evaluates to FALSE - // - if (Iterator != DriverEntry->Depex) { - DEBUG ((DEBUG_DISPATCH, " SOR\n")); - DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected SOR opcode)\n")); - return FALSE; - } - DEBUG ((DEBUG_DISPATCH, " SOR = Requested\n")); - // - // Otherwise, it is the first opcode and should be treated as a NOP. - // - break; case EFI_DEP_PUSH: // diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index d83224e322..3ed464e938 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -2,7 +2,7 @@ SMM Driver Dispatcher. Step #1 - When a FV protocol is added to the system every driver in the FV - is added to the mDiscoveredList. The SOR, Before, and After Depex are + is added to the mDiscoveredList. The Before, and After Depex are pre-processed as drivers are added to the mDiscoveredList. If an Apriori file exists in the FV those drivers are addeded to the mScheduledQueue. The mFvHandleList is used to make sure a @@ -26,7 +26,6 @@ is the state diagram for the DXE dispatcher Depex - Dependency Expresion. - SOR - Schedule On Request - Don't schedule if this bit is set. Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available @@ -644,10 +643,8 @@ SmmLoadImage ( /** Preprocess dependency expression and update DriverEntry to reflect the - state of Before, After, and SOR dependencies. If DriverEntry->Before - or DriverEntry->After is set it will never be cleared. If SOR is set - it will be cleared by SmmSchedule(), and then the driver can be - dispatched. + state of Before and After dependencies. If DriverEntry->Before + or DriverEntry->After is set it will never be cleared. @param DriverEntry DriverEntry element to update . @@ -662,11 +659,7 @@ SmmPreProcessDepex ( UINT8 *Iterator; Iterator = DriverEntry->Depex; - if (*Iterator == EFI_DEP_SOR) { - DriverEntry->Unrequested = TRUE; - } else { - DriverEntry->Dependent = TRUE; - } + DriverEntry->Dependent = TRUE; if (*Iterator == EFI_DEP_BEFORE) { DriverEntry->Before = TRUE; @@ -735,8 +728,8 @@ SmmGetDepexSectionAndPreProccess ( } } else { // - // Set Before, After, and Unrequested state information based on Depex - // Driver will be put in Dependent or Unrequested state + // Set Before and After state information based on Depex + // Driver will be put in Dependent state // SmmPreProcessDepex (DriverEntry); DriverEntry->DepexProtocolError = FALSE; @@ -745,54 +738,6 @@ SmmGetDepexSectionAndPreProccess ( return Status; } -/** - Check every driver and locate a matching one. If the driver is found, the Unrequested - state flag is cleared. - - @param FirmwareVolumeHandle The handle of the Firmware Volume that contains - the firmware file specified by DriverName. - @param DriverName The Driver name to put in the Dependent state. - - @retval EFI_SUCCESS The DriverName was found and it's SOR bit was - cleared - @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was - not set. - -**/ -EFI_STATUS -SmmSchedule ( - IN EFI_HANDLE FirmwareVolumeHandle, - IN EFI_GUID *DriverName - ) -{ - LIST_ENTRY *Link; - EFI_SMM_DRIVER_ENTRY *DriverEntry; - - // - // Check every driver - // - for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { - DriverEntry = CR(Link, EFI_SMM_DRIVER_ENTRY, Link, EFI_SMM_DRIVER_ENTRY_SIGNATURE); - if (DriverEntry->FvHandle == FirmwareVolumeHandle && - DriverEntry->Unrequested && - CompareGuid (DriverName, &DriverEntry->FileName)) { - // - // Move the driver from the Unrequested to the Dependent state - // - DriverEntry->Unrequested = FALSE; - DriverEntry->Dependent = TRUE; - - DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_SUCCESS\n", DriverName)); - - return EFI_SUCCESS; - } - } - - DEBUG ((DEBUG_DISPATCH, "Schedule FFS(%g) - EFI_NOT_FOUND\n", DriverName)); - - return EFI_NOT_FOUND; -} - /** This is the main Dispatcher for SMM and it exits when there are no more drivers to run. Drain the mScheduledQueue and load and start a PE @@ -856,22 +801,11 @@ SmmDispatcher ( // Update the driver state to reflect that it's been loaded // if (EFI_ERROR (Status)) { - - if (Status == EFI_SECURITY_VIOLATION) { - // - // Take driver from Scheduled to Untrused state - // - DriverEntry->Untrusted = TRUE; - } else { - // - // The SMM Driver could not be loaded, and do not attempt to load or start it again. - // Take driver from Scheduled to Initialized. - // - // This case include the Never Trusted state if EFI_ACCESS_DENIED is returned - // - DriverEntry->Initialized = TRUE; - } - + // + // The SMM Driver could not be loaded, and do not attempt to load or start it again. + // Take driver from Scheduled to Initialized. + // + DriverEntry->Initialized = TRUE; DriverEntry->Scheduled = FALSE; RemoveEntryList (&DriverEntry->ScheduledLink); @@ -930,12 +864,6 @@ SmmDispatcher ( SmmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry); ReadyToRun = TRUE; } - } else { - if (DriverEntry->Unrequested) { - DEBUG ((DEBUG_DISPATCH, "Evaluate SMM DEPEX for FFS(%g)\n", &DriverEntry->FileName)); - DEBUG ((DEBUG_DISPATCH, " SOR = Not Requested\n")); - DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE\n")); - } } } } while (ReadyToRun); @@ -1131,7 +1059,7 @@ SmmFvToDevicePath ( /** Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry, and initilize any state variables. Read the Depex from the FV and store it - in DriverEntry. Pre-process the Depex to set the SOR, Before and After state. + in DriverEntry. Pre-process the Depex to set the Before and After state. The Discovered list is never free'ed and contains booleans that represent the other possible SMM driver states. diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h index 9562e982ed..5cd1237056 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -80,9 +80,7 @@ typedef struct { EFI_GUID BeforeAfterGuid; BOOLEAN Dependent; - BOOLEAN Unrequested; BOOLEAN Scheduled; - BOOLEAN Untrusted; BOOLEAN Initialized; BOOLEAN DepexProtocolError; @@ -702,8 +700,7 @@ SmmRemoveInterfaceFromProtocol ( /** This is the POSTFIX version of the dependency evaluator. This code does not need to handle Before or After, as it is not valid to call this - routine in this case. The SOR is just ignored and is a nop in the grammer. - POSTFIX means all the math is done on top of the stack. + routine in this case. POSTFIX means all the math is done on top of the stack. @param DriverEntry DriverEntry element to update. -- 2.39.2