From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web12.7072.1657618285263341164 for ; Tue, 12 Jul 2022 02:31:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=XiD+omLQ; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: ted.kuo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657618287; x=1689154287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+NE/LpqKuawuy7M9pMlDKBMuw0n07vEVmTtoaRh3zSw=; b=XiD+omLQDAEZ3o5zVqU+ZSLNnAVNAagDyYoKvQ+Y49JGctp/4iCbPPix hZORzawXyXgFL9OEBgB0tw3xtv423XSwhQKOjQ3wikByw257AGkQ1oUvF 5yQalSdNqiYdBRzdhoffRyFWHSrsn79t3hV9SOTH5LPq/VuEpK/dKJiUf driTPxf2KtwQxpPa5+X+cocaKNSex/eeeyA+RZi0IV5Cm+2nyDY4Xwl8C 6s08sk9ZtscanBQYD4cv2QLdZ1WhlDAjvnIo3YvWfScFJPi4qhbmuUStW rGONCIV+DZKUnrld7mkJHLjUERr518bhCDE8oTAkWpW03mhFQ6jLJiB6Y Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10405"; a="265298767" X-IronPort-AV: E=Sophos;i="5.92,265,1650956400"; d="scan'208";a="265298767" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 02:31:27 -0700 X-IronPort-AV: E=Sophos;i="5.92,265,1650956400"; d="scan'208";a="545360981" Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2022 02:31:26 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v2 2/2] IntelFsp2Pkg: Update SEC_IDT_TABLE struct Date: Tue, 12 Jul 2022 17:30:58 +0800 Message-Id: X-Mailer: git-send-email 2.35.3.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3957 The reserved IDT table size in SecCore is too small for X64. Changed the ty= pe of IdtTable in SEC_IDT_TABLE from UINT64 to IA32_IDT_GATE_DESCRIPTOR to have sufficient size reserved in IdtTable for X64. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Signed-off-by: Ted Kuo --- IntelFsp2Pkg/FspSecCore/SecFsp.c | 9 +++++---- IntelFsp2Pkg/FspSecCore/SecFsp.h | 2 +- IntelFsp2Pkg/FspSecCore/SecMain.c | 16 ++++++++-------- IntelFsp2Pkg/FspSecCore/SecMain.h | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.c index 7fde6e7f41..e9b4091b20 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.c +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c @@ -16,19 +16,20 @@ @return FSP specific IDT gate descriptor.=0D =0D **/=0D -UINT64=0D +IA32_IDT_GATE_DESCRIPTOR=0D FspGetExceptionHandler (=0D IN UINT64 IdtEntryTemplate=0D )=0D {=0D UINT32 Entry;=0D - UINT64 ExceptionHandler;=0D + IA32_IDT_GATE_DESCRIPTOR ExceptionHandler;=0D IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor;=0D FSP_INFO_HEADER *FspInfoHeader;=0D =0D + ZeroMem ((VOID *)&ExceptionHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));= =0D FspInfoHeader =3D (FSP_INFO_HEADER *)(UINTN)AsmGetF= spInfoHeader ();=0D - ExceptionHandler =3D IdtEntryTemplate;=0D - IdtGateDescriptor =3D (IA32_IDT_GATE_DESCRIPTOR *)&Exce= ptionHandler;=0D + *(UINT64 *)&ExceptionHandler =3D IdtEntryTemplate;=0D + IdtGateDescriptor =3D &ExceptionHandler;=0D Entry =3D (IdtGateDescriptor->Bits.OffsetHi= gh << 16) | IdtGateDescriptor->Bits.OffsetLow;=0D Entry =3D FspInfoHeader->ImageBase + FspInf= oHeader->ImageSize - (~Entry + 1);=0D IdtGateDescriptor->Bits.OffsetHigh =3D (UINT16)(Entry >> 16);=0D diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.h b/IntelFsp2Pkg/FspSecCore/Sec= Fsp.h index 41931a33dd..e84528b378 100644 --- a/IntelFsp2Pkg/FspSecCore/SecFsp.h +++ b/IntelFsp2Pkg/FspSecCore/SecFsp.h @@ -30,7 +30,7 @@ @return FSP specific IDT gate descriptor.=0D =0D **/=0D -UINT64=0D +IA32_IDT_GATE_DESCRIPTOR=0D FspGetExceptionHandler (=0D IN UINT64 IdtEntryTemplate=0D );=0D diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/Se= cMain.c index 8effe2225c..94ea3865b4 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.c +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c @@ -58,13 +58,13 @@ SecStartup ( IN UINT32 ApiIdx=0D )=0D {=0D - EFI_SEC_PEI_HAND_OFF SecCoreData;=0D - IA32_DESCRIPTOR IdtDescriptor;=0D - SEC_IDT_TABLE IdtTableInStack;=0D - UINT32 Index;=0D - FSP_GLOBAL_DATA PeiFspData;=0D - UINT64 ExceptionHandler;=0D - UINTN IdtSize;=0D + EFI_SEC_PEI_HAND_OFF SecCoreData;=0D + IA32_DESCRIPTOR IdtDescriptor;=0D + SEC_IDT_TABLE IdtTableInStack;=0D + UINT32 Index;=0D + FSP_GLOBAL_DATA PeiFspData;=0D + IA32_IDT_GATE_DESCRIPTOR ExceptionHandler;=0D + UINTN IdtSize;=0D =0D //=0D // Process all libraries constructor function linked to SecCore.=0D @@ -119,7 +119,7 @@ SecStartup ( if (IdtDescriptor.Base =3D=3D 0) {=0D ExceptionHandler =3D FspGetExceptionHandler (mIdtEntryTemplate);=0D for (Index =3D 0; Index < FixedPcdGet8 (PcdFspMaxInterruptSupported); = Index++) {=0D - CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&Exceptio= nHandler, sizeof (UINT64));=0D + CopyMem ((VOID *)&IdtTableInStack.IdtTable[Index], (VOID *)&Exceptio= nHandler, sizeof (IA32_IDT_GATE_DESCRIPTOR));=0D }=0D =0D IdtSize =3D sizeof (IdtTableInStack.IdtTable);=0D diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h b/IntelFsp2Pkg/FspSecCore/Se= cMain.h index 7c2642ad48..1fe7c15aeb 100644 --- a/IntelFsp2Pkg/FspSecCore/SecMain.h +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h @@ -38,8 +38,8 @@ typedef struct _SEC_IDT_TABLE { // Note: For IA32, only the 4 bytes immediately preceding IDT is used to= store=0D // EFI_PEI_SERVICES**=0D //=0D - UINT64 PeiService;=0D - UINT64 IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];=0D + UINT64 PeiService;=0D + IA32_IDT_GATE_DESCRIPTOR IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSuppo= rted)];=0D } SEC_IDT_TABLE;=0D =0D /**=0D --=20 2.35.3.windows.1