From 16b6347b307d19cc1ace4d0a0f0c083954d87652 Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Sat, 28 Feb 2015 02:36:06 +0000 Subject: 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 Reviewed-by: Ni Ruiyu git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16951 6f19259b-4bc3-4df7-8a09-765794883524 --- Nt32Pkg/Sec/SecMain.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Nt32Pkg/Sec') diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c index 602cca9..e6eb3cf 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.
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
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. // -- cgit v1.1