From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 82EB92118D95C for ; Wed, 7 Nov 2018 18:58:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2018 18:58:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,478,1534834800"; d="scan'208";a="272288212" Received: from ydong10-win10.ccr.corp.intel.com ([10.239.9.125]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2018 18:58:01 -0800 From: Eric Dong To: edk2-devel@lists.01.org Cc: Laszlo Ersek , Ruiyu Ni Date: Thu, 8 Nov 2018 10:57:58 +0800 Message-Id: <20181108025800.12112-1-eric.dong@intel.com> X-Mailer: git-send-email 2.15.0.windows.1 Subject: [Patch 0/2] Separate semaphore container. 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, 08 Nov 2018 02:58:03 -0000 In current implementation, core level semaphore use same container with package level semaphore. This design will let the core level semaphore not works as expected in below case: 1. Feature A has CPU_FEATURE_CORE_BEFORE dependence with Feature B. 2. Feature C has CPU_FEATURE_PACKAGE_AFTER dependence with Feature B. in this case an core level semaphore will be add between A and B, and an package level semaphore will be add between B and C. For a CPU has one package, two cores and 4 threads. Execute like below: Thread 1 Thread 2 ..... Thread 4 ReleaseSemaph(1,2) -| WaitForSemaph(1(2)) -|<-----------------------These two are Core Semaph ReleaseSemaph(1,2) -| WaitForSemaph(2) -| <--- Core Semaph ReleaseSemaph (1,2,3,4) -| WaitForSemaph (1(4)) -| <---------------- Package Semaph ReleaseSemaph(3,4) WaitForSemaph(4(2)) <- Core Semaph In above case, for thread 4, when it executes a core semaphore, i will found WaitForSemaph(4(2)) is met because Thread 1 has execute a package semaphore and ReleaseSemaph(4) for it before. This is not an expect behavior. Thread 4 should wait for thread 3 to do this. Fix this issue by separate the semaphore container for core level and package level. Cc: Laszlo Ersek Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong Eric Dong (2): UefiCpuPkg/RegisterCpuFeaturesLib: Separate semaphore container. UefiCpuPkg/PiSmmCpuDxeSmm: Separate semaphore container. .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 9 ++++++--- .../RegisterCpuFeaturesLib/RegisterCpuFeatures.h | 7 ++++--- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 21 ++++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) -- 2.15.0.windows.1