From: Andrei Tatar Date: Fri, 5 May 2023 18:29:23 +0000 (+0200) Subject: patches: Use unikraft syscall in cxa_guard X-Git-Tag: RELEASE-0.14.0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=17ce85c6bd95323a472ec3790713bade17325995;p=unikraft%2Flibs%2Flibcxxabi.git patches: Use unikraft syscall in cxa_guard This patch replaces calls to libc syscall() with short-circuited unikraft-specific static implementations of these syscalls. Co-authored-by: Marco Schlumpp Signed-off-by: Marco Schlumpp Signed-off-by: Andrei Tatar Reviewed-by: Stefan Jumarea Reviewed-by: Maria Sfiraiala Reviewed-by: Razvan Deaconescu Approved-by: Eduard Vintilă Tested-by: Unikraft CI GitHub-Closes: #4 --- diff --git a/Makefile.uk b/Makefile.uk index 1ac401d..9fdae29 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -51,6 +51,7 @@ LIBCXXABI_VERSION=14.0.6 LIBCXXABI_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXXABI_VERSION)/libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz LIBCXXABI_PATCHDIR=$(LIBCXXABI_BASE)/patches $(eval $(call fetch,libcxxabi,$(LIBCXXABI_URL))) +$(eval $(call patch,libcxxabi,$(LIBCXXABI_PATCHDIR),libcxxabi-$(LIBCXXABI_VERSION).src)) ################################################################################ # Helpers diff --git a/patches/0001-cxa_guard_impl_syscall.patch b/patches/0001-cxa_guard_impl_syscall.patch new file mode 100644 index 0000000..12914b6 --- /dev/null +++ b/patches/0001-cxa_guard_impl_syscall.patch @@ -0,0 +1,37 @@ +diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h +index 72940cc7e..822765d89 100644 +--- a/src/cxa_guard_impl.h ++++ b/src/cxa_guard_impl.h +@@ -56,6 +56,7 @@ + + #include + #include ++#include + #include <__threading_support> + #ifndef _LIBCXXABI_HAS_NO_THREADS + # if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) +@@ -157,7 +158,7 @@ uint32_t PlatformThreadID() { + #elif defined(SYS_gettid) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) + uint32_t PlatformThreadID() { + static_assert(sizeof(pid_t) == sizeof(uint32_t), ""); +- return static_cast(syscall(SYS_gettid)); ++ return static_cast(uk_syscall_static(SYS_gettid)); + } + #else + constexpr uint32_t (*PlatformThreadID)() = nullptr; +@@ -410,13 +411,13 @@ private: + #if defined(SYS_futex) + void PlatformFutexWait(int* addr, int expect) { + constexpr int WAIT = 0; +- syscall(SYS_futex, addr, WAIT, expect, 0); ++ uk_syscall_static(SYS_futex, addr, WAIT, expect, 0); + __tsan_acquire(addr); + } + void PlatformFutexWake(int* addr) { + constexpr int WAKE = 1; + __tsan_release(addr); +- syscall(SYS_futex, addr, WAKE, INT_MAX); ++ uk_syscall_static(SYS_futex, addr, WAKE, INT_MAX); + } + #else + constexpr void (*PlatformFutexWait)(int*, int) = nullptr;