]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/SmmBaseHelper/X64/PageFaultHandler.asm
Save/Restore missing volatile registers (XMM0-5) save/restore in Page Fault handler.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / SmmBaseHelper / X64 / PageFaultHandler.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2010 - 2012, 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
8 ;
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.
11 ;
12 ; Module Name:
13 ;
14 ; PageFaultHandler.asm
15 ;
16 ; Abstract:
17 ;
18 ; Defines page fault handler used to hook SMM IDT
19 ;
20 ;------------------------------------------------------------------------------
21
22 EXTERN mOriginalHandler:QWORD
23 EXTERN PageFaultHandler:PROC
24
25 .code
26
27 PageFaultHandlerHook PROC
28 push rax ; save all volatile registers
29 push rcx
30 push rdx
31 push r8
32 push r9
33 push r10
34 push r11
35
36 add rsp, -10h * 6 - 8 ; reserve memory to store XMM registers and make address 16-byte alignment
37 movdqa [rsp], xmm0
38 movdqa [rsp + 10h], xmm1
39 movdqa [rsp + 20h], xmm2
40 movdqa [rsp + 30h], xmm3
41 movdqa [rsp + 40h], xmm4
42 movdqa [rsp + 50h], xmm5
43
44 add rsp, -20h
45 call PageFaultHandler
46 add rsp, 20h
47
48 movdqa xmm0, [rsp]
49 movdqa xmm1, [rsp + 10h]
50 movdqa xmm2, [rsp + 20h]
51 movdqa xmm3, [rsp + 30h]
52 movdqa xmm4, [rsp + 40h]
53 movdqa xmm5, [rsp + 50h]
54 add rsp, 10h * 6 + 8
55
56 test al, al ; set ZF flag
57 pop r11
58 pop r10
59 pop r9
60 pop r8
61 pop rdx
62 pop rcx
63 pop rax ; restore all volatile registers
64 jnz @F ; check ZF flag
65 jmp mOriginalHandler
66 @@:
67 add rsp, 08h ; skip error code for PF
68 iretq
69 PageFaultHandlerHook ENDP
70 END