From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.171.2.68; helo=ma1-aaemail-dr-lapp02.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from ma1-aaemail-dr-lapp02.apple.com (ma1-aaemail-dr-lapp02.apple.com [17.171.2.68]) (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 5B9442117D289 for ; Tue, 23 Oct 2018 03:30:01 -0700 (PDT) Received: from pps.filterd (ma1-aaemail-dr-lapp02.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp02.apple.com (8.16.0.22/8.16.0.22) with SMTP id w9NAR9n0052635; Tue, 23 Oct 2018 03:29:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=mime-version : content-transfer-encoding : content-type : sender : subject : from : in-reply-to : date : cc : message-id : references : to; s=20180706; bh=yBkGIkyE0C5wyTSjJfExMSi/5NzQLonzGmenR5G9M5Y=; b=QU1fABMEfFj/Yo2Ysv+069omSeozwOn6ysRgv+cA++5+eVwDn2K25hTsqdpdDHfOMJ1L Gj6zmg/KgGwH8/WT9XTSb5y+FuaPKEN5sBiLk3Pyv3mHCOk2JbEy+eH25z9RH2CiRm8/ JmuT0xs6q0oxjvK+i/bxoPeZeJRPNDyzwfUAYwmSbA+bphaq7/YzRbhyO2HSoH4GL0ia RJ3GPdkicNgQN9MM5U55rdLkP/P+Hx6opZX/wBjz8LynG43yFMocAvLPZI51Y6C+jYxc yYTp3V6aZDVHiT6Q43/rUKH1dkhYisOxFDoVZoA2EOCHk/8GF6LA+Z2ck7rV/xCtPnw6 gw== Received: from ma1-mtap-s01.corp.apple.com (ma1-mtap-s01.corp.apple.com [17.40.76.5]) by ma1-aaemail-dr-lapp02.apple.com with ESMTP id 2n811xb2vu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 23 Oct 2018 03:29:59 -0700 MIME-version: 1.0 Received: from nwk-mmpp-sz12.apple.com (nwk-mmpp-sz12.apple.com [17.128.115.204]) by ma1-mtap-s01.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PH10077JRTY7050@ma1-mtap-s01.corp.apple.com>; Tue, 23 Oct 2018 03:29:59 -0700 (PDT) Received: from process_viserion-daemon.nwk-mmpp-sz12.apple.com by nwk-mmpp-sz12.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PH100800QHSW700@nwk-mmpp-sz12.apple.com>; Tue, 23 Oct 2018 03:29:59 -0700 (PDT) X-Va-A: X-Va-T-CD: ed581c386db55f905dbd7481fd9c461d X-Va-E-CD: d7750f6ad5f3aa447c8e39f0066643ba X-Va-R-CD: 6689d2fe4fd4b14f0c274ea5da412b71 X-Va-CD: 0 X-Va-ID: ed0b5c8f-76cf-4638-ba83-5923febfbb77 X-V-A: X-V-T-CD: 81ca60fce39c2560b6c4a7e5841f9b8f X-V-E-CD: d7750f6ad5f3aa447c8e39f0066643ba X-V-R-CD: 6689d2fe4fd4b14f0c274ea5da412b71 X-V-CD: 0 X-V-ID: 5dfb3805-bd31-4676-a178-771dd3141dfc Received: from process_milters-daemon.nwk-mmpp-sz12.apple.com by nwk-mmpp-sz12.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PH100600RQMN000@nwk-mmpp-sz12.apple.com>; Tue, 23 Oct 2018 03:29:58 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-23_03:,, signatures=0 X-Proofpoint-Scanner-Instance: nwk-grpmailp-qapp15.corp.apple.com-10000_instance1 Received: from [17.234.44.172] (unknown [17.234.44.172]) by nwk-mmpp-sz12.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PH100MYGRTXG450@nwk-mmpp-sz12.apple.com>; Tue, 23 Oct 2018 03:29:58 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: <20181023093330.11468-1-chasel.chiu@intel.com> Date: Tue, 23 Oct 2018 03:29:15 -0700 Cc: edk2-devel@lists.01.org, Jiewen Yao Message-id: References: <20181023093330.11468-1-chasel.chiu@intel.com> To: "Chasel, Chiu" X-Mailer: Apple Mail (2.3445.6.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-23_03:, , signatures=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: Tue, 23 Oct 2018 10:30:02 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Oct 23, 2018, at 2:33 AM, Chasel, Chiu wrote: > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1265 > > 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. > > Test: Verified on internal platform and boots successfully. > > 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(-) > > 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 > > [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; > > // > // Process all libraries constructor function linked to SecCore. > @@ -98,13 +99,26 @@ SecStartup ( > // | | > // |-------------------|----> TempRamBase > IdtTableInStack.PeiService = NULL; > - ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate); > - for (Index = 0; Index < SEC_IDT_ENTRY_COUNT; Index ++) { > - CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64)); > + AsmReadIdtr (&IdtDescriptor); > + if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) { Are these architectural value at reset? Thanks, Andrew Fish > + ExceptionHandler = FspGetExceptionHandler(mIdtEntryTemplate); > + for (Index = 0; Index < FixedPcdGet8(PcdFspMaxInterruptSupported); Index ++) { > + CopyMem ((VOID*)&IdtTableInStack.IdtTable[Index], (VOID*)&ExceptionHandler, sizeof (UINT64)); > + } > + IdtSize = 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 = IdtDescriptor.Limit + 1; > + } > + CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize); > } > - > IdtDescriptor.Base = (UINTN) &IdtTableInStack.IdtTable; > - IdtDescriptor.Limit = (UINT16)(sizeof (IdtTableInStack.IdtTable) - 1); > + IdtDescriptor.Limit = (UINT16)(IdtSize - 1); > > AsmWriteIdtr (&IdtDescriptor); > > 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 > > - 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 > > -#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) ( \ > > typedef struct _SEC_IDT_TABLE { > EFI_PEI_SERVICES *PeiService; > - UINT64 IdtTable[SEC_IDT_ENTRY_COUNT]; > + UINT64 IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)]; > } SEC_IDT_TABLE; > > /** > diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dec b/IntelFsp2Pkg/IntelFsp2Pkg.dec > 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 > > [PcdsFixedAtBuild,PcdsDynamic,PcdsDynamicEx] > gIntelFsp2PkgTokenSpaceGuid.PcdFspReservedMemoryLength |0x00100000|UINT32|0x46530000 > -- > 2.13.3.windows.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel