[PATCH 3/5] elf/app: Pass argc and argv to elf init functions

2016-09-02 Thread Benoit Canet
This is needed by go c-shared libraries to setup argc and argv correctly Signed-off-by: Benoît Canet --- core/app.cc| 4 +++- core/elf.cc| 10 +- include/osv/elf.hh | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/app.cc b/core/app.cc inde

[PATCH 4/5] vdso: Stubb the vdso fast syscall compatibility library

2016-09-02 Thread Benoit Canet
Go use this on linux to lookup time. We need a shared libary that we will expose to the go runtime by passing it's pointer in order for go to resolve this kinds of symbols. This so will be reworked after next patch. Signed-off-by: Benoît Canet --- Makefile| 8 +++- libc/vds

[PATCH 2/5] app: Prepare argc and argv earlier

2016-09-02 Thread Benoit Canet
This patch prepare to pass argc and argv to the elf loader so it can forward it to the init() function of the elf object Signed-off-by: Benoît Cnet --- core/app.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/app.cc b/core/app.cc index 515096e..2cf3e42 100644 --- a/

[PATCH 5/5] auxv: Pass the libvdso.so address via auxv

2016-09-02 Thread Benoit Canet
This will allow go program to get the vdso library address. Signed-off-by: Benoît Canet --- core/app.cc| 29 ++--- include/osv/app.hh | 8 +++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/core/app.cc b/core/app.cc index 2c3257b..f2665fc 10

[PATCH 1/5] app: Factorize argc and argv construction

2016-09-02 Thread Benoit Canet
The go c-shared object need the libc to pass them the argc and argv parameters in order to initialize the runtime properly. This is a preparation patch for this. Signed-off-by: Benoît Canet --- core/app.cc| 65 -- include/osv/app.hh |

[PATCH 2/5] app: Prepare argc and argv earlier

2016-09-02 Thread Benoit Canet
This patch prepare to pass argc and argv to the elf loader so it can forward it to the init() function of the elf object Signed-off-by: Benoît Cnet --- core/app.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/app.cc b/core/app.cc index 515096e..2cf3e42 100644 --- a/

[PATCH 1/5] app: Factorize argc and argv construction

2016-09-02 Thread Benoit Canet
The go c-shared object need the libc to pass them the argc and argv parameters in order to initialize the runtime properly. This is a preparation patch for this. Signed-off-by: Benoît Canet --- core/app.cc| 65 -- include/osv/app.hh |

[PATCH 3/5] elf/app: Pass argc and argv to elf init functions

2016-09-02 Thread Benoit Canet
This is needed by go c-shared libraries to setup argc and argv correctly Signed-off-by: Benoît Canet --- core/app.cc| 4 +++- core/elf.cc| 10 +- include/osv/elf.hh | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/app.cc b/core/app.cc inde

[PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Benoit Canet
The c-shared is intented to build C libraries hence it does not export main and it's initialization does not set the fs register with arch_prctl() leading to a crash. Use -buildmode=shared -buildmode=pie to produce a library which export main and is position independant while having and init calli

[PATCH] linux: arch_prctl() system call

2016-08-31 Thread Benoit Canet
Needed by libraries produced by the Go compiler. With this patch and the golang app the runtime init crash later because of a vdso issue. It can be examinated by insertion an abort() before osv send SIGSEGV to the program. (gdb) bt at /usr/lib/golang/src/runtime/mheap.go:503 argc=, argv=

[PATCH v2] signal: Make room for 64th signal

2016-08-30 Thread Benoit Canet
The last signal of the list didn't have enough room for him because signal numbers start at 1. Make him some room so sigaction won't fail for him when go lib execute. Reviewed-by: Benoît Canet --- libc/signal.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/signal.hh b

[PATCH] signal: Make room for 64th signal

2016-08-30 Thread Benoit Canet
The last signal of the list didn't have enough room for him because signal numbers start at 1. Make him some room so sigaction won't fail for him when go lib execute. Reviewed-by: Benoît Canet --- libc/signal.cc | 4 ++-- libc/signal.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) d

[PATCH v2 2/2] syscall: implement rt_sigprocmask

2016-08-29 Thread Benoit Canet
This is the next syscall required by the go hello world Signed-off-by: BenoÃt Canet --- linux.cc | 6 ++ 1 file changed, 6 insertions(+) diff --git a/linux.cc b/linux.cc index 08341f9..e78bb0c 100644 --- a/linux.cc +++ b/linux.cc @@ -292,6 +292,11 @@ int rt_sigaction(int sig, const struct k

[PATCH v2 1/2] syscall: implement rt_sigaction

2016-08-29 Thread Benoit Canet
This is one of the first syscall used by go binaries. The kernel syscall have some custom layout that must be convert forth and back to and from libc. Do it. Signed-off-by: Benoît Canet --- linux.cc | 29 + 1 file changed, 29 insertions(+) diff --git a/linux.cc b/lin

[PATCH 2/2] syscall: implement rt_sigaction

2016-08-29 Thread Benoit Canet
This is one of the first syscall used by go binaries. The kernel syscall have some custom layout that must be convert forth and back to and from libc. Do it. Signed-off-by: Benoît Canet --- linux.cc | 29 + 1 file changed, 29 insertions(+) diff --git a/linux.cc b/lin

[PATCH 1/2] syscall: save also %rbp

2016-08-29 Thread Benoit Canet
From: Nadav Har'El Not saving and restoring the rbp register causes tst-syscall to crash in the debug build. Refs #791. Signed-off-by: Nadav Har'El --- arch/x64/entry.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x64/entry.S b/arch/x64/entry.S index 0526aa7..c2417b8 100644 ---

[PATCH] test: Add gettid() syscall test

2016-08-28 Thread Benoit Canet
Just call gettid() with inline asm and print the result. Signed-off-by: Benoît Canet --- tests/tst-syscall.cc | 13 + 1 file changed, 13 insertions(+) diff --git a/tests/tst-syscall.cc b/tests/tst-syscall.cc index 50074b5..96860d6 100644 --- a/tests/tst-syscall.cc +++ b/tests/tst-sy

[PATCH] test: Add gettid() syscall test

2016-08-28 Thread Benoit Canet
Just call gettid() with inline asm and print the result. Signed-off-by: Benoît Canet --- modules/tests/Makefile | 3 ++- tests/tst-gettid-syscall.cc | 17 + 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/tst-gettid-syscall.cc diff --git a/module

[PATCH] syscall: Add a C syscall example

2016-08-28 Thread Benoit Canet
This C syscall example is just doing exit(42) Signed-off-by: Benoît Canet --- syscall/Makefile | 9 + syscall/module.py| 3 +++ syscall/syscall.c| 16 syscall/usr.manifest | 1 + 4 files changed, 29 insertions(+) create mode 100644 syscall/Makefile creat

[PATCH v5 1/2] x64: 'syscall' instruction support

2016-08-28 Thread Benoit Canet
Enable "fast system calls" via the 'syscall' instruction on OSv. The instruction is used by Go programs on Linux/x86-64 for system calls. Signed-off-by: Pekka Enberg Signed-off-by: Benoît Canet --- arch/x64/arch-setup.cc | 25 + arch/x64/entry.S | 96 ++

[PATCH v4 1/2] x64: 'syscall' instruction support

2016-08-28 Thread Benoit Canet
Enable "fast system calls" via the 'syscall' instruction on OSv. The instruction is used by Go programs on Linux/x86-64 for system calls. Signed-off-by: Pekka Enberg Signed-off-by: Benoît Canet --- arch/x64/arch-setup.cc | 25 ++ arch/x64/entry.S | 90 +

[PATCH 1/2] x64: 'syscall' instruction support

2016-08-28 Thread Benoit Canet
Enable "fast system calls" via the 'syscall' instruction on OSv. The instruction is used by Go programs on Linux/x86-64 for system calls. Signed-off-by: Pekka Enberg Signed-off-by: Benoît Canet --- arch/x64/arch-setup.cc | 25 ++ arch/x64/entry.S | 90 +

[PATCH 1/2] x64: 'syscall' instruction support

2016-08-28 Thread Benoit Canet
Enable "fast system calls" via the 'syscall' instruction on OSv. The instruction is used by Go programs on Linux/x86-64 for system calls. Signed-off-by: Pekka Enberg Signed-off-by: Benoît Canet --- arch/x64/arch-setup.cc | 25 + arch/x64/entry.S | 51 ++

[PATCH 2/2] syscalls: Add most syscalls required by GO binaries

2016-08-25 Thread Benoit Canet
The commented one will require manual work. Signed-off-by: Benoît Canet --- linux.cc | 56 syscalls.h | 141 + 2 files changed, 180 insertions(+), 17 deletions(-) create mode 100644 syscalls.h diff --git a/

[PATCH 1/2] x64: 'syscall' instruction support

2016-08-25 Thread Benoit Canet
Enable "fast system calls" via the 'syscall' instruction on OSv. The instruction is used by Go programs on Linux/x86-64 for system calls. Signed-off-by: Pekka Enberg Signed-off-by: Benoît Canet --- arch/x64/arch-setup.cc | 12 arch/x64/entry.S | 20 arch/

[PATCH 1/2] getifaddrs: Make getifaddr return physical interface mac address

2016-08-17 Thread Benoit Canet
This fix a bug in OSv musl that has been fixed in upstream musl by using netlink. Since OSv does not implement netlink add a function in if.cc in order to copy and interface mac address given it's index then wrapp it in C in getifaddrs_wrapper.cc since getifaddrs.c is not easilly portable to C++ an

[PATCH 2/2] ifup: mark the interface as running

2016-08-17 Thread Benoit Canet
Signed-of-by: BenoÃt Canet --- bsd/porting/networking.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd/porting/networking.cc b/bsd/porting/networking.cc index 1af0ecc..92a423f 100644 --- a/bsd/porting/networking.cc +++ b/bsd/porting/networking.cc @@ -135,7 +135,7 @@ int

[PATCH v3 3/3] tcp_lro: Add missing braces

2016-07-24 Thread Benoit Canet
GCC 6.1.1 on Fedora 24 requires this. We should alway break on malloc returning NULL in order to the NULL pointer not being inserted. Signed-off-by: BenoÃt Canet --- bsd/sys/netinet/tcp_lro.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bsd/sys/netinet/tcp_lro.cc b/

[PATCH v3 1/3] bus_dma: correctly indent bus_dma_tag_create

2016-07-24 Thread Benoit Canet
GCC 6.1.1 on Fedora 24 requires this. Signed-off-by: BenoÃt Canet --- bsd/porting/bus_dma.cc | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bsd/porting/bus_dma.cc b/bsd/porting/bus_dma.cc index e070182..087bc94 100644 --- a/bsd/porting/bus_dma.cc +++ b/bsd/porting

[PATCH v3 2/3] tcp_lro: Add missing braces

2016-07-24 Thread Benoit Canet
GCC 6.1.1 on Fedora 24 requires this. The hint on the brace position is the comment above: /* * Grab the current time and record it so we know when the * most recent congestion event was. Only record it when the * timeout has fired more than once, as there is a reasonable * chance the first o