UefiCpuPkg: Merge StuffRsb.inc files into one in UefiCpuPkg/Include

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1091

Previously, when compiling NASM source files, BaseTools did not support
including files outside of the NASM source file directory. As a result, we
duplicated multiple copies of "StuffRsb.inc" files in UefiCpuPkg. Those
INC files contain the common logic to stuff the Return Stack Buffer and
are identical.

After the fix of BZ 1085:
https://bugzilla.tianocore.org/show_bug.cgi?id=1085
The above support was introduced.

Thus, this commit will merge all the StuffRsb.inc files in UefiCpuPkg into
one file. The merged file will be named 'StuffRsbNasm.inc' and be placed
under folder UefiCpuPkg/Include/.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Hao Wu 2018-12-21 13:45:55 +08:00
parent e02ba81ac8
commit ada4a003f9
12 changed files with 10 additions and 174 deletions

View File

@ -11,7 +11,8 @@
; ;
; Abstract: ; Abstract:
; ;
; This file provides macro definitions for stuffing the Return Stack Buffer (RSB). ; This file provides macro definitions for stuffing the Return Stack Buffer (RSB)
; for NASM files.
; ;
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
%define MSR_IA32_MISC_ENABLE 0x1A0 %define MSR_IA32_MISC_ENABLE 0x1A0
%define MSR_EFER 0xc0000080 %define MSR_EFER 0xc0000080

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
global ASM_PFX(gcStmPsd) global ASM_PFX(gcStmPsd)

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
; ;
; Variables referrenced by C code ; Variables referrenced by C code

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
global ASM_PFX(gcStmPsd) global ASM_PFX(gcStmPsd)

View File

@ -1,55 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Abstract:
;
; This file provides macro definitions for stuffing the Return Stack Buffer (RSB).
;
;------------------------------------------------------------------------------
%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

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
%define MSR_IA32_MISC_ENABLE 0x1A0 %define MSR_IA32_MISC_ENABLE 0x1A0
%define MSR_EFER 0xc0000080 %define MSR_EFER 0xc0000080

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
extern ASM_PFX(SmmInitHandler) extern ASM_PFX(SmmInitHandler)
extern ASM_PFX(mRebasedFlag) extern ASM_PFX(mRebasedFlag)

View File

@ -1,55 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Abstract:
;
; This file provides macro definitions for stuffing the Return Stack Buffer (RSB).
;
;------------------------------------------------------------------------------
%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

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
; ;
; Variables referrenced by C code ; Variables referrenced by C code

View File

@ -18,7 +18,7 @@
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "StuffRsb.inc" %include "StuffRsbNasm.inc"
extern ASM_PFX(SmmInitHandler) extern ASM_PFX(SmmInitHandler)
extern ASM_PFX(mRebasedFlag) extern ASM_PFX(mRebasedFlag)

View File

@ -1,55 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Abstract:
;
; This file provides macro definitions for stuffing the Return Stack Buffer (RSB).
;
;------------------------------------------------------------------------------
%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