[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


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 00:09:25 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Sun, 07 Jul 2019 21:09:58 +0000
  • Ironport-phdr: 9a23:xQFCkR+x0M1rMf9uRHKM819IXTAuvvDOBiVQ1KB20OgcTK2v8tzYMVDF4r011RmVBN+dsKIP0rSO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhWiDanb75/Lxq6oRjQu8UKnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahMxugqxGrhyvpBtxzIzaYIyOKPZyYrnQcc8ASGZdQspcUTFKDIOmb4sICuoMJfhVr47mp1sSrBu+AxSnCuXyyj9Qm3/9wKo33PgmEQHdwAwgHtQOvG7QrNXoLKcSTPu4w7XTzTnZd/NWxCzy5JLSchAmuPyBW697f8TWyUkqDQzFj1OQpJTgPzyPyusNqW+b7/F6WeK0kGErsxpxoiS1ycc2lonFnJkVxUvC+C5kw4g1PcW1RFN0bNK5CpddtCGXO5FoTs88QWxkoig3xqUbtZO0YSQG0pcqyh7FZ/CZfYWF7AjvWPueLDtmgn9uZaixiAyo8Ue6z+3xTsy00FFXoSVbitTMrXUN1wDL6siAV/t94l+t2TaR2ADX7eFJOV40la/BJJ4gxr48jIYcsV/ZEi/uhUX5l7Wadl8j+uSw6uTnZKvppoOEOoNphQzyL74il8+/DOgiLAQCQWqW9f6y2bH7+E32WrRKjvk4kqnDt5DaINwWqbK+Aw9OzoYj6hC/Ay2i0NQFhXkHMUlIdw6cj4TzI1HOPev3Ae2lg1SriDtr3ezJPqX9ApXRKXjOiLLhfbd7605dzwoz1slT6I9KBbEfPv3zXlT8tNjZDh8iLwy02PzrCdpj2YMYQ26PBbWZMKzKu1+S+u0vO/WMZJMSuDvlJfgq+frujX4hmVADZ6Wp3YYXaHGkEfRnOEiZZ2TjjcsFEWgQpQUyVvLliECaWz5Je3myR7485i08CI++FofDR4WtgLuH3CuhHZ1We35JClaNEHj2bYWJQPEMZzyOLc9liDMLTqKtRJE81ULmiAivzrthL+3PvyEVq5/n/Nx0/PHI0wE/83pzFcvO/XuKSjRfmXgURjl++L1nvAQpwVCYzal+xfhFDcF77OgPShowc4Tbmb8pQ+vuUx7MK4/aAG2tRc+rVGk8
  • Ironport-sdr: 6rGlMLAi3qAM7cwmOpyc8eJylAWKENXHYFh+pmUifgjuIfEf497Od+o8+W9k+8iqEZoyAQYiNl Y8iLTax1+vYA==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.