Date   

[PATCH v4] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Zhang, Shenglei
 

In DxeCheckBootVariable.c, add check for BootOrder and Variable
that return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL
when allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

v4: Update the logic in DxeCheckBootVariable.c.
We directly return when BootOrder/Variable == NULL, in previous versions.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 6 +++---
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
index 85bd5b3d..06a40505 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,7 +130,7 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, (VOID **)&BootOrder, &OrderSize);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR(Status)||(BootOrder == NULL)) {
continue;
}
for (Index = 0; Index < OrderSize/sizeof(CHAR16); Index++) {
@@ -222,7 +222,7 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR(Status)&&(Variable != NULL)) {
DumpKeyOption (KeyOptionName, Variable, Size);
} else {
break;
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
index 82709d44..28ca8382 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1


Re: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Chiu, Chasel
 

Feedbacks in below inline.

Thanks!
Chasel

-----Original Message-----
From: Zhang, Shenglei <shenglei.zhang@intel.com>
Sent: Wednesday, September 18, 2019 9:54 AM
To: devel@edk2.groups.io
Cc: Kubacki, Michael A <michael.a.kubacki@intel.com>; Chiu, Chasel
<chasel.chiu@intel.com>; Desimone, Nathaniel L
<nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for
pointers

In DxeCheckBootVariable.c, add check for BootOrder and Variable that
return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL when
allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 8 +++++++-
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
index 85bd5b3d..f658beb7 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB
ootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,6 +130,9 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex <
sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]);
ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder",
mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid,
(VOID **)&BootOrder, &OrderSize);
+ if(BootOrder == NULL) {
+ return EFI_NOT_FOUND;
+ }
I think we should continue the loop when BootOrder == NULL, we should not just return.
Suggest to combine the condition check in following line:

If (EFI_ERROR(Status) || (BootOrder == NULL)) {
continue;
}






if (EFI_ERROR(Status)) {
continue;
}
@@ -222,6 +225,9 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x",
mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid,
&Variable, &Size);
+ if(Variable == NULL) {
+ return EFI_NOT_FOUND;
+ }

Same here, I think we should not return directly.
Combine the check in following line:

If (!EFI_ERROR(Status) && (Variable != NULL)) {
DumpKeyOption (...);
else {
...





if (!EFI_ERROR(Status)) {
DumpKeyOption (KeyOptionName, Variable, Size);
} else {
diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
index 82709d44..28ca8382 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG
cd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors *
sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1


[PATCH V3 3/3] MdeModulePkg/BM_UI: Add the new terminal types to related menu

Gao, Zhichao
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186

Add the new introduced terminal types to related setup menu to change
the terminal type from setup. Most platforms would have its own
configure setup menu and they need to change it to support these.
The new introduced terminal types are Linux, XtermR6, VT400 and SCO.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
.../BootMaintenanceManager.h | 12 ++++---
.../BootMaintenanceManagerStrings.uni | 10 +++++-
.../ConsoleOption.c | 35 ++++++-------------
.../BootMaintenanceManagerUiLib/Data.c | 16 ++++++---
4 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
index ea3cdce794..67847d8bf3 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
@@ -1,7 +1,7 @@
/** @file
Header file for boot maintenance module.

-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -92,7 +92,11 @@ typedef enum _TYPE_OF_TERMINAL {
TerminalTypeVt100,
TerminalTypeVt100Plus,
TerminalTypeVtUtf8,
- TerminalTypeTtyTerm
+ TerminalTypeTtyTerm,
+ TerminalTypeLinux,
+ TerminalTypeXtermR6,
+ TerminalTypeVt400,
+ TerminalTypeSCO
} TYPE_OF_TERMINAL;

//
@@ -1301,12 +1305,12 @@ extern BM_MENU_OPTION ConsoleOutMenu;
extern BM_MENU_OPTION ConsoleErrMenu;
extern BM_MENU_OPTION DriverMenu;
extern BM_MENU_OPTION TerminalMenu;
-extern UINT16 TerminalType[5];
+extern UINT16 TerminalType[9];
extern COM_ATTR BaudRateList[19];
extern COM_ATTR DataBitsList[4];
extern COM_ATTR ParityList[5];
extern COM_ATTR StopBitsList[3];
-extern EFI_GUID TerminalTypeGuid[5];
+extern EFI_GUID TerminalTypeGuid[9];
extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath[];
extern UINT16 mFlowControlType[2];
extern UINT32 mFlowControlValue[2];
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
index 2e67d27bd0..3d47473e6c 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerStrings.uni
@@ -1,7 +1,7 @@
///** @file
// String definitions for Boot Maintenance Utility.
//
-// Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
//**/
@@ -233,6 +233,14 @@
#language fr-FR "VT_UTF8"
#string STR_COM_TYPE_4 #language en-US "TTY_TERM"
#language fr-FR "TTY_TERM"
+#string STR_COM_TYPE_5 #language en-US "LINUX"
+ #language fr-FR "LINUX"
+#string STR_COM_TYPE_6 #language en-US "XTERM_R6"
+ #language fr-FR "XTERM_R6"
+#string STR_COM_TYPE_7 #language en-US "VT_400"
+ #language fr-FR "VT_400"
+#string STR_COM_TYPE_8 #language en-US "SCO"
+ #language fr-FR "SCO"
#string STR_RESET #language en-US "Reset System"
#language fr-FR "Reset System"
#string STR_FORM_GOTO_MAIN #language en-US "Go Back To Main Page"
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
index 7a53b58771..b0641c5ee9 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
@@ -897,6 +897,7 @@ IsTerminalDevicePath (
VENDOR_DEVICE_PATH *Vendor;
UART_DEVICE_PATH *Uart;
ACPI_HID_DEVICE_PATH *Acpi;
+ UINTN Index;

IsTerminal = FALSE;

@@ -929,37 +930,21 @@ IsTerminalDevicePath (
}

//
- // There are four kinds of Terminal types
+ // There are 9 kinds of Terminal types
// check to see whether this devicepath
// is one of that type
//
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {
- *Termi = TerminalTypePcAnsi;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {
- *Termi = TerminalTypeVt100;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {
- *Termi = TerminalTypeVt100Plus;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {
- *Termi = TerminalTypeVtUtf8;
- IsTerminal = TRUE;
- } else {
- if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[4])) {
- *Termi = TerminalTypeTtyTerm;
- IsTerminal = TRUE;
- } else {
- IsTerminal = FALSE;
- }
- }
- }
+ for (Index = 0; Index < ARRAY_SIZE (TerminalTypeGuid); Index++) {
+ if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) {
+ *Termi = Index;
+ IsTerminal = TRUE;
}
}

+ if (Index == ARRAY_SIZE (TerminalTypeGuid)) {
+ IsTerminal = FALSE;
+ }
+
if (!IsTerminal) {
return FALSE;
}
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
index b9d86b09d8..21c4ef3d55 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c
@@ -1,7 +1,7 @@
/** @file
Define some data used for Boot Maint

-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -16,12 +16,16 @@ EFI_IFR_GUID_LABEL *mEndLabel = NULL;
///
/// Terminal type string token storage
///
-UINT16 TerminalType[] = {
+UINT16 TerminalType[9] = {
STRING_TOKEN(STR_COM_TYPE_0),
STRING_TOKEN(STR_COM_TYPE_1),
STRING_TOKEN(STR_COM_TYPE_2),
STRING_TOKEN(STR_COM_TYPE_3),
STRING_TOKEN(STR_COM_TYPE_4),
+ STRING_TOKEN(STR_COM_TYPE_5),
+ STRING_TOKEN(STR_COM_TYPE_6),
+ STRING_TOKEN(STR_COM_TYPE_7),
+ STRING_TOKEN(STR_COM_TYPE_8),
};

///
@@ -248,10 +252,14 @@ COM_ATTR StopBitsList[3] = {
///
/// Guid for messaging path, used in Serial port setting.
///
-EFI_GUID TerminalTypeGuid[] = {
+EFI_GUID TerminalTypeGuid[9] = {
DEVICE_PATH_MESSAGING_PC_ANSI,
DEVICE_PATH_MESSAGING_VT_100,
DEVICE_PATH_MESSAGING_VT_100_PLUS,
DEVICE_PATH_MESSAGING_VT_UTF8,
- EFI_TTY_TERM_GUID
+ EFI_TTY_TERM_GUID,
+ EDKII_LINUX_TERM_GUID,
+ EDKII_XTERM_R6_GUID,
+ EDKII_VT400_GUID,
+ EDKII_SCO_TERM_GUID
};
--
2.21.0.windows.1


[PATCH V3 2/3] MdeModulePkg/TerminalDxe: Extend the terminal console support types

Gao, Zhichao
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186

Extend the support types of terminal console driver. New added types
are Linux, XtermR6, VT400 and SCO.

Refer to
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

Add the missing VT100+ function keys map.

Add F1-F12 function keys map for Linux, XtermR6, VT400 and SCO.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
.../Universal/Console/TerminalDxe/Terminal.c | 17 +-
.../Universal/Console/TerminalDxe/Terminal.h | 37 ++-
.../Console/TerminalDxe/TerminalConIn.c | 282 ++++++++++++++++--
.../Console/TerminalDxe/TerminalConOut.c | 4 +
.../Console/TerminalDxe/TerminalDxe.inf | 6 +-
5 files changed, 320 insertions(+), 26 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
index c76b2c5100..fd26e4dafe 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c
@@ -2,7 +2,7 @@
Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
Simple Text Output Protocol upon Serial IO Protocol.

-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -28,7 +28,11 @@ EFI_GUID *mTerminalType[] = {
&gEfiVT100Guid,
&gEfiVT100PlusGuid,
&gEfiVTUTF8Guid,
- &gEfiTtyTermGuid
+ &gEfiTtyTermGuid,
+ &gEdkiiLinuxTermGuid,
+ &gEdkiiXtermR6Guid,
+ &gEdkiiVT400Guid,
+ &gEdkiiSCOTermGuid
};


@@ -37,7 +41,11 @@ CHAR16 *mSerialConsoleNames[] = {
L"VT-100 Serial Console",
L"VT-100+ Serial Console",
L"VT-UTF8 Serial Console",
- L"Tty Terminal Serial Console"
+ L"Tty Terminal Serial Console",
+ L"Linux Terminal Serial Console",
+ L"Xterm R6 Serial Console",
+ L"VT-400 Serial Console",
+ L"SCO Terminal Serial Console"
};

TERMINAL_DEV mTerminalDevTemplate = {
@@ -187,7 +195,8 @@ TerminalDriverBindingSupported (

}
//
- // only supports PC ANSI, VT100, VT100+, VT-UTF8, and TtyTerm terminal types
+ // only supports PC ANSI, VT100, VT100+, VT-UTF8, TtyTerm
+ // Linux, XtermR6, VT400 and SCO terminal types
//
if (TerminalTypeFromGuid (&Node->Guid) == ARRAY_SIZE (mTerminalType)) {
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index b2f0901fc1..d683aa792f 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -1,7 +1,7 @@
/** @file
Header file for Terminal driver.

-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -81,7 +81,11 @@ typedef enum {
TerminalTypeVt100,
TerminalTypeVt100Plus,
TerminalTypeVtUtf8,
- TerminalTypeTtyTerm
+ TerminalTypeTtyTerm,
+ TerminalTypeLinux,
+ TerminalTypeXtermR6,
+ TerminalTypeVt400,
+ TerminalTypeSCO
} TERMINAL_TYPE;

typedef struct {
@@ -126,7 +130,9 @@ typedef struct {
#define INPUT_STATE_LEFTOPENBRACKET 0x04
#define INPUT_STATE_O 0x08
#define INPUT_STATE_2 0x10
-#define INPUT_STATE_LEFTOPENBRACKET_2 0x20
+#define INPUT_STATE_LEFTOPENBRACKET_TTY 0x20
+#define INPUT_STATE_1 0x40
+#define INPUT_STATE_LEFTOPENBRACKET_2ND 0x80

#define RESET_STATE_DEFAULT 0x00
#define RESET_STATE_ESC_R 0x01
@@ -848,7 +854,8 @@ TerminalRemoveConsoleDevVariable (
/**
Build termial device path according to terminal type.

- @param TerminalType The terminal type is PC ANSI, VT100, VT100+ or VT-UTF8.
+ @param TerminalType The terminal type is PC ANSI, VT100, VT100+, VT-UTF8, TTY-Term,
+ Linux, XtermR6, VT400 and SCO.
@param ParentDevicePath Parent device path.
@param TerminalDevicePath Returned terminal device path, if building successfully.

@@ -1209,6 +1216,28 @@ AnsiRawDataToUnicode (
| F12 | 0x16 | | ESC @ | |
+=========+======+===========+==========+==========+

+Putty function key map:
+ +=========+======+===========+=============+=============+=============+=========+
+ | | EFI | | | | | |
+ | | Scan | | | Normal | | |
+ | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ +=========+======+===========+=============+=============+=============+=========+
+ | F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
+ | F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
+ | F3 | 0x0D | ESC O R | ESC O R | ESC [ 1 3 ~ | ESC [ [ C | ESC [ O |
+ | F4 | 0x0E | ESC O S | ESC O S | ESC [ 1 4 ~ | ESC [ [ D | ESC [ P |
+ | F5 | 0x0F | ESC O T | ESC [ 1 5 ~ | ESC [ 1 5 ~ | ESC [ [ E | ESC [ Q |
+ | F6 | 0x10 | ESC O U | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ R |
+ | F7 | 0x11 | ESC O V | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ S |
+ | F8 | 0x12 | ESC O W | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ T |
+ | F9 | 0x13 | ESC O X | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ U |
+ | F10 | 0x14 | ESC O Y | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ V |
+ | Escape | 0x17 | ESC | ESC | ESC | ESC | ESC |
+ | F11 | 0x15 | ESC O Z | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ W |
+ | F12 | 0x16 | ESC O [ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ X |
+ +=========+======+===========+=============+=============+=============+=========+
+
+
Special Mappings
================
ESC R ESC r ESC R = Reset System
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 4ede416774..ac31f27984 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -2,7 +2,7 @@
Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.

(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -453,6 +453,10 @@ TranslateRawDataToEfiKey (
case TerminalTypeVt100:
case TerminalTypeVt100Plus:
case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:
AnsiRawDataToUnicode (TerminalDevice);
UnicodeToEfiKey (TerminalDevice);
break;
@@ -1319,6 +1323,27 @@ UnicodeToEfiKeyFlushState (
| F12 | 0x16 | | ESC @ | |
+=========+======+===========+==========+==========+

+Putty function key map:
+ +=========+======+===========+=============+=============+=============+=========+
+ | | EFI | | | | | |
+ | | Scan | | | Normal | | |
+ | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ +=========+======+===========+=============+=============+=============+=========+
+ | F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
+ | F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
+ | F3 | 0x0D | ESC O R | ESC O R | ESC [ 1 3 ~ | ESC [ [ C | ESC [ O |
+ | F4 | 0x0E | ESC O S | ESC O S | ESC [ 1 4 ~ | ESC [ [ D | ESC [ P |
+ | F5 | 0x0F | ESC O T | ESC [ 1 5 ~ | ESC [ 1 5 ~ | ESC [ [ E | ESC [ Q |
+ | F6 | 0x10 | ESC O U | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ 1 7 ~ | ESC [ R |
+ | F7 | 0x11 | ESC O V | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ 1 8 ~ | ESC [ S |
+ | F8 | 0x12 | ESC O W | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ 1 9 ~ | ESC [ T |
+ | F9 | 0x13 | ESC O X | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ 2 0 ~ | ESC [ U |
+ | F10 | 0x14 | ESC O Y | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ 2 1 ~ | ESC [ V |
+ | Escape | 0x17 | ESC | ESC | ESC | ESC | ESC |
+ | F11 | 0x15 | ESC O Z | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ 2 3 ~ | ESC [ W |
+ | F12 | 0x16 | ESC O [ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ 2 4 ~ | ESC [ X |
+ +=========+======+===========+=============+=============+=============+=========+
+
Special Mappings
================
ESC R ESC r ESC R = Reset System
@@ -1378,7 +1403,9 @@ UnicodeToEfiKey (
}

if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm)) {
+ TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
+ TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt100Plus)) {
TerminalDevice->InputState |= INPUT_STATE_O;
TerminalDevice->ResetState = RESET_STATE_DEFAULT;
continue;
@@ -1548,6 +1575,60 @@ UnicodeToEfiKey (
Key.ScanCode = SCAN_END;
break;
}
+ } else if (TerminalDevice->TerminalType == TerminalTypeVt100Plus) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'T':
+ Key.ScanCode = SCAN_F5;
+ break;
+ case 'U':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case 'V':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case 'W':
+ Key.ScanCode = SCAN_F8;
+ break;
+ case 'X':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case 'Y':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case 'Z':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '[':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ } else if (TerminalDevice->TerminalType == TerminalTypeXtermR6) {
+ switch (UnicodeChar) {
+ case 'P':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'R':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'S':
+ Key.ScanCode = SCAN_F4;
+ break;
+ }
}

if (Key.ScanCode != SCAN_NULL) {
@@ -1564,15 +1645,34 @@ UnicodeToEfiKey (

case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET:

+ if (UnicodeChar == '1' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux)) {
+ TerminalDevice->InputState |= INPUT_STATE_1;
+ continue;
+ }
+
+ if (UnicodeChar == '2' && (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux)) {
+ TerminalDevice->InputState |= INPUT_STATE_2;
+ continue;
+ }
+
+ if (UnicodeChar == LEFTOPENBRACKET && TerminalDevice->TerminalType == TerminalTypeLinux) {
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2ND;
+ continue;
+ }
+
TerminalDevice->ResetState = RESET_STATE_DEFAULT;

Key.ScanCode = SCAN_NULL;

if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
TerminalDevice->TerminalType == TerminalTypeVt100 ||
- TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
- TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
- TerminalDevice->TerminalType == TerminalTypeTtyTerm) {
+ TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
+ TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
switch (UnicodeChar) {
case 'A':
Key.ScanCode = SCAN_UP;
@@ -1614,12 +1714,15 @@ UnicodeToEfiKey (
case 'X':
if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
Key.ScanCode = SCAN_DELETE;
+ } else if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F12;
}
break;
case 'P':
if (TerminalDevice->TerminalType == TerminalTypeVt100) {
Key.ScanCode = SCAN_DELETE;
- } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ } else if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F4;
}
break;
@@ -1629,7 +1732,8 @@ UnicodeToEfiKey (
}
break;
case 'V':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F10;
}
break;
@@ -1644,7 +1748,8 @@ UnicodeToEfiKey (
}
break;
case 'U':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F9;
}
break;
@@ -1654,40 +1759,52 @@ UnicodeToEfiKey (
}
break;
case 'M':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F1;
}
break;
case 'N':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F2;
}
break;
case 'O':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F3;
}
break;
case 'Q':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F5;
}
break;
case 'R':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F6;
}
break;
case 'S':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F7;
}
break;
case 'T':
- if (TerminalDevice->TerminalType == TerminalTypePcAnsi) {
+ if (TerminalDevice->TerminalType == TerminalTypePcAnsi ||
+ TerminalDevice->TerminalType == TerminalTypeSCO) {
Key.ScanCode = SCAN_F8;
}
break;
+ case 'W':
+ if (TerminalDevice->TerminalType == TerminalTypeSCO) {
+ Key.ScanCode = SCAN_F11;
+ }
+ break;
default :
break;
}
@@ -1704,10 +1821,105 @@ UnicodeToEfiKey (
UnicodeChar <= '9') {
TerminalDevice->TtyEscapeStr[0] = UnicodeChar;
TerminalDevice->TtyEscapeIndex = 1;
- TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2;
+ TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_TTY;
+ continue;
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
+
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_1:
+
+ TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+
+ Key.ScanCode = SCAN_NULL;
+
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case '1':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F1;
+ }
+ break;
+ case '2':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F2;
+ }
+ break;
+ case '3':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F3;
+ }
+ break;
+ case '4':
+ if (TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F4;
+ }
+ break;
+ case '5':
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400) {
+ Key.ScanCode = SCAN_F5;
+ }
+ break;
+ case '7':
+ Key.ScanCode = SCAN_F6;
+ break;
+ case '8':
+ Key.ScanCode = SCAN_F7;
+ break;
+ case '9':
+ Key.ScanCode = SCAN_F8;
+ break;
+ }
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
continue;
}

+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;
+
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_2:
+
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
+ if (TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
+ TerminalDevice->TerminalType == TerminalTypeVt400 ||
+ TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case '0':
+ Key.ScanCode = SCAN_F9;
+ break;
+ case '1':
+ Key.ScanCode = SCAN_F10;
+ break;
+ case '3':
+ Key.ScanCode = SCAN_F11;
+ break;
+ case '4':
+ Key.ScanCode = SCAN_F12;
+ break;
+ }
+ }
+
if (Key.ScanCode != SCAN_NULL) {
Key.UnicodeChar = 0;
EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
@@ -1720,8 +1932,44 @@ UnicodeToEfiKey (

break;

+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2ND:
+
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ Key.ScanCode = SCAN_NULL;
+
+ if (TerminalDevice->TerminalType == TerminalTypeLinux) {
+ switch (UnicodeChar) {
+ case 'A':
+ Key.ScanCode = SCAN_F1;
+ break;
+ case 'B':
+ Key.ScanCode = SCAN_F2;
+ break;
+ case 'C':
+ Key.ScanCode = SCAN_F3;
+ break;
+ case 'D':
+ Key.ScanCode = SCAN_F4;
+ break;
+ case 'E':
+ Key.ScanCode = SCAN_F5;
+ break;
+ }
+ }
+
+ if (Key.ScanCode != SCAN_NULL) {
+ Key.UnicodeChar = 0;
+ EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+ TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+ continue;
+ }
+
+ UnicodeToEfiKeyFlushState (TerminalDevice);
+
+ break;

- case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2:
+ case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_TTY:
/*
* Here we handle the VT220 escape codes that we accept. This
* state is only used by the TTY terminal type.
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index 7ef655cca5..aae470e956 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -222,6 +222,10 @@ TerminalConOutOutputString (
case TerminalTypeVt100:
case TerminalTypeVt100Plus:
case TerminalTypeTtyTerm:
+ case TerminalTypeLinux:
+ case TerminalTypeXtermR6:
+ case TerminalTypeVt400:
+ case TerminalTypeSCO:

if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {
//
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
index 24e164ef4d..b2a8aeba85 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
@@ -5,7 +5,7 @@
# protocols based on Serial I/O protocol for serial devices including hotplug serial
# devices.
#
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
@@ -69,6 +69,10 @@
gEfiVT100PlusGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiPcAnsiGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEfiTtyTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiLinuxTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiXtermR6Guid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiVT400Guid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
+ gEdkiiSCOTermGuid ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID

[Protocols]
--
2.21.0.windows.1


[PATCH V3 1/3] MdeModulePkg: Extend the support keyboard type of Terminal console

Gao, Zhichao
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186

A common terminal console software Putty support various types of
keyboard type, such as normal mode, Linux mode, Xterm R6, Vt400,
VT100+ and SCO. Refer to the link:
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
MdeModulePkg/Include/Guid/TtyTerm.h | 13 +++++++++++++
MdeModulePkg/MdeModulePkg.dec | 4 ++++
2 files changed, 17 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/TtyTerm.h b/MdeModulePkg/Include/Guid/TtyTerm.h
index 8333344b9d..471a651d4d 100644
--- a/MdeModulePkg/Include/Guid/TtyTerm.h
+++ b/MdeModulePkg/Include/Guid/TtyTerm.h
@@ -4,6 +4,7 @@ provide support for modern *nix terminals.


Copyright (c) 2015 Linaro Ltd.
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -14,6 +15,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_TTY_TERM_GUID \
{0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 } }

+#define EDKII_LINUX_TERM_GUID \
+ {0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 } }
+
+#define EDKII_XTERM_R6_GUID \
+ {0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb } }
+
+#define EDKII_VT400_GUID \
+ {0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd } }
+
+#define EDKII_SCO_TERM_GUID \
+ {0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a } }
+
extern EFI_GUID gEfiTtyTermGuid;

#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 17beb45235..7f72c122fc 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -342,6 +342,10 @@

## Include/Guid/TtyTerm.h
gEfiTtyTermGuid = { 0x7d916d80, 0x5bb1, 0x458c, {0xa4, 0x8f, 0xe2, 0x5f, 0xdd, 0x51, 0xef, 0x94 }}
+ gEdkiiLinuxTermGuid = { 0xe4364a7f, 0xf825, 0x430e, {0x9d, 0x3a, 0x9c, 0x9b, 0xe6, 0x81, 0x7c, 0xa5 }}
+ gEdkiiXtermR6Guid = { 0xfbfca56b, 0xbb36, 0x4b78, {0xaa, 0xab, 0xbe, 0x1b, 0x97, 0xec, 0x7c, 0xcb }}
+ gEdkiiVT400Guid = { 0x8e46dddd, 0x3d49, 0x4a9d, {0xb8, 0x75, 0x3c, 0x08, 0x6f, 0x6a, 0xa2, 0xbd }}
+ gEdkiiSCOTermGuid = { 0xfc7dd6e0, 0x813c, 0x434d, {0xb4, 0xda, 0x3b, 0xd6, 0x49, 0xe9, 0xe1, 0x5a }}

## Include/Guid/HiiBootMaintenanceFormset.h
gEfiIfrBootMaintenanceGuid = { 0xb2dedc91, 0xd59f, 0x48d2, { 0x89, 0x8a, 0x12, 0x49, 0xc, 0x74, 0xa4, 0xe0 }}
--
2.21.0.windows.1


[PATCH V3 0/3] MdeModulePkg/TerminalConsole: Extend the support terminal types

Gao, Zhichao
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186

Putty is a very popular terminal tool in windows. So add the whole support
terminal keyboard type for it. The new introduced type is Linux, XtermR6,
VT400 and SCO. And enhance the support for VT100+.
This patch set only add the support of function key. Refer to the link:
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys

V2:
Fix typo.
Merge the type guid defination into TtyTerm.h.

V3:
Fix incorrect removal of Ttyterm parse.
Change the guid name of terminal type linux and SCO to clear ones:
LinuxTerm and SCOTerm.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-of-by: Zhichao Gao <zhichao.gao@intel.com>

Zhichao Gao (3):
MdeModulePkg: Extend the support keyboard type of Terminal console
MdeModulePkg/TerminalDxe: Extend the terminal console support types
MdeModulePkg/BM_UI: Add the new terminal types to related menu

MdeModulePkg/Include/Guid/TtyTerm.h | 13 +
.../BootMaintenanceManager.h | 12 +-
.../BootMaintenanceManagerStrings.uni | 10 +-
.../ConsoleOption.c | 35 +--
.../BootMaintenanceManagerUiLib/Data.c | 16 +-
MdeModulePkg/MdeModulePkg.dec | 4 +
.../Universal/Console/TerminalDxe/Terminal.c | 17 +-
.../Universal/Console/TerminalDxe/Terminal.h | 37 ++-
.../Console/TerminalDxe/TerminalConIn.c | 282 ++++++++++++++++--
.../Console/TerminalDxe/TerminalConOut.c | 4 +
.../Console/TerminalDxe/TerminalDxe.inf | 6 +-
11 files changed, 376 insertions(+), 60 deletions(-)

--
2.21.0.windows.1


Re: [patch v2 3/5] MdeModulePkg/UefiBootManager: Unload image on EFI_SECURITY_VIOLATION

Gao, Zhichao
 

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Dandan Bi
Sent: Wednesday, September 18, 2019 11:06 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com>; Gao,
Liming <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>
Subject: [edk2-devel] [patch v2 3/5] MdeModulePkg/UefiBootManager:
Unload image on EFI_SECURITY_VIOLATION

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval, the
Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer the
execution of an image, we can not treat EFI_SECURITY_VIOLATION like any
other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly for
the callers in UefiBootManagerLib which don't have the policy to defer the
execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 9 +++++++++
.../Library/UefiBootManagerLib/BmLoadOption.c | 11 ++++++++++-
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 11
++++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 952033fc82..760d7647b8 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1859,10 +1859,19 @@ EfiBootManagerBoot (
if (FilePath != NULL) {
FreePool (FilePath);
}

if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not
be started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
//
// Report Status Code with the failure status to indicate that the failure to
load boot option
//
BmReportLoadFailure
(EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);
BootOption->Status = Status;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
index 07592f8ebd..af47b787d1 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
@@ -1,9 +1,9 @@
/** @file
Load option library functions which relate with creating and processing load
options.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -1409,10 +1409,19 @@ EfiBootManagerProcessLoadOption (
FileSize,
&ImageHandle
);
FreePool (FileBuffer);

+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be
started right now.
+ // If the caller doesn't have the option to defer the execution of an image,
we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
Status = gBS->HandleProtocol (ImageHandle,
&gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
ASSERT_EFI_ERROR (Status);

ImageInfo->LoadOptionsSize = LoadOption->OptionalDataSize; diff --git
a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 6b8fb4d924..833e38c6fe 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -1,9 +1,9 @@
/** @file
Misc library functions.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -491,10 +491,19 @@ EfiBootManagerDispatchDeferredImages (
ImageDevicePath,
NULL,
0,
&ImageHandle
);
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not
be started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
LoadCount++;
//
// Before calling the image, enable the Watchdog Timer for
// a 5 Minute period
--
2.18.0.windows.1



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

Liming Gao
 

Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Laszlo Ersek
Sent: Wednesday, September 18, 2019 3:49 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D
<michael.d.kinney@intel.com>
Subject: [edk2-devel] [PATCH 17/35] MdePkg/DxeServicesLib: remove bogus
cast

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/Library/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 != NULL);

Status = gBS->HandleProtocol (
- (EFI_HANDLE *) ImageHandle,
+ ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
--
2.19.1.3.g30247aa5d201



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47404): https://edk2.groups.io/g/devel/message/47404
Mute This Topic: https://groups.io/mt/34180218/1759384
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [liming.gao@intel.com]
-=-=-=-=-=-=


Re: [patch v2 4/5] MdeModulePkg/PlatformDriOverride: Unload image on EFI_SECURITY_VIOLATION

Wu, Hao A
 

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Dandan Bi
Sent: Wednesday, September 18, 2019 11:06 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J; Wu, Hao A; Gao, Liming; Laszlo Ersek
Subject: [edk2-devel] [patch v2 4/5] MdeModulePkg/PlatformDriOverride:
Unload image on EFI_SECURITY_VIOLATION

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the caller in PlatformDriOverrideDxe which don't have the policy to
defer the execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../PlatformDriOverrideDxe/PlatDriOverrideLib.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git
a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
index 2d3736b468..f91f038b7a 100644
---
a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
+++
b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
@@ -1,9 +1,9 @@
/** @file
Implementation of the shared functions to do the platform driver vverride
mapping.

- Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "InternalPlatDriOverrideDxe.h"
@@ -1484,10 +1484,19 @@ GetDriverFromMapping (
);
ASSERT (DriverBinding != NULL);
DriverImageInfo->ImageHandle = ImageHandle;
}
} else {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and
an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can
not be started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource
leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


DriverImageInfo->UnLoadable = TRUE;
DriverImageInfo->ImageHandle = NULL;
}
}
}
--
2.18.0.windows.1



Re: [patch v2 2/5] MdeModulePkg/DxeCapsuleLibFmp: Unload image on EFI_SECURITY_VIOLATION

Wu, Hao A
 

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Dandan Bi
Sent: Wednesday, September 18, 2019 11:06 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J; Wu, Hao A; Gao, Liming; Laszlo Ersek
Subject: [edk2-devel] [patch v2 2/5] MdeModulePkg/DxeCapsuleLibFmp:
Unload image on EFI_SECURITY_VIOLATION

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in DxeCapsuleLibFmp which don't have the policy to defer
the execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 95aa9de087..5dda561a04 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -1028,10 +1028,19 @@ StartFmpImage (
ImageSize,
&ImageHandle
);
DEBUG((DEBUG_INFO, "FmpCapsule: LoadImage - %r\n", Status));
if (EFI_ERROR(Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an
ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be
started right now.
+ // If the caller doesn't have the option to defer the execution of an
image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


FreePool(DriverDevicePath);
return Status;
}

DEBUG((DEBUG_INFO, "FmpCapsule: StartImage ...\n"));
--
2.18.0.windows.1



[PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange()

Steven Shi
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2193

The current CopyFileOnChange() method in Misc.py does not
accept the input SrcFile parameter as a dir, but the method
does not check the SrcFile is dir or not. This patch is to
add more input parameter type checking and error message output
for method CopyFileOnChange.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 714eb840ea..a488536cb4 100755
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None):
SrcFile = LongFilePath(SrcFile)
Dst = LongFilePath(Dst)

- if not os.path.exists(SrcFile):
+ if os.path.isdir(SrcFile):
+ EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile)
return False

if os.path.isdir(Dst):
--
2.17.1.windows.2


[PATCH v2 0/1] BaseTools: Add more parameter checking for CopyFileOnChange()

Steven Shi
 

This patch is to add directory input parameter type checking and error message output
for method CopyFileOnChange.

V2:
Remove the redundant os.path.exists checking for better performance

V1:
Initial patch

Steven Shi (1):
BaseTools: Add more parameter checking for CopyFileOnChange()

BaseTools/Source/Python/Common/Misc.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--
2.17.1.windows.2


[patch v2 5/5] ShellPkg: Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in ShellPkg which don't have the policy to defer the
execution of the image.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
---
ShellPkg/Application/Shell/ShellManParser.c | 9 +++++++++
.../Library/UefiShellDebug1CommandsLib/LoadPciRom.c | 11 ++++++++++-
ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 11 ++++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Application/Shell/ShellManParser.c
index 6909f29441..4d5a5668aa 100644
--- a/ShellPkg/Application/Shell/ShellManParser.c
+++ b/ShellPkg/Application/Shell/ShellManParser.c
@@ -643,10 +643,19 @@ ProcessManFile(
goto Done;
}
DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CmdFilePathName);
Status = gBS->LoadImage(FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
if(EFI_ERROR(Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid the resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (CmdFileImgHandle);
+ }
*HelpText = NULL;
goto Done;
}
Status = gBS->OpenProtocol(
CmdFileImgHandle,
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c
index 1b169d0d3c..5b6cba17f3 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c
@@ -1,10 +1,10 @@
/** @file
Main file for LoadPciRom shell Debug1 function.

(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "UefiShellDebug1CommandsLib.h"
@@ -332,10 +332,19 @@ LoadEfiDriversFromRomImage (
ImageBuffer,
ImageLength,
&ImageHandle
);
if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
} else {
Status = gBS->StartImage (ImageHandle, NULL, NULL);
if (EFI_ERROR (Status)) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
index 6a94b48c86..b6e7c952fa 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c
@@ -1,10 +1,10 @@
/** @file
Main file for attrib shell level 2 function.

(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "UefiShellLevel2CommandsLib.h"
@@ -110,10 +110,19 @@ LoadDriver(
NULL,
0,
&LoadedDriverHandle);

if (EFI_ERROR(Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (LoadedDriverHandle);
+ }
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_NOT_IMAGE), gShellLevel2HiiHandle, FileName, Status);
} else {
//
// Make sure it is a driver image
//
--
2.18.0.windows.1


[patch v2 4/5] MdeModulePkg/PlatformDriOverride: Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the caller in PlatformDriOverrideDxe which don't have the policy to
defer the execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
.../PlatformDriOverrideDxe/PlatDriOverrideLib.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
index 2d3736b468..f91f038b7a 100644
--- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
+++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c
@@ -1,9 +1,9 @@
/** @file
Implementation of the shared functions to do the platform driver vverride mapping.

- Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "InternalPlatDriOverrideDxe.h"
@@ -1484,10 +1484,19 @@ GetDriverFromMapping (
);
ASSERT (DriverBinding != NULL);
DriverImageInfo->ImageHandle = ImageHandle;
}
} else {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
DriverImageInfo->UnLoadable = TRUE;
DriverImageInfo->ImageHandle = NULL;
}
}
}
--
2.18.0.windows.1


[patch v2 3/5] MdeModulePkg/UefiBootManager: Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in UefiBootManagerLib which don't have the policy to defer
the execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 9 +++++++++
.../Library/UefiBootManagerLib/BmLoadOption.c | 11 ++++++++++-
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 11 ++++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 952033fc82..760d7647b8 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1859,10 +1859,19 @@ EfiBootManagerBoot (
if (FilePath != NULL) {
FreePool (FilePath);
}

if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
//
// Report Status Code with the failure status to indicate that the failure to load boot option
//
BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);
BootOption->Status = Status;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
index 07592f8ebd..af47b787d1 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c
@@ -1,9 +1,9 @@
/** @file
Load option library functions which relate with creating and processing load options.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -1409,10 +1409,19 @@ EfiBootManagerProcessLoadOption (
FileSize,
&ImageHandle
);
FreePool (FileBuffer);

+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
ASSERT_EFI_ERROR (Status);

ImageInfo->LoadOptionsSize = LoadOption->OptionalDataSize;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 6b8fb4d924..833e38c6fe 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -1,9 +1,9 @@
/** @file
Misc library functions.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

@@ -491,10 +491,19 @@ EfiBootManagerDispatchDeferredImages (
ImageDevicePath,
NULL,
0,
&ImageHandle
);
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
if (!EFI_ERROR (Status)) {
LoadCount++;
//
// Before calling the image, enable the Watchdog Timer for
// a 5 Minute period
--
2.18.0.windows.1


[patch v2 2/5] MdeModulePkg/DxeCapsuleLibFmp: Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in DxeCapsuleLibFmp which don't have the policy to defer
the execution of the image.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 95aa9de087..5dda561a04 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -1028,10 +1028,19 @@ StartFmpImage (
ImageSize,
&ImageHandle
);
DEBUG((DEBUG_INFO, "FmpCapsule: LoadImage - %r\n", Status));
if (EFI_ERROR(Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
FreePool(DriverDevicePath);
return Status;
}

DEBUG((DEBUG_INFO, "FmpCapsule: StartImage ...\n"));
--
2.18.0.windows.1


[patch v2 1/5] EmbeddedPkg: Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in EmbeddedPkg which don't have the policy to defer the
execution of the image.

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Laszlo Ersek <lersek@redhat.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
---
.../AndroidFastboot/Arm/BootAndroidBootImg.c | 9 +++++++++
.../Library/AndroidBootImgLib/AndroidBootImgLib.c | 12 ++++++++++++
2 files changed, 21 insertions(+)

diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index 591afbe7cc..fe05878b4b 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -71,10 +71,19 @@ StartEfiApplication (

// Load the image from the device path with Boot Services function
Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0,
&ImageHandle);
if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
return Status;
}

// Passed LoadOptions to the EFI Application
if (LoadOptionsSize != 0) {
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index d9e7aa7d2b..e1036954ee 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -439,10 +439,22 @@ AndroidBootImgBoot (
+ KernelSize;

Status = gBS->LoadImage (TRUE, gImageHandle,
(EFI_DEVICE_PATH *)&KernelDevicePath,
(VOID*)(UINTN)Kernel, KernelSize, &ImageHandle);
+ if (EFI_ERROR (Status)) {
+ //
+ // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
+ // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
+ // If the caller doesn't have the option to defer the execution of an image, we should
+ // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
+ //
+ if (Status == EFI_SECURITY_VIOLATION) {
+ gBS->UnloadImage (ImageHandle);
+ }
+ return Status;
+ }

// Set kernel arguments
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
(VOID **) &ImageInfo);
ImageInfo->LoadOptions = NewKernelArg;
--
2.18.0.windows.1


[patch v2 0/5] Unload image on EFI_SECURITY_VIOLATION

Dandan Bi
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992

v2:
(1) Just separate the patch in MdeModulePkg into module level, the changes in EmbeddedPkg and ShellPkg are the same with V1.
(2) Drop the update in PciBusDxe module in MdeModulePkg since with EFI_SECURITY_VIOLATION returned, the image may be used later.


For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval,
the Image was loaded and an ImageHandle was created with a valid
EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
This follows UEFI Spec.

But if the caller of LoadImage() doesn't have the option to defer
the execution of an image, we can not treat EFI_SECURITY_VIOLATION
like any other LoadImage() error, we should unload image for the
EFI_SECURITY_VIOLATION to avoid resource leak.

This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly
for the callers in edk2 which don't have the policy to defer the
execution of the image.

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Dandan Bi (3):
EmbeddedPkg: Unload image on EFI_SECURITY_VIOLATION
MdeModulePkg/DxeCapsuleLibFmp: Unload image on EFI_SECURITY_VIOLATION
MdeModulePkg/UefiBootManager: Unload image on EFI_SECURITY_VIOLATION
MdeModulePkg/PlatformDriOverride: Unload image on
EFI_SECURITY_VIOLATION
ShellPkg: Unload image on EFI_SECURITY_VIOLATION

.../AndroidFastboot/Arm/BootAndroidBootImg.c | 9 +++++++++
.../Library/AndroidBootImgLib/AndroidBootImgLib.c | 12 ++++++++++++
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 9 +++++++++
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 9 +++++++++
.../Library/UefiBootManagerLib/BmLoadOption.c | 11 ++++++++++-
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 11 ++++++++++-
.../PlatformDriOverrideDxe/PlatDriOverrideLib.c | 11 ++++++++++-
ShellPkg/Application/Shell/ShellManParser.c | 9 +++++++++
.../Library/UefiShellDebug1CommandsLib/LoadPciRom.c | 11 ++++++++++-
ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 11 ++++++++++-
10 files changed, 98 insertions(+), 5 deletions(-)

--
2.18.0.windows.1


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

Dong, Eric
 

Reviewed-by: Eric Dong <eric.dong@intel.com>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Wednesday, September 18, 2019 3:49 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Dong, Eric <eric.dong@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
Wang, Jian J <jian.j.wang@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH 15/35] MdeModulePkg/PiSmmCore: make type punning
consistent

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 OVMF
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/PiSmmCore/Smi.c
index f8bd9f49ee3c..488af6754faf 100644
--- a/MdeModulePkg/Core/PiSmmCore/Smi.c
+++ b/MdeModulePkg/Core/PiSmmCore/Smi.c
@@ -282,7 +282,7 @@ SmiHandlerUnRegister (
//
SmiHandler = NULL;
for ( HandlerLink = GetFirstNode (&mRootSmiEntry.SmiHandlers)
- ; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) && (SmiHandler !=
DispatchHandle)
+ ; !IsNull (&mRootSmiEntry.SmiHandlers, HandlerLink) &&
+ ((EFI_HANDLE) SmiHandler != DispatchHandle)
; HandlerLink = GetNextNode (&mRootSmiEntry.SmiHandlers, HandlerLink)
) {
SmiHandler = CR (HandlerLink, SMI_HANDLER, Link,
SMI_HANDLER_SIGNATURE); @@ -292,19 +292,19 @@
SmiHandlerUnRegister (
// Look for it in non-root SMI handlers
//
for ( EntryLink = GetFirstNode (&mSmiEntryList)
- ; !IsNull (&mSmiEntryList, EntryLink) && (SmiHandler != DispatchHandle)
+ ; !IsNull (&mSmiEntryList, EntryLink) && ((EFI_HANDLE) SmiHandler
+ != DispatchHandle)
; EntryLink = GetNextNode (&mSmiEntryList, EntryLink)
) {
SmiEntry = CR (EntryLink, SMI_ENTRY, AllEntries, SMI_ENTRY_SIGNATURE);
for ( HandlerLink = GetFirstNode (&SmiEntry->SmiHandlers)
- ; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) && (SmiHandler !=
DispatchHandle)
+ ; !IsNull (&SmiEntry->SmiHandlers, HandlerLink) &&
+ ((EFI_HANDLE) SmiHandler != DispatchHandle)
; HandlerLink = GetNextNode (&SmiEntry->SmiHandlers, HandlerLink)
) {
SmiHandler = CR (HandlerLink, SMI_HANDLER, Link,
SMI_HANDLER_SIGNATURE);
}
}

- if (SmiHandler != DispatchHandle) {
+ if ((EFI_HANDLE) SmiHandler != DispatchHandle) {
return EFI_INVALID_PARAMETER;
}

--
2.19.1.3.g30247aa5d201


[PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for pointers

Zhang, Shenglei
 

In DxeCheckBootVariable.c, add check for BootOrder and Variable
that return EFI_NOT_FOUND when they are NULL.
In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL
when allocating memory to what it points to.

Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update copyright

v3: Fix the coding style.

.../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 8 +++++++-
.../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++---
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
index 85bd5b3d..f658beb7 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckBootVariable.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -130,6 +130,9 @@ TestPointCheckLoadOptionVariable (
for (ListIndex = 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); ListIndex++) {
UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoadOptionVariableList[ListIndex]);
Status = GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, (VOID **)&BootOrder, &OrderSize);
+ if(BootOrder == NULL) {
+ return EFI_NOT_FOUND;
+ }
if (EFI_ERROR(Status)) {
continue;
}
@@ -222,6 +225,9 @@ TestPointCheckKeyOptionVariable (
for (Index = 0; ; Index++) {
UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", mKeyOptionVariableList[ListIndex], Index);
Status = GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, &Variable, &Size);
+ if(Variable == NULL) {
+ return EFI_NOT_FOUND;
+ }
if (!EFI_ERROR(Status)) {
DumpKeyOption (KeyOptionName, Variable, Size);
} else {
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
index 82709d44..28ca8382 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckGcd.c
@@ -1,6 +1,6 @@
/** @file

-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -241,11 +241,13 @@ TestPointDumpGcd (
}
}
if (GcdMemoryMap != NULL) {
- *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ if (GcdIoMap != NULL) {
+ *GcdIoMap = AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap);
+ }
*GcdIoMapNumberOfDescriptors = NumberOfDescriptors;
}
}
-
+
if (DumpPrint) {
DEBUG ((DEBUG_INFO, "==== TestPointDumpGcd - Exit\n"));
}
--
2.18.0.windows.1