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

Re: [Minios-devel] [UNIKRAFT/LIBUCONTEXT PATCH 2/2] Initial port of libucontext on Unikraft (x86)



Hi Charalampos,

Thanks for the patch! Unfortunately, this patch won't apply: you should send a 
v2 that creates a new "ukucontext" library under the libs directory, and puts 
all files within that, the way other Unikraft internal libraries do. Please 
also make sure that paths are relative to the base directory of the repo.

Thanks again,

-- Felipe

On 25.06.19, 14:54, "Minios-devel on behalf of Charalampos Mainas" 
<minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of 
Charalampos.Mainas@xxxxxxxxx> wrote:

    ---
     Config.uk                                   |  5 ++
     Makefile.uk                                 | 85 +++++++++++++++++++++
     include/ucontext.h                          | 76 ++++++++++++++++++
     patches/0001-Add-ucontext-header-file.patch | 29 +++++++
     4 files changed, 195 insertions(+)
     create mode 100644 Config.uk
     create mode 100644 Makefile.uk
     create mode 100644 include/ucontext.h
     create mode 100644 patches/0001-Add-ucontext-header-file.patch
    
    diff --git a/Config.uk b/Config.uk
    new file mode 100644
    index 0000000..d0675aa
    --- /dev/null
    +++ b/Config.uk
    @@ -0,0 +1,5 @@
    +menuconfig LIBUCONTEXT
    +           bool "ucontext.h API"
    +           default n
    +      select LIBNEWLIBC
    +
    diff --git a/Makefile.uk b/Makefile.uk
    new file mode 100644
    index 0000000..5be0492
    --- /dev/null
    +++ b/Makefile.uk
    @@ -0,0 +1,85 @@
    +#  libmkl-dnn Makefile.uk
    +#
    +#  Authors: Charalampos Mainas <Charalampos.Mainas@xxxxxxxxx>
    +#
    +#   Copyright (c) 2019, NEC Europe Ltd., NEC Corporation. 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,libucontext,$(CONFIG_LIBUCONTEXT)))
    +
    
+################################################################################
    +# Sources
    
+################################################################################
    +LIBUCONTEXT_VERSION=libucontext-master
    
+LIBUCONTEXT_URL=https://github.com/AdelieLinux/libucontext/archive/master.zip
    +LIBUCONTEXT_DIR=$(LIBUCONTEXT_VERSION)
    +
    +LIBUCONTEXT_PATCHDIR=$(LIBUCONTEXT_BASE)/patches
    +$(eval $(call fetch,libucontext,$(LIBUCONTEXT_URL),master.zip))
    +$(eval $(call 
patch,libucontext,$(LIBUCONTEXT_PATCHDIR),$(LIBUCONTEXT_DIR)))
    +
    
+################################################################################
    +# Helpers
    
+################################################################################
    +LIBUCONTEXT_SRC=$(LIBUCONTEXT_ORIGIN)/$(LIBUCONTEXT_DIR)/arch/x86_64/
    +
    
+################################################################################
    +# Library includes
    
+################################################################################
    +CINCLUDES-$(CONFIG_LIBUCONTEXT) += -I$(LIBUCONTEXT_BASE)/include      
    +
    
+################################################################################
    +# Global flags
    
+################################################################################
    +# Suppress some warnings to make the build process look neater
    +SUPPRESS_FLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-nonnull  
     \
    +-Wno-unused-but-set-variable -Wno-unused-label -Wno-char-subscripts        
     \
    +-Wno-unused-function -Wno-missing-field-initializers -Wno-uninitialized    
     \
    +-Wno-array-bounds -Wno-maybe-uninitialized -Wno-pointer-sign 
-Wno-unused-value  \
    +-Wno-unused-macros -Wno-parentheses -Wno-implicit-function-declaration     
     \
    +-Wno-missing-braces -Wno-endif-labels -Wno-unused-but-set-variable         
     \
    +-Wno-implicit-function-declaration -Wno-type-limits -Wno-sign-compare
    +
    +LIBUCONTEXT_CFLAGS-y   += $(SUPPRESS_FLAGS)
    +LIBUCONTEXT_CXXFLAGS-y += $(SUPPRESS_FLAGS)
    +
    
+################################################################################
    +# Sources
    
+################################################################################
    +LIBUCONTEXT_SRCS-y += $(LIBUCONTEXT_SRC)/getcontext.S
    +LIBUCONTEXT_SRCS-y += $(LIBUCONTEXT_SRC)/makecontext.c
    +LIBUCONTEXT_SRCS-y += $(LIBUCONTEXT_SRC)/setcontext.S
    +LIBUCONTEXT_SRCS-y += $(LIBUCONTEXT_SRC)/startcontext.S
    +LIBUCONTEXT_SRCS-y += $(LIBUCONTEXT_SRC)/swapcontext.S
    +
    diff --git a/include/ucontext.h b/include/ucontext.h
    new file mode 100644
    index 0000000..3d8ce4d
    --- /dev/null
    +++ b/include/ucontext.h
    @@ -0,0 +1,76 @@
    +/* Taken from musl header files (ucontext.h and arch/x86_64/bits/signal.h) 
*/
    +
    +#include <signal.h>
    +
    +#ifdef _GNU_SOURCE
    +#define REG_R8          0
    +#define REG_R9          1
    +#define REG_R10         2
    +#define REG_R11         3
    +#define REG_R12         4
    +#define REG_R13         5
    +#define REG_R14         6
    +#define REG_R15         7
    +#define REG_RDI         8
    +#define REG_RSI         9
    +#define REG_RBP         10
    +#define REG_RBX         11
    +#define REG_RDX         12
    +#define REG_RAX         13
    +#define REG_RCX         14
    +#define REG_RSP         15
    +#define REG_RIP         16
    +#define REG_EFL         17
    +#define REG_CSGSFS      18
    +#define REG_ERR         19
    +#define REG_TRAPNO      20
    +#define REG_OLDMASK     21
    +#define REG_CR2         22
    +#endif
    +
    +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
    +typedef long long greg_t, gregset_t[23];
    +typedef struct _fpstate {
    +   unsigned short cwd, swd, ftw, fop;
    +   unsigned long long rip, rdp;
    +   unsigned mxcsr, mxcr_mask;
    +   struct {
    +           unsigned short significand[4], exponent, padding[3];
    +   } _st[8];
    +   struct {
    +           unsigned element[4];
    +   } _xmm[16];
    +   unsigned padding[24];
    +} *fpregset_t;
    +struct sigcontext {
    +   unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
    +   unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags;
    +   unsigned short cs, gs, fs, __pad0;
    +   unsigned long err, trapno, oldmask, cr2;
    +   struct _fpstate *fpstate;
    +   unsigned long __reserved1[8];
    +};
    +typedef struct {
    +   gregset_t gregs;
    +   fpregset_t fpregs;
    +   unsigned long long __reserved1[8];
    +} mcontext_t;
    +#else
    +typedef struct {
    +   unsigned long __space[32];
    +} mcontext_t;
    +#endif
    +
    +typedef struct __ucontext {
    +   unsigned long uc_flags;
    +   struct __ucontext *uc_link;
    +   stack_t uc_stack;
    +   mcontext_t uc_mcontext;
    +   sigset_t uc_sigmask;
    +   unsigned long __fpregs_mem[64];
    +} ucontext_t;
    +
    +int  getcontext(ucontext_t *);
    +int  setcontext(const ucontext_t *);
    +void makecontext(ucontext_t *, void (*__func) (void), int, ...);
    +int  swapcontext(ucontext_t *, const ucontext_t *);
    diff --git a/patches/0001-Add-ucontext-header-file.patch 
b/patches/0001-Add-ucontext-header-file.patch
    new file mode 100644
    index 0000000..b960972
    --- /dev/null
    +++ b/patches/0001-Add-ucontext-header-file.patch
    @@ -0,0 +1,29 @@
    +From bbcaae992f53d8648abab5254e81bdf30640911c Mon Sep 17 00:00:00 2001
    +From: Charalampos Mainas <Charalampos.Mainas@xxxxxxxxx>
    +Date: Wed, 29 May 2019 11:34:03 +0200
    +Subject: [PATCH] Add ucontext header file
    +
    +On musl ucontext.h header file is included by signal.h header file. 
    +
    +Signed-off-by: Charalampos Mainas <Charalampos.Mainas@xxxxxxxxx>
    +
    +---
    + arch/x86_64/makecontext.c | 2 +-
    + 1 file changed, 1 insertion(+), 1 deletion(-)
    +
    +diff --git a/arch/x86_64/makecontext.c b/arch/x86_64/makecontext.c
    +index ba6ca59..e272008 100644
    +--- a/arch/x86_64/makecontext.c
    ++++ b/arch/x86_64/makecontext.c
    +@@ -13,7 +13,7 @@
    + #define _GNU_SOURCE
    + #include <stddef.h>
    + #include <stdarg.h>
    +-#include <signal.h>
    ++#include <ucontext.h>
    + #include <string.h>
    + #include <stdint.h>
    + 
    +-- 
    +2.17.1
    +
    -- 
    2.17.1
    
    
    _______________________________________________
    Minios-devel mailing list
    Minios-devel@xxxxxxxxxxxxxxxxxxxx
    https://lists.xenproject.org/mailman/listinfo/minios-devel

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