|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 2/4] plat/common/x86: Add common assembly macros for threads
We currently add only the macros for saving and restoring the protected
registers for x86.
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
plat/common/x86/thread_macros.S | 51 +++++++++++++++++++++++++++++++++++++++++
plat/common/x86/thread_start.S | 16 ++++---------
2 files changed, 55 insertions(+), 12 deletions(-)
create mode 100644 plat/common/x86/thread_macros.S
diff --git a/plat/common/x86/thread_macros.S b/plat/common/x86/thread_macros.S
new file mode 100644
index 00000000..569b00d5
--- /dev/null
+++ b/plat/common/x86/thread_macros.S
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights
reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+.macro PROTECTED_REGS_SAVE
+ pushq %rbp
+ pushq %rbx
+ pushq %r12
+ pushq %r13
+ pushq %r14
+ pushq %r15
+.endm
+
+.macro PROTECTED_REGS_RESTORE
+ popq %r15
+ popq %r14
+ popq %r13
+ popq %r12
+ popq %rbx
+ popq %rbp
+.endm
diff --git a/plat/common/x86/thread_start.S b/plat/common/x86/thread_start.S
index a6ab297e..57d957a6 100644
--- a/plat/common/x86/thread_start.S
+++ b/plat/common/x86/thread_start.S
@@ -30,6 +30,8 @@
#define ENTRY(X) .globl X ; X :
+#include "thread_macros.S"
+
ENTRY(asm_thread_starter)
popq %rdi
popq %rbx
@@ -44,22 +46,12 @@ ENTRY(asm_ctx_start)
ret
ENTRY(asm_sw_ctx_switch)
- pushq %rbp
- pushq %rbx
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
+ PROTECTED_REGS_SAVE
movq %rsp, OFFSETOF_SW_CTX_SP(%rdi) /* save ESP */
movq OFFSETOF_SW_CTX_SP(%rsi), %rsp /* restore ESP */
movq $1f, OFFSETOF_SW_CTX_IP(%rdi) /* save EIP */
pushq OFFSETOF_SW_CTX_IP(%rsi) /* restore EIP */
ret
1:
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %rbx
- popq %rbp
+ PROTECTED_REGS_RESTORE
ret
--
2.11.0
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |