summaryrefslogtreecommitdiff
path: root/Nt32Pkg/Sec
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-02-28 02:36:06 +0000
committershenshushi <shenshushi@Edk2>2015-02-28 02:36:06 +0000
commit16b6347b307d19cc1ace4d0a0f0c083954d87652 (patch)
treedb20588ddd09dc251b1afa4563f643ab2cb93c73 /Nt32Pkg/Sec
parent83685b43912479a5acc05479430300f5ee7ce6e3 (diff)
downloadedk2-platforms-16b6347b307d19cc1ace4d0a0f0c083954d87652.tar.xz
NT32Pkg: Bind NT32 process to a single core to avoid NT32 crash issue in some multi-core processors.
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
Diffstat (limited to 'Nt32Pkg/Sec')
-rw-r--r--Nt32Pkg/Sec/SecMain.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c
index 602cca9b1b..e6eb3cf45e 100644
--- a/Nt32Pkg/Sec/SecMain.c
+++ b/Nt32Pkg/Sec/SecMain.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -183,6 +183,10 @@ Returns:
CHAR16 *MemorySizeStr;
CHAR16 *FirmwareVolumesStr;
UINTN *StackPointer;
+ UINT32 ProcessAffinityMask;
+ UINT32 SystemAffinityMask;
+ INT32 LowBit;
+
//
// Enable the privilege so that RTC driver can successfully run SetTime()
@@ -200,6 +204,20 @@ Returns:
SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n");
//
+ // Determine the first thread available to this process.
+ //
+ if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) {
+ LowBit = (INT32)LowBitSet32 (ProcessAffinityMask);
+ if (LowBit != -1) {
+ //
+ // Force the system to bind the process to a single thread to work
+ // around odd semaphore type crashes.
+ //
+ SetProcessAffinityMask (GetCurrentProcess (), (INTN)(BIT0 << LowBit));
+ }
+ }
+
+ //
// Make some Windows calls to Set the process to the highest priority in the
// idle class. We need this to have good performance.
//