public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Chiu, Chasel" <chasel.chiu@intel.com>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [edk2-devel] [PATCH] IntelFsp2Pkg: PeiService pointer not reset to 0 in SecMain
Date: Fri, 26 Jul 2019 00:24:10 +0000	[thread overview]
Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAED772C7@ORSMSX114.amr.corp.intel.com> (raw)
In-Reply-To: <20190725155059.84-1-chasel.chiu@intel.com>

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu, Chasel
Sent: Thursday, July 25, 2019 8:51 AM
To: devel@edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [edk2-devel] [PATCH] IntelFsp2Pkg: PeiService pointer not reset to 0 in SecMain

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

Current FSP SEC_IDT_TABLE structure is not natural aligned:
  typedef struct _SEC_IDT_TABLE {
    EFI_PEI_SERVICES  *PeiService;
    UINT64            IdtTable[];
  } SEC_IDT_TABLE;
Compiler will insert DWORD padding between 2 elements and
GetPeiServicesTablePointer() in early phase then always returns padding data from stack, which was not rest to 0 in SecMain.

Solution is to align FSP SEC_IDT_TABLE structure to UefiCpuPkg to have UINT64 as PeiService field and rest it to 0.

Test: Verified on internal platform and booting successfully
      with FSP API mode.

Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 IntelFsp2Pkg/FspSecCore/SecMain.c |  2 +-  IntelFsp2Pkg/FspSecCore/SecMain.h | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/SecMain.c
index a63d1336e4..7169afc6c7 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.c
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
@@ -114,7 +114,7 @@ SecStartup (
   // |                   |
   // |                   |
   // |-------------------|---->  TempRamBase
-  IdtTableInStack.PeiService  = NULL;
+  IdtTableInStack.PeiService = 0;
   AsmReadIdtr (&IdtDescriptor);
   if (IdtDescriptor.Base == 0) {
     ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate);
diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h b/IntelFsp2Pkg/FspSecCore/SecMain.h
index 6fb16febab..af7f387960 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.h
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2019, Intel Corporation. All rights 
+ reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -29,7 +29,13 @@ typedef VOID (*PEI_CORE_ENTRY) ( \  );
 
 typedef struct _SEC_IDT_TABLE {
-  EFI_PEI_SERVICES  *PeiService;
+  //
+  // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since 
+ IDT base  // address should be 8-byte alignment.
+  // Note: For IA32, only the 4 bytes immediately preceding IDT is used 
+ to store  // EFI_PEI_SERVICES**  //
+  UINT64            PeiService;
   UINT64            IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];
 } SEC_IDT_TABLE;
 
--
2.13.3.windows.1





  reply	other threads:[~2019-07-26  0:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 15:50 [PATCH] IntelFsp2Pkg: PeiService pointer not reset to 0 in SecMain Chiu, Chasel
2019-07-26  0:24 ` Nate DeSimone [this message]
2019-07-26  1:28 ` [edk2-devel] " Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02A34F284D1DA44BB705E61F7180EF0AAED772C7@ORSMSX114.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox