Date   

[PATCH 33/35] StandaloneMmPkg/Core: stop abusing EFI_HANDLE for FwVolHeader tracking

Laszlo Ersek
 

The FvHasBeenProcessed() and FvIsBeingProcesssed() functions make sure
that every firmware volume is processed only once (every driver in every
firmware volume should be discovered only once). For this, the functions
use a linked list.

In MdeModulePkg's DXE Core and SMM Core, the key used for identifying
those firmware volumes that have been processed is the EFI_HANDLE on whic=
h
the DXE or SMM firmware volume protocol is installed. In the
StandaloneMmPkg core however, the key is the address of the firmware
volume header; that is, it has type (EFI_FIRMWARE_VOLUME_HEADER*).

(EFI_FIRMWARE_VOLUME_HEADER*) has nothing to do with EFI_HANDLE.
EFI_HANDLE just happens to be specified as (VOID*), and therefore the
conversion between (EFI_FIRMWARE_VOLUME_HEADER*) and EFI_HANDLE is silent=
.

(The FvHasBeenProcessed() and FvIsBeingProcesssed() functions were likely
copied verbatim from MdeModulePkg's DXE Core and/or the SMM Core, and not
flagged by the compiler in StandaloneMmPkg due to UEFI regrettably
specifying EFI_HANDLE as (VOID*), thereby enabling the above implicit
conversion.)

We should not exploit this circumstance. Represent the key type faithfull=
y
instead.

This is a semantic fix; there is no change in operation.

Cc: Achin Gupta <achin.gupta@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

StandaloneMmPkg/Core/StandaloneMmCore.h | 2 +-
StandaloneMmPkg/Core/Dispatcher.c | 80 +++++++++++---------
StandaloneMmPkg/Core/FwVol.c | 16 ++--
3 files changed, 52 insertions(+), 46 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Co=
re/StandaloneMmCore.h
index dcf91bc5e916..23ddbe169faf 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.h
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.h
@@ -67,7 +67,7 @@ typedef struct {
=20
LIST_ENTRY ScheduledLink; // mScheduledQueue
=20
- EFI_HANDLE FvHandle;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_GUID FileName;
VOID *Pe32Data;
UINTN Pe32DataSize;
diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dis=
patcher.c
index 3788389f95ed..9853445a64a1 100644
--- a/StandaloneMmPkg/Core/Dispatcher.c
+++ b/StandaloneMmPkg/Core/Dispatcher.c
@@ -5,7 +5,7 @@
is added to the mDiscoveredList. The Before, and After Depex=
are
pre-processed as drivers are added to the mDiscoveredList. I=
f an Apriori
file exists in the FV those drivers are addeded to the
- mScheduledQueue. The mFvHandleList is used to make sure a
+ mScheduledQueue. The mFwVolList is used to make sure a
FV is only processed once.
=20
Step #2 - Dispatch. Remove driver from the mScheduledQueue and load an=
d
@@ -40,13 +40,13 @@
//
// MM Dispatcher Data structures
//
-#define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')
+#define KNOWN_FWVOL_SIGNATURE SIGNATURE_32('k','n','o','w')
=20
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link; // mFvHandleList
- EFI_HANDLE Handle;
-} KNOWN_HANDLE;
+ UINTN Signature;
+ LIST_ENTRY Link; // mFwVolList
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+} KNOWN_FWVOL;
=20
//
// Function Prototypes
@@ -86,9 +86,10 @@ LIST_ENTRY mDiscoveredList =3D INITIALIZE_LIST_HEAD_V=
ARIABLE (mDiscoveredList);
LIST_ENTRY mScheduledQueue =3D INITIALIZE_LIST_HEAD_VARIABLE (mSchedule=
dQueue);
=20
//
-// List of handles who's Fv's have been parsed and added to the mFwDrive=
rList.
+// List of firmware volume headers whose containing firmware volumes hav=
e been
+// parsed and added to the mFwDriverList.
//
-LIST_ENTRY mFvHandleList =3D INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleLi=
st);
+LIST_ENTRY mFwVolList =3D INITIALIZE_LIST_HEAD_VARIABLE (mFwVolList);
=20
//
// Flag for the MM Dispacher. TRUE if dispatcher is execuing.
@@ -769,26 +770,30 @@ MmInsertOnScheduledQueueWhileProcessingBeforeAndAft=
er (
}
=20
/**
- Return TRUE if the Fv has been processed, FALSE if not.
+ Return TRUE if the firmware volume has been processed, FALSE if not.
=20
- @param FvHandle The handle of a FV that's being tested
+ @param FwVolHeader The header of the firmware volume that's=
being
+ tested.
=20
- @retval TRUE Fv protocol on FvHandle has been process=
ed
- @retval FALSE Fv protocol on FvHandle has not yet been
- processed
+ @retval TRUE The firmware volume denoted by FwVolHead=
er has
+ been processed
+ @retval FALSE The firmware volume denoted by FwVolHead=
er has
+ not yet been processed
=20
**/
BOOLEAN
FvHasBeenProcessed (
- IN EFI_HANDLE FvHandle
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
)
{
LIST_ENTRY *Link;
- KNOWN_HANDLE *KnownHandle;
+ KNOWN_FWVOL *KnownFwVol;
=20
- for (Link =3D mFvHandleList.ForwardLink; Link !=3D &mFvHandleList; Lin=
k =3D Link->ForwardLink) {
- KnownHandle =3D CR (Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE=
);
- if (KnownHandle->Handle =3D=3D FvHandle) {
+ for (Link =3D mFwVolList.ForwardLink;
+ Link !=3D &mFwVolList;
+ Link =3D Link->ForwardLink) {
+ KnownFwVol =3D CR (Link, KNOWN_FWVOL, Link, KNOWN_FWVOL_SIGNATURE);
+ if (KnownFwVol->FwVolHeader =3D=3D FwVolHeader) {
return TRUE;
}
}
@@ -796,28 +801,29 @@ FvHasBeenProcessed (
}
=20
/**
- Remember that Fv protocol on FvHandle has had it's drivers placed on t=
he
- mDiscoveredList. This fucntion adds entries on the mFvHandleList. Item=
s are
- never removed/freed from the mFvHandleList.
+ Remember that the firmware volume denoted by FwVolHeader has had its d=
rivers
+ placed on mDiscoveredList. This function adds entries to mFwVolList. I=
tems
+ are never removed/freed from mFwVolList.
=20
- @param FvHandle The handle of a FV that has been process=
ed
+ @param FwVolHeader The header of the firmware volume that's=
being
+ processed.
=20
**/
VOID
FvIsBeingProcesssed (
- IN EFI_HANDLE FvHandle
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
)
{
- KNOWN_HANDLE *KnownHandle;
+ KNOWN_FWVOL *KnownFwVol;
=20
- DEBUG ((DEBUG_INFO, "FvIsBeingProcesssed - 0x%08x\n", FvHandle));
+ DEBUG ((DEBUG_INFO, "FvIsBeingProcesssed - 0x%08x\n", KnownFwVol));
=20
- KnownHandle =3D AllocatePool (sizeof (KNOWN_HANDLE));
- ASSERT (KnownHandle !=3D NULL);
+ KnownFwVol =3D AllocatePool (sizeof (KNOWN_FWVOL));
+ ASSERT (KnownFwVol !=3D NULL);
=20
- KnownHandle->Signature =3D KNOWN_HANDLE_SIGNATURE;
- KnownHandle->Handle =3D FvHandle;
- InsertTailList (&mFvHandleList, &KnownHandle->Link);
+ KnownFwVol->Signature =3D KNOWN_FWVOL_SIGNATURE;
+ KnownFwVol->FwVolHeader =3D FwVolHeader;
+ InsertTailList (&mFwVolList, &KnownFwVol->Link);
}
=20
/**
@@ -842,12 +848,12 @@ FvIsBeingProcesssed (
**/
EFI_STATUS
MmAddToDriverList (
- IN EFI_HANDLE FvHandle,
- IN VOID *Pe32Data,
- IN UINTN Pe32DataSize,
- IN VOID *Depex,
- IN UINTN DepexSize,
- IN EFI_GUID *DriverName
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN VOID *Pe32Data,
+ IN UINTN Pe32DataSize,
+ IN VOID *Depex,
+ IN UINTN DepexSize,
+ IN EFI_GUID *DriverName
)
{
EFI_MM_DRIVER_ENTRY *DriverEntry;
@@ -863,7 +869,7 @@ MmAddToDriverList (
=20
DriverEntry->Signature =3D EFI_MM_DRIVER_ENTRY_SIGNATURE;
CopyGuid (&DriverEntry->FileName, DriverName);
- DriverEntry->FvHandle =3D FvHandle;
+ DriverEntry->FwVolHeader =3D FwVolHeader;
DriverEntry->Pe32Data =3D Pe32Data;
DriverEntry->Pe32DataSize =3D Pe32DataSize;
DriverEntry->Depex =3D Depex;
diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c
index 9fe0c257a43a..99ecf4af4714 100644
--- a/StandaloneMmPkg/Core/FwVol.c
+++ b/StandaloneMmPkg/Core/FwVol.c
@@ -24,22 +24,22 @@ EFI_FV_FILETYPE mMmFileTypes[] =3D {
=20
EFI_STATUS
MmAddToDriverList (
- IN EFI_HANDLE FvHandle,
- IN VOID *Pe32Data,
- IN UINTN Pe32DataSize,
- IN VOID *Depex,
- IN UINTN DepexSize,
- IN EFI_GUID *DriverName
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN VOID *Pe32Data,
+ IN UINTN Pe32DataSize,
+ IN VOID *Depex,
+ IN UINTN DepexSize,
+ IN EFI_GUID *DriverName
);
=20
BOOLEAN
FvHasBeenProcessed (
- IN EFI_HANDLE FvHandle
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
);
=20
VOID
FvIsBeingProcesssed (
- IN EFI_HANDLE FvHandle
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
);
=20
EFI_STATUS
--=20
2.19.1.3.g30247aa5d201


[PATCH 32/35] ShellPkg/UefiShellLib: clarify workaround for unfixable EdkShell bug

Laszlo Ersek
 

The EDK 1 Shell (available at <https://github.com/tianocore/edk-Shell>)
has a bug in its EFI_SHELL_ENVIRONMENT2.Execute() implementation that
edk2's UefiShellLib has no choice but to work around.

Improve the explanation in the code. Also, document the implicit
EFI_HANDLE -> (EFI_HANDLE*) conversion, which happens implicitly after
dereferencing ParentHandle, with an explicit cast.

In practice, this patch is a no-op.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

ShellPkg/Library/UefiShellLib/UefiShellLib.c | 22 ++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Libr=
ary/UefiShellLib/UefiShellLib.c
index 835d0f88ca74..9f07a58eb23d 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -1291,9 +1291,27 @@ ShellExecute (
if (mEfiShellEnvironment2 !=3D NULL) {
//
// Call EFI Shell version.
- // Due to oddity in the EFI shell we want to dereference the ParentH=
andle here
//
- CmdStatus =3D (mEfiShellEnvironment2->Execute(*ParentHandle,
+ // Due to an unfixable bug in the EdkShell implementation, we must
+ // dereference "ParentHandle" here:
+ //
+ // 1. The EFI shell installs the EFI_SHELL_ENVIRONMENT2 protocol,
+ // identified by gEfiShellEnvironment2Guid.
+ // 2. The Execute() member function takes "ParentImageHandle" as fir=
st
+ // parameter, with type (EFI_HANDLE*).
+ // 3. In the EdkShell implementation, SEnvExecute() implements the
+ // Execute() member function. It passes "ParentImageHandle" corre=
ctly to
+ // SEnvDoExecute().
+ // 4. SEnvDoExecute() takes the (EFI_HANDLE*), and passes it directl=
y --
+ // without de-referencing -- to the HandleProtocol() boot service=
.
+ // 5. But HandleProtocol() takes an EFI_HANDLE.
+ //
+ // Therefore we must
+ // - de-reference "ParentHandle" here, to mask the bug in
+ // SEnvDoExecute(), and
+ // - pass the resultant EFI_HANDLE as an (EFI_HANDLE*).
+ //
+ CmdStatus =3D (mEfiShellEnvironment2->Execute((EFI_HANDLE *)*ParentH=
andle,
CommandLine,
Output));
//
--=20
2.19.1.3.g30247aa5d201


[PATCH 31/35] ShellPkg/UefiShellDebug1CommandsLib: fix ShellCloseFile() call

Laszlo Ersek
 

In the FileBufferSave() function, we invoke ShellCloseFile() if "Director=
y
Can Not Be Saved".

The ShellCloseFile() function takes a (SHELL_FILE_HANDLE*) parameter
called "FileHandle", and correctly passes the de-referenced (*FileHandle)
to EFI_SHELL_CLOSE_FILE, which takes a SHELL_FILE_HANDLE.

However, FileBufferSave() passes SHELL_FILE_HANDLE to ShellCloseFile(),
not the expected (SHELL_FILE_HANDLE*). Correct it.

This fixes an actual bug that has remained hidden for two reasons:

- pointer-to-VOID converts from/to any pointer-to-object type silently,
- the bug is on an error path which has likely never fired in practice.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
tested: edit (saving a file)

ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.=
c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
index 464f9de38e52..fd324cc4a861 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
@@ -1462,7 +1462,7 @@ FileBufferSave (
=20
if (Info !=3D NULL && Info->Attribute & EFI_FILE_DIRECTORY) {
StatusBarSetStatusString (L"Directory Can Not Be Saved");
- ShellCloseFile(FileHandle);
+ ShellCloseFile (&FileHandle);
FreePool(Info);
return EFI_LOAD_ERROR;
}
--=20
2.19.1.3.g30247aa5d201


[PATCH 30/35] ShellPkg: stop taking EFI_HANDLE in place of SHELL_FILE_HANDLE

Laszlo Ersek
 

The TouchFileByHandle() and IsDirectoryEmpty() functions are passed
SHELL_FILE_HANDLE parameters, and they use those parameters correctly.
However, their parameter lists say EFI_HANDLE.

Spell out the right type in the parameter lists.

In practice, this change is a no-op (because, quite regrettably, both
EFI_HANDLE and SHELL_FILE_HANDLE are specified to be typedefs of (VOID*))=
.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
tested: rm, touch

ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 2 +-
ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/=
Library/UefiShellLevel2CommandsLib/Rm.c
index 3a1196f1529e..59f7eec376f2 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
@@ -24,7 +24,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D {
**/
BOOLEAN
IsDirectoryEmpty (
- IN EFI_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
EFI_STATUS Status;
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c b/ShellP=
kg/Library/UefiShellLevel3CommandsLib/Touch.c
index 0f00344c815e..a215f5774c69 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
@@ -21,7 +21,7 @@
**/
EFI_STATUS
TouchFileByHandle (
- IN EFI_HANDLE Handle
+ IN SHELL_FILE_HANDLE Handle
)
{
EFI_STATUS Status;
--=20
2.19.1.3.g30247aa5d201


[PATCH 29/35] ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLE

Laszlo Ersek
 

The UefiShell*CommandsLib instances have constructor functions that do
something like:

gHiiHandle =3D HiiAddPackages (...);
...
ShellCommandRegisterCommandName (..., gHiiHandle, ...);

and destructor functions that implement the following pattern:

HiiRemovePackages (gHiiHandle);

The -- semantic, not functional -- problem is that "gHiiHandle" is
declared with type EFI_HANDLE, and not EFI_HII_HANDLE, in all of these
library instances, even though HiiAddPackages() correctly returns
EFI_HII_HANDLE, and HiiRemovePackages() takes EFI_HII_HANDLE.

Once we fix the type of "gHiiHandle", it causes sort of a butterfly
effect, because it is passed around widely. Track down and update all of
those locations.

The DynamicCommand lib instances use a similar pattern, so they are
affected too.

NOTE: in practice, this patch is a no-op, as both EFI_HII_HANDLE and
EFI_HANDLE are typedefs to (VOID*). However, we shouldn't use EFI_HANDLE
where semantically EFI_HII_HANDLE is passed around.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
tested with:
- level 1: stall, exit
- level 2: ls
- level 3: pause
- dynamic command: tftp
- handle parsing: drivers, devices, dh

ShellPkg/Include/Library/ShellCommandLib.h =
| 2 +-
ShellPkg/Include/Library/ShellLib.h =
| 4 ++--
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h =
| 4 ++--
ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h =
| 4 ++--
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h =
| 2 +-
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h=
| 2 +-
ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib=
.h | 2 +-
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h=
| 2 +-
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h=
| 2 +-
ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h=
| 2 +-
ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsL=
ib.h | 2 +-
ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsL=
ib.h | 2 +-
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c =
| 6 +++---
ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c =
| 6 +++---
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c =
| 2 +-
ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c =
| 2 +-
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c =
| 2 +-
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c=
| 2 +-
ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib=
.c | 2 +-
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c=
| 2 +-
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c=
| 2 +-
ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c=
| 2 +-
ShellPkg/Library/UefiShellLib/UefiShellLib.c =
| 4 ++--
ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsL=
ib.c | 2 +-
ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsL=
ib.c | 2 +-
25 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Includ=
e/Library/ShellCommandLib.h
index 287bc0eba7f9..63fcac82a2de 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -136,7 +136,7 @@ ShellCommandRegisterCommandName (
IN UINT32 ShellMinSupportLevel,
IN CONST CHAR16 *ProfileName,
IN CONST BOOLEAN CanAffectLE,
- IN CONST EFI_HANDLE HiiHandle,
+ IN CONST EFI_HII_HANDLE HiiHandle,
IN CONST EFI_STRING_ID ManFormatHelp
);
=20
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Libra=
ry/ShellLib.h
index 31594796cd21..1dc41f2cc11b 100644
--- a/ShellPkg/Include/Library/ShellLib.h
+++ b/ShellPkg/Include/Library/ShellLib.h
@@ -965,7 +965,7 @@ ShellPrintHiiEx(
IN INT32 Row OPTIONAL,
IN CONST CHAR8 *Language OPTIONAL,
IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
+ IN CONST EFI_HII_HANDLE HiiFormatHandle,
...
);
=20
@@ -1260,7 +1260,7 @@ EFIAPI
ShellPromptForResponseHii (
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
+ IN CONST EFI_HII_HANDLE HiiFormatHandle,
IN OUT VOID **Response
);
=20
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/Dyn=
amicCommand/DpDynamicCommand/Dp.h
index 43aa4505ee37..e446cccde923 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
@@ -36,7 +36,7 @@
#include <Library/UefiHiiServicesLib.h>
#include <Library/PerformanceLib.h>
=20
-extern EFI_HANDLE mDpHiiHandle;
+extern EFI_HII_HANDLE mDpHiiHandle;
=20
#define DP_MAJOR_VERSION 2
#define DP_MINOR_VERSION 5
@@ -133,7 +133,7 @@ RunDp (
=20
@return HII handle.
**/
-EFI_HANDLE
+EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
);
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h b/ShellPkg=
/DynamicCommand/TftpDynamicCommand/Tftp.h
index 7a9ed4724e1f..4cd778436813 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
@@ -30,7 +30,7 @@
#include <Library/PrintLib.h>
#include <Library/UefiHiiServicesLib.h>
=20
-extern EFI_HANDLE mTftpHiiHandle;
+extern EFI_HII_HANDLE mTftpHiiHandle;
=20
typedef struct {
UINTN FileSize;
@@ -62,7 +62,7 @@ RunTftp (
=20
@return HII handle.
**/
-EFI_HANDLE
+EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
);
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h b=
/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
index 36fe628a8c68..8ecc2f6bf5a2 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
@@ -46,7 +46,7 @@ typedef struct{
SHELL_GET_MAN_FILENAME GetManFileName;
SHELL_RUN_COMMAND CommandHandler;
BOOLEAN LastError;
- EFI_HANDLE HiiHandle;
+ EFI_HII_HANDLE HiiHandle;
EFI_STRING_ID ManFormatHelp;
} SHELL_COMMAND_INTERNAL_LIST_ENTRY;
=20
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C=
ommandsLib.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug=
1CommandsLib.h
index 32a933b9f062..082d488cb283 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands=
Lib.h
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands=
Lib.h
@@ -52,7 +52,7 @@
#include <Library/HandleParsingLib.h>
=20
=20
-extern EFI_HANDLE gShellDebug1HiiHandle;
+extern EFI_HII_HANDLE gShellDebug1HiiHandle;
=20
/**
Function returns a system configuration table that is stored in the
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver=
1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDr=
iver1CommandsLib.h
index 7e0b8b094057..ee795c4ce024 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman=
dsLib.h
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman=
dsLib.h
@@ -58,7 +58,7 @@
#include <Library/HandleParsingLib.h>
=20
=20
-extern EFI_HANDLE gShellDriver1HiiHandle;
+extern EFI_HII_HANDLE gShellDriver1HiiHandle;
extern BOOLEAN gInReconnect;
=20
/**
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1C=
ommandsLib.h b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel=
1CommandsLib.h
index 55acdd2b1f95..f2f9cc5dcf3b 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Commands=
Lib.h
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Commands=
Lib.h
@@ -33,7 +33,7 @@
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
=20
-extern EFI_HANDLE gShellLevel1HiiHandle;
+extern EFI_HII_HANDLE gShellLevel1HiiHandle;
=20
/**
Function for 'stall' command.
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2C=
ommandsLib.h b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel=
2CommandsLib.h
index 6d522d4bb4a1..77be6f1a12c7 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands=
Lib.h
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands=
Lib.h
@@ -43,7 +43,7 @@
#include <Library/FileHandleLib.h>
=20
extern CONST CHAR16 mFileName[];
-extern EFI_HANDLE gShellLevel2HiiHandle;
+extern EFI_HII_HANDLE gShellLevel2HiiHandle;
=20
/**
Function for 'attrib' command.
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3C=
ommandsLib.h b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel=
3CommandsLib.h
index 2d97ae4d3c91..c095b9275ed0 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Commands=
Lib.h
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Commands=
Lib.h
@@ -32,7 +32,7 @@
#include <Library/HiiLib.h>
#include <Library/FileHandleLib.h>
=20
-extern EFI_HANDLE gShellLevel3HiiHandle;
+extern EFI_HII_HANDLE gShellLevel3HiiHandle;
=20
/**
Function for 'type' command.
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwo=
rk1CommandsLib.h b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShel=
lNetwork1CommandsLib.h
index d4ed8c04652d..fddada2efa48 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Comm=
andsLib.h
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Comm=
andsLib.h
@@ -38,7 +38,7 @@
#include <Library/DevicePathLib.h>
#include <Library/PrintLib.h>
=20
-extern EFI_HANDLE gShellNetwork1HiiHandle;
+extern EFI_HII_HANDLE gShellNetwork1HiiHandle;
=20
/**
Function for 'ping' command.
diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwo=
rk2CommandsLib.h b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShel=
lNetwork2CommandsLib.h
index 9a5db32f2b76..9ea42cf26d53 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comm=
andsLib.h
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comm=
andsLib.h
@@ -27,7 +27,7 @@
#include <Library/HiiLib.h>
#include <Library/NetLib.h>
=20
-extern EFI_HANDLE gShellNetwork2HiiHandle;
+extern EFI_HII_HANDLE gShellNetwork2HiiHandle;
=20
/**
Function for 'ping6' command.
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/Dyn=
amicCommand/DpDynamicCommand/Dp.c
index 735cdcbcc018..4ec4c18348bd 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -36,7 +36,7 @@ typedef struct {
=20
#pragma pack()
=20
-EFI_HANDLE mDpHiiHandle;
+EFI_HII_HANDLE mDpHiiHandle;
=20
typedef struct {
EFI_HANDLE Handle;
@@ -924,14 +924,14 @@ Done:
=20
@return HII handle.
**/
-EFI_HANDLE
+EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HANDLE HiiHandle;
+ EFI_HII_HANDLE HiiHandle;
=20
//
// Retrieve HII package list from ImageHandle
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg=
/DynamicCommand/TftpDynamicCommand/Tftp.c
index 607899032e9d..f28da9af723c 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
@@ -11,7 +11,7 @@
#include "Tftp.h"
=20
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
-EFI_HANDLE mTftpHiiHandle;
+EFI_HII_HANDLE mTftpHiiHandle;
=20
/*
Constant strings and definitions related to the message indicating th=
e amount of
@@ -1087,14 +1087,14 @@ CheckPacket (
=20
@return HII handle.
**/
-EFI_HANDLE
+EFI_HII_HANDLE
InitializeHiiPackage (
EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
- EFI_HANDLE HiiHandle;
+ EFI_HII_HANDLE HiiHandle;
=20
//
// Retrieve HII package list from ImageHandle
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c=
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index f179c4109223..f62d30ef677a 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -14,7 +14,7 @@
#include <PiDxe.h>
#include <Protocol/FirmwareVolume2.h>
=20
-EFI_HANDLE mHandleParsingHiiHandle =3D NULL;
+EFI_HII_HANDLE mHandleParsingHiiHandle =3D NULL;
HANDLE_INDEX_LIST mHandleList =3D {{{NULL,NULL},0,0},0};
GUID_INFO_BLOCK *mGuidList;
UINTN mGuidListCount;
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgComman=
dLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib=
.c
index e8b48b4990dd..f8bcaebe46c8 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -38,7 +38,7 @@
#include <Library/UefiBootManagerLib.h>
=20
STATIC CONST CHAR16 mFileName[] =3D L"ShellCommands";
-STATIC EFI_HANDLE gShellBcfgHiiHandle =3D NULL;
+STATIC EFI_HII_HANDLE gShellBcfgHiiHandle =3D NULL;
=20
typedef enum {
BcfgTargetBootOrder =3D 0,
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b=
/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 826ced30a8c8..4c48b65fbc1d 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -554,7 +554,7 @@ ShellCommandRegisterCommandName (
IN UINT32 ShellMinSupportLevel,
IN CONST CHAR16 *ProfileName,
IN CONST BOOLEAN CanAffectLE,
- IN CONST EFI_HANDLE HiiHandle,
+ IN CONST EFI_HII_HANDLE HiiHandle,
IN CONST EFI_STRING_ID ManFormatHelp
)
{
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1C=
ommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug=
1CommandsLib.c
index ddce3bef5a30..f918867f47af 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands=
Lib.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Commands=
Lib.c
@@ -10,7 +10,7 @@
#include <Library/BcfgCommandLib.h>
=20
STATIC CONST CHAR16 mFileName[] =3D L"Debug1Commands";
-EFI_HANDLE gShellDebug1HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellDebug1HiiHandle =3D NULL;
=20
/**
Gets the debug file name. This will be used if HII is not working.
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver=
1CommandsLib.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDr=
iver1CommandsLib.c
index 4a05fa9942c4..e2219c62ec25 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman=
dsLib.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman=
dsLib.c
@@ -9,7 +9,7 @@
#include "UefiShellDriver1CommandsLib.h"
=20
STATIC CONST CHAR16 mFileName[] =3D L"Driver1Commands";
-EFI_HANDLE gShellDriver1HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellDriver1HiiHandle =3D NULL;
BOOLEAN gInReconnect =3D FALSE;
=20
/**
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1C=
ommandsLib.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel=
1CommandsLib.c
index ecbee99e3b3d..88cddd88ddc4 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Commands=
Lib.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Commands=
Lib.c
@@ -10,7 +10,7 @@
#include "UefiShellLevel1CommandsLib.h"
=20
STATIC CONST CHAR16 mFileName[] =3D L"ShellCommands";
-EFI_HANDLE gShellLevel1HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellLevel1HiiHandle =3D NULL;
=20
/**
Return the help text filename. Only used if no HII information found.
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2C=
ommandsLib.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel=
2CommandsLib.c
index c2a0bb492fbb..69427637bb87 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands=
Lib.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands=
Lib.c
@@ -29,7 +29,7 @@
#include "UefiShellLevel2CommandsLib.h"
=20
CONST CHAR16 mFileName[] =3D L"ShellCommands";
-EFI_HANDLE gShellLevel2HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellLevel2HiiHandle =3D NULL;
=20
/**
Get the filename to get help text from if not using HII.
diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3C=
ommandsLib.c b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel=
3CommandsLib.c
index 7d2cc4a48371..ce4afd117aa1 100644
--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Commands=
Lib.c
+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Commands=
Lib.c
@@ -9,7 +9,7 @@
#include "UefiShellLevel3CommandsLib.h"
=20
CONST CHAR16 gShellLevel3FileName[] =3D L"ShellCommands";
-EFI_HANDLE gShellLevel3HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellLevel3HiiHandle =3D NULL;
=20
/**
return the filename to get help from is not using HII.
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Libr=
ary/UefiShellLib/UefiShellLib.c
index 5be530092e1b..835d0f88ca74 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -2997,7 +2997,7 @@ ShellPrintHiiEx(
IN INT32 Row OPTIONAL,
IN CONST CHAR8 *Language OPTIONAL,
IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
+ IN CONST EFI_HII_HANDLE HiiFormatHandle,
...
)
{
@@ -3609,7 +3609,7 @@ EFIAPI
ShellPromptForResponseHii (
IN SHELL_PROMPT_REQUEST_TYPE Type,
IN CONST EFI_STRING_ID HiiFormatStringId,
- IN CONST EFI_HANDLE HiiFormatHandle,
+ IN CONST EFI_HII_HANDLE HiiFormatHandle,
IN OUT VOID **Response
)
{
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwo=
rk1CommandsLib.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShel=
lNetwork1CommandsLib.c
index 7e823cabd2fe..9a2b23fdc5ba 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Comm=
andsLib.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Comm=
andsLib.c
@@ -8,7 +8,7 @@
#include "UefiShellNetwork1CommandsLib.h"
=20
CONST CHAR16 gShellNetwork1FileName[] =3D L"ShellCommands";
-EFI_HANDLE gShellNetwork1HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellNetwork1HiiHandle =3D NULL;
=20
/**
return the file name of the help text file if not using HII.
diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwo=
rk2CommandsLib.c b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShel=
lNetwork2CommandsLib.c
index 5a7ffbfa19eb..4aab4295c1ba 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comm=
andsLib.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comm=
andsLib.c
@@ -8,7 +8,7 @@
#include "UefiShellNetwork2CommandsLib.h"
=20
CONST CHAR16 gShellNetwork2FileName[] =3D L"ShellCommands";
-EFI_HANDLE gShellNetwork2HiiHandle =3D NULL;
+EFI_HII_HANDLE gShellNetwork2HiiHandle =3D NULL;
=20
/**
return the file name of the help text file if not using HII.
--=20
2.19.1.3.g30247aa5d201


[PATCH 28/35] ShellPkg/UefiShellDriver1CommandsLib: fix parameter list typo

Laszlo Ersek
 

The ShellCommandRunConnect() function passes EFI_HANDLE -- (VOID*) --
objects to ConvertAndConnectControllers(), and
ConvertAndConnectControllers() passes those to gBS->OpenProtocol().

Accordingly, ConvertAndConnectControllers() should specify EFI_HANDLE
parameter types, not (EFI_HANDLE*) -- (VOID**) -- types.

This typo is masked because (VOID*) converts to and from any
pointer-to-object type silently.

Note that functionally speaking there is no problem, so this patch does
not change beavior, only cleans up the code.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
tested with "connect -r"

ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c b/She=
llPkg/Library/UefiShellDriver1CommandsLib/Connect.c
index 359394dfd291..3f4e132674ea 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
@@ -346,8 +346,8 @@ ShellConnectFromDevPaths (
**/
EFI_STATUS
ConvertAndConnectControllers (
- IN EFI_HANDLE *Handle1 OPTIONAL,
- IN EFI_HANDLE *Handle2 OPTIONAL,
+ IN EFI_HANDLE Handle1 OPTIONAL,
+ IN EFI_HANDLE Handle2 OPTIONAL,
IN CONST BOOLEAN Recursive,
IN CONST BOOLEAN Output
)
--=20
2.19.1.3.g30247aa5d201


[PATCH 27/35] SecurityPkg: stop abusing EFI_EVENT for protocol notify registration

Laszlo Ersek
 

EfiCreateProtocolNotifyEvent() takes a (VOID**) for "Registration",
similarly to gBS->RegisterProtocolNotify(). We should pass the address of
an actual pointer-to-VOID, and not the address of an EFI_EVENT. EFI_EVENT
just happens to be specified as (VOID*), and has nothing to do with the
registration.

This change is a no-op in practice; it's a semantic improvement.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jian Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

SecurityPkg/HddPassword/HddPasswordDxe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.c b/SecurityPkg/HddPa=
ssword/HddPasswordDxe.c
index b0d795b6597f..051e64091d7f 100644
--- a/SecurityPkg/HddPassword/HddPasswordDxe.c
+++ b/SecurityPkg/HddPassword/HddPasswordDxe.c
@@ -2770,7 +2770,7 @@ HddPasswordDxeInit (
{
EFI_STATUS Status;
HDD_PASSWORD_DXE_PRIVATE_DATA *Private;
- EFI_EVENT Registration;
+ VOID *Registration;
EFI_EVENT EndOfDxeEvent;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
=20
--=20
2.19.1.3.g30247aa5d201


[PATCH 26/35] SecurityPkg: fix UninstallMultipleProtocolInterfaces() calls

Laszlo Ersek
 

Unlike the InstallMultipleProtocolInterfaces() boot service, which takes
an (EFI_HANDLE*) as first parameter, the
UninstallMultipleProtocolInterfaces() boot service takes an EFI_HANDLE as
first parameter.

These are actual bugs. They must have remained hidden until now because
they are all in Unload() functions, which are probably exercised
infrequently. Fix the UninstallMultipleProtocolInterfaces() calls.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jian Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c =
| 2 +-
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c =
| 2 +-
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDr=
iver.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c b/SecurityPkg/=
Tcg/Tcg2Config/Tcg2ConfigDriver.c
index 54155a338100..9052eced757d 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
@@ -443,7 +443,7 @@ Tcg2ConfigDriverUnload (
ASSERT (PrivateData->Signature =3D=3D TCG2_CONFIG_PRIVATE_DATA_SIGNATU=
RE);
=20
gBS->UninstallMultipleProtocolInterfaces (
- &ImageHandle,
+ ImageHandle,
&gEfiCallerIdGuid,
PrivateData,
NULL
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c b/SecurityPkg=
/Tcg/TcgConfigDxe/TcgConfigDriver.c
index 341879e4c4ba..fb06624fdb8f 100644
--- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c
+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c
@@ -138,7 +138,7 @@ TcgConfigDriverUnload (
ASSERT (PrivateData->Signature =3D=3D TCG_CONFIG_PRIVATE_DATA_SIGNATUR=
E);
=20
gBS->UninstallMultipleProtocolInterfaces (
- &ImageHandle,
+ ImageHandle,
&gEfiCallerIdGuid,
PrivateData,
NULL
diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/Secure=
BootConfigDriver.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDx=
e/SecureBootConfigDriver.c
index 798ef9cfbc01..6c0294151e6c 100644
--- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCon=
figDriver.c
+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCon=
figDriver.c
@@ -115,7 +115,7 @@ SecureBootConfigDriverUnload (
ASSERT (PrivateData->Signature =3D=3D SECUREBOOT_CONFIG_PRIVATE_DATA_S=
IGNATURE);
=20
gBS->UninstallMultipleProtocolInterfaces (
- &ImageHandle,
+ ImageHandle,
&gEfiCallerIdGuid,
PrivateData,
NULL
--=20
2.19.1.3.g30247aa5d201


[PATCH 25/35] OvmfPkg/VideoDxe: document EFI_EDID_OVERRIDE_PROTOCOL.GetEdid() call

Laszlo Ersek
 

According to the UEFI spec -- and to the edk2 header
"MdePkg/Include/Protocol/EdidOverride.h" too --,
EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID takes an (EFI_HANDLE*), and not an
EFI_HANDLE, as second parameter ("ChildHandle").

This is probably [*] a bug in the UEFI spec. Given that this CSM module
(VideoDxe) had been used for a long time on physical platforms before it
was moved to OvmfPkg, keep the current "ChildHandle" argument, just cast
it explicitly.

[*] The edk2 tree contains no other GetEdid() call, and also no GetEdid()
implementation.

The edk2-platforms tree contains two GetEdid() calls, at commit
022c212167e0, in files
- "Drivers/DisplayLink/DisplayLinkPkg/DisplayLinkGop/Edid.c",
- "Drivers/OptionRomPkg/CirrusLogic5430Dxe/Edid.c".

From these, the first passes an (EFI_HANDLE*) as "ChildHandle", the
second passes an EFI_HANDLE. It's difficult to draw a conclusion. :/

No functional changes.

(I've also requested a non-normative (informative) clarification for the
UEFI spec: <https://mantis.uefi.org/mantis/view.php?id=3D2018>, in the
direction that matches this patch.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c b/OvmfPkg/Csm/Bio=
sThunk/VideoDxe/BiosVideo.c
index 0640656dba14..995136adee27 100644
--- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c
+++ b/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c
@@ -1402,9 +1402,13 @@ BiosVideoCheckForVbe (
goto Done;
}
=20
+ //
+ // Cast "ChildHandle" to (EFI_HANDLE*) in order to work around the s=
pec bug
+ // in UEFI v2.8, reported as Mantis#2018.
+ //
Status =3D EdidOverride->GetEdid (
EdidOverride,
- BiosVideoPrivate->Handle,
+ (EFI_HANDLE *) BiosVideoPrivate->Handle,
&EdidAttributes,
&EdidOverrideDataSize,
(UINT8 **) &EdidOverrideDataBlock
--=20
2.19.1.3.g30247aa5d201


[PATCH 24/35] OvmfPkg/PlatformDxe: fix EFI_HII_HANDLE parameters of internal functions

Laszlo Ersek
 

In the following call tree:

PlatformInit ()
mInstalledPackages =3D HiiAddPackages ()
GopInstalled ()
PopulateForm (PackageList =3D mInstalledPackages)
CreateResolutionOptions (PackageList)
HiiSetString (PackageList
HiiUpdateForm (PackageList)

PlatformDxe passes around an EFI_HII_HANDLE that (a) originates from
HiiAddPackages() and (b) is ultimately passed to HiiSetString() and
HiiUpdateForm(). The intermediate functions PopulateForm() and
CreateResolutionOptions() however take that parameter as an
(EFI_HII_HANDLE*).

There is no bug in practice (because the affected functions never try to
de-reference the "PackageList" parameter, they just pass it on), but the
function prototypes are semantically wrong. Fix that.

This could remain hidden so long because pointer-to-VOID silently convert=
s
to/from any pointer-to-object type, and the UEFI spec mandates that
EFI_HII_HANDLE be a typedef to (VOID*).

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
tested in UiApp

OvmfPkg/PlatformDxe/Platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platfor=
m.c
index 09181769babf..23ad43901f66 100644
--- a/OvmfPkg/PlatformDxe/Platform.c
+++ b/OvmfPkg/PlatformDxe/Platform.c
@@ -486,7 +486,7 @@ STATIC
EFI_STATUS
EFIAPI
CreateResolutionOptions (
- IN EFI_HII_HANDLE *PackageList,
+ IN EFI_HII_HANDLE PackageList,
OUT VOID **OpCodeBuffer,
IN UINTN NumGopModes,
IN GOP_MODE *GopModes
@@ -547,7 +547,7 @@ STATIC
EFI_STATUS
EFIAPI
PopulateForm (
- IN EFI_HII_HANDLE *PackageList,
+ IN EFI_HII_HANDLE PackageList,
IN EFI_GUID *FormSetGuid,
IN EFI_FORM_ID FormId,
IN UINTN NumGopModes,
--=20
2.19.1.3.g30247aa5d201


[PATCH 23/35] OvmfPkg/VirtioNetDxe: fix SignalEvent() call

Laszlo Ersek
 

The SignalEvent() boot service takes an EFI_EVENT, not an (EFI_EVENT*).
Fix the call in the notification function of
"EFI_SIMPLE_NETWORK_PROTOCOL.WaitForPacket".

This is an actual bug. The reason it's never been triggered is likely tha=
t
the "SNP.WaitForPacket" event is rarely waited for by applications -- edk=
2
itself has zero instances of that, for example.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

OvmfPkg/VirtioNetDxe/Events.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.=
c
index 620910774bc5..83e96e5e5d91 100644
--- a/OvmfPkg/VirtioNetDxe/Events.c
+++ b/OvmfPkg/VirtioNetDxe/Events.c
@@ -58,7 +58,7 @@ VirtioNetIsPacketAvailable (
MemoryFence ();
=20
if (Dev->RxLastUsed !=3D RxCurUsed) {
- gBS->SignalEvent (&Dev->Snp.WaitForPacket);
+ gBS->SignalEvent (Dev->Snp.WaitForPacket);
}
}
=20
--=20
2.19.1.3.g30247aa5d201


[PATCH 22/35] OvmfPkg/XenBusDxe: fix UninstallMultipleProtocolInterfaces() call

Laszlo Ersek
 

Unlike the InstallMultipleProtocolInterfaces() boot service, which takes
an (EFI_HANDLE*) as first parameter, the
UninstallMultipleProtocolInterfaces() boot service takes an EFI_HANDLE as
first parameter.

This is an actual bug. It must have remained hidden until now because it'=
s
on an error path. Fix the UninstallMultipleProtocolInterfaces() call.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien.grall@arm.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

OvmfPkg/XenBusDxe/XenBus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/XenBusDxe/XenBus.c b/OvmfPkg/XenBusDxe/XenBus.c
index bb8ddbc4d44d..2451e58a5961 100644
--- a/OvmfPkg/XenBusDxe/XenBus.c
+++ b/OvmfPkg/XenBusDxe/XenBus.c
@@ -210,7 +210,7 @@ XenBusAddDevice (
=20
ErrorOpenProtocolByChild:
gBS->UninstallMultipleProtocolInterfaces (
- &Private->Handle,
+ Private->Handle,
&gEfiDevicePathProtocolGuid, Private->DevicePath,
&gXenBusProtocolGuid, &Private->XenBusIo,
NULL);
--=20
2.19.1.3.g30247aa5d201


[PATCH 21/35] NetworkPkg/TcpDxe: fix SockFreeFoo() parameter list

Laszlo Ersek
 

The SockFreeFoo() callback function for NetbufFromExt() has to match the
NET_VECTOR_EXT_FREE prototype, which takes a (VOID*) as callback argument
(Arg). EFI_EVENT has nothing to do with NET_VECTOR_EXT_FREE. Fix the
SockFreeFoo() parameter list.

This change is a no-op in practice.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

NetworkPkg/TcpDxe/SockImpl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/TcpDxe/SockImpl.c b/NetworkPkg/TcpDxe/SockImpl.c
index f5e01771e2a8..fb28e2ed40d3 100644
--- a/NetworkPkg/TcpDxe/SockImpl.c
+++ b/NetworkPkg/TcpDxe/SockImpl.c
@@ -67,13 +67,13 @@ SockBufNext (
/**
User provided callback function for NetbufFromExt.
=20
- @param[in] Event The Event this notify function registered to, igno=
red.
+ @param[in] Arg The Arg parameter forwarded by NetbufFromExt(). Ig=
nored.
=20
**/
VOID
EFIAPI
SockFreeFoo (
- IN EFI_EVENT Event
+ IN VOID *Arg
)
{
return;
--=20
2.19.1.3.g30247aa5d201


[PATCH 20/35] NetworkPkg/Ip4Dxe: fix NetLibDestroyServiceChild() call

Laszlo Ersek
 

Both NetLibDestroyServiceChild() and EFI_SERVICE_BINDING_DESTROY_CHILD
take an EFI_HANDLE for the "ChildHandle" parameter, not an (EFI_HANDLE*).

This patch fixes a real bug.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
possibly only build-tested

NetworkPkg/Ip4Dxe/Ip4If.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/Ip4Dxe/Ip4If.c b/NetworkPkg/Ip4Dxe/Ip4If.c
index 44b8d9fc8faf..53a333037f94 100644
--- a/NetworkPkg/Ip4Dxe/Ip4If.c
+++ b/NetworkPkg/Ip4Dxe/Ip4If.c
@@ -592,7 +592,7 @@ Ip4SetAddress (
Interface->Controller,
Interface->Image,
&gEfiArpServiceBindingProtocolGuid,
- &Interface->ArpHandle
+ Interface->ArpHandle
);
=20
Interface->ArpHandle =3D NULL;
@@ -657,7 +657,7 @@ ON_ERROR:
Interface->Controller,
Interface->Image,
&gEfiArpServiceBindingProtocolGuid,
- &Interface->ArpHandle
+ Interface->ArpHandle
);
=20
return Status;
--=20
2.19.1.3.g30247aa5d201


[PATCH 19/35] NetworkPkg: fix CloseProtocol & UninstallMultipleProtocolInterfaces calls

Laszlo Ersek
 

Both the "ControllerHandle" parameter of CloseProtocol() and the "Handle"
parameter of UninstallMultipleProtocolInterfaces() have type EFI_HANDLE,
not (EFI_HANDLE*).

This patch fixes actual bugs. The issues have been dormant likely because
they are on error paths. (Or, in case of TlsAuthConfigDxe, because the
driver is unloaded likely very infrequently.)

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

NetworkPkg/DnsDxe/DnsDriver.c | 4 ++--
NetworkPkg/IScsiDxe/IScsiConfig.c | 2 +-
NetworkPkg/Ip4Dxe/Ip4Driver.c | 2 +-
NetworkPkg/Ip6Dxe/Ip6Driver.c | 2 +-
NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c | 2 +-
NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDriver.c b/NetworkPkg/DnsDxe/DnsDriver.=
c
index 94d072159a4d..ad007da8b7d6 100644
--- a/NetworkPkg/DnsDxe/DnsDriver.c
+++ b/NetworkPkg/DnsDxe/DnsDriver.c
@@ -1145,7 +1145,7 @@ Dns4ServiceBindingCreateChild (
DnsSb->ConnectUdp->UdpHandle,
&gEfiUdp4ProtocolGuid,
gDns4DriverBinding.DriverBindingHandle,
- ChildHandle
+ *ChildHandle
);
=20
gBS->UninstallMultipleProtocolInterfaces (
@@ -1388,7 +1388,7 @@ Dns6ServiceBindingCreateChild (
DnsSb->ConnectUdp->UdpHandle,
&gEfiUdp6ProtocolGuid,
gDns6DriverBinding.DriverBindingHandle,
- ChildHandle
+ *ChildHandle
);
=20
gBS->UninstallMultipleProtocolInterfaces (
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScs=
iConfig.c
index b876da7f5ccd..d773849fd3b0 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -3852,7 +3852,7 @@ IScsiConfigFormInit (
);
if (CallbackInfo->RegisteredHandle =3D=3D NULL) {
gBS->UninstallMultipleProtocolInterfaces (
- &CallbackInfo->DriverHandle,
+ CallbackInfo->DriverHandle,
&gEfiDevicePathProtocolGuid,
&mIScsiHiiVendorDevicePath,
&gEfiHiiConfigAccessProtocolGuid,
diff --git a/NetworkPkg/Ip4Dxe/Ip4Driver.c b/NetworkPkg/Ip4Dxe/Ip4Driver.=
c
index ebd4dec1dfe4..62be8b681a18 100644
--- a/NetworkPkg/Ip4Dxe/Ip4Driver.c
+++ b/NetworkPkg/Ip4Dxe/Ip4Driver.c
@@ -891,7 +891,7 @@ Ip4ServiceBindingCreateChild (
);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- ChildHandle,
+ *ChildHandle,
&gEfiIp4ProtocolGuid,
&IpInstance->Ip4Proto,
NULL
diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.=
c
index 7dc9e45af7b6..63d8428dbced 100644
--- a/NetworkPkg/Ip6Dxe/Ip6Driver.c
+++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c
@@ -888,7 +888,7 @@ Ip6ServiceBindingCreateChild (
);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- ChildHandle,
+ *ChildHandle,
&gEfiIp6ProtocolGuid,
&IpInstance->Ip6Proto,
NULL
diff --git a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c b/NetworkPkg/Mtftp4Dxe/M=
tftp4Driver.c
index ae9e65544a86..06c4e202d3ef 100644
--- a/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c
+++ b/NetworkPkg/Mtftp4Dxe/Mtftp4Driver.c
@@ -592,7 +592,7 @@ Mtftp4ServiceBindingCreateChild (
MtftpSb->ConnectUdp->UdpHandle,
&gEfiUdp4ProtocolGuid,
gMtftp4DriverBinding.DriverBindingHandle,
- ChildHandle
+ *ChildHandle
);
goto ON_ERROR;
}
diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c b/NetworkPkg/=
TlsAuthConfigDxe/TlsAuthConfigDxe.c
index 18ee763002b4..c0870ab9979c 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
@@ -39,7 +39,7 @@ TlsAuthConfigDxeUnload (
ASSERT (PrivateData->Signature =3D=3D TLS_AUTH_CONFIG_PRIVATE_DATA_SIG=
NATURE);
=20
gBS->UninstallMultipleProtocolInterfaces (
- &ImageHandle,
+ ImageHandle,
&gEfiCallerIdGuid,
PrivateData,
NULL
--=20
2.19.1.3.g30247aa5d201


[PATCH 18/35] NetworkPkg/DxeNetLib: fix type typo in NetLibGetMacAddress()

Laszlo Ersek
 

NetLibGetSnpHandle() returns an EFI_HANDLE, not an (EFI_HANDLE*).
NetLibGetMacAddress() only uses the return value ("SnpHandle") for a
NULL-check. Fix the type of "SnpHandle".

This patch is a no-op.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
lightly tested: MAC strings are displayed in UiApp

NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Librar=
y/DxeNetLib/DxeNetLib.c
index 8e2f720666ea..a39c20be3d34 100644
--- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c
+++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c
@@ -2182,7 +2182,7 @@ NetLibGetMacAddress (
EFI_SIMPLE_NETWORK_MODE SnpModeData;
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
EFI_SERVICE_BINDING_PROTOCOL *MnpSb;
- EFI_HANDLE *SnpHandle;
+ EFI_HANDLE SnpHandle;
EFI_HANDLE MnpChildHandle;
=20
ASSERT (MacAddress !=3D NULL);
--=20
2.19.1.3.g30247aa5d201


[PATCH 17/35] MdePkg/DxeServicesLib: remove bogus cast

Laszlo Ersek
 

The HandleProtocol() boot service takes an EFI_HANDLE, not an
(EFI_HANDLE*). Remove the bogus cast in the
InternalImageHandleToFvHandle() function.

This is a semantic cleanup; there is no change in behavior.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
lightly tested, most probably: it's practically impossible to build a
platform without consuming DxeServicesLib

MdePkg/Library/DxeServicesLib/DxeServicesLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c b/MdePkg/Libr=
ary/DxeServicesLib/DxeServicesLib.c
index c416b2dd8c65..0735b2f80400 100644
--- a/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
+++ b/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
@@ -49,7 +49,7 @@ InternalImageHandleToFvHandle (
ASSERT (ImageHandle !=3D NULL);
=20
Status =3D gBS->HandleProtocol (
- (EFI_HANDLE *) ImageHandle,
+ ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
--=20
2.19.1.3.g30247aa5d201


[PATCH 16/35] MdeModulePkg/S3SaveState: cast Position for S3BootScriptLib explicitly

Laszlo Ersek
 

The BootScriptInsert() and BootScriptLabel() functions take the in/out
parameter "Position" as (EFI_S3_BOOT_SCRIPT_POSITION*), and pass it to
S3BootScriptMoveLastOpcode() and S3BootScriptLabel(), respectively.

The callees take the in/out parameter "Position" as (VOID**). Add explici=
t
casts for clarity.

There is no change in functionality.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
lightly tested: multiple drivers in OVMF write S3 boot script fragmen=
ts

MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c | 4 ++--
MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c b/M=
deModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
index e94d15772d78..cfa8ebbd2f5d 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
@@ -810,7 +810,7 @@ BootScriptInsert (
}
=20
if (!EFI_ERROR (Status)) {
- Status =3D S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);
+ Status =3D S3BootScriptMoveLastOpcode (BeforeOrAfter, (VOID **)Positi=
on);
}
return Status;
}
@@ -851,7 +851,7 @@ BootScriptLabel (
IN CONST CHAR8 *Label
)
{
- return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, Position, L=
abel);
+ return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, (VOID **)Po=
sition, Label);
}
/**
Compare two positions in the boot script table and return their relati=
ve position.
diff --git a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c =
b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
index 9637df4fb82a..fc6d29e48ba9 100644
--- a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
@@ -808,7 +808,7 @@ BootScriptInsert (
}
=20
if (!EFI_ERROR (Status)) {
- Status =3D S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);
+ Status =3D S3BootScriptMoveLastOpcode (BeforeOrAfter, (VOID **)Positi=
on);
}
return Status;
}
@@ -849,7 +849,7 @@ BootScriptLabel (
IN CONST CHAR8 *Label
)
{
- return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, Position, L=
abel);
+ return S3BootScriptLabel (BeforeOrAfter, CreateIfNotFound, (VOID **)Po=
sition, Label);
}
/**
Compare two positions in the boot script table and return their relati=
ve position.
--=20
2.19.1.3.g30247aa5d201


[PATCH 15/35] MdeModulePkg/PiSmmCore: make type punning consistent

Laszlo Ersek
 

The SmiHandlerRegister() function explicitly casts "SmiHandler" (of type
(SMI_HANDLER*)) to EFI_HANDLE, when outputting "DispatchHandle".

Apply the same cast in the counterpart function SmiHandlerUnRegister(),
which compares multiple "SmiHandler"s against the input "DispatchHandle".

This is a semantic cleanup; there is no functional change.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only, most likely -- I'm unaware of any code paths in OV=
MF
that would lead to SmiHandlerUnRegister()

MdeModulePkg/Core/PiSmmCore/Smi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/Smi.c b/MdeModulePkg/Core/PiSmmC=
ore/Smi.c
index f8bd9f49ee3c..488af6754faf 100644
--- a/MdeModulePkg/Core/PiSmmCore/Smi.c
+++ b/MdeModulePkg/Core/PiSmmCore/Smi.c
@@ -282,7 +282,7 @@ SmiHandlerUnRegister (
//
SmiHandler =3D NULL;
for ( HandlerLink =3D GetFirstNode (&mRootSmiEntry.SmiHandlers)
- ; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) && (SmiHandler=
!=3D DispatchHandle)
+ ; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) && ((EFI_HANDL=
E) SmiHandler !=3D DispatchHandle)
; HandlerLink =3D GetNextNode (&mRootSmiEntry.SmiHandlers, Handler=
Link)
) {
SmiHandler =3D CR (HandlerLink, SMI_HANDLER, Link, SMI_HANDLER_SIGNA=
TURE);
@@ -292,19 +292,19 @@ SmiHandlerUnRegister (
// Look for it in non-root SMI handlers
//
for ( EntryLink =3D GetFirstNode (&mSmiEntryList)
- ; !IsNull (&mSmiEntryList, EntryLink) && (SmiHandler !=3D Dispatch=
Handle)
+ ; !IsNull (&mSmiEntryList, EntryLink) && ((EFI_HANDLE) SmiHandler =
!=3D DispatchHandle)
; EntryLink =3D GetNextNode (&mSmiEntryList, EntryLink)
) {
SmiEntry =3D CR (EntryLink, SMI_ENTRY, AllEntries, SMI_ENTRY_SIGNATU=
RE);
for ( HandlerLink =3D GetFirstNode (&SmiEntry->SmiHandlers)
- ; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) && (SmiHandler !=
=3D DispatchHandle)
+ ; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) && ((EFI_HANDLE)=
SmiHandler !=3D DispatchHandle)
; HandlerLink =3D GetNextNode (&SmiEntry->SmiHandlers, HandlerLi=
nk)
) {
SmiHandler =3D CR (HandlerLink, SMI_HANDLER, Link, SMI_HANDLER_SIG=
NATURE);
}
}
=20
- if (SmiHandler !=3D DispatchHandle) {
+ if ((EFI_HANDLE) SmiHandler !=3D DispatchHandle) {
return EFI_INVALID_PARAMETER;
}
=20
--=20
2.19.1.3.g30247aa5d201


[PATCH 14/35] MdeModulePkg: fix UninstallMultipleProtocolInterfaces() calls

Laszlo Ersek
 

Unlike the InstallMultipleProtocolInterfaces() boot service, which takes
an (EFI_HANDLE*) as first parameter, the
UninstallMultipleProtocolInterfaces() boot service takes an EFI_HANDLE as
first parameter.

These are actual bugs. They must have remained hidden until now because
they are on error paths. Fix the UninstallMultipleProtocolInterfaces()
calls.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c | 2 +-
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c | 2 +-
MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 6 +++---
MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 2 +-
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c | 2 +-
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 2 +-
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c | 2 +-
7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c b/MdeModulePkg/Bus/I2c/=
I2cDxe/I2cBus.c
index 2b54ec51dca0..ed33a51da252 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
@@ -720,7 +720,7 @@ Error:
=20
if (I2cBusContext !=3D NULL) {
Status =3D gBS->UninstallMultipleProtocolInterfaces (
- &Controller,
+ Controller,
gEfiCallerIdGuid,
I2cBusContext,
NULL
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModuleP=
kg/Bus/Pci/NvmExpressDxe/NvmExpress.c
index c6e401176a4b..3bde96bc9576 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
@@ -244,7 +244,7 @@ EnumerateNvmeDevNamespace (
);
if(EFI_ERROR(Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &Device->DeviceHandle,
+ Device->DeviceHandle,
&gEfiDevicePathProtocolGuid,
Device->DevicePath,
&gEfiBlockIoProtocolGuid,
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModul=
ePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index b7832c6970ad..292dd25da817 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -313,7 +313,7 @@ RegisterPciDevice (
);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &PciIoDevice->Handle,
+ PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
@@ -351,7 +351,7 @@ RegisterPciDevice (
);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &PciIoDevice->Handle,
+ PciIoDevice->Handle,
&gEfiDevicePathProtocolGuid,
PciIoDevice->DevicePath,
&gEfiPciIoProtocolGuid,
@@ -360,7 +360,7 @@ RegisterPciDevice (
);
if (HasEfiImage) {
gBS->UninstallMultipleProtocolInterfaces (
- &PciIoDevice->Handle,
+ PciIoDevice->Handle,
&gEfiLoadFile2ProtocolGuid,
&PciIoDevice->LoadFile2,
NULL
diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg=
/Bus/Pci/PciSioSerialDxe/Serial.c
index 82db93a8b117..9fe8a482e067 100644
--- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
@@ -665,7 +665,7 @@ CreateSerialDevice (
=20
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &SerialDevice->Handle,
+ SerialDevice->Handle,
&gEfiDevicePathProtocolGuid, SerialDevice->DevicePath,
&gEfiSerialIoProtocolGuid, &SerialDevice->SerialIo,
NULL
diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c b/MdeModulePkg/Bus/Sd/=
EmmcDxe/EmmcDxe.c
index 62f18d1878bd..e2ae56c5058a 100644
--- a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
+++ b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
@@ -475,7 +475,7 @@ InstallProtocolOnPartition (
);
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &Partition->Handle,
+ Partition->Handle,
&gEfiDevicePathProtocolGuid,
Partition->DevicePath,
&gEfiBlockIoProtocolGuid,
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bu=
s/Usb/UsbBusDxe/UsbEnumer.c
index eaa0d70024bb..cc0de52de411 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -159,7 +159,7 @@ UsbCreateInterface (
=20
if (EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- &UsbIf->Handle,
+ UsbIf->Handle,
&gEfiDevicePathProtocolGuid,
UsbIf->DevicePath,
&gEfiUsbIoProtocolGuid,
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeMo=
dulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
index 8c27e18cdb87..0dcbc5da2cb8 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
@@ -575,7 +575,7 @@ UsbMassInitMultiLun (
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: OpenUsbIoProtocol By Ch=
ild (%r)\n", Status));
gBS->UninstallMultipleProtocolInterfaces (
- &UsbMass->Controller,
+ UsbMass->Controller,
&gEfiDevicePathProtocolGuid,
UsbMass->DevicePath,
&gEfiBlockIoProtocolGuid,
--=20
2.19.1.3.g30247aa5d201