1 #------------------------------------------------------------------------------
3 # Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php.
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 # Exception handlers used in SM mode
20 #------------------------------------------------------------------------------
22 ASM_GLOBAL ASM_PFX(gcStmPsd)
24 ASM_GLOBAL ASM_PFX(SmmStmExceptionHandler)
25 ASM_GLOBAL ASM_PFX(SmmStmSetup)
26 ASM_GLOBAL ASM_PFX(SmmStmTeardown)
28 .equ MSR_IA32_MISC_ENABLE, 0x1A0
29 .equ MSR_EFER, 0xc0000080
30 .equ MSR_EFER_XD, 0x800
43 .byte 0x5 # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr
54 .long ASM_PFX(_OnStmSetup)
56 .long ASM_PFX(_OnStmTeardown)
58 .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint
59 .quad 0 # SmmSmiHandlerRsp
62 .long 0x80010100 # RequiredStmSmmRevId
63 .long ASM_PFX(_OnException)
65 .quad 0 # ExceptionStack
67 .word 0x1F # ExceptionFilter
70 .quad 0 # BiosHwResourceRequirementsPtr
72 .byte 0 # PhysicalAddressBits
73 .equ PSD_SIZE, . - ASM_PFX(gcStmPsd)
77 #------------------------------------------------------------------------------
78 # SMM Exception handlers
79 #------------------------------------------------------------------------------
80 ASM_GLOBAL ASM_PFX(_OnException)
81 ASM_PFX(_OnException):
84 call ASM_PFX(SmmStmExceptionHandler)
89 .byte 0xf, 0x1, 0xc1 # VMCALL
92 ASM_GLOBAL ASM_PFX(_OnStmSetup)
95 # Check XD disable bit
98 movl $ASM_PFX(gStmXdSupported), %eax
102 movl $MSR_IA32_MISC_ENABLE, %ecx
104 movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32]
105 testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34]
107 andw $0x0FFFB, %dx # clear XD Disable bit if it is set
112 orw $MSR_EFER_XD,%ax # enable NXE
117 call ASM_PFX(SmmStmSetup)
119 movl $ASM_PFX(gStmXdSupported), %eax
123 popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32]
126 movl $MSR_IA32_MISC_ENABLE, %ecx
128 orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM
134 ASM_GLOBAL ASM_PFX(_OnStmTeardown)
135 ASM_PFX(_OnStmTeardown):
137 # Check XD disable bit
140 movl $ASM_PFX(gStmXdSupported), %eax
144 movl $MSR_IA32_MISC_ENABLE, %ecx
146 movl %edx, %esi # save MSR_IA32_MISC_ENABLE[63-32]
147 testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34]
149 andw $0x0FFFB, %dx # clear XD Disable bit if it is set
154 orw $MSR_EFER_XD,%ax # enable NXE
159 call ASM_PFX(SmmStmTeardown)
161 movl $ASM_PFX(gStmXdSupported), %eax
165 popl %edx # get saved MSR_IA32_MISC_ENABLE[63-32]
168 movl $MSR_IA32_MISC_ENABLE, %ecx
170 orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM