* [PATCH v3 0/2] Avoid Emulator Segmentation fault
@ 2022-03-02 6:58 Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
0 siblings, 2 replies; 3+ messages in thread
From: Guomin Jiang @ 2022-03-02 6:58 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
V3:
Fix uncrustify error
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 | 13 +++++++------
.../Console/GraphicsConsoleDxe/GraphicsConsole.c | 4 ++--
2 files changed, 9 insertions(+), 8 deletions(-)
--
2.35.1.windows.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
2022-03-02 6:58 [PATCH v3 0/2] Avoid Emulator Segmentation fault Guomin Jiang
@ 2022-03-02 6:58 ` Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Guomin Jiang @ 2022-03-02 6:58 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>
Reviewed-by: 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] 3+ messages in thread
* [PATCH v3 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully
2022-03-02 6:58 [PATCH v3 0/2] Avoid Emulator Segmentation fault Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
@ 2022-03-02 6:58 ` Guomin Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Guomin Jiang @ 2022-03-02 6:58 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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
EmulatorPkg/EmuGopDxe/GopScreen.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..88d95b88e162 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
@@ -107,11 +107,7 @@ EmuGopSetMode (
return EFI_UNSUPPORTED;
}
- 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;
+ ModeData = &Private->ModeData[ModeNumber];
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] 3+ messages in thread
end of thread, other threads:[~2022-03-02 6:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-02 6:58 [PATCH v3 0/2] Avoid Emulator Segmentation fault Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
2022-03-02 6:58 ` [PATCH v3 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox