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)
32 .equ MSR_IA32_MISC_ENABLE, 0x1A0
33 .equ MSR_EFER, 0x0c0000080
34 .equ MSR_EFER_XD, 0x0800
39 # This structure serves as a template for all processors.
46 .byte 0xF # Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr
57 .quad ASM_PFX(_OnStmSetup)
58 .quad ASM_PFX(_OnStmTeardown)
59 .quad 0 # SmmSmiHandlerRip - SMM guest entrypoint
60 .quad 0 # SmmSmiHandlerRsp
63 .long 0x80010100 # RequiredStmSmmRevId
64 .quad 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)
76 #------------------------------------------------------------------------------
77 # SMM Exception handlers
78 #------------------------------------------------------------------------------
80 ASM_GLOBAL ASM_PFX(_OnException)
81 ASM_PFX(_OnException):
84 call ASM_PFX(SmmStmExceptionHandler)
88 .byte 0xf, 0x1, 0xc1 # VMCALL
91 ASM_GLOBAL ASM_PFX(_OnStmSetup)
94 # Check XD disable bit
97 movabsq $ASM_PFX(gStmXdSupported), %rax
101 movl $MSR_IA32_MISC_ENABLE, %ecx
103 movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32]
104 testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34]
106 andw $0x0FFFB, %dx # clear XD Disable bit if it is set
111 orw $MSR_EFER_XD,%ax # enable NXE
117 call ASM_PFX(SmmStmSetup)
120 movabsq $ASM_PFX(gStmXdSupported), %rax
124 popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32]
127 movl $MSR_IA32_MISC_ENABLE, %ecx
129 orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM
135 ASM_GLOBAL ASM_PFX(_OnStmTeardown)
136 ASM_PFX(_OnStmTeardown):
138 # Check XD disable bit
141 movabsq $ASM_PFX(gStmXdSupported), %rax
145 movl $MSR_IA32_MISC_ENABLE, %ecx
147 movq %rdx, %r8 # save MSR_IA32_MISC_ENABLE[63-32]
148 testl $BIT2, %edx # MSR_IA32_MISC_ENABLE[34]
150 andw $0x0FFFB, %dx # clear XD Disable bit if it is set
155 orw $MSR_EFER_XD,%ax # enable NXE
161 call ASM_PFX(SmmStmTeardown)
164 movabsq $ASM_PFX(gStmXdSupported), %rax
168 popq %rdx # get saved MSR_IA32_MISC_ENABLE[63-32]
171 movl $MSR_IA32_MISC_ENABLE, %ecx
173 orw $BIT2, %dx # set XD Disable bit if it was set before entering into SMM