diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-08-17 16:24:52 +0200 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-09-02 07:59:21 +0100 |
commit | 4d1f5a214bb3c7904c26f2634294dee2a18be5d3 (patch) | |
tree | c85c5ddf8707130428d08aeacf30a6eabf51edee /MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S | |
parent | 72b0eaa02679de8a0f0984a4d41ed1386262f3f3 (diff) | |
download | edk2-platforms-4d1f5a214bb3c7904c26f2634294dee2a18be5d3.tar.xz |
MdeModulePkg/EbcDxe AARCH64: use a fixed size thunk structure
The thunk generation is needlessly complex, given that it attempts to
deal with variable length instructions, which don't exist on AArch64.
So replace it with a simple template coded in assembler, with a matching
struct definition in C. That way, we can create and manipulate the thunks
easily without looping over the instructions looking for 'magic' numbers.
Also, use x16 rather than x9, since it is the architectural register to
use for thunks/veneers.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S')
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S b/MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S index 17f379248a..b4b8531f1a 100644 --- a/MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S +++ b/MdeModulePkg/Universal/EbcDxe/AArch64/EbcLowLevel.S @@ -3,8 +3,10 @@ // This code provides low level routines that support the Virtual Machine
// for option ROMs.
//
-// Copyright (c) 2015, The Linux Foundation. All rights reserved.
+// Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>
+// Copyright (c) 2015, The Linux Foundation. All rights reserved.<BR>
// Copyright (c) 2007 - 2014, 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
@@ -19,6 +21,8 @@ ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative) ASM_GLOBAL ASM_PFX(EbcLLEbcInterpret)
ASM_GLOBAL ASM_PFX(EbcLLExecuteEbcImageEntryPoint)
+ASM_GLOBAL ASM_PFX(mEbcInstructionBufferTemplate)
+
//****************************************************************************
// EbcLLCALLEX
//
@@ -61,7 +65,7 @@ ASM_PFX(EbcLLCALLEXNative): //
// This function is called by the thunk code to handle an Native to EBC call
// This can handle up to 16 arguments (1-8 on in x0-x7, 9-16 are on the stack)
-// x9 contains the Entry point that will be the first argument when
+// x16 contains the Entry point that will be the first argument when
// EBCInterpret is called.
//
//****************************************************************************
@@ -97,7 +101,7 @@ ASM_PFX(EbcLLEbcInterpret): mov x3, x2
mov x2, x1
mov x1, x0
- mov x0, x9
+ mov x0, x16
// call C-code
bl ASM_PFX(EbcInterpret)
@@ -111,7 +115,7 @@ ASM_PFX(EbcLLEbcInterpret): // EbcLLExecuteEbcImageEntryPoint
//
// This function is called by the thunk code to handle the image entry point
-// x9 contains the Entry point that will be the first argument when
+// x16 contains the Entry point that will be the third argument when
// ExecuteEbcImageEntryPoint is called.
//
//****************************************************************************
@@ -120,9 +124,27 @@ ASM_PFX(EbcLLExecuteEbcImageEntryPoint): // build new parameter calling convention
mov x2, x1
mov x1, x0
- mov x0, x9
+ mov x0, x16
// call C-code
bl ASM_PFX(ExecuteEbcImageEntryPoint)
ldp x29, x30, [sp], #16
ret
+
+//****************************************************************************
+// mEbcInstructionBufferTemplate
+//****************************************************************************
+ .section ".rodata", "a"
+ .align 3
+ASM_PFX(mEbcInstructionBufferTemplate):
+ adr x17, 0f
+ ldp x16, x17, [x17]
+ br x17
+
+ //
+ // Add a magic code here to help the VM recognize the thunk.
+ //
+ hlt #0xEBC
+
+0: .quad 0 // EBC_ENTRYPOINT_SIGNATURE
+ .quad 0 // EBC_LL_EBC_ENTRYPOINT_SIGNATURE
|