]>
Commit | Line | Data |
---|---|---|
0df50560 HW |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r | |
4 | ; This program and the accompanying materials\r | |
5 | ; are licensed and made available under the terms and conditions of the BSD License\r | |
6 | ; which accompanies this distribution. The full text of the license may be found at\r | |
7 | ; http://opensource.org/licenses/bsd-license.php.\r | |
8 | ;\r | |
9 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | ;\r | |
12 | ; Abstract:\r | |
13 | ;\r | |
ada4a003 HW |
14 | ; This file provides macro definitions for stuffing the Return Stack Buffer (RSB)\r |
15 | ; for NASM files.\r | |
0df50560 HW |
16 | ;\r |
17 | ;------------------------------------------------------------------------------\r | |
18 | \r | |
19 | %define RSB_STUFF_ENTRIES 0x20\r | |
20 | \r | |
21 | ;\r | |
22 | ; parameters:\r | |
23 | ; @param 1: register to use as counter (e.g. IA32:eax, X64:rax)\r | |
24 | ; @param 2: stack pointer to restore (IA32:esp, X64:rsp)\r | |
25 | ; @param 3: the size of a stack frame (IA32:4, X64:8)\r | |
26 | ;\r | |
27 | %macro StuffRsb 3\r | |
28 | mov %1, RSB_STUFF_ENTRIES / 2\r | |
29 | %%Unroll1:\r | |
30 | call %%Unroll2\r | |
31 | %%SpecTrap1:\r | |
32 | pause\r | |
33 | lfence\r | |
34 | jmp %%SpecTrap1\r | |
35 | %%Unroll2:\r | |
36 | call %%StuffLoop\r | |
37 | %%SpecTrap2:\r | |
38 | pause\r | |
39 | lfence\r | |
40 | jmp %%SpecTrap2\r | |
41 | %%StuffLoop:\r | |
42 | dec %1\r | |
43 | jnz %%Unroll1\r | |
44 | add %2, RSB_STUFF_ENTRIES * %3 ; Restore the stack pointer\r | |
45 | %endmacro\r | |
46 | \r | |
47 | ;\r | |
48 | ; RSB stuffing macros for IA32 and X64\r | |
49 | ;\r | |
50 | %macro StuffRsb32 0\r | |
51 | StuffRsb eax, esp, 4\r | |
52 | %endmacro\r | |
53 | \r | |
54 | %macro StuffRsb64 0\r | |
55 | StuffRsb rax, rsp, 8\r | |
56 | %endmacro\r |