* [PATCH 0/2] Avoid Emulator Segmentation fault @ 2022-02-22 3:40 Guomin Jiang 2022-02-22 3:40 ` [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Guomin Jiang @ 2022-02-22 3:40 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 Guomin Jiang (2): MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully EmulatorPkg/EmuGopDxe/GopScreen.c | 9 +++++---- .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 15 ++------------- 2 files changed, 7 insertions(+), 17 deletions(-) -- 2.35.1.windows.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error 2022-02-22 3:40 [PATCH 0/2] Avoid Emulator Segmentation fault Guomin Jiang @ 2022-02-22 3:40 ` Guomin Jiang 2022-02-22 3:40 ` [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Guomin Jiang @ 2022-02-22 3:40 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> --- .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 1bdd1b8a6732..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. @@ -531,17 +531,6 @@ GraphicsConsoleControllerDriverStart ( goto Error; } } - - // - // Double confirm SetMode can success - // - Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber); - if (EFI_ERROR (Status)) { - // - // The mode set operation failed - // - goto Error; - } } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { // // At first try to set user-defined resolution -- 2.35.1.windows.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully 2022-02-22 3:40 [PATCH 0/2] Avoid Emulator Segmentation fault Guomin Jiang 2022-02-22 3:40 ` [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang @ 2022-02-22 3:40 ` Guomin Jiang 2022-03-01 7:16 ` Ni, Ray [not found] ` <16D5FEACC0A8B3B7.28921@groups.io> [not found] ` <16D5FEAC9A733E6B.24964@groups.io> 3 siblings, 1 reply; 6+ messages in thread From: Guomin Jiang @ 2022-02-22 3:40 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c index 41f748bc6402..ec5ef795d6e5 100644 --- a/EmulatorPkg/EmuGopDxe/GopScreen.c +++ b/EmulatorPkg/EmuGopDxe/GopScreen.c @@ -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] 6+ messages in thread
* Re: [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully 2022-02-22 3:40 ` [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang @ 2022-03-01 7:16 ` Ni, Ray 0 siblings, 0 replies; 6+ messages in thread From: Ni, Ray @ 2022-03-01 7:16 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, February 22, 2022 11:41 AM To: devel@edk2.groups.io Cc: Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com> Subject: [PATCH 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c index 41f748bc6402..ec5ef795d6e5 100644 --- a/EmulatorPkg/EmuGopDxe/GopScreen.c +++ b/EmulatorPkg/EmuGopDxe/GopScreen.c @@ -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] 6+ messages in thread
[parent not found: <16D5FEACC0A8B3B7.28921@groups.io>]
* Re: [edk2-devel] [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully [not found] ` <16D5FEACC0A8B3B7.28921@groups.io> @ 2022-02-24 0:55 ` Guomin Jiang 0 siblings, 0 replies; 6+ messages in thread From: Guomin Jiang @ 2022-02-24 0:55 UTC (permalink / raw) To: devel@edk2.groups.io; +Cc: Andrew Fish, Ni, Ray Hi Fish and Ray, Can you help review it? Thanks Guomin > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin > Jiang > Sent: Tuesday, February 22, 2022 11:41 AM > To: devel@edk2.groups.io > Cc: Andrew Fish <afish@apple.com>; Ni, Ray <ray.ni@intel.com> > Subject: [edk2-devel] [PATCH 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 | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c > b/EmulatorPkg/EmuGopDxe/GopScreen.c > index 41f748bc6402..ec5ef795d6e5 100644 > --- a/EmulatorPkg/EmuGopDxe/GopScreen.c > +++ b/EmulatorPkg/EmuGopDxe/GopScreen.c > @@ -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 [flat|nested] 6+ messages in thread
[parent not found: <16D5FEAC9A733E6B.24964@groups.io>]
* Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error [not found] ` <16D5FEAC9A733E6B.24964@groups.io> @ 2022-02-24 0:56 ` Guomin Jiang 0 siblings, 0 replies; 6+ messages in thread From: Guomin Jiang @ 2022-02-24 0:56 UTC (permalink / raw) To: devel@edk2.groups.io; +Cc: Wang, Jian J, Gao, Liming, Gao, Zhichao, Ni, Ray Hi Liming, Jian, Zhichao, Ray, Can you help review it? Thanks Guomin > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guomin > Jiang > Sent: Tuesday, February 22, 2022 11:41 AM > 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: [edk2-devel] [PATCH 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> > --- > .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 15 ++------------- > 1 file changed, 2 insertions(+), 13 deletions(-) > > diff --git > a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole > .c > b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsol > e.c > index 1bdd1b8a6732..07436cbd15bf 100644 > --- > a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole > .c > +++ > b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsol > e.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. > @@ -531,17 +531,6 @@ GraphicsConsoleControllerDriverStart ( > goto Error; > } > } > - > - // > - // Double confirm SetMode can success > - // > - Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, > ModeNumber); > - if (EFI_ERROR (Status)) { > - // > - // The mode set operation failed > - // > - goto Error; > - } > } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { > // > // At first try to set user-defined resolution > -- > 2.35.1.windows.2 > > > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-01 7:17 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-02-22 3:40 [PATCH 0/2] Avoid Emulator Segmentation fault Guomin Jiang 2022-02-22 3:40 ` [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang 2022-02-22 3:40 ` [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang 2022-03-01 7:16 ` Ni, Ray [not found] ` <16D5FEACC0A8B3B7.28921@groups.io> 2022-02-24 0:55 ` [edk2-devel] " Guomin Jiang [not found] ` <16D5FEAC9A733E6B.24964@groups.io> 2022-02-24 0:56 ` [edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox