[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT/LIBUNWIND PATCH v3 2/2] Initial port of Libunwind to Unikraft



Hi Vlad,

Patch looks good, thanks.

-- Felipe

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

============================================================
Dr. Felipe Huici
Chief Researcher, Systems and Machine Learning Group
NEC Laboratories Europe GmbH
Kurfuerstenanlage 36, D-69115 Heidelberg
Tel.  +49
(0)6221 4342-241
Fax:  +49
(0)6221 4342-155
 
e-mail:
felipe.huici@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

On 07.04.19, 13:07, "Vlad-Andrei BĂDOIU (78692)" 
<vlad_andrei.badoiu@xxxxxxxxxxxxxxx> wrote:

    This is our initial port of libunwind to Unikraft as external
    library. Libc is required for it to work.
    
    In the dependency list it should stay as follows:
    ...:$(UK_LIBS)/libunwind:$(UK_LIBS)/compiler-rt:
    $(UK_LIBS)/libcxxabi:$(UK_LIBS)/libcxx:$(UK_LIBS)/newlib:...
    
    Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
    ---
     CODING_STYLE.md                    |  4 ++
     CONTRIBUTING.md                    |  4 ++
     Config.uk                          |  6 ++
     MAINTAINERS.md                     | 11 ++++
     Makefile.uk                        | 92 ++++++++++++++++++++++++++++++
     README.md                          |  5 ++
     exportsyms.uk                      | 33 +++++++++++
     patches/0001-Updated-the-RIP.patch | 37 ++++++++++++
     8 files changed, 192 insertions(+)
     create mode 100644 CODING_STYLE.md
     create mode 100644 CONTRIBUTING.md
     create mode 100644 Config.uk
     create mode 100644 MAINTAINERS.md
     create mode 100644 Makefile.uk
     create mode 100644 README.md
     create mode 100644 exportsyms.uk
     create mode 100644 patches/0001-Updated-the-RIP.patch
    
    diff --git a/CODING_STYLE.md b/CODING_STYLE.md
    new file mode 100644
    index 0000000..5730041
    --- /dev/null
    +++ b/CODING_STYLE.md
    @@ -0,0 +1,4 @@
    +Coding Style
    +============
    +
    +Please refer to the `CODING_STYLE.md` file in the main Unikraft repository.
    diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
    new file mode 100644
    index 0000000..5f55eca
    --- /dev/null
    +++ b/CONTRIBUTING.md
    @@ -0,0 +1,4 @@
    +Contributing to Unikraft
    +=======================
    +
    +Please refer to the `CONTRIBUTING.md` file in the main Unikraft repository.
    diff --git a/Config.uk b/Config.uk
    new file mode 100644
    index 0000000..9f78aee
    --- /dev/null
    +++ b/Config.uk
    @@ -0,0 +1,6 @@
    +menuconfig LIBUNWIND
    +    bool "libunwind - unwinder"
    +   select LIBNOLIBC if !HAVE_LIBC
    +   select LIBCOMPILER_RT
    +   depends on !PLAT_LINUXU
    +    default n
    diff --git a/MAINTAINERS.md b/MAINTAINERS.md
    new file mode 100644
    index 0000000..e2aa947
    --- /dev/null
    +++ b/MAINTAINERS.md
    @@ -0,0 +1,11 @@
    +Maintainers List
    +================
    +
    +For notes on how to read this information, please refer to 
`MAINTAINERS.md` in
    +the main Unikraft repository.
    +
    +   NEWLIB-UNIKRAFT
    +   M:      Felipe Huici <felipe.huici@xxxxxxxxx>
    +   M:      Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
    +   L:      minios-devel@xxxxxxxxxxxxx
    +   F: *
    diff --git a/Makefile.uk b/Makefile.uk
    new file mode 100644
    index 0000000..a80a4fe
    --- /dev/null
    +++ b/Makefile.uk
    @@ -0,0 +1,92 @@
    +#  libunwind Makefile.uk
    +#
    +#  Authors: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
    +#
    +#  Copyright (c) 2019, Politehnica University 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.
    +#
    +
    +
    
+################################################################################
    +# Library registration
    
+################################################################################
    +$(eval $(call addlib_s,libunwind,$(CONFIG_LIBUNWIND)))
    +
    +ifeq ($(CONFIG_LIBUNWIND),y)
    +ifneq ($(CONFIG_LIBCOMPILER_RT),y)
    +$(error Require libcompiler_rt)
    +endif
    +ifeq ($(CONFIG_PLAT_LINUXU), y)
    +$(error Libunwind not supported on Linuxu)
    +endif
    +endif
    +
    
+################################################################################
    +# Sources
    
+################################################################################
    +LIBUNWIND_VERSION=7.0.0
    
+LIBUNWIND_URL=http://releases.llvm.org/$(LIBUNWIND_VERSION)/libunwind-$(LIBUNWIND_VERSION).src.tar.xz
    +LIBUNWIND_PATCHDIR=$(LIBUNWIND_BASE)/patches
    +$(eval $(call fetch,libunwind,$(LIBUNWIND_URL)))
    +$(eval $(call 
patch,libunwind,$(LIBUNWIND_PATCHDIR),libunwind-$(LIBUNWIND_VERSION).src))
    +
    
+################################################################################
    +# Helpers
    
+################################################################################
    +LIBUNWIND_SUBDIR=libunwind-$(LIBUNWIND_VERSION).src
    +LIBUNWIND_SRC=$(LIBUNWIND_ORIGIN)/$(LIBUNWIND_SUBDIR)
    +
    
+################################################################################
    +# Library includes
    
+################################################################################
    +CINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/src
    +CINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/include
    +CXXINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/src
    +CXXINCLUDES-$(CONFIG_LIBUNWIND) += -I$(LIBUNWIND_SRC)/include
    +
    
+################################################################################
    +# Global flags
    
+################################################################################
    +CONFIG_FLAGS   += -D _LIBUNWIND_HAS_NO_THREADS  -D __ELF__  -D 
_LIBUNWIND_IS_NATIVE_ONLY           \
    +             -D _LIBUNWIND_SUPPORT_DWARF_UNWIND -D _LIBUNWIND_IS_BAREMETAL 
                        \
    +             -D _LIBUNWIND_BUILD_ZERO_COST_APIS -D 
_LIBUNWIND_TARGET_X86_64 -D __x86_64__
    +
    +LIBUNWIND_CFLAGS-y      +=  $(CONFIG_FLAGS)
    +LIBUNWIND_CXXFLAGS-y    +=  $(CONFIG_FLAGS)
    +
    
+################################################################################
    +# Library sources
    
+################################################################################
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindLevel1.c
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/Unwind-sjlj.c
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindLevel1-gcc-ext.c
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/libunwind.cpp
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/Unwind-EHABI.cpp
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindRegistersRestore.S
    +LIBUNWIND_SRCS-y += $(LIBUNWIND_SRC)/src/UnwindRegistersSave.S
    diff --git a/README.md b/README.md
    new file mode 100644
    index 0000000..ab369e6
    --- /dev/null
    +++ b/README.md
    @@ -0,0 +1,5 @@
    +libunwind for Unikraft
    +===================
    +
    +Please refer to the `README.md` as well as the documentation in the `doc/`
    +subdirectory of the main unikraft repository.
    diff --git a/exportsyms.uk b/exportsyms.uk
    new file mode 100644
    index 0000000..1b7cf1e
    --- /dev/null
    +++ b/exportsyms.uk
    @@ -0,0 +1,33 @@
    +_Unwind_Backtrace
    +_Unwind_DeleteException
    +_Unwind_FindEnclosingFunction
    +_Unwind_Find_FDE
    +_Unwind_ForcedUnwind
    +_Unwind_GetCFA
    +_Unwind_GetDataRelBase
    +_Unwind_GetGR
    +_Unwind_GetIP
    +_Unwind_GetIPInfo
    +_Unwind_GetLanguageSpecificData
    +_Unwind_GetRegionStart
    +_Unwind_GetTextRelBase
    +_Unwind_RaiseException
    +_Unwind_Resume
    +_Unwind_Resume_or_Rethrow
    +_Unwind_SetGR
    +_Unwind_SetIP
    +unw_getcontext
    +unw_get_fpreg
    +unw_get_proc_info
    +unw_get_proc_name
    +unw_get_reg
    +unw_init_local
    +unw_is_fpreg
    +unw_is_signal_frame
    +unw_iterate_dwarf_unwind_cache
    +unw_local_addr_space
    +unw_regname
    +unw_resume
    +unw_set_fpreg
    +unw_set_reg
    +unw_step
    diff --git a/patches/0001-Updated-the-RIP.patch 
b/patches/0001-Updated-the-RIP.patch
    new file mode 100644
    index 0000000..dcbdfcd
    --- /dev/null
    +++ b/patches/0001-Updated-the-RIP.patch
    @@ -0,0 +1,37 @@
    +From 863cddb4f2f89b51b38785f49b6c7cf3fc9e3f2c Mon Sep 17 00:00:00 2001
    +From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
    +Date: Mon, 3 Dec 2018 18:59:59 +0200
    +Subject: [PATCH] Updated the RIP
    +
    +This patch changes the RIP that is saved
    +by the unw_getcontext function. Now the
    +RIP is pointing to the throw that has
    +triggered the exception.
    +
    +Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
    +---
    + UnwindRegistersSave.S | 8 +++++++-
    + 1 file changed, 7 insertions(+), 1 deletion(-)
    +
    +diff --git a/UnwindRegistersSave.S b/UnwindRegistersSave.S
    +index 07db14b..8223ea1 100644
    +--- a/src/UnwindRegistersSave.S
    ++++ b/src/UnwindRegistersSave.S
    +@@ -88,7 +88,13 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
    +   movq  %r13,104(PTR)
    +   movq  %r14,112(PTR)
    +   movq  %r15,120(PTR)
    +-  movq  (%rsp),TMP
    ++  push %rax 
    ++  movq %rbp, (%rax)
    ++  movq (%rax), %rax
    ++  addq $8, %rax
    ++  movq (%rax), %rax
    ++  movq  %rax, TMP
    ++  pop %rax 
    +   movq  TMP,128(PTR) # store return address as rip
    +   # skip rflags
    +   # skip cs
    +-- 
    +2.19.2
    +
    -- 
    2.20.1
    
    

_______________________________________________
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®.