1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
3 ; This program and the accompanying materials
4 ; are licensed and made available under the terms and conditions of the BSD License
5 ; which accompanies this distribution. The full text of the license may be found at
6 ; http://opensource.org/licenses/bsd-license.php.
8 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 ; Exception handlers used in SM mode
19 ;-------------------------------------------------------------------------------
21 global ASM_PFX(gcStmPsd)
23 extern ASM_PFX(SmmStmExceptionHandler)
24 extern ASM_PFX(SmmStmSetup)
25 extern ASM_PFX(SmmStmTeardown)
26 extern ASM_PFX(gStmXdSupported)
27 extern ASM_PFX(gStmSmiHandlerIdtr)
29 %define MSR_IA32_MISC_ENABLE 0x1A0
30 %define MSR_EFER 0xc0000080
31 %define MSR_EFER_XD 0x800
44 DB 0x05 ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr
55 DD ASM_PFX(OnStmSetup)
57 DD ASM_PFX(OnStmTeardown)
59 DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint
60 DQ 0 ; SmmSmiHandlerRsp
63 DD 0x80010100 ; RequiredStmSmmRevId
64 DD ASM_PFX(OnException)
68 DW 0x01F ; ExceptionFilter
72 DQ 0 ; BiosHwResourceRequirementsPtr
74 DB 0 ; PhysicalAddressBits
75 PSD_SIZE equ $ - ASM_PFX(gcStmPsd)
78 ;------------------------------------------------------------------------------
79 ; SMM Exception handlers
80 ;------------------------------------------------------------------------------
81 global ASM_PFX(OnException)
85 call ASM_PFX(SmmStmExceptionHandler)
93 global ASM_PFX(OnStmSetup)
96 ; Check XD disable bit
99 mov eax, ASM_PFX(gStmXdSupported)
103 mov ecx, MSR_IA32_MISC_ENABLE
105 mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32]
106 test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
108 and dx, 0xFFFB ; clear XD Disable bit if it is set
113 or ax, MSR_EFER_XD ; enable NXE
118 call ASM_PFX(SmmStmSetup)
120 mov eax, ASM_PFX(gStmXdSupported)
124 pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32]
127 mov ecx, MSR_IA32_MISC_ENABLE
129 or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM
135 global ASM_PFX(OnStmTeardown)
136 ASM_PFX(OnStmTeardown):
138 ; Check XD disable bit
141 mov eax, ASM_PFX(gStmXdSupported)
145 mov ecx, MSR_IA32_MISC_ENABLE
147 mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32]
148 test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
150 and dx, 0xFFFB ; clear XD Disable bit if it is set
155 or ax, MSR_EFER_XD ; enable NXE
160 call ASM_PFX(SmmStmTeardown)
162 mov eax, ASM_PFX(gStmXdSupported)
166 pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32]
169 mov ecx, MSR_IA32_MISC_ENABLE
171 or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM