]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NT32Pkg: Bind NT32 process to a single core to avoid NT32 crash issue in some multi...
authorQiu Shumin <shumin.qiu@intel.com>
Sat, 28 Feb 2015 02:36:06 +0000 (02:36 +0000)
committershenshushi <shenshushi@Edk2>
Sat, 28 Feb 2015 02:36:06 +0000 (02:36 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ni Ruiyu <ni.ruiyu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16951 6f19259b-4bc3-4df7-8a09-765794883524

Nt32Pkg/Sec/SecMain.c

index 602cca9b1bfed9b6ca8f5dcc0b16ab4388ecda24..e6eb3cf45e05575f17adf15104a49dd0acb2e0b6 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -183,6 +183,10 @@ Returns:
   CHAR16                *MemorySizeStr;\r
   CHAR16                *FirmwareVolumesStr;\r
   UINTN                 *StackPointer;\r
+  UINT32                ProcessAffinityMask;\r
+  UINT32                SystemAffinityMask;\r
+  INT32                 LowBit;\r
+\r
 \r
   //\r
   // Enable the privilege so that RTC driver can successfully run SetTime()\r
@@ -199,6 +203,20 @@ Returns:
 \r
   SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n");\r
 \r
+  //\r
+  // Determine the first thread available to this process.\r
+  //\r
+  if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) {\r
+    LowBit = (INT32)LowBitSet32 (ProcessAffinityMask);\r
+    if (LowBit != -1) {\r
+      //\r
+      // Force the system to bind the process to a single thread to work\r
+      // around odd semaphore type crashes.\r
+      //\r
+      SetProcessAffinityMask (GetCurrentProcess (), (INTN)(BIT0 << LowBit));\r
+    }\r
+  }\r
+\r
   //\r
   // Make some Windows calls to Set the process to the highest priority in the\r
   //  idle class. We need this to have good performance.\r