* [PATCH v2 0/2] Avoid Emulator Segmentation fault
@ 2022-03-01 9:18 Guomin Jiang
2022-03-01 9:18 ` [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
2022-03-01 9:18 ` [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
0 siblings, 2 replies; 5+ messages in thread
From: Guomin Jiang @ 2022-03-01 9:18 UTC (permalink / raw)
To: devel
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
Correct the logic to handle the case that XServer not present to avoid Segmentation fault
V2:
Fix typo error.
Guomin Jiang (2):
MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully
EmulatorPkg/EmuGopDxe/GopScreen.c | 11 ++++++-----
.../Console/GraphicsConsoleDxe/GraphicsConsole.c | 4 ++--
2 files changed, 8 insertions(+), 7 deletions(-)
--
2.35.1.windows.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
2022-03-01 9:18 [PATCH v2 0/2] Avoid Emulator Segmentation fault Guomin Jiang
@ 2022-03-01 9:18 ` Guomin Jiang
2022-03-01 9:23 ` Ni, Ray
2022-03-01 9:18 ` [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
1 sibling, 1 reply; 5+ messages in thread
From: Guomin Jiang @ 2022-03-01 9:18 UTC (permalink / raw)
To: devel; +Cc: Jian J Wang, Liming Gao, Zhichao Gao, Ray Ni
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.
If we don't handle it, it will Segmentation fault.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
.../Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 8f0cba9fcde9..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -1,7 +1,7 @@
/** @file
This is the main routine for initializing the Graphics Console support routines.
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
}
}
- if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+ if (EFI_ERROR (Status) || (ModeNumber != Private->GraphicsOutput->Mode->Mode)) {
//
// Current graphics mode is not set or is not set to the mode which we have found,
// set the new graphic mode.
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully
2022-03-01 9:18 [PATCH v2 0/2] Avoid Emulator Segmentation fault Guomin Jiang
2022-03-01 9:18 ` [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
@ 2022-03-01 9:18 ` Guomin Jiang
2022-03-01 9:20 ` Ni, Ray
1 sibling, 1 reply; 5+ messages in thread
From: Guomin Jiang @ 2022-03-01 9:18 UTC (permalink / raw)
To: devel; +Cc: Andrew Fish, Ray Ni
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
WindowOpen will fail in some case. for example, without XServer.
Shouldn't set ModeInfo in this case to avoid the caller use it
incorrectly
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
EmulatorPkg/EmuGopDxe/GopScreen.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..9249eca1dd03 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -108,10 +108,6 @@ EmuGopSetMode (
}
ModeData = &Private->ModeData[ModeNumber];
- This->Mode->Mode = ModeNumber;
- Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
- Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
- Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
if (Private->HardwareNeedsStarting) {
Status = EmuGopStartWindow (
@@ -128,6 +124,11 @@ EmuGopSetMode (
Private->HardwareNeedsStarting = FALSE;
}
+ This->Mode->Mode = ModeNumber;
+ Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
+ Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
+ Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
+
Status = Private->EmuGraphicsWindow->Size (
Private->EmuGraphicsWindow,
ModeData->HorizontalResolution,
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully
2022-03-01 9:18 ` [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
@ 2022-03-01 9:20 ` Ni, Ray
0 siblings, 0 replies; 5+ messages in thread
From: Ni, Ray @ 2022-03-01 9:20 UTC (permalink / raw)
To: Jiang, Guomin, devel@edk2.groups.io; +Cc: Andrew Fish
Reviewed-by: Ray Ni <ray.ni@intel.com>
-----Original Message-----
From: Jiang, Guomin <guomin.jiang@intel.com>
Sent: Tuesday, March 1, 2022 5:19 PM
To: devel@edk2.groups.io
Cc: Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
WindowOpen will fail in some case. for example, without XServer.
Shouldn't set ModeInfo in this case to avoid the caller use it incorrectly
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
EmulatorPkg/EmuGopDxe/GopScreen.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..9249eca1dd03 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -108,10 +108,6 @@ EmuGopSetMode (
}
ModeData = &Private->ModeData[ModeNumber];
- This->Mode->Mode = ModeNumber;
- Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
- Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
- Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
if (Private->HardwareNeedsStarting) {
Status = EmuGopStartWindow (
@@ -128,6 +124,11 @@ EmuGopSetMode (
Private->HardwareNeedsStarting = FALSE;
}
+ This->Mode->Mode = ModeNumber;
+ Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
+ Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
+ Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
+
Status = Private->EmuGraphicsWindow->Size (
Private->EmuGraphicsWindow,
ModeData->HorizontalResolution,
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
2022-03-01 9:18 ` [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
@ 2022-03-01 9:23 ` Ni, Ray
0 siblings, 0 replies; 5+ messages in thread
From: Ni, Ray @ 2022-03-01 9:23 UTC (permalink / raw)
To: Jiang, Guomin, devel@edk2.groups.io
Cc: Wang, Jian J, Gao, Liming, Gao, Zhichao
Reviewed-by: Ray Ni <ray.ni@intel.com>
-----Original Message-----
From: Jiang, Guomin <guomin.jiang@intel.com>
Sent: Tuesday, March 1, 2022 5:19 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.
If we don't handle it, it will Segmentation fault.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
.../Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 8f0cba9fcde9..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -1,7 +1,7 @@
/** @file
This is the main routine for initializing the Graphics Console support routines.
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
}
}
- if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+ if (EFI_ERROR (Status) || (ModeNumber != Private->GraphicsOutput->Mode->Mode)) {
//
// Current graphics mode is not set or is not set to the mode which we have found,
// set the new graphic mode.
--
2.35.1.windows.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-01 9:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-01 9:18 [PATCH v2 0/2] Avoid Emulator Segmentation fault Guomin Jiang
2022-03-01 9:18 ` [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
2022-03-01 9:23 ` Ni, Ray
2022-03-01 9:18 ` [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
2022-03-01 9:20 ` Ni, Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox