1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2009 - 2018, 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 %include "StuffRsb.inc"
23 global ASM_PFX(gcStmPsd)
25 extern ASM_PFX(SmmStmExceptionHandler)
26 extern ASM_PFX(SmmStmSetup)
27 extern ASM_PFX(SmmStmTeardown)
28 extern ASM_PFX(gStmXdSupported)
29 extern ASM_PFX(gStmSmiHandlerIdtr)
31 %define MSR_IA32_MISC_ENABLE 0x1A0
32 %define MSR_EFER 0xc0000080
33 %define MSR_EFER_XD 0x800
46 DB 0x05 ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr
57 DD ASM_PFX(OnStmSetup)
59 DD ASM_PFX(OnStmTeardown)
61 DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint
62 DQ 0 ; SmmSmiHandlerRsp
65 DD 0x80010100 ; RequiredStmSmmRevId
66 DD ASM_PFX(OnException)
70 DW 0x01F ; ExceptionFilter
74 DQ 0 ; BiosHwResourceRequirementsPtr
76 DB 0 ; PhysicalAddressBits
77 PSD_SIZE equ $ - ASM_PFX(gcStmPsd)
80 ;------------------------------------------------------------------------------
81 ; SMM Exception handlers
82 ;------------------------------------------------------------------------------
83 global ASM_PFX(OnException)
87 call ASM_PFX(SmmStmExceptionHandler)
95 global ASM_PFX(OnStmSetup)
98 ; Check XD disable bit
101 mov eax, ASM_PFX(gStmXdSupported)
105 mov ecx, MSR_IA32_MISC_ENABLE
107 mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32]
108 test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
110 and dx, 0xFFFB ; clear XD Disable bit if it is set
115 or ax, MSR_EFER_XD ; enable NXE
120 call ASM_PFX(SmmStmSetup)
122 mov eax, ASM_PFX(gStmXdSupported)
126 pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32]
129 mov ecx, MSR_IA32_MISC_ENABLE
131 or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM
138 global ASM_PFX(OnStmTeardown)
139 ASM_PFX(OnStmTeardown):
141 ; Check XD disable bit
144 mov eax, ASM_PFX(gStmXdSupported)
148 mov ecx, MSR_IA32_MISC_ENABLE
150 mov esi, edx ; save MSR_IA32_MISC_ENABLE[63-32]
151 test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
153 and dx, 0xFFFB ; clear XD Disable bit if it is set
158 or ax, MSR_EFER_XD ; enable NXE
163 call ASM_PFX(SmmStmTeardown)
165 mov eax, ASM_PFX(gStmXdSupported)
169 pop edx ; get saved MSR_IA32_MISC_ENABLE[63-32]
172 mov ecx, MSR_IA32_MISC_ENABLE
174 or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM