From nobody Sat Nov 2 14:30:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 148999799066555.288849578031886; Mon, 20 Mar 2017 01:19:50 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7CCE180466; Mon, 20 Mar 2017 01:19:49 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 0A5E0803A6 for ; Mon, 20 Mar 2017 01:19:48 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 20 Mar 2017 01:19:47 -0700 Received: from jfan12-desk.ccr.corp.intel.com ([10.239.158.57]) by FMSMGA003.fm.intel.com with ESMTP; 20 Mar 2017 01:19:45 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,193,1486454400"; d="scan'208";a="836555013" From: Jeff Fan To: edk2-devel@lists.01.org Date: Mon, 20 Mar 2017 16:19:38 +0800 Message-Id: <20170320081939.6196-2-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20170320081939.6196-1-jeff.fan@intel.com> References: <20170320081939.6196-1-jeff.fan@intel.com> Subject: [edk2] [PATCH v5 03/11] UefiCpuPkg/PiSmmCpuDxeSmm: Skip if AllocatedSize is 0 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Feng Tian MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Needn't to copy register table if AllocatedSize is 0. v4: Fix potential uninitialized variable issue. v5: Set DestinationRegisterTableList[Index].RegisterTableEntry before RegisterTableEntry is updated. Cc: Feng Tian Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index 12efc1f..c3280b8 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -826,21 +826,25 @@ CopyRegisterTable ( =20 CopyMem (DestinationRegisterTableList, SourceRegisterTableList, NumberOf= Cpus * sizeof (CPU_REGISTER_TABLE)); for (Index =3D 0; Index < NumberOfCpus; Index++) { - RegisterTableEntry =3D AllocatePool (DestinationRegisterTableList[Inde= x].AllocatedSize); - ASSERT (RegisterTableEntry !=3D NULL); - CopyMem (RegisterTableEntry, (VOID *)(UINTN)SourceRegisterTableList[In= dex].RegisterTableEntry, DestinationRegisterTableList[Index].AllocatedSize); - // - // Go though all MSRs in register table to initialize MSR spin lock - // - for (Index1 =3D 0; Index1 < DestinationRegisterTableList[Index].TableL= ength; Index1++, RegisterTableEntry++) { - if ((RegisterTableEntry->RegisterType =3D=3D Msr) && (RegisterTableE= ntry->ValidBitLength < 64)) { - // - // Initialize MSR spin lock only for those MSRs need bit field wri= ting - // - InitMsrSpinLockByIndex (RegisterTableEntry->Index); + if (DestinationRegisterTableList[Index].AllocatedSize !=3D 0) { + RegisterTableEntry =3D AllocateCopyPool ( + DestinationRegisterTableList[Index].AllocatedSize, + (VOID *)(UINTN)SourceRegisterTableList[Index].RegisterTableEntry + ); + ASSERT (RegisterTableEntry !=3D NULL); + DestinationRegisterTableList[Index].RegisterTableEntry =3D (EFI_PHYS= ICAL_ADDRESS)(UINTN)RegisterTableEntry; + // + // Go though all MSRs in register table to initialize MSR spin lock + // + for (Index1 =3D 0; Index1 < DestinationRegisterTableList[Index].Tabl= eLength; Index1++, RegisterTableEntry++) { + if ((RegisterTableEntry->RegisterType =3D=3D Msr) && (RegisterTabl= eEntry->ValidBitLength < 64)) { + // + // Initialize MSR spin lock only for those MSRs need bit field w= riting + // + InitMsrSpinLockByIndex (RegisterTableEntry->Index); + } } } - DestinationRegisterTableList[Index].RegisterTableEntry =3D (EFI_PHYSIC= AL_ADDRESS)(UINTN)RegisterTableEntry; } } =20 --=20 2.9.3.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel