audk/UefiCpuPkg/Include/StuffRsbNasm.inc
Michael D Kinney 0acd869796 UefiCpuPkg: Replace BSD License with BSD+Patent License
https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
2019-04-09 10:58:28 -07:00

51 lines
1.2 KiB
PHP

;------------------------------------------------------------------------------
;
; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Abstract:
;
; This file provides macro definitions for stuffing the Return Stack Buffer (RSB)
; for NASM files.
;
;------------------------------------------------------------------------------
%define RSB_STUFF_ENTRIES 0x20
;
; parameters:
; @param 1: register to use as counter (e.g. IA32:eax, X64:rax)
; @param 2: stack pointer to restore (IA32:esp, X64:rsp)
; @param 3: the size of a stack frame (IA32:4, X64:8)
;
%macro StuffRsb 3
mov %1, RSB_STUFF_ENTRIES / 2
%%Unroll1:
call %%Unroll2
%%SpecTrap1:
pause
lfence
jmp %%SpecTrap1
%%Unroll2:
call %%StuffLoop
%%SpecTrap2:
pause
lfence
jmp %%SpecTrap2
%%StuffLoop:
dec %1
jnz %%Unroll1
add %2, RSB_STUFF_ENTRIES * %3 ; Restore the stack pointer
%endmacro
;
; RSB stuffing macros for IA32 and X64
;
%macro StuffRsb32 0
StuffRsb eax, esp, 4
%endmacro
%macro StuffRsb64 0
StuffRsb rax, rsp, 8
%endmacro