]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c
UefiCpuPkg/PiSmmCpuDxeSmm: remove DBs from SmmRelocationSemaphoreComplete32()
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / X64 / Semaphore.c
1 /** @file
2 Semaphore mechanism to indicate to the BSP that an AP has exited SMM
3 after SMBASE relocation.
4
5 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "PiSmmCpuDxeSmm.h"
17
18 X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32;
19 X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32;
20
21 UINTN mSmmRelocationOriginalAddress;
22 volatile BOOLEAN *mRebasedFlag;
23
24 /**
25 AP Semaphore operation in 32-bit mode while BSP runs in 64-bit mode.
26 **/
27 VOID
28 SmmRelocationSemaphoreComplete32 (
29 VOID
30 );
31
32 /**
33 Hook return address of SMM Save State so that semaphore code
34 can be executed immediately after AP exits SMM to indicate to
35 the BSP that an AP has exited SMM after SMBASE relocation.
36
37 @param[in] CpuIndex The processor index.
38 @param[in] RebasedFlag A pointer to a flag that is set to TRUE
39 immediately after AP exits SMM.
40
41 **/
42 VOID
43 SemaphoreHook (
44 IN UINTN CpuIndex,
45 IN volatile BOOLEAN *RebasedFlag
46 )
47 {
48 SMRAM_SAVE_STATE_MAP *CpuState;
49 UINTN TempValue;
50
51 mRebasedFlag = RebasedFlag;
52 PatchInstructionX86 (
53 gPatchRebasedFlagAddr32,
54 (UINT32)(UINTN)mRebasedFlag,
55 4
56 );
57
58 CpuState = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);
59 mSmmRelocationOriginalAddress = HookReturnFromSmm (
60 CpuIndex,
61 CpuState,
62 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete32,
63 (UINT64)(UINTN)&SmmRelocationSemaphoreComplete
64 );
65
66 //
67 // Use temp value to fix ICC complier warning
68 //
69 TempValue = (UINTN)&mSmmRelocationOriginalAddress;
70 PatchInstructionX86 (
71 gPatchSmmRelocationOriginalAddressPtr32,
72 (UINT32)TempValue,
73 4
74 );
75 }