public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
@ 2018-10-29  1:17 Chasel, Chiu
  2018-10-29  1:51 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Chasel, Chiu @ 2018-10-29  1:17 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiewen Yao, Desimone Nathaniel L, Chasel Chiu

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

When copying IDT table in SecMain, the pointer might be
NULL so added the check to fix it.

Test: Verified on internal platform and boots successfully.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 IntelFsp2Pkg/FspSecCore/SecMain.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/SecMain.c
index f319c68cc5..70460a3c8b 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.c
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
@@ -100,7 +100,7 @@ SecStartup (
   // |-------------------|---->  TempRamBase
   IdtTableInStack.PeiService  = NULL;
   AsmReadIdtr (&IdtDescriptor);
-  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {
+  if (IdtDescriptor.Base == 0) {
     ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);
     for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); Index ++) {
       CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64));
@@ -113,8 +113,9 @@ SecStartup (
       // ERROR: IDT table size from boot loader is larger than FSP can support, DeadLoop here!
       //
       CpuDeadLoop();
+    } else {
+      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);
     }
-    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);
   }
   IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;
   IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
-- 
2.13.3.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
  2018-10-29  1:17 [PATCH v2] IntelFsp2Pkg: Fixed potentially NULL pointer accessing Chasel, Chiu
@ 2018-10-29  1:51 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2018-10-29  1:51 UTC (permalink / raw)
  To: Chiu, Chasel, edk2-devel@lists.01.org

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: Chiu, Chasel
> Sent: Monday, October 29, 2018 9:18 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
> Subject: [PATCH v2] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1280
> 
> When copying IDT table in SecMain, the pointer might be
> NULL so added the check to fix it.
> 
> Test: Verified on internal platform and boots successfully.
> 
> Cc: Jiewen Yao <Jiewen.yao@intel.com>
> Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  IntelFsp2Pkg/FspSecCore/SecMain.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c
> b/IntelFsp2Pkg/FspSecCore/SecMain.c
> index f319c68cc5..70460a3c8b 100644
> --- a/IntelFsp2Pkg/FspSecCore/SecMain.c
> +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
> @@ -100,7 +100,7 @@ SecStartup (
>    // |-------------------|---->  TempRamBase
>    IdtTableInStack.PeiService  = NULL;
>    AsmReadIdtr (&IdtDescriptor);
> -  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {
> +  if (IdtDescriptor.Base == 0) {
>      ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);
>      for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported);
> Index ++) {
>        CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index],
> (VOID*)&ExceptionHandler, sizeof (UINT64));
> @@ -113,8 +113,9 @@ SecStartup (
>        // ERROR: IDT table size from boot loader is larger than FSP can
> support, DeadLoop here!
>        //
>        CpuDeadLoop();
> +    } else {
> +      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>      }
> -    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>    }
>    IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;
>    IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
> --
> 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-29  1:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29  1:17 [PATCH v2] IntelFsp2Pkg: Fixed potentially NULL pointer accessing Chasel, Chiu
2018-10-29  1:51 ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox