]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Include/StuffRsbNasm.inc
ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / UefiCpuPkg / Include / StuffRsbNasm.inc
CommitLineData
0df50560
HW
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
0acd8697 4; SPDX-License-Identifier: BSD-2-Clause-Patent\r
0df50560
HW
5;\r
6; Abstract:\r
7;\r
ada4a003
HW
8; This file provides macro definitions for stuffing the Return Stack Buffer (RSB)\r
9; for NASM files.\r
0df50560
HW
10;\r
11;------------------------------------------------------------------------------\r
12\r
13%define RSB_STUFF_ENTRIES 0x20\r
14\r
15;\r
16; parameters:\r
17; @param 1: register to use as counter (e.g. IA32:eax, X64:rax)\r
18; @param 2: stack pointer to restore (IA32:esp, X64:rsp)\r
19; @param 3: the size of a stack frame (IA32:4, X64:8)\r
20;\r
21%macro StuffRsb 3\r
22 mov %1, RSB_STUFF_ENTRIES / 2\r
23 %%Unroll1:\r
24 call %%Unroll2\r
25 %%SpecTrap1:\r
26 pause\r
27 lfence\r
28 jmp %%SpecTrap1\r
29 %%Unroll2:\r
30 call %%StuffLoop\r
31 %%SpecTrap2:\r
32 pause\r
33 lfence\r
34 jmp %%SpecTrap2\r
35 %%StuffLoop:\r
36 dec %1\r
37 jnz %%Unroll1\r
38 add %2, RSB_STUFF_ENTRIES * %3 ; Restore the stack pointer\r
39%endmacro\r
40\r
41;\r
42; RSB stuffing macros for IA32 and X64\r
43;\r
44%macro StuffRsb32 0\r
45 StuffRsb eax, esp, 4\r
46%endmacro\r
47\r
48%macro StuffRsb64 0\r
49 StuffRsb rax, rsp, 8\r
50%endmacro\r