From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9F9AD21173C6E for ; Thu, 25 Oct 2018 01:15:52 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 01:15:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,423,1534834800"; d="scan'208";a="102338681" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 25 Oct 2018 01:15:51 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Oct 2018 01:15:51 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Oct 2018 01:15:51 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.84]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.102]) with mapi id 14.03.0415.000; Thu, 25 Oct 2018 16:15:49 +0800 From: "Yao, Jiewen" To: "Chiu, Chasel" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2] IntelFsp2Pkg: FSP should not override IDT Thread-Index: AQHUarODIySr4Qsh4Eix9D6fhA2mwKUvoG3g Date: Thu, 25 Oct 2018 08:15:48 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AE28C11@shsmsx102.ccr.corp.intel.com> References: <20181023093330.11468-1-chasel.chiu@intel.com> In-Reply-To: <20181023093330.11468-1-chasel.chiu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWY5ZWI4ZjUtM2Y1Ny00MWFkLWIxYjctZDBmNTIyZjQ4OTg3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQzE0Z3VqYnlLNkVBQ1ZvVTZzbUl4OU1HMDFWVUI5WERjbE5wRnIwaFprcEMzUDczMVFUdlhXYzUycmxlaFwvclUifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] IntelFsp2Pkg: FSP should not override IDT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2018 08:15:52 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Chiu, Chasel > Sent: Tuesday, October 23, 2018 5:34 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen ; Desimone, Nathaniel L > ; Chiu, Chasel > Subject: [PATCH v2] IntelFsp2Pkg: FSP should not override IDT >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1265 >=20 > FSP should not override IDT table when it is initialized > by boot loader. IDT should be re-initialized in FSP only > when it is invalid. > To mitigate temporary memory usage a PCD > PcdFspMaxInterruptSupported created for platform to decide > how many interrupts the FSP IDT table can support. >=20 > Test: Verified on internal platform and boots successfully. >=20 > Cc: Jiewen Yao > Cc: Desimone Nathaniel L > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chasel Chiu > --- > IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 1 + > IntelFsp2Pkg/FspSecCore/SecMain.c | 24 > +++++++++++++++++++----- > IntelFsp2Pkg/FspSecCore/SecMain.h | 6 ++---- > IntelFsp2Pkg/IntelFsp2Pkg.dec | 4 ++++ > 4 files changed, 26 insertions(+), 9 deletions(-) >=20 > diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf > b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf > index c61af10b8a..dafe6f5993 100644 > --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf > +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf > @@ -62,6 +62,7 @@ > gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamSize ## > CONSUMES > gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize ## > CONSUMES > gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage ## > CONSUMES > + gIntelFsp2PkgTokenSpaceGuid.PcdFspMaxInterruptSupported ## > CONSUMES >=20 > [Ppis] > gEfiTemporaryRamSupportPpiGuid > ## PRODUCES > diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c > b/IntelFsp2Pkg/FspSecCore/SecMain.c > index 37fd4dfdeb..ddbfc4fcdf 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecMain.c > +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c > @@ -70,6 +70,7 @@ SecStartup ( > UINT32 Index; > FSP_GLOBAL_DATA PeiFspData; > UINT64 ExceptionHandler; > + UINTN IdtSize; >=20 > // > // Process all libraries constructor function linked to SecCore. > @@ -98,13 +99,26 @@ SecStartup ( > // | | > // |-------------------|----> TempRamBase > IdtTableInStack.PeiService =3D NULL; > - ExceptionHandler =3D FspGetExceptionHandler(mIdtEntryTemplate); > - for (Index =3D 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) { > - CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], > (VOID*)&ExceptionHandler, sizeof (UINT64)); > + AsmReadIdtr (&IdtDescriptor); > + if ((IdtDescriptor.Base =3D=3D 0) && (IdtDescriptor.Limit =3D=3D 0xFFF= F)) { > + ExceptionHandler =3D FspGetExceptionHandler(mIdtEntryTemplate); > + for (Index =3D 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); > Index ++) { > + CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], > (VOID*)&ExceptionHandler, sizeof (UINT64)); > + } > + IdtSize =3D sizeof (IdtTableInStack.IdtTable); > + } else { > + if (IdtDescriptor.Limit + 1 > sizeof (IdtTableInStack.IdtTable)) { > + // > + // ERROR: IDT table size from boot loader is larger than FSP can > support, DeadLoop here! > + // > + CpuDeadLoop(); > + } else { > + IdtSize =3D IdtDescriptor.Limit + 1; > + } > + CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) > IdtDescriptor.Base, IdtSize); > } > - > IdtDescriptor.Base =3D (UINTN) &IdtTableInStack.IdtTable; > - IdtDescriptor.Limit =3D (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1= ); > + IdtDescriptor.Limit =3D (UINT16)(IdtSize - 1); >=20 > AsmWriteIdtr (&IdtDescriptor); >=20 > diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h > b/IntelFsp2Pkg/FspSecCore/SecMain.h > index 291bc5ca5c..19ac2fbfc1 100644 > --- a/IntelFsp2Pkg/FspSecCore/SecMain.h > +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h > @@ -1,6 +1,6 @@ > /** @file >=20 > - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the > BSD License > which accompanies this distribution. The full text of the license may= be > found at > @@ -29,8 +29,6 @@ > #include > #include >=20 > -#define SEC_IDT_ENTRY_COUNT 34 > - > typedef VOID (*PEI_CORE_ENTRY) ( \ > IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \ > IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \ > @@ -38,7 +36,7 @@ typedef VOID (*PEI_CORE_ENTRY) ( \ >=20 > typedef struct _SEC_IDT_TABLE { > EFI_PEI_SERVICES *PeiService; > - UINT64 IdtTable[SEC_IDT_ENTRY_COUNT]; > + UINT64 IdtTable[FixedPcdGet8 > (PcdFspMaxInterruptSupported)]; > } SEC_IDT_TABLE; >=20 > /** > diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dec b/IntelFsp2Pkg/IntelFsp2Pkg.de= c > index 5b037d65e2..50496241da 100644 > --- a/IntelFsp2Pkg/IntelFsp2Pkg.dec > +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dec > @@ -86,6 +86,10 @@ > # x % of FSP temporary memory will be used for heap > # (100 - x) % of FSP temporary memory will be used for stack > gIntelFsp2PkgTokenSpaceGuid.PcdFspHeapSizePercentage | > 50| UINT8|0x10000004 > + # > + # Maximal Interrupt supported in IDT table. > + # > + gIntelFsp2PkgTokenSpaceGuid.PcdFspMaxInterruptSupported | > 34| UINT8|0x10000005 >=20 > [PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx] > gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength > |0x00100000|UINT32|0x46530000 > -- > 2.13.3.windows.1