From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 68ECE81EE8 for ; Tue, 15 Nov 2016 06:08:10 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 15 Nov 2016 06:08:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,495,1473145200"; d="scan'208";a="1068738150" Received: from jfan12-desk.ccr.corp.intel.com ([10.239.9.5]) by fmsmga001.fm.intel.com with ESMTP; 15 Nov 2016 06:08:13 -0800 From: Jeff Fan To: edk2-devel@lists.01.org Cc: Paolo Bonzini , Laszlo Ersek , Jiewen Yao , Feng Tian , Michael D Kinney Date: Tue, 15 Nov 2016 22:08:09 +0800 Message-Id: <20161115140809.5292-3-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20161115140809.5292-1-jeff.fan@intel.com> References: <20161115140809.5292-1-jeff.fan@intel.com> Subject: [PATCH v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile for mNumberToFinish X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2016 14:08:10 -0000 The GCC 5.4 will optimize mNumberToFinish in EarlyInitializeCpu(). It will cause S3 resume failure. Adding *volatile* could make sure compiler does not so such optimization. Cc: Paolo Bonzini Cc: Laszlo Ersek Cc: Jiewen Yao Cc: Feng Tian Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c index 3fb6864..6324d7e 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -55,7 +55,7 @@ AsmGetAddressMap ( #define LEGACY_REGION_BASE (0xA0000 - LEGACY_REGION_SIZE) ACPI_CPU_DATA mAcpiCpuData; -UINT32 mNumberToFinish; +volatile UINT32 mNumberToFinish; MP_CPU_EXCHANGE_INFO *mExchangeInfo; BOOLEAN mRestoreSmmConfigurationInS3 = FALSE; VOID *mGdtForAp = NULL; @@ -371,7 +371,7 @@ EarlyMPRendezvousProcedure ( // // Count down the number with lock mechanism. // - InterlockedDecrement (&mNumberToFinish); + InterlockedDecrement ((UINT32 *) &mNumberToFinish); } /** -- 2.9.3.windows.2