mirror of
https://github.com/clearlinux/graphene.git
synced 2026-08-21 13:18:07 +00:00
- Fix calling convention issues in the glibc 2.19 patch
- Port gipc module to Linux kernel 4.3 - Simplify PAL signal handling - Fix bug #4 (epoll-related syscalls) - Fix bug #10 - Fix bug #14 - Merge pull request #18
This commit is contained in:
committed by
Don Porter
parent
fd2c16d61f
commit
f7532bbc0d
+4
-2
@@ -20,18 +20,20 @@ ifeq ($(SYS),x86_64-linux-gnu)
|
||||
$(GLIBC_TARGET): $(BUILD_DIR)/Makefile
|
||||
cd $(BUILD_DIR) && $(MAKE)
|
||||
|
||||
$(BUILD_DIR)/Makefile: $(GLIBC_SRC)/configure
|
||||
$(BUILD_DIR)/Makefile: $(addprefix $(GLIBC_SRC)/,configure elf/Versions nptl/Versions dlfcn/Versions)
|
||||
ifeq ($(DEBUG),1)
|
||||
./buildglibc.py --quiet --debug
|
||||
else
|
||||
./buildglibc.py --quiet
|
||||
endif
|
||||
|
||||
$(GLIBC_SRC)/configure:
|
||||
ifeq ($(shell git ls-files $(GLIBC_SRC)/configure),)
|
||||
$(GLIBC_SRC)/configure: $(GLIBC_SRC).patch
|
||||
[ -f $(GLIBC_SRC).tar.gz ] || \
|
||||
wget http://ftp.gnu.org/gnu/glibc/$(GLIBC_SRC).tar.gz
|
||||
tar -xzf $(GLIBC_SRC).tar.gz
|
||||
cd $(GLIBC_SRC) && patch -p1 < ../$(GLIBC_SRC).patch
|
||||
endif
|
||||
|
||||
.PHONY: pack
|
||||
pack: $(GLIBC_TARGET)
|
||||
|
||||
+111
-134
@@ -316,7 +316,7 @@ index 4c58fc9..0ae2fa8 100644
|
||||
dl-routines += dl-cache
|
||||
endif
|
||||
diff --git a/elf/Versions b/elf/Versions
|
||||
index 2383992..1cdf63a 100644
|
||||
index 2383992..98687f6 100644
|
||||
--- a/elf/Versions
|
||||
+++ b/elf/Versions
|
||||
@@ -24,14 +24,15 @@ libc {
|
||||
@@ -348,7 +348,7 @@ index 2383992..1cdf63a 100644
|
||||
__pointer_chk_guard;
|
||||
}
|
||||
+ SHIM {
|
||||
+ syscalldb; glibc_vers_2_17; glibc_option; register_library;
|
||||
+ syscalldb; glibc_version; glibc_option; register_library;
|
||||
+ }
|
||||
}
|
||||
diff --git a/elf/circleload1.c b/elf/circleload1.c
|
||||
@@ -563,7 +563,7 @@ index 0ae0b7f..f883910 100644
|
||||
static int
|
||||
check_loaded_objects (const char **loaded)
|
||||
diff --git a/elf/rtld.c b/elf/rtld.c
|
||||
index 6dcbabc..82cfb7d 100644
|
||||
index 6dcbabc..c87c773 100644
|
||||
--- a/elf/rtld.c
|
||||
+++ b/elf/rtld.c
|
||||
@@ -356,6 +356,23 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
|
||||
@@ -574,15 +574,15 @@ index 6dcbabc..82cfb7d 100644
|
||||
+ library. If not, tell the user to update glibc. */
|
||||
+#include "glibc-version.h"
|
||||
+
|
||||
+volatile const int glibc_vers_2_17 __attribute__((weak)) = GLIBC_VERSION_2_17;
|
||||
+volatile const int glibc_version __attribute__((weak)) = GLIBC_VERSION;
|
||||
+
|
||||
+static void __attribute__((noinline,optimize("-O0")))
|
||||
+check_glibc_version (void)
|
||||
+{
|
||||
+ if (glibc_vers_2_17 != GLIBC_VERSION_2_17)
|
||||
+ if (glibc_version != GLIBC_VERSION)
|
||||
+ {
|
||||
+ _dl_fatal_printf ("Warning from Graphene: "
|
||||
+ "Glibc version is incorrect. Please rebuild Glibc.\n");
|
||||
+ "Glibc version is incorrect. Please rebuild Glibc.\n");
|
||||
+ _exit (1);
|
||||
+ }
|
||||
+}
|
||||
@@ -994,7 +994,7 @@ index a036b92..40a1eaf 100644
|
||||
|
||||
#include "../fork.c"
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
|
||||
index f2dca07..e5b3f2f 100644
|
||||
index f2dca07..0ce7c67 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
|
||||
@@ -90,7 +90,7 @@ __lll_lock_wait_private:
|
||||
@@ -1002,7 +1002,7 @@ index f2dca07..e5b3f2f 100644
|
||||
1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
2: movl %edx, %eax
|
||||
xchgl %eax, (%rdi) /* NB: lock is implied */
|
||||
@@ -1011,7 +1011,7 @@ index f2dca07..e5b3f2f 100644
|
||||
1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
2: movl %edx, %eax
|
||||
xchgl %eax, (%rdi) /* NB: lock is implied */
|
||||
@@ -1020,7 +1020,7 @@ index f2dca07..e5b3f2f 100644
|
||||
1: movl $SYS_futex, %eax
|
||||
movl $2, %edx
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
2: xchgl %edx, (%rdi) /* NB: lock is implied */
|
||||
|
||||
@@ -1029,7 +1029,7 @@ index f2dca07..e5b3f2f 100644
|
||||
movq %r12, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* NB: %edx == 2 */
|
||||
xchgl %edx, (%r12)
|
||||
@@ -1038,7 +1038,7 @@ index f2dca07..e5b3f2f 100644
|
||||
movl $1, %edx /* Wake one thread. */
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
popq %rdx
|
||||
cfi_adjust_cfa_offset(-8)
|
||||
@@ -1047,7 +1047,7 @@ index f2dca07..e5b3f2f 100644
|
||||
movl $1, %edx /* Wake one thread. */
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
popq %rdx
|
||||
cfi_adjust_cfa_offset(-8)
|
||||
@@ -1056,7 +1056,7 @@ index f2dca07..e5b3f2f 100644
|
||||
movq %r12, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
cmpl $0, (%rdi)
|
||||
jne 1f
|
||||
@@ -1110,7 +1110,7 @@ index 0a26739..8aae14a 100644
|
||||
"jne 1b" \
|
||||
: "=&a" (__ignore) \
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
|
||||
index 990b6f9..89dbe32 100644
|
||||
index 990b6f9..b01214d 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
|
||||
@@ -80,7 +80,7 @@ __lll_robust_lock_wait:
|
||||
@@ -1118,7 +1118,7 @@ index 990b6f9..89dbe32 100644
|
||||
|
||||
1: movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
movl (%rdi), %eax
|
||||
|
||||
@@ -1127,7 +1127,7 @@ index 990b6f9..89dbe32 100644
|
||||
|
||||
5: movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movl %eax, %ecx
|
||||
|
||||
movl (%rdi), %eax
|
||||
@@ -1136,12 +1136,12 @@ index 990b6f9..89dbe32 100644
|
||||
movq %r12, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %rcx
|
||||
|
||||
movl (%r12), %eax
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
|
||||
index eec17f2..4472960 100644
|
||||
index eec17f2..a350340 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
|
||||
@@ -62,7 +62,7 @@ pthread_barrier_wait:
|
||||
@@ -1149,7 +1149,7 @@ index eec17f2..4472960 100644
|
||||
xorq %r10, %r10
|
||||
8: movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Don't return on spurious wakeups. The syscall does not change
|
||||
any register except %eax so there is no need to reload any of
|
||||
@@ -1158,12 +1158,12 @@ index eec17f2..4472960 100644
|
||||
orl PRIVATE(%rdi), %esi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Increment LEFT. If this brings the count back to the
|
||||
initial count unlock the object. */
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
|
||||
index 985e0f1..f180ab1 100644
|
||||
index 985e0f1..d559456 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
|
||||
@@ -90,7 +90,7 @@ __pthread_cond_broadcast:
|
||||
@@ -1171,7 +1171,7 @@ index 985e0f1..f180ab1 100644
|
||||
movl $1, %edx
|
||||
movl $0x7fffffff, %r10d
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* For any kind of error, which mainly is EAGAIN, we try again
|
||||
with WAKE. The general test also covers running on old
|
||||
@@ -1180,7 +1180,7 @@ index 985e0f1..f180ab1 100644
|
||||
movl $1, %edx
|
||||
movl $0x7fffffff, %r10d
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* For any kind of error, which mainly is EAGAIN, we try again
|
||||
with WAKE. The general test also covers running on old
|
||||
@@ -1189,12 +1189,12 @@ index 985e0f1..f180ab1 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
jmp 10b
|
||||
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
|
||||
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
|
||||
index 53d65b6..8724325 100644
|
||||
index 53d65b6..16df581 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
|
||||
@@ -82,7 +82,7 @@ __pthread_cond_signal:
|
||||
@@ -1202,7 +1202,7 @@ index 53d65b6..8724325 100644
|
||||
#endif
|
||||
movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
#if cond_lock != 0
|
||||
subq $cond_lock, %r8
|
||||
#endif
|
||||
@@ -1211,7 +1211,7 @@ index 53d65b6..8724325 100644
|
||||
xorq %r10, %r10
|
||||
movl (%rdi), %r9d // XXX Can this be right?
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
leaq -cond_futex(%rdi), %r8
|
||||
|
||||
@@ -1220,12 +1220,12 @@ index 53d65b6..8724325 100644
|
||||
/* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
|
||||
movl $1, %edx */
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Unlock. */
|
||||
4: LOCK
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
|
||||
index 0dc2340..cac13bf 100644
|
||||
index 0dc2340..8aff242 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
|
||||
@@ -188,7 +188,7 @@ __pthread_cond_timedwait:
|
||||
@@ -1233,7 +1233,7 @@ index 0dc2340..cac13bf 100644
|
||||
addq $cond_futex, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
cmpl $0, %eax
|
||||
sete %r15b
|
||||
@@ -1242,7 +1242,7 @@ index 0dc2340..cac13bf 100644
|
||||
addq $cond_futex, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
62: movq %rax, %r14
|
||||
|
||||
movl (%rsp), %edi
|
||||
@@ -1251,7 +1251,7 @@ index 0dc2340..cac13bf 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
subq $cond_nwaiters, %rdi
|
||||
|
||||
55: LOCK
|
||||
@@ -1268,7 +1268,7 @@ index 0dc2340..cac13bf 100644
|
||||
movl $__NR_clock_gettime, %eax
|
||||
- syscall
|
||||
-# endif
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Compute relative timeout. */
|
||||
movq (%r13), %rcx
|
||||
@@ -1277,7 +1277,7 @@ index 0dc2340..cac13bf 100644
|
||||
addq $cond_futex, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %r14
|
||||
|
||||
movl (%rsp), %edi
|
||||
@@ -1286,7 +1286,7 @@ index 0dc2340..cac13bf 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
subq $cond_nwaiters, %rdi
|
||||
movl $1, %r12d
|
||||
|
||||
@@ -1295,12 +1295,12 @@ index 0dc2340..cac13bf 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Lock the mutex only if we don't own it already. This only happens
|
||||
in case of PI mutexes, if we got cancelled after a successful
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
|
||||
index 0e61d0a..60e104b 100644
|
||||
index 0e61d0a..b4bcc15 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
|
||||
@@ -138,7 +138,7 @@ __pthread_cond_wait:
|
||||
@@ -1308,7 +1308,7 @@ index 0e61d0a..60e104b 100644
|
||||
movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
cmpl $0, %eax
|
||||
sete %r8b
|
||||
@@ -1317,7 +1317,7 @@ index 0e61d0a..60e104b 100644
|
||||
60: xorb %r8b, %r8b
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
62: movl (%rsp), %edi
|
||||
callq __pthread_disable_asynccancel
|
||||
@@ -1326,7 +1326,7 @@ index 0e61d0a..60e104b 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
subq $cond_nwaiters, %rdi
|
||||
|
||||
17: LOCK
|
||||
@@ -1335,7 +1335,7 @@ index 0e61d0a..60e104b 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
subq $cond_nwaiters, %rdi
|
||||
movl $1, %ecx
|
||||
|
||||
@@ -1344,12 +1344,12 @@ index 0e61d0a..60e104b 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Lock the mutex only if we don't own it already. This only happens
|
||||
in case of PI mutexes, if we got cancelled after a successful
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
|
||||
index 2cbe2fa..d4e229a 100644
|
||||
index 2cbe2fa..489998a 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
|
||||
@@ -90,7 +90,7 @@ __pthread_once:
|
||||
@@ -1357,7 +1357,7 @@ index 2cbe2fa..d4e229a 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
jmp 6b
|
||||
|
||||
/* Preserve the pointer to the control variable. */
|
||||
@@ -1366,7 +1366,7 @@ index 2cbe2fa..d4e229a 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
4: addq $8, %rsp
|
||||
cfi_adjust_cfa_offset(-8)
|
||||
@@ -1375,12 +1375,12 @@ index 2cbe2fa..d4e229a 100644
|
||||
#endif
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
movq %r8, %rdi
|
||||
.LcallUR:
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
|
||||
index 3bbb4c7..8ebf317 100644
|
||||
index 3bbb4c7..53d5ca6 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
|
||||
@@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
|
||||
@@ -1388,12 +1388,12 @@ index 3bbb4c7..8ebf317 100644
|
||||
addq $READERS_WAKEUP, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
subq $READERS_WAKEUP, %rdi
|
||||
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
|
||||
index 40bcc04..d6c9c82 100644
|
||||
index 40bcc04..348170e 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
|
||||
@@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
|
||||
@@ -1401,12 +1401,12 @@ index 40bcc04..d6c9c82 100644
|
||||
21: leaq READERS_WAKEUP(%r12), %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %rdx
|
||||
|
||||
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
|
||||
index f57ef52..78a2655 100644
|
||||
index f57ef52..e9ac77f 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
|
||||
@@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
|
||||
@@ -1414,12 +1414,12 @@ index f57ef52..78a2655 100644
|
||||
21: leaq WRITERS_WAKEUP(%r12), %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %rdx
|
||||
|
||||
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
|
||||
index d779f7b..4dec0c0 100644
|
||||
index d779f7b..849c74f 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
|
||||
@@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
|
||||
@@ -1427,12 +1427,12 @@ index d779f7b..4dec0c0 100644
|
||||
movl $SYS_futex, %eax
|
||||
movq %r10, %rdi
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
xorl %eax, %eax
|
||||
retq
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
|
||||
index e444def..ba31821 100644
|
||||
index e444def..fd94930 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
|
||||
@@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
|
||||
@@ -1440,12 +1440,12 @@ index e444def..ba31821 100644
|
||||
addq $WRITERS_WAKEUP, %rdi
|
||||
movl $SYS_futex, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
subq $WRITERS_WAKEUP, %rdi
|
||||
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
|
||||
index 1c11600..d276efa 100644
|
||||
index 1c11600..bd166cf 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
|
||||
@@ -52,7 +52,7 @@ sem_post:
|
||||
@@ -1453,12 +1453,12 @@ index 1c11600..d276efa 100644
|
||||
orl PRIVATE(%rdi), %esi
|
||||
movl $1, %edx
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
testq %rax, %rax
|
||||
js 1f
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
|
||||
index 880610e..06fd57c 100644
|
||||
index 880610e..e520049 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
|
||||
@@ -97,7 +97,7 @@ sem_timedwait:
|
||||
@@ -1466,7 +1466,7 @@ index 880610e..06fd57c 100644
|
||||
movl $SYS_futex, %eax
|
||||
xorl %edx, %edx
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %r9
|
||||
#if VALUE != 0
|
||||
leaq -VALUE(%rdi), %rdi
|
||||
@@ -1475,12 +1475,12 @@ index 880610e..06fd57c 100644
|
||||
movl $SYS_futex, %eax
|
||||
xorl %edx, %edx
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %r14
|
||||
|
||||
movl 16(%rsp), %edi
|
||||
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
|
||||
index 8f4d068..d9b49e4 100644
|
||||
index 8f4d068..fe6dfbf 100644
|
||||
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
|
||||
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
|
||||
@@ -81,7 +81,7 @@ sem_wait:
|
||||
@@ -1488,34 +1488,34 @@ index 8f4d068..d9b49e4 100644
|
||||
#endif
|
||||
xorl %edx, %edx
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
movq %rax, %rcx
|
||||
|
||||
xchgq %r8, %rdi
|
||||
diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
|
||||
index 18a15a1..ac3d6d3 100644
|
||||
index 18a15a1..f050241 100644
|
||||
--- a/nptl/sysdeps/x86_64/pthreaddef.h
|
||||
+++ b/nptl/sysdeps/x86_64/pthreaddef.h
|
||||
@@ -48,4 +48,5 @@
|
||||
@@ -48,4 +48,4 @@
|
||||
|
||||
/* While there is no such syscall. */
|
||||
#define __exit_thread_inline(val) \
|
||||
- asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
|
||||
+ asm volatile ("pushq %%rbx\n\tmovq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
|
||||
+ "call %%rbx\n\t" :: "a" (__NR_exit), "D" (val) : "bx" )
|
||||
+ asm volatile (SYSCALLDB :: "a" (__NR_exit), "D" (val))
|
||||
diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
|
||||
index cbb5e9e..19b18ef 100644
|
||||
index cbb5e9e..9b87e25 100644
|
||||
--- a/nptl/sysdeps/x86_64/tls.h
|
||||
+++ b/nptl/sysdeps/x86_64/tls.h
|
||||
@@ -28,6 +28,7 @@
|
||||
@@ -28,6 +28,8 @@
|
||||
# include <sysdep.h>
|
||||
# include <libc-internal.h>
|
||||
# include <kernel-features.h>
|
||||
+# include <shim_tls.h>
|
||||
+# include <syscalldb.h>
|
||||
|
||||
/* Replacement type for __m128 since this file is included by ld.so,
|
||||
which is compiled with -mno-sse. It must not change the alignment
|
||||
@@ -67,6 +68,10 @@ typedef struct
|
||||
@@ -67,6 +69,10 @@ typedef struct
|
||||
# else
|
||||
int __glibc_reserved1;
|
||||
# endif
|
||||
@@ -1526,20 +1526,15 @@ index cbb5e9e..19b18ef 100644
|
||||
int rtld_must_xmm_save;
|
||||
/* Reservation of some values for the TM ABI. */
|
||||
void *__private_tm[4];
|
||||
@@ -137,6 +142,12 @@ typedef struct
|
||||
@@ -137,7 +143,6 @@ typedef struct
|
||||
# define GET_DTV(descr) \
|
||||
(((tcbhead_t *) (descr))->dtv)
|
||||
|
||||
+/* For Graphene */
|
||||
+#define SYSCALLDB \
|
||||
+ "pushq %%rbx\n\t" \
|
||||
+ "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
|
||||
+ "callq *%%rbx\n\t" \
|
||||
+ "popq %%rbx\n\t"
|
||||
|
||||
-
|
||||
/* Code to initially initialize the thread pointer. This might need
|
||||
special attention since 'errno' is not yet available and if the
|
||||
@@ -154,7 +165,7 @@ typedef struct
|
||||
operation can cause a failure 'errno' must not be touched.
|
||||
@@ -154,7 +159,7 @@ typedef struct
|
||||
_head->self = _thrdescr; \
|
||||
\
|
||||
/* It is a simple syscall to set the %fs value for the thread. */ \
|
||||
@@ -1605,7 +1600,7 @@ index 2468228..a9f1cd6 100644
|
||||
#ifdef ABORT_INSTRUCTION
|
||||
ABORT_INSTRUCTION;
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
|
||||
index 49f0384..ee59c00 100644
|
||||
index 49f0384..6b1a975 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
|
||||
@@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
|
||||
@@ -1613,7 +1608,7 @@ index 49f0384..ee59c00 100644
|
||||
lea -sizeSS(%rsp), %RSI_LP
|
||||
movl $__NR_sigaltstack, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
+
|
||||
/* Without working sigaltstack we cannot perform the test. */
|
||||
testl %eax, %eax
|
||||
@@ -1637,7 +1632,7 @@ index f712110..f6bad14 100644
|
||||
|
||||
#include "../clock_gettime.c"
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
|
||||
index 0508730..c011e7a 100644
|
||||
index 0508730..e1b35ec 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/clone.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
|
||||
@@ -59,11 +59,15 @@ ENTRY (__clone)
|
||||
@@ -1663,7 +1658,7 @@ index 0508730..c011e7a 100644
|
||||
wrong. */
|
||||
cfi_endproc;
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
+L(clone_return):
|
||||
testq %rax,%rax
|
||||
@@ -1674,7 +1669,7 @@ index 0508730..c011e7a 100644
|
||||
jne 2f
|
||||
movl $SYS_ify(getpid), %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
2: movl %eax, %fs:PID
|
||||
movl %eax, %fs:TID
|
||||
1:
|
||||
@@ -1686,7 +1681,7 @@ index 0508730..c011e7a 100644
|
||||
popq %rdi /* Argument. */
|
||||
call *%rax
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
|
||||
index 140db03..870fb02 100644
|
||||
index 140db03..6967f10 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
|
||||
@@ -75,7 +75,7 @@ ENTRY(__getcontext)
|
||||
@@ -1694,7 +1689,7 @@ index 140db03..870fb02 100644
|
||||
movl $_NSIG8,%r10d
|
||||
movl $__NR_rt_sigprocmask, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
cmpq $-4095, %rax /* Check %rax for error. */
|
||||
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
|
||||
|
||||
@@ -1728,7 +1723,7 @@ index 440ca7f..571125d 100644
|
||||
weak_alias (__gettimeofday, gettimeofday)
|
||||
libc_hidden_weak (gettimeofday)
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
|
||||
index 0fd47f2..0247e2f 100644
|
||||
index 0fd47f2..7a82975 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
|
||||
@@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
|
||||
@@ -1752,7 +1747,7 @@ index 0fd47f2..0247e2f 100644
|
||||
movl $__NR_getcpu, %eax
|
||||
- syscall
|
||||
-# ifndef __ASSUME_GETCPU_SYSCALL
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
+#endif
|
||||
+
|
||||
+#if 0 /* for Graphene, never do vsyscall */
|
||||
@@ -1767,7 +1762,7 @@ index 0fd47f2..0247e2f 100644
|
||||
callq *%rax
|
||||
1:
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
|
||||
index b726fa0..96bf0ec 100644
|
||||
index b726fa0..bb3ae34 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
|
||||
@@ -43,7 +43,7 @@ ENTRY(__setcontext)
|
||||
@@ -1775,26 +1770,25 @@ index b726fa0..96bf0ec 100644
|
||||
movl $_NSIG8,%r10d
|
||||
movl $__NR_rt_sigprocmask, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
popq %rdi /* Reload %rdi, adjust stack. */
|
||||
cfi_adjust_cfa_offset(-8)
|
||||
cmpq $-4095, %rax /* Check %rax for error. */
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
|
||||
index ab23985..39d0bdc 100644
|
||||
index ab23985..38a6b69 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
|
||||
@@ -129,7 +129,8 @@ asm \
|
||||
@@ -129,7 +129,7 @@ asm \
|
||||
" .type __" #name ",@function\n" \
|
||||
"__" #name ":\n" \
|
||||
" movq $" #syscall ", %rax\n" \
|
||||
- " syscall\n" \
|
||||
+ " movq syscalldb@GOTPCREL(%rip), %rbx\n" \
|
||||
+ " call *%rbx\n" \
|
||||
+ SYSCALLDB_ASM \
|
||||
".LEND_" #name ":\n" \
|
||||
".section .eh_frame,\"a\",@progbits\n" \
|
||||
".LSTARTFRAME_" #name ":\n" \
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
|
||||
index b3854fa..fd42f66 100644
|
||||
index b3854fa..6369bfe 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
|
||||
@@ -75,7 +75,7 @@ ENTRY(__swapcontext)
|
||||
@@ -1802,12 +1796,12 @@ index b3854fa..fd42f66 100644
|
||||
movl $_NSIG8,%r10d
|
||||
movl $__NR_rt_sigprocmask, %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
cmpq $-4095, %rax /* Check %rax for error. */
|
||||
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
|
||||
index 92c2f5b..7b7ee12 100644
|
||||
index 92c2f5b..33f820f 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
|
||||
@@ -34,7 +34,7 @@ ENTRY (syscall)
|
||||
@@ -1815,12 +1809,12 @@ index 92c2f5b..7b7ee12 100644
|
||||
movq %r9, %r8
|
||||
movq 8(%rsp),%r9 /* arg6 is on the stack. */
|
||||
- syscall /* Do the system call. */
|
||||
+ SYSCALL /* Do the system call. */
|
||||
+ SYSCALLDB /* Do the system call. */
|
||||
cmpq $-4095, %rax /* Check %rax for error. */
|
||||
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
|
||||
ret /* Return to caller. */
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
|
||||
index 4a9a9d9..3b7434d 100644
|
||||
index 4a9a9d9..dc452ed 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
|
||||
@@ -21,6 +21,7 @@
|
||||
@@ -1831,33 +1825,23 @@ index 4a9a9d9..3b7434d 100644
|
||||
|
||||
#ifdef IS_IN_rtld
|
||||
# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
|
||||
@@ -172,11 +173,18 @@
|
||||
|
||||
Syscalls of more than 6 arguments are not supported. */
|
||||
|
||||
+# undef SYSCALL
|
||||
+# define SYSCALL \
|
||||
+ pushq %rbx; \
|
||||
+ movq syscalldb@GOTPCREL(%rip), %rbx; \
|
||||
+ call *%rbx; \
|
||||
+ popq %rbx;
|
||||
+
|
||||
# undef DO_CALL
|
||||
@@ -176,7 +177,7 @@
|
||||
# define DO_CALL(syscall_name, args) \
|
||||
DOARGS_##args \
|
||||
movl $SYS_ify (syscall_name), %eax; \
|
||||
- syscall;
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
# define DOARGS_0 /* nothing */
|
||||
# define DOARGS_1 /* nothing */
|
||||
@@ -190,9 +198,20 @@
|
||||
@@ -190,9 +191,20 @@
|
||||
/* Define a macro which expands inline into the wrapper code for a system
|
||||
call. */
|
||||
# undef INLINE_SYSCALL
|
||||
-# define INLINE_SYSCALL(name, nr, args...) \
|
||||
+# define INLINE_SYSCALL(name, nr_args...) \
|
||||
+ ({ \
|
||||
({ \
|
||||
- unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
|
||||
+ unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
|
||||
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
|
||||
+ { \
|
||||
@@ -1868,13 +1852,12 @@ index 4a9a9d9..3b7434d 100644
|
||||
+
|
||||
+# undef INLINE_SYSCALL_ASM
|
||||
+# define INLINE_SYSCALL_ASM(name, nr_args...) \
|
||||
({ \
|
||||
- unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
|
||||
+ ({ \
|
||||
+ unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
|
||||
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
|
||||
{ \
|
||||
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
||||
@@ -204,9 +223,9 @@
|
||||
@@ -204,9 +216,9 @@
|
||||
into the wrapper code for a system call. It should be used when size
|
||||
of any argument > size of long int. */
|
||||
# undef INLINE_SYSCALL_TYPES
|
||||
@@ -1886,16 +1869,14 @@ index 4a9a9d9..3b7434d 100644
|
||||
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
|
||||
{ \
|
||||
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
||||
@@ -223,13 +242,20 @@
|
||||
@@ -223,13 +235,19 @@
|
||||
LOAD_ARGS_##nr (args) \
|
||||
LOAD_REGS_##nr \
|
||||
asm volatile ( \
|
||||
- "syscall\n\t" \
|
||||
+ "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
|
||||
+ "call *%%rbx\n\t" \
|
||||
+ SYSCALLDB \
|
||||
: "=a" (resultvar) \
|
||||
- : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
|
||||
+ : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
|
||||
: "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
|
||||
(long int) resultvar; })
|
||||
+# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
|
||||
+
|
||||
@@ -1911,20 +1892,16 @@ index 4a9a9d9..3b7434d 100644
|
||||
|
||||
# define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
|
||||
({ \
|
||||
@@ -237,9 +263,10 @@
|
||||
@@ -237,7 +255,7 @@
|
||||
LOAD_ARGS_TYPES_##nr (args) \
|
||||
LOAD_REGS_TYPES_##nr (args) \
|
||||
asm volatile ( \
|
||||
- "syscall\n\t" \
|
||||
+ "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
|
||||
+ "call *%%rbx\n\t" \
|
||||
+ SYSCALLDB \
|
||||
: "=a" (resultvar) \
|
||||
- : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
|
||||
+ : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
|
||||
: "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
|
||||
(long int) resultvar; })
|
||||
# undef INTERNAL_SYSCALL_TYPES
|
||||
# define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
|
||||
@@ -252,6 +279,7 @@
|
||||
@@ -252,6 +270,7 @@
|
||||
# undef INTERNAL_SYSCALL_ERRNO
|
||||
# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
|
||||
|
||||
@@ -1932,7 +1909,7 @@ index 4a9a9d9..3b7434d 100644
|
||||
# ifdef SHARED
|
||||
# define INLINE_VSYSCALL(name, nr, args...) \
|
||||
({ \
|
||||
@@ -300,12 +328,13 @@
|
||||
@@ -300,12 +319,13 @@
|
||||
v_ret; \
|
||||
})
|
||||
|
||||
@@ -2018,7 +1995,7 @@ index 79f1fab..0000000
|
||||
-
|
||||
-#endif
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
|
||||
index d3b450a..76bda33 100644
|
||||
index d3b450a..75a63e1 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
|
||||
@@ -38,7 +38,7 @@ ENTRY (__vfork)
|
||||
@@ -2026,7 +2003,7 @@ index d3b450a..76bda33 100644
|
||||
/* Stuff the syscall number in RAX and enter into the kernel. */
|
||||
movl $SYS_ify (vfork), %eax
|
||||
- syscall
|
||||
+ SYSCALL
|
||||
+ SYSCALLDB
|
||||
|
||||
/* Push back the return PC. */
|
||||
pushq %rdi
|
||||
|
||||
@@ -5,11 +5,30 @@
|
||||
.weak syscalldb
|
||||
.type syscalldb, @function
|
||||
|
||||
# define SYSCALLDB \
|
||||
pushq %rbx; \
|
||||
movq syscalldb@GOTPCREL(%rip), %rbx; \
|
||||
call *%rbx; \
|
||||
popq %rbx;
|
||||
|
||||
|
||||
#else /* !__ASSEMBLER__ */
|
||||
asm (
|
||||
".weak syscalldb\r\n"
|
||||
".type syscalldb, @function\r\n");
|
||||
|
||||
#define SYSCALLDB \
|
||||
"subq $128, %%rsp\n\t" \
|
||||
"pushq %%rbx\n\t" \
|
||||
"movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
|
||||
"callq *%%rbx\n\t" \
|
||||
"popq %%rbx\n\t" \
|
||||
"addq $128, %%rsp\n\t"
|
||||
|
||||
#define SYSCALLDB_ASM \
|
||||
"movq syscalldb@GOTPCREL(%rip), %rbx\n\t" \
|
||||
"callq *%rbx\n\t"
|
||||
|
||||
long int glibc_option (const char * opt);
|
||||
|
||||
asm (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* update the file whenever changes made to glibc.
|
||||
pick whatever random value. */
|
||||
|
||||
#define GLIBC_VERSION_2_17 0xd893a451
|
||||
#define GLIBC_VERSION 0xf200364c
|
||||
|
||||
int register_library (const char * name, unsigned long load_address);
|
||||
|
||||
@@ -17,4 +17,8 @@
|
||||
|
||||
#define EXECVE_RTLD 1
|
||||
|
||||
/* debug message printout */
|
||||
#define DEBUGBUF_SIZE 256
|
||||
#define DEBUGBUF_BREAK 0
|
||||
|
||||
#endif /* _SHIM_DEFS_H_ */
|
||||
|
||||
@@ -331,7 +331,7 @@ int directory_open (struct shim_handle * hdl, struct shim_dentry * dent,
|
||||
void get_dentry (struct shim_dentry * dent);
|
||||
void put_dentry (struct shim_dentry * dent);
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
static_inline
|
||||
void fast_pathcpy (char * dst, const char * src, int size, char ** ptr)
|
||||
{
|
||||
char * d = dst;
|
||||
@@ -341,7 +341,7 @@ void fast_pathcpy (char * dst, const char * src, int size, char ** ptr)
|
||||
*ptr = d;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
static_inline
|
||||
char * dentry_get_path (struct shim_dentry * dent, bool on_stack,
|
||||
int * sizeptr)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#define extern_alias(name) \
|
||||
extern __typeof(name) shim_##name __attribute ((alias (alias_str(name))))
|
||||
|
||||
#define static_inline static inline __attribute__((always_inline))
|
||||
|
||||
#include <shim_types.h>
|
||||
#include <shim_defs.h>
|
||||
#include <shim_atomic.h>
|
||||
@@ -49,9 +51,6 @@
|
||||
#define IS_INTERNAL(thread) ((thread)->tid >= INTERNAL_TID_BASE)
|
||||
#define TID_PRINTFMT
|
||||
|
||||
/* debug message printout */
|
||||
# define DEBUGBUF_SIZE 80
|
||||
|
||||
struct debug_buf {
|
||||
int start;
|
||||
int end;
|
||||
@@ -137,18 +136,12 @@ int shim_terminate (void);
|
||||
#define USE_PAUSE 1
|
||||
#define USE_ASSERT 1
|
||||
|
||||
extern bool in_gdb;
|
||||
static inline void do_pause (void);
|
||||
|
||||
#define BREAK_GDB() do { asm volatile ("int $3"); } while (0)
|
||||
|
||||
#if USE_PAUSE == 1
|
||||
# define pause() \
|
||||
do { \
|
||||
if (in_gdb) BREAK_GDB(); else do_pause(); \
|
||||
} while (0)
|
||||
# define pause() do { do_pause(); } while (0)
|
||||
#else
|
||||
# define pause() do { if (in_gdb) BREAK_GDB(); } while (0)
|
||||
# define pause() do {} while (0)
|
||||
#endif
|
||||
|
||||
#define bug() \
|
||||
|
||||
@@ -535,7 +535,7 @@ struct shim_ipc_info * discover_client (struct shim_ipc_port * port,
|
||||
int __init_ipc_msg (struct shim_ipc_msg * msg, int code, int size, IDTYPE dest);
|
||||
struct shim_ipc_msg * create_ipc_msg (int code, int size, IDTYPE dest);
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
static_inline
|
||||
struct shim_ipc_msg * create_ipc_msg_on_stack (int code, int size, IDTYPE dest)
|
||||
{
|
||||
struct shim_ipc_msg * msg = __alloca(IPC_MSG_SIZE(size));
|
||||
@@ -548,7 +548,7 @@ int __init_ipc_msg_duplex (struct shim_ipc_msg_obj * msg, int code, int size,
|
||||
struct shim_ipc_msg_obj *
|
||||
create_ipc_msg_duplex (int code, int size, IDTYPE dest);
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
static_inline
|
||||
struct shim_ipc_msg_obj *
|
||||
create_ipc_msg_duplex_on_stack (int code, int size, IDTYPE dest)
|
||||
{
|
||||
@@ -563,7 +563,7 @@ int __init_ipc_resp_msg (struct shim_ipc_msg * resp, int ret,
|
||||
struct shim_ipc_msg *
|
||||
create_ipc_resp_msg (int ret, IDTYPE dest, unsigned long seq);
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
static_inline
|
||||
struct shim_ipc_msg *
|
||||
create_ipc_resp_msg_on_stack (int ret, IDTYPE dest, unsigned long seq)
|
||||
{
|
||||
|
||||
@@ -113,7 +113,7 @@ struct shim_signal_log {
|
||||
|
||||
extern const char * const siglist[NUM_KNOWN_SIGS + 1];
|
||||
|
||||
static inline const char * signal_name (int sig)
|
||||
static_inline const char * signal_name (int sig)
|
||||
{
|
||||
if (sig <= NUM_KNOWN_SIGS)
|
||||
return siglist[sig];
|
||||
|
||||
@@ -33,6 +33,8 @@ struct shim_regs {
|
||||
unsigned long r14;
|
||||
unsigned long r13;
|
||||
unsigned long r12;
|
||||
unsigned long r11;
|
||||
unsigned long r10;
|
||||
unsigned long r9;
|
||||
unsigned long r8;
|
||||
unsigned long rcx;
|
||||
|
||||
@@ -167,9 +167,7 @@ void free (void * mem);
|
||||
void * remalloc (const void * mem, size_t size);
|
||||
#endif
|
||||
|
||||
static inline
|
||||
__attribute__((always_inline))
|
||||
char * qstrtostr (struct shim_qstr * qstr, bool on_stack)
|
||||
static_inline char * qstrtostr (struct shim_qstr * qstr, bool on_stack)
|
||||
{
|
||||
int len = qstr->len;
|
||||
char * buf = on_stack ? __alloca(len + 1) : malloc(len + 1);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
libsysdb.so.cached
|
||||
@@ -1 +1 @@
|
||||
bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o libsysdb.a libsysdb_debug.so libsysdb.so shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o f963ae7fe22483f709f5d91102546740ef2760008af2b7800dba463527caa301f60b48f45aba39c718db0b75a6edd71e
|
||||
bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o libsysdb.a libsysdb_debug.so libsysdb.so shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o 9bbabfb9b051d17da7c0a24460c1e5962c8455579e4a2c677929332c8f5418b1302df7010af7f613d8910ba7b288b7ac
|
||||
Binary file not shown.
@@ -804,6 +804,9 @@ BEGIN_CP_FUNC(handle)
|
||||
entry->phandle = &new_hdl->pal_handle;
|
||||
}
|
||||
|
||||
if (hdl->type == TYPE_EPOLL)
|
||||
DO_CP(epoll_fd, &hdl->info.epoll.fds, &new_hdl->info.epoll.fds);
|
||||
|
||||
unlock(hdl->lock);
|
||||
ADD_CP_FUNC_ENTRY(off);
|
||||
} else {
|
||||
|
||||
@@ -115,6 +115,9 @@ void __store_context (shim_tcb_t * tcb, PAL_CONTEXT * pal_context,
|
||||
context->uc_mcontext.gregs[REG_R15] = regs->r15;
|
||||
context->uc_mcontext.gregs[REG_R14] = regs->r14;
|
||||
context->uc_mcontext.gregs[REG_R13] = regs->r13;
|
||||
context->uc_mcontext.gregs[REG_R12] = regs->r12;
|
||||
context->uc_mcontext.gregs[REG_R11] = regs->r11;
|
||||
context->uc_mcontext.gregs[REG_R10] = regs->r10;
|
||||
context->uc_mcontext.gregs[REG_R9] = regs->r9;
|
||||
context->uc_mcontext.gregs[REG_R8] = regs->r8;
|
||||
context->uc_mcontext.gregs[REG_RCX] = regs->rcx;
|
||||
@@ -268,7 +271,7 @@ static void illegal_upcall (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
|
||||
{
|
||||
if (IS_INTERNAL_TID(get_cur_tid()) || is_internal(context)) {
|
||||
internal:
|
||||
internal_fault("Internal memory fault", arg, context);
|
||||
internal_fault("Internal illegal fault", arg, context);
|
||||
pause();
|
||||
goto ret_exception;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,9 @@
|
||||
static void __attribute__((unused))
|
||||
elf_dynamic_do_rel (struct link_map * l, ElfW(Addr) reladdr, int relsize)
|
||||
{
|
||||
if (!l->l_info[DT_SYMTAB])
|
||||
return;
|
||||
|
||||
ElfW(Sym) * symtab = (void *) D_PTR (l->l_info[DT_SYMTAB]);
|
||||
ElfW(Rel) * r = (void *) reladdr;
|
||||
ElfW(Rel) * end = (void *) (reladdr + relsize);
|
||||
|
||||
@@ -34,6 +34,9 @@ elf_get_dynamic_info (struct link_map * l)
|
||||
#endif
|
||||
ElfW(Dyn) * dyn = l->l_ld;
|
||||
|
||||
if (dyn == NULL)
|
||||
return;
|
||||
|
||||
while (dyn->d_tag != DT_NULL) {
|
||||
int tag = 0;
|
||||
|
||||
|
||||
@@ -692,12 +692,10 @@ postmap:
|
||||
goto call_lose;
|
||||
}
|
||||
} else {
|
||||
l->l_ld = (ElfW(Dyn) *) RELOCATE(l, l->l_ld);
|
||||
l->l_real_ld = (ElfW(Dyn) *) RELOCATE(l, l->l_ld);
|
||||
l->l_ld = remalloc(l->l_real_ld, sizeof(ElfW(Dyn)) * l->l_ldnum);
|
||||
}
|
||||
|
||||
l->l_real_ld = l->l_ld;
|
||||
l->l_ld = remalloc(l->l_ld, sizeof(ElfW(Dyn)) * l->l_ldnum);
|
||||
|
||||
elf_get_dynamic_info(l);
|
||||
|
||||
/* When we profile the SONAME might be needed for something else but
|
||||
|
||||
@@ -389,8 +389,10 @@ int close_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
|
||||
unlock(port->msgs_lock);
|
||||
}
|
||||
|
||||
if (msg->thread)
|
||||
if (msg->thread) {
|
||||
put_thread(msg->thread);
|
||||
msg->thread = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
SHIM {
|
||||
global:
|
||||
syscalldb; register_library;
|
||||
glibc_vers_*; glibc_option;
|
||||
glibc_version; glibc_option;
|
||||
local: *;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ unsigned long allocmask;
|
||||
SHIM libraries */
|
||||
#include "glibc-version.h"
|
||||
|
||||
const unsigned int glibc_vers_2_17 = GLIBC_VERSION_2_17;
|
||||
const unsigned int glibc_version = GLIBC_VERSION;
|
||||
|
||||
static void handle_failure (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
|
||||
{
|
||||
@@ -174,8 +174,6 @@ const char ** library_paths;
|
||||
LOCKTYPE __master_lock;
|
||||
bool lock_enabled;
|
||||
|
||||
bool in_gdb;
|
||||
|
||||
void init_tcb (shim_tcb_t * tcb)
|
||||
{
|
||||
tcb->canary = SHIM_TLS_CANARY;
|
||||
@@ -421,13 +419,6 @@ int read_environs (const char ** envp)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'I': {
|
||||
if (strcmp_static(*e, "IN_GDB=1")) {
|
||||
in_gdb = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,9 @@ static struct shim_heap * __alloc_enough_heap (size_t size)
|
||||
if (heap == smallest && heap->current != heap->end) {
|
||||
DkVirtualMemoryFree(heap->current, heap->end - heap->current);
|
||||
int flags = VMA_INTERNAL;
|
||||
unlock(shim_heap_lock);
|
||||
bkeep_munmap(heap->current, heap->end - heap->current, &flags);
|
||||
lock(shim_heap_lock);
|
||||
}
|
||||
|
||||
heap->start = heap->current = start;
|
||||
|
||||
@@ -423,7 +423,6 @@ DEFINE_SHIM_SYSCALL (fsync, 1, shim_do_fsync, int, int, fd)
|
||||
/* fdatasync: sys/shim_open.c */
|
||||
DEFINE_SHIM_SYSCALL (fdatasync, 1, shim_do_fdatasync, int, int, fd)
|
||||
|
||||
|
||||
/* truncate: sys/shim_open.c */
|
||||
DEFINE_SHIM_SYSCALL (truncate, 2, shim_do_truncate, int, const char *, path,
|
||||
loff_t, length)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <shim_thread.h>
|
||||
#include <shim_handle.h>
|
||||
#include <shim_fs.h>
|
||||
#include <shim_checkpoint.h>
|
||||
|
||||
#include <pal.h>
|
||||
#include <pal_error.h>
|
||||
@@ -64,6 +65,9 @@ struct shim_epoll_fd {
|
||||
|
||||
int shim_do_epoll_create1 (int flags)
|
||||
{
|
||||
if ((flags & ~EPOLL_CLOEXEC))
|
||||
return -EINVAL;
|
||||
|
||||
struct shim_handle * hdl = get_new_handle();
|
||||
if (!hdl)
|
||||
return -ENOMEM;
|
||||
@@ -79,7 +83,8 @@ int shim_do_epoll_create1 (int flags)
|
||||
create_event(&epoll->event);
|
||||
INIT_LIST_HEAD(&epoll->fds);
|
||||
|
||||
int vfd = set_new_fd_handle(hdl, flags, NULL);
|
||||
int vfd = set_new_fd_handle(hdl, (flags & EPOLL_CLOEXEC) ? FD_CLOEXEC : 0,
|
||||
NULL);
|
||||
put_handle(hdl);
|
||||
return vfd;
|
||||
}
|
||||
@@ -87,6 +92,9 @@ int shim_do_epoll_create1 (int flags)
|
||||
/* the 'size' argument of epoll_create is not used */
|
||||
int shim_do_epoll_create (int size)
|
||||
{
|
||||
if (size < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return shim_do_epoll_create1(0);
|
||||
}
|
||||
|
||||
@@ -321,3 +329,58 @@ struct shim_fs_ops epoll_fs_ops = {
|
||||
|
||||
struct shim_mount epoll_builtin_fs = { .type = "epoll",
|
||||
.fs_ops = &epoll_fs_ops, };
|
||||
|
||||
BEGIN_CP_FUNC(epoll_fd)
|
||||
{
|
||||
assert(size == sizeof(struct list_head));
|
||||
|
||||
struct list_head * old_list = (struct list_head *) obj;
|
||||
struct list_head * new_list = (struct list_head *) objp;
|
||||
struct shim_epoll_fd * epoll_fd;
|
||||
|
||||
debug("checkpoint epoll: %p -> %p (base = %p)\n", old_list, new_list, base);
|
||||
|
||||
INIT_LIST_HEAD(new_list);
|
||||
|
||||
list_for_each_entry(epoll_fd, old_list, list) {
|
||||
ptr_t off = ADD_CP_OFFSET(sizeof(struct shim_epoll_fd));
|
||||
|
||||
struct shim_epoll_fd * new_epoll_fd =
|
||||
(struct shim_epoll_fd *) (base + off);
|
||||
|
||||
new_epoll_fd->fd = epoll_fd->fd;
|
||||
new_epoll_fd->events = epoll_fd->events;
|
||||
new_epoll_fd->data = epoll_fd->data;
|
||||
new_epoll_fd->revents = epoll_fd->revents;
|
||||
new_epoll_fd->pal_handle = NULL;
|
||||
list_add(new_list, &new_epoll_fd->list);
|
||||
|
||||
DO_CP(handle, epoll_fd->handle, &new_epoll_fd->handle);
|
||||
}
|
||||
|
||||
ADD_CP_FUNC_ENTRY((ptr_t) objp - base);
|
||||
}
|
||||
END_CP_FUNC(epoll_fd)
|
||||
|
||||
BEGIN_RS_FUNC(epoll_fd)
|
||||
{
|
||||
struct list_head * list = (void *) (base + GET_CP_FUNC_ENTRY());
|
||||
struct list_head * e;
|
||||
|
||||
CP_REBASE(*list);
|
||||
|
||||
for (e = list->next ; e != list ; e = e->next) {
|
||||
struct shim_epoll_fd * epoll_fd =
|
||||
list_entry(e, struct shim_epoll_fd, list);
|
||||
|
||||
CP_REBASE(epoll_fd->handle);
|
||||
epoll_fd->pal_handle = epoll_fd->handle->pal_handle;
|
||||
CP_REBASE(*e);
|
||||
|
||||
DEBUG_RS("fd=%d,path=%s,type=%s,uri=%s",
|
||||
epoll_fd->fd, qstrgetstr(&epoll_fd->handle->path),
|
||||
epoll_fd->handle->fs_type,
|
||||
qstrgetstr(&epoll_fd->handle->uri));
|
||||
}
|
||||
}
|
||||
END_RS_FUNC(epoll_fd)
|
||||
|
||||
@@ -481,13 +481,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
// DEP 10/20/16: Assuming fsync >> fdatasync for now
|
||||
// and no app depends on only syncing data for correctness.
|
||||
int shim_do_fdatasync (int fd)
|
||||
{
|
||||
return shim_do_fsync(fd);
|
||||
}
|
||||
|
||||
|
||||
// DEP 10/20/16: Assuming fsync >> fdatasync for now
|
||||
// and no app depends on only syncing data for correctness.
|
||||
|
||||
@@ -117,6 +117,7 @@ static int __do_poll (int npolls, struct poll_handle * polls,
|
||||
struct poll_handle * polling = NULL;
|
||||
struct poll_handle * p, ** n, * q;
|
||||
PAL_HANDLE * pals = NULL;
|
||||
int ret = 0;
|
||||
|
||||
#ifdef PROFILE
|
||||
unsigned long begin_time = GET_PROFILE_INTERVAL();
|
||||
@@ -215,23 +216,29 @@ no_op:
|
||||
if (need_poll) {
|
||||
int polled = hdl->fs->fs_ops->poll(hdl, need_poll);
|
||||
|
||||
if (polled & FS_POLL_ER) {
|
||||
debug("fd %d known to have error\n", p->fd);
|
||||
p->flags |= KNOWN_R|KNOWN_W|RET_E;
|
||||
if (polled < 0) {
|
||||
if (polled != -EAGAIN) {
|
||||
ret = polled;
|
||||
goto done_polling;
|
||||
}
|
||||
} else {
|
||||
if (polled & FS_POLL_ER) {
|
||||
debug("fd %d known to have error\n", p->fd);
|
||||
p->flags |= KNOWN_R|KNOWN_W|RET_E;
|
||||
}
|
||||
|
||||
if ((polled & FS_POLL_RD)) {
|
||||
debug("fd %d known to be readable\n", p->fd);
|
||||
p->flags |= KNOWN_R|RET_R;
|
||||
}
|
||||
|
||||
if (polled & FS_POLL_WR) {
|
||||
debug("fd %d known to be writeable\n", p->fd);
|
||||
p->flags |= KNOWN_W|RET_W;
|
||||
}
|
||||
|
||||
do_r = do_w = false;
|
||||
}
|
||||
|
||||
if ((polled & FS_POLL_RD)) {
|
||||
debug("fd %d known to be readable\n", p->fd);
|
||||
p->flags |= KNOWN_R|RET_R;
|
||||
do_r = false;
|
||||
}
|
||||
|
||||
if (polled & FS_POLL_WR) {
|
||||
debug("fd %d known to be writeable\n", p->fd);
|
||||
p->flags |= KNOWN_W|RET_W;
|
||||
do_w = false;
|
||||
}
|
||||
}
|
||||
|
||||
SAVE_PROFILE_INTERVAL(do_poll_vfs_polling);
|
||||
@@ -274,8 +281,10 @@ done_finding:
|
||||
|
||||
SAVE_PROFILE_INTERVAL_SINCE(do_poll_first_loop, begin_time);
|
||||
|
||||
if (!npals)
|
||||
if (!npals) {
|
||||
ret = 0;
|
||||
goto done_polling;
|
||||
}
|
||||
|
||||
pals = __try_alloca(cur, sizeof(PAL_HANDLE) * npals);
|
||||
npals = 0;
|
||||
@@ -364,6 +373,7 @@ done_finding:
|
||||
SAVE_PROFILE_INTERVAL(do_poll_third_loop);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
done_polling:
|
||||
for (p = polling ; p ; p = p->next)
|
||||
put_handle(p->handle);
|
||||
@@ -373,7 +383,7 @@ done_polling:
|
||||
if (pals)
|
||||
__try_free(cur, pals);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int shim_do_poll (struct pollfd * fds, nfds_t nfds, int timeout)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
static struct old_utsname graphene_uname = {
|
||||
.sysname = "Linux",
|
||||
.nodename = "localhost",
|
||||
.release = "3.10",
|
||||
.release = "3.10.0",
|
||||
.version = "1",
|
||||
.machine = "x86_64"
|
||||
};
|
||||
|
||||
@@ -31,15 +31,11 @@
|
||||
syscalldb:
|
||||
.cfi_startproc
|
||||
|
||||
# avoid red zone for previous rsp
|
||||
subq $128, %rsp
|
||||
.cfi_def_cfa_offset 136
|
||||
|
||||
# DEP 7/9/12: Push a stack pointer so clone can find the return address
|
||||
pushq %rbp
|
||||
.cfi_def_cfa_offset 144
|
||||
.cfi_def_cfa_offset 16
|
||||
movq %rsp, %rbp
|
||||
.cfi_offset 6,-144
|
||||
.cfi_offset 6,-16
|
||||
.cfi_def_cfa_register 6
|
||||
|
||||
pushq %rbx
|
||||
@@ -59,15 +55,17 @@ isdef:
|
||||
pushq %rcx
|
||||
pushq %r8
|
||||
pushq %r9
|
||||
pushq %r10
|
||||
pushq %r11
|
||||
pushq %r12
|
||||
pushq %r13
|
||||
pushq %r14
|
||||
pushq %r15
|
||||
|
||||
movq %rax, %fs:(SHIM_TCB_OFFSET + 24)
|
||||
leaq 232(%rsp), %rax
|
||||
leaq 8(%rbp), %rax
|
||||
movq %rax, %fs:(SHIM_TCB_OFFSET + 32)
|
||||
movq -8(%rax), %rax
|
||||
movq (%rbp), %rax
|
||||
movq %rax, %fs:(SHIM_TCB_OFFSET + 40)
|
||||
movq %rsp, %fs:(SHIM_TCB_OFFSET + 48)
|
||||
|
||||
@@ -82,6 +80,8 @@ isdef:
|
||||
popq %r14
|
||||
popq %r13
|
||||
popq %r12
|
||||
popq %r11
|
||||
popq %r10
|
||||
popq %r9
|
||||
popq %r8
|
||||
popq %rcx
|
||||
@@ -101,7 +101,6 @@ isundef:
|
||||
ret:
|
||||
popq %rbx
|
||||
popq %rbp
|
||||
addq $128, %rsp
|
||||
retq
|
||||
|
||||
.cfi_endproc
|
||||
|
||||
@@ -56,6 +56,7 @@ debug_fputch (void * f, int ch, void * b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if DEBUGBUF_BREAK == 1
|
||||
if (buf->end == DEBUGBUF_SIZE - 4) {
|
||||
buf->buf[buf->end++] = '.';
|
||||
buf->buf[buf->end++] = '.';
|
||||
@@ -65,6 +66,11 @@ debug_fputch (void * f, int ch, void * b)
|
||||
buf->buf[buf->end++] = '.';
|
||||
buf->buf[buf->end++] = '.';
|
||||
}
|
||||
#else
|
||||
if (buf->end == DEBUGBUF_SIZE) {
|
||||
debug_fputs(NULL, buf->buf, buf->end);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,19 +28,18 @@ CXX += -g
|
||||
endif
|
||||
export DEBUG
|
||||
|
||||
reldir = $(shell p=`dirname $(1)` ; d=; while [ "$$p" != "." ]; do p=`dirname $$p`; d=../$$d; done; echo $$d)
|
||||
|
||||
manifest_rules = \
|
||||
-e 's:\$$(PALDIR):$(PALDIR):g' \
|
||||
-e 's:\$$(PALDIR):'$$RELDIR'$(PALDIR):g' \
|
||||
-e 's:\$$(PWD):$(PWD):g' \
|
||||
-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
|
||||
-e 's:\$$(SHIMDIR):$(SHIMDIR):g' \
|
||||
-e 's:\$$(SHIMPATH):$(SHIMDIR)/libsysdb.so:g' \
|
||||
-e 's:\$$(LIBCDIR):$(LIBCDIR):g' \
|
||||
-e 's:\$$(SHIMDIR):'$$RELDIR'$(SHIMDIR):g' \
|
||||
-e 's:\$$(SHIMPATH):'$$RELDIR'$(SHIMDIR)/libsysdb.so:g' \
|
||||
-e 's:\$$(LIBCDIR):'$$RELDIR'$(LIBCDIR):g' \
|
||||
$(extra_rules)
|
||||
|
||||
%manifest: %manifest.template
|
||||
@echo [ $@ ]
|
||||
RELDIR=$(filter-out ./,$(shell realpath --relative-to=$(abspath $(dir $@)) $(PWD))/) && \
|
||||
sed $(manifest_rules) $< > $@
|
||||
(grep -q '^#!' $@ && chmod +x $@) || true
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ start-multithreaded-native-server:
|
||||
$(if $(CONF),$(CONF),lighttpd-multithreaded.conf)
|
||||
|
||||
start-graphene-server:
|
||||
$(PREFIX) ./lighttpd.manifest.sgx -D -m /lighttpd -f \
|
||||
$(PREFIX) ./lighttpd.manifest -D -m /lighttpd -f \
|
||||
$(if $(CONF),$(CONF),lighttpd.conf)
|
||||
|
||||
start-multithreaded-graphene-server:
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
PAL_LOADER=$(readlink -f ${BASH_SOURCE[0]})
|
||||
PAL_DIR=$(readlink -f $(dirname $PAL_LOADER)/../../../../Pal/src)
|
||||
PAL=$PAL_DIR/pal
|
||||
PAL_SEC=$PAL_DIR/pal_sec
|
||||
|
||||
MANIFEST=
|
||||
GDB_CMD=
|
||||
@@ -19,23 +18,10 @@ fi
|
||||
|
||||
if [ "$SEC" == "1" ]; then
|
||||
echo "Use reference monitor"
|
||||
PAL_CMD=$PAL_SEC
|
||||
fi
|
||||
|
||||
while [ "$1" != "" ];
|
||||
do
|
||||
if [ "$1" = "-gdb" ]; then
|
||||
GDB_CMD="gdb --args"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$1" = "-sec" ]; then
|
||||
PAL_CMD=$PAL_SEC
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$MANIFEST" == "" ]; then
|
||||
MANIFEST=$1
|
||||
shift
|
||||
|
||||
@@ -1 +1 @@
|
||||
alarm brk clone condvar.pthread cpuinfo dir divzero dup epoll epoll_socket errno exec exec_fork exec_victim file fork fork_bomb fork_exec fs futextest.pthread get_time.m helloworld helloworld.pthread kill malloc meminfo msg_create msg_create.libos msg_send msg_send.libos multiproc multisleep pid_alloc pid_kill pie pipe pipe_latency proc readdir rename sandbox_create.libos script sem sleep socketpair sqrt.m start.pthread.m static sync.pthread system tcp test_start_pthread_m.m time udp unix vfork vfork_exec 3c639d63c9ff0015a3841d70bb63af6b9ae969d9130b6a3ab6820100d0c8fac53cb0605f9137cc253be503dbeaadc38d
|
||||
alarm brk clone condvar.pthread cpuinfo dir divzero dup epoll epoll_socket errno exec exec_fork exec_victim file fork fork_bomb fork_exec fs futextest.pthread get_time.m helloworld helloworld.pthread kill malloc meminfo msg_create msg_create.libos msg_send msg_send.libos multiproc multisleep pid_alloc pid_kill pie pipe pipe_latency proc readdir rename sandbox_create.libos script sem sleep socketpair sqrt.m start.pthread.m static sync.pthread system tcp test_start_pthread_m.m time udp unix vfork vfork_exec 611bc4da88ef4941be3cfbba5c7402d9cc0b95281d139e18ae86d4a0d799fc536785bbc42af5e6951fe230ede19fc7f0
|
||||
Binary file not shown.
@@ -1,10 +1,10 @@
|
||||
special_executables = static pie
|
||||
c_executables = $(filter-out $(special_executables),$(patsubst %.c,%,$(wildcard *.c)))
|
||||
cxx_executables = $(patsubst %.cpp,%,$(wildcard *.cpp))
|
||||
manifests = $(patsubst %.template,%,$(wildcard *.manifest.template))
|
||||
manifests = $(patsubst %.template,%,$(wildcard *.manifest.template)) manifest
|
||||
|
||||
exec_target = $(special_executables) $(c_executables) $(cxx_executables) ls.manifest
|
||||
target = $(exec_target) $(manifests) pal pal_sec
|
||||
target = $(exec_target) $(manifests) pal
|
||||
|
||||
level = ../
|
||||
include ../Makefile
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
#include <linux/bitmap.h>
|
||||
#include <asm/mman.h>
|
||||
#include <asm/tlb.h>
|
||||
#ifdef CONFIG_GRAPHENE_BULK_IPC
|
||||
# include "graphene.h"
|
||||
#endif
|
||||
|
||||
#include "graphene-ipc.h"
|
||||
#include "ksyms.h"
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
||||
@@ -37,19 +36,6 @@ struct kmem_cache *gipc_send_buffer_cachep;
|
||||
# define GIPC_BUG_ON(cond)
|
||||
#endif
|
||||
|
||||
#define LOOKUP_KALLSYMS(sym) \
|
||||
do { \
|
||||
my_##sym = (void *) kallsyms_lookup_name(#sym); \
|
||||
if (!my_##sym) { \
|
||||
printk(KERN_ERR "Graphene error: " \
|
||||
"can't find kernel function " #sym "\n");\
|
||||
return -ENOENT; \
|
||||
} else { \
|
||||
printk(KERN_INFO "resolved symbol " #sym " %p\n", \
|
||||
my_##sym); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if defined(CONFIG_GRAPHENE_BULK_IPC) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
||||
# define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
|
||||
@@ -64,27 +50,30 @@ struct kmem_cache *gipc_send_buffer_cachep;
|
||||
do_mmap_pgoff((file), (addr), (len), (prot), (flags), (pgoff))
|
||||
# endif /* kernel_version < 3.9.0 */
|
||||
#else
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
||||
# define MY_DO_MMAP_PGOFF
|
||||
unsigned long (*my_do_mmap_pgoff) (struct file *, unsigned long,
|
||||
unsigned long, unsigned long,
|
||||
unsigned long, unsigned long,
|
||||
unsigned long *);
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||
# define MY_DO_MMAP
|
||||
# define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
|
||||
({ \
|
||||
unsigned long populate; \
|
||||
unsigned long rv = my_do_mmap_pgoff((file), (addr), \
|
||||
(len), (prot), \
|
||||
(flags), (pgoff), \
|
||||
&populate); \
|
||||
unsigned long rv; \
|
||||
rv = KSYM(do_mmap)((file), (addr), (len), \
|
||||
(prot), (flags), 0, (pgoff), \
|
||||
&populate); \
|
||||
rv; })
|
||||
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
||||
# define MY_DO_MMAP_PGOFF
|
||||
# define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
|
||||
({ \
|
||||
unsigned long populate; \
|
||||
unsigned long rv; \
|
||||
rv = KSYM(do_mmap_pgoff)((file), (addr), (len), \
|
||||
(prot), (flags), (pgoff), \
|
||||
&populate); \
|
||||
rv; })
|
||||
# else
|
||||
# define MY_DO_MMAP_PGOFF
|
||||
unsigned long (*my_do_mmap_pgoff) (struct file *, unsigned long,
|
||||
unsigned long, unsigned long,
|
||||
unsigned long, unsigned long);
|
||||
# define DO_MMAP_PGOFF(file, addr, len, prot, flags, pgoff) \
|
||||
my_do_mmap_pgoff((file), (addr), (len), (prot), (flags), (pgoff))
|
||||
KSYM(do_mmap_pgoff)((file), (addr), (len), (prot), (flags), (pgoff))
|
||||
# endif /* kernel version < 3.9 */
|
||||
#endif /* !CONFIG_GRAPHENE_BULK_IPC && kernel version > 3.4.0 */
|
||||
|
||||
@@ -93,20 +82,30 @@ unsigned long (*my_do_mmap_pgoff) (struct file *, unsigned long,
|
||||
# define FLUSH_TLB_MM_RANGE flush_tlb_mm_range
|
||||
# else
|
||||
# define MY_FLUSH_TLB_MM_RANGE
|
||||
void (*my_flush_tlb_mm_range) (struct mm_struct *, unsigned long,
|
||||
unsigned long, unsigned long);
|
||||
# define FLUSH_TLB_MM_RANGE my_flush_tlb_mm_range
|
||||
# define FLUSH_TLB_MM_RANGE KSYM(flush_tlb_mm_range)
|
||||
# endif
|
||||
#else /* LINUX_VERSION_CODE < 3.7.0 */
|
||||
# if defined(CONFIG_GRAPHENE_BULK_IPC) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
|
||||
# define FLUSH_TLB_PAGE flush_tlb_page
|
||||
# else
|
||||
# define MY_FLUSH_TLB_PAGE
|
||||
void (*my_flush_tlb_page) (struct vm_area_struct *, unsigned long);
|
||||
# define FLUSH_TLB_PAGE my_flush_tlb_page
|
||||
# define FLUSH_TLB_PAGE KSYM(flush_tlb_page)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef MY_DO_MMAP
|
||||
IMPORT_KSYM(do_mmap);
|
||||
#endif
|
||||
#ifdef MY_DO_MMAP_PGOFF
|
||||
IMPORT_KSYM(do_mmap_pgoff);
|
||||
#endif
|
||||
#ifdef MY_FLUSH_TLB_MM_RANGE
|
||||
IMPORT_KSYM(flush_tlb_mm_range);
|
||||
#endif
|
||||
#ifdef MY_FLUSH_TLB_PAGE
|
||||
IMPORT_KSYM(flush_tlb_page);
|
||||
#endif
|
||||
|
||||
#ifndef gipc_get_session
|
||||
u64 (*my_gipc_get_session) (struct task_struct *) = NULL;
|
||||
#endif
|
||||
@@ -916,14 +915,17 @@ static int __init gipc_init(void)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
#ifdef MY_DO_MMAP
|
||||
LOOKUP_KSYM(do_mmap);
|
||||
#endif
|
||||
#ifdef MY_DO_MMAP_PGOFF
|
||||
LOOKUP_KALLSYMS(do_mmap_pgoff);
|
||||
LOOKUP_KSYM(do_mmap_pgoff);
|
||||
#endif
|
||||
#ifdef MY_FLUSH_TLB_MM_RANGE
|
||||
LOOKUP_KALLSYMS(flush_tlb_mm_range);
|
||||
LOOKUP_KSYM(flush_tlb_mm_range);
|
||||
#endif
|
||||
#ifdef MY_FLUSH_TLB_PAGE
|
||||
LOOKUP_KALLSYMS(flush_tlb_page);
|
||||
LOOKUP_KSYM(flush_tlb_page);
|
||||
#endif
|
||||
|
||||
#ifndef gipc_get_session
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../linux-kernel/graphene/graphene.h
|
||||
@@ -3,9 +3,10 @@
|
||||
SCRIPT=`readlink -f "${BASH_SOURCE[0]}"`
|
||||
DIR=`dirname $SCRIPT`
|
||||
MOD=graphene-ipc
|
||||
MODNAME=graphene_ipc
|
||||
VER=0.0.1
|
||||
|
||||
/sbin/lsmod | grep -q graphene_ipc
|
||||
/sbin/lsmod | grep -q $MODNAME
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$MOD already running"
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _KSYM_H
|
||||
#define _KSYM_H
|
||||
|
||||
#include <linux/kallsyms.h>
|
||||
|
||||
#define __KSYM(name) __ksym_##name
|
||||
#define KSYM(name) ({ BUG_ON(!__KSYM(name)); __KSYM(name); })
|
||||
#define IMPORT_KSYM(name) __typeof(name) * __KSYM(name)
|
||||
#define IMPORT_KSYM_PROTO(name, ret, ...) ret (*__KSYM(name)) (__VA_ARGS__)
|
||||
#define LOOKUP_KSYM(name) \
|
||||
do { \
|
||||
__KSYM(name) = (void *) kallsyms_lookup_name(#name); \
|
||||
if (!__KSYM(name)) { \
|
||||
pr_err("Unknown symbol: " #name "\n"); \
|
||||
return -EINVAL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
module="graphene-ipc"
|
||||
MOD=graphene-ipc
|
||||
MODNAME=graphene_ipc
|
||||
|
||||
(/sbin/lsmod | grep -q "graphene_ipc") && \
|
||||
((echo "unloading graphene_ipc..."; /sbin/rmmod graphene_ipc) || exit 1) || continue
|
||||
(/sbin/lsmod | grep -q $MODNAME) && \
|
||||
((echo "unloading $MODNAME..."; /sbin/rmmod $MODNAME) || exit 1) || continue
|
||||
|
||||
# invoke insmod with all arguments we got
|
||||
# and use a pathname, as newer modutils don't look in . by default
|
||||
echo "loading graphene_ipc..."
|
||||
/sbin/insmod ./$module.ko $* || exit 1
|
||||
echo "loading $MODNAME..."
|
||||
/sbin/insmod ./$MOD.ko $* || exit 1
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
DIR=`readlink -f "${BASH_SOURCE[0]}"`
|
||||
MOD=graphene-ipc
|
||||
MODNAME=graphene_ipc
|
||||
VER=0.0.1
|
||||
|
||||
/sbin/lsmod | grep -q graphene_ipc
|
||||
/sbin/lsmod | grep -q $MODNAME
|
||||
if [ $? -eq 0 ]; then
|
||||
modprobe -r graphene-ipc
|
||||
modprobe -r $MODNAME
|
||||
fi
|
||||
|
||||
/usr/sbin/dkms status | grep -q $MOD
|
||||
|
||||
@@ -1 +1 @@
|
||||
Bootstrap Bootstrap2 Bootstrap3 Directory Exception File Ipc Memory Misc Pipe Preload1.so Preload2.so Process Process2 Process3 SendHandle Socket Symbols Thread acacabbb77227418b9442ca05ee56c5b884e6db4561907c3ac66ba611286675ea89f9e37f9bb86ff5d54b8f0d1e06391
|
||||
Bootstrap Bootstrap2 Bootstrap3 Directory Exception File Ipc Memory Misc Pipe Preload1.so Preload2.so Process Process2 Process3 SendHandle Socket Symbols Thread da9eddeb36c6f24f4fbebb7f94c198b81fe757849556080cda2c40cbbeadf4cd86e72533983cda9fc0af34f65ce75d16
|
||||
Binary file not shown.
+35
-39
@@ -31,23 +31,50 @@
|
||||
#include "api.h"
|
||||
#include "linux_list.h"
|
||||
|
||||
#define INIT_EVENT_HANDLER { .lock = LOCK_INIT }
|
||||
|
||||
struct pal_event_handler {
|
||||
PAL_LOCK lock;
|
||||
PAL_EVENT_HANDLER upcall;
|
||||
};
|
||||
|
||||
struct pal_event_handler handlers[] = {
|
||||
[PAL_EVENT_DIVZERO] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_MEMFAULT] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_ILLEGAL] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_QUIT] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_SUSPEND] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_RESUME] = INIT_EVENT_HANDLER,
|
||||
[PAL_EVENT_FAILURE] = INIT_EVENT_HANDLER,
|
||||
};
|
||||
|
||||
PAL_EVENT_HANDLER _DkGetExceptionHandler (PAL_NUM event)
|
||||
{
|
||||
struct pal_event_handler * eh = &handlers[event];
|
||||
|
||||
_DkInternalLock(&eh->lock);
|
||||
PAL_EVENT_HANDLER upcall = eh->upcall;
|
||||
_DkInternalUnlock(&eh->lock);
|
||||
|
||||
return upcall;
|
||||
}
|
||||
|
||||
PAL_BOL
|
||||
DkSetExceptionHandler (void (*handler) (PAL_PTR, PAL_NUM, PAL_CONTEXT *),
|
||||
PAL_NUM event, PAL_FLG flags)
|
||||
DkSetExceptionHandler (PAL_EVENT_HANDLER handler, PAL_NUM event, PAL_FLG flags)
|
||||
{
|
||||
ENTER_PAL_CALL(DkSetExceptionHandler);
|
||||
|
||||
if (!handler || event <= 0 || event > PAL_EVENT_NUM_BOUND) {
|
||||
if (!handler || event == 0 ||
|
||||
event > sizeof(handlers) / sizeof(handlers[0])) {
|
||||
_DkRaiseFailure(PAL_ERROR_INVAL);
|
||||
LEAVE_PAL_CALL_RETURN(PAL_FALSE);
|
||||
}
|
||||
|
||||
int ret = _DkExceptionHandlers[event](event, handler, flags);
|
||||
struct pal_event_handler * eh = &handlers[event];
|
||||
|
||||
if (ret < 0) {
|
||||
_DkRaiseFailure(-ret);
|
||||
LEAVE_PAL_CALL_RETURN(PAL_FALSE);
|
||||
}
|
||||
_DkInternalLock(&eh->lock);
|
||||
eh->upcall = handler;
|
||||
_DkInternalUnlock(&eh->lock);
|
||||
|
||||
LEAVE_PAL_CALL_RETURN(PAL_TRUE);
|
||||
}
|
||||
@@ -56,34 +83,3 @@ void DkExceptionReturn (PAL_PTR event)
|
||||
{
|
||||
_DkExceptionReturn(event);
|
||||
}
|
||||
|
||||
#ifndef NO_HANDLE_COMPATIBILITY
|
||||
unsigned long _DkHandleCompatibilityException (unsigned long syscallno,
|
||||
unsigned long args[6])
|
||||
{
|
||||
printf("compatibility support: detected an unintercepted system call\n");
|
||||
|
||||
if (!pal_state.syscall_sym_addr)
|
||||
_DkProcessExit(-1);
|
||||
|
||||
unsigned long ret;
|
||||
|
||||
asm volatile ("movq %6, %%r10\r\n"
|
||||
"movq %7, %%r8\r\n"
|
||||
"movq %8, %%r9\r\n"
|
||||
"callq *%1\r\n"
|
||||
"movq %%rax, %0\r\n"
|
||||
: "=a" (ret)
|
||||
: "r"(pal_state.syscall_sym_addr),
|
||||
"a" (syscallno),
|
||||
"D" (args[0]),
|
||||
"S" (args[1]),
|
||||
"d" (args[2]),
|
||||
"r" (args[3]),
|
||||
"r" (args[4]),
|
||||
"r" (args[5])
|
||||
: "memory", "r10", "r8", "r9");
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -204,22 +204,6 @@ out:
|
||||
__pal_control.debug_stream = handle;
|
||||
}
|
||||
|
||||
static void set_syscall_symbol (void)
|
||||
{
|
||||
char cfgbuf[CONFIG_MAX];
|
||||
int ret;
|
||||
|
||||
if (!pal_state.root_config)
|
||||
return;
|
||||
|
||||
ret = get_config(pal_state.root_config, "loader.syscall_symbol",
|
||||
cfgbuf, CONFIG_MAX);
|
||||
if (ret <= 0)
|
||||
return;
|
||||
|
||||
pal_state.syscall_sym_name = remalloc(cfgbuf, ret + 1);
|
||||
}
|
||||
|
||||
static int loader_filter (const char * key, int len)
|
||||
{
|
||||
/* try to do this as fast as possible */
|
||||
@@ -413,7 +397,6 @@ has_manifest:
|
||||
#endif
|
||||
|
||||
set_debug_type();
|
||||
set_syscall_symbol();
|
||||
|
||||
__pal_control.process_id = _DkGetProcessId();
|
||||
__pal_control.host_id = _DkGetHostId();
|
||||
|
||||
+15
-25
@@ -419,14 +419,13 @@ postmap:
|
||||
goto call_lose;
|
||||
}
|
||||
} else {
|
||||
l->l_ld = (ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||
l->l_real_ld = l->l_ld =
|
||||
(ElfW(Dyn) *) ((ElfW(Addr)) l->l_ld + l->l_addr);
|
||||
|
||||
if (do_copy_dyn)
|
||||
l->l_ld = remalloc(l->l_ld, sizeof(ElfW(Dyn)) * l->l_ldnum);
|
||||
}
|
||||
|
||||
l->l_real_ld = l->l_ld;
|
||||
|
||||
if (do_copy_dyn)
|
||||
l->l_ld = remalloc(l->l_ld, sizeof(ElfW(Dyn)) * l->l_ldnum);
|
||||
|
||||
elf_get_dynamic_info(l->l_ld, l->l_info, l->l_addr);
|
||||
|
||||
if (l->l_phdr == NULL) {
|
||||
@@ -496,7 +495,9 @@ void free_elf_object (struct link_map * map)
|
||||
if (map->l_next)
|
||||
map->l_next->l_prev = map->l_prev;
|
||||
|
||||
#ifdef DEBUG
|
||||
_DkDebugDelMap(map);
|
||||
#endif
|
||||
|
||||
if (loaded_maps == map)
|
||||
loaded_maps = map->l_next;
|
||||
@@ -572,7 +573,10 @@ int add_elf_object(void * addr, PAL_HANDLE handle, int type)
|
||||
if (type == OBJECT_EXEC)
|
||||
exec_map = map;
|
||||
|
||||
#ifdef DEBUG
|
||||
_DkDebugAddMap(map);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -903,7 +907,10 @@ done:
|
||||
if (map->l_type == OBJECT_EXEC)
|
||||
exec_map = map;
|
||||
|
||||
#ifdef DEBUG
|
||||
_DkDebugAddMap(map);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
verify_failed:
|
||||
@@ -1201,33 +1208,16 @@ static int relocate_elf_object (struct link_map * l)
|
||||
if ((ret = protect_relro(l)) < 0)
|
||||
return ret;
|
||||
|
||||
if (l->l_type == OBJECT_PRELOAD && pal_state.syscall_sym_name) {
|
||||
uint_fast32_t fast_hash = elf_fast_hash(pal_state.syscall_sym_name);
|
||||
long int hash = elf_hash(pal_state.syscall_sym_name);
|
||||
ElfW(Sym) * sym = NULL;
|
||||
|
||||
sym = do_lookup_map(NULL, pal_state.syscall_sym_name, fast_hash,
|
||||
hash, l);
|
||||
|
||||
if (sym) {
|
||||
pal_state.syscall_sym_addr =
|
||||
(void *) (l->l_addr + sym->st_value);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DkDebugAttachBinary (PAL_STR uri, PAL_PTR start_addr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
const char * realname;
|
||||
|
||||
if (strpartcmp_static(uri, "file:"))
|
||||
realname = uri + static_strlen("file:");
|
||||
else
|
||||
if (!strpartcmp_static(uri, "file:"))
|
||||
return;
|
||||
|
||||
const char * realname = uri + static_strlen("file:");
|
||||
struct link_map * l = new_elf_object(realname, OBJECT_EXTERNAL);
|
||||
|
||||
/* This is the ELF header. We read it in `open_verify'. */
|
||||
|
||||
+3
-1
@@ -41,7 +41,9 @@
|
||||
(void *) (l->l_addr + relative->r_offset))
|
||||
#endif
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#ifndef MIN
|
||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static void __attribute_unused
|
||||
elf_dynamic_do_rel (struct link_map *l, ElfW(Addr) reladdr, int relsize)
|
||||
|
||||
@@ -70,6 +70,11 @@ elf_get_dynamic_info (ElfW(Dyn) *dyn, ElfW(Dyn) **l_info, ElfW(Addr) l_addr)
|
||||
typedef Elf64_Xword d_tag_utype;
|
||||
#endif
|
||||
|
||||
#ifndef RTLD_BOOTSTRAP
|
||||
if (dyn == NULL)
|
||||
return;
|
||||
#endif
|
||||
|
||||
while (dyn->d_tag != DT_NULL) {
|
||||
if ((d_tag_utype) dyn->d_tag < DT_NUM)
|
||||
l_info[dyn->d_tag] = dyn;
|
||||
|
||||
@@ -39,43 +39,11 @@
|
||||
#include <linux/signal.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
struct exception_handler {
|
||||
struct spinlock lock;
|
||||
int flags;
|
||||
PAL_UPCALL upcall;
|
||||
} __attribute__((aligned(sizeof(int))));
|
||||
|
||||
struct exception_event {
|
||||
int event_num;
|
||||
int flags;
|
||||
PAL_CONTEXT * context;
|
||||
struct pal_frame * frame;
|
||||
};
|
||||
|
||||
#define DECLARE_HANDLER_HEAD(event) \
|
||||
static struct exception_handler handler_##event = \
|
||||
{ .lock = LOCK_INIT, \
|
||||
.upcall = NULL, \
|
||||
.flags = 0, }
|
||||
|
||||
DECLARE_HANDLER_HEAD(DivZero);
|
||||
DECLARE_HANDLER_HEAD(MemFault);
|
||||
DECLARE_HANDLER_HEAD(Illegal);
|
||||
DECLARE_HANDLER_HEAD(Quit);
|
||||
DECLARE_HANDLER_HEAD(Suspend);
|
||||
DECLARE_HANDLER_HEAD(Resume);
|
||||
DECLARE_HANDLER_HEAD(Failure);
|
||||
|
||||
struct exception_handler * pal_handlers [PAL_EVENT_NUM_BOUND] = {
|
||||
NULL, /* reserved */
|
||||
&handler_DivZero,
|
||||
&handler_MemFault,
|
||||
&handler_Illegal,
|
||||
&handler_Quit,
|
||||
&handler_Suspend,
|
||||
&handler_Resume,
|
||||
&handler_Failure,
|
||||
};
|
||||
typedef struct exception_event {
|
||||
PAL_IDX event_num;
|
||||
PAL_CONTEXT * context;
|
||||
struct pal_frame * frame;
|
||||
} PAL_EVENT;
|
||||
|
||||
#define SIGNAL_MASK_TIME 1000
|
||||
|
||||
@@ -84,30 +52,27 @@ struct exception_handler * pal_handlers [PAL_EVENT_NUM_BOUND] = {
|
||||
"movq %%rax, %0\r\n" \
|
||||
: "=b"(ptr) :: "memory", "rax")
|
||||
|
||||
void _DkGenericEventTrigger (int event_num, PAL_UPCALL upcall,
|
||||
int flags, PAL_NUM arg, struct pal_frame * frame,
|
||||
void _DkGenericEventTrigger (PAL_IDX event_num, PAL_EVENT_HANDLER upcall,
|
||||
PAL_NUM arg, struct pal_frame * frame,
|
||||
PAL_CONTEXT * context)
|
||||
{
|
||||
struct exception_event event;
|
||||
|
||||
event.event_num = event_num;
|
||||
event.flags = flags;
|
||||
event.context = context;
|
||||
event.frame = frame;
|
||||
|
||||
(*upcall) ((PAL_PTR) &event, arg, context);
|
||||
}
|
||||
|
||||
static bool _DkGenericSignalHandle (int event_num, PAL_NUM arg,
|
||||
struct pal_frame * frame,
|
||||
PAL_CONTEXT * context)
|
||||
static bool
|
||||
_DkGenericSignalHandle (int event_num, PAL_NUM arg, struct pal_frame * frame,
|
||||
PAL_CONTEXT * context)
|
||||
{
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
_DkSpinLock(&handler->lock);
|
||||
PAL_UPCALL upcall = handler->upcall;
|
||||
int flags = handler->flags;
|
||||
_DkSpinUnlock(&handler->lock);
|
||||
PAL_EVENT_HANDLER upcall = _DkGetExceptionHandler(event_num);
|
||||
|
||||
if (upcall) {
|
||||
_DkGenericEventTrigger(event_num, upcall, flags, arg, frame, context);
|
||||
_DkGenericEventTrigger(event_num, upcall, arg, frame, context);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -146,30 +111,6 @@ static struct pal_frame * get_frame (sgx_context_t * uc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int _DkEventUpcall (int event_num, PAL_UPCALL upcall, int flags)
|
||||
{
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
_DkSpinLock(&handler->lock);
|
||||
handler->upcall = upcall;
|
||||
handler->flags = flags;
|
||||
_DkSpinUnlock(&handler->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef void (*PAL_UPCALL) (PAL_PTR, PAL_NUM, PAL_CONTEXT *);
|
||||
|
||||
int (*_DkExceptionHandlers[PAL_EVENT_NUM_BOUND])
|
||||
(int, PAL_UPCALL, int) = {
|
||||
/* reserved */ NULL,
|
||||
/* DivZero */ &_DkEventUpcall,
|
||||
/* MemFault */ &_DkEventUpcall,
|
||||
/* Illegal */ &_DkEventUpcall,
|
||||
/* Quit */ &_DkEventUpcall,
|
||||
/* Suspend */ &_DkEventUpcall,
|
||||
/* Resume */ &_DkEventUpcall,
|
||||
/* Failure */ &_DkEventUpcall,
|
||||
};
|
||||
|
||||
asm (".type arch_exception_return_asm, @function;"
|
||||
"arch_exception_return_asm:"
|
||||
" pop %rax;"
|
||||
@@ -190,8 +131,8 @@ asm (".type arch_exception_return_asm, @function;"
|
||||
|
||||
extern void arch_exception_return (void) asm ("arch_exception_return_asm");
|
||||
|
||||
void _DkExceptionRealHandler (int event, PAL_CONTEXT * context, PAL_NUM arg,
|
||||
struct pal_frame * frame)
|
||||
void _DkExceptionRealHandler (int event, PAL_NUM arg, struct pal_frame * frame,
|
||||
PAL_CONTEXT * context)
|
||||
{
|
||||
if (frame) {
|
||||
frame = __alloca(sizeof(struct pal_frame));
|
||||
@@ -341,25 +282,28 @@ handle_event:
|
||||
struct pal_frame * frame = get_frame(uc);
|
||||
|
||||
PAL_NUM arg = 0;
|
||||
_DkExceptionRealHandler(event_num, ctx, arg, frame);
|
||||
_DkExceptionRealHandler(event_num, arg, frame, ctx);
|
||||
restore_sgx_context(uc);
|
||||
}
|
||||
|
||||
void _DkRaiseFailure (int error)
|
||||
{
|
||||
_DkSpinLock(&handler_Failure.lock);
|
||||
PAL_UPCALL upcall = handler_Failure.upcall;
|
||||
int flags = handler_Failure.flags;
|
||||
_DkSpinUnlock(&handler_Failure.lock);
|
||||
PAL_EVENT_HANDLER upcall = _DkGetExceptionHandler(PAL_EVENT_FAILURE);
|
||||
|
||||
if (upcall)
|
||||
_DkGenericEventTrigger(PAL_EVENT_FAILURE, upcall, flags, error,
|
||||
NULL, NULL);
|
||||
if (!upcall)
|
||||
return;
|
||||
|
||||
PAL_EVENT event;
|
||||
event.event_num = PAL_EVENT_FAILURE;
|
||||
event.context = NULL;
|
||||
event.frame = NULL;
|
||||
|
||||
(*upcall) ((PAL_PTR) &event, error, NULL);
|
||||
}
|
||||
|
||||
void _DkExceptionReturn (void * event)
|
||||
{
|
||||
struct exception_event * e = (struct exception_event *) event;
|
||||
PAL_EVENT * e = event;
|
||||
sgx_context_t uc;
|
||||
PAL_CONTEXT * ctx = e->context;
|
||||
|
||||
|
||||
@@ -37,13 +37,9 @@
|
||||
static inline Elf64_Addr __attribute__ ((unused))
|
||||
elf_machine_dynamic (void)
|
||||
{
|
||||
Elf64_Addr addr;
|
||||
|
||||
/* This works because we have our GOT address available in the small PIC
|
||||
model. */
|
||||
addr = (Elf64_Addr) &_DYNAMIC;
|
||||
|
||||
return addr;
|
||||
return (Elf64_Addr) &_DYNAMIC;
|
||||
}
|
||||
|
||||
/* Return the run-time load address of the shared object. */
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "pal_error.h"
|
||||
#include "pal_security.h"
|
||||
#include "api.h"
|
||||
#include "linux_list.h"
|
||||
|
||||
#include <atomic.h>
|
||||
#include <sigset.h>
|
||||
@@ -98,9 +97,6 @@ int set_sighandler (int * sigs, int nsig, void * handler)
|
||||
__sigaddset((__sigset_t *) &action.sa_mask, SIGCONT);
|
||||
|
||||
for (int i = 0 ; i < nsig ; i++) {
|
||||
if (__sigismember(&linux_state.set_signals, sigs[i]))
|
||||
continue;
|
||||
|
||||
#if defined(__i386__)
|
||||
int ret = INLINE_SYSCALL(sigaction, 3, sigs[i], &action, NULL)
|
||||
#else
|
||||
@@ -109,133 +105,17 @@ int set_sighandler (int * sigs, int nsig, void * handler)
|
||||
#endif
|
||||
if (IS_ERR(ret))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
__sigaddset(&linux_state.set_signals, sigs[i]);
|
||||
}
|
||||
|
||||
|
||||
bool maskset = false;
|
||||
int ret = 0;
|
||||
__sigset_t mask;
|
||||
__sigemptyset(&mask);
|
||||
|
||||
for (int i = 0 ; i < nsig ; i++)
|
||||
if (__sigismember(&linux_state.blocked_signals, sigs[i])) {
|
||||
__sigdelset(&linux_state.blocked_signals, sigs[i]);
|
||||
__sigaddset(&mask, sigs[i]);
|
||||
maskset = true;
|
||||
}
|
||||
|
||||
if (maskset) {
|
||||
#if defined(__i386__)
|
||||
ret = INLINE_SYSCALL(sigprocmask, 3, SIG_UNBLOCK, &mask, NULL)
|
||||
#else
|
||||
ret = INLINE_SYSCALL(rt_sigprocmask, 4, SIG_UNBLOCK, &mask, NULL,
|
||||
sizeof(sigset_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IS_ERR(ret))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int block_signals (int * sigs, int nsig)
|
||||
{
|
||||
bool maskset = false;
|
||||
int ret = 0;
|
||||
__sigset_t mask;
|
||||
__sigemptyset(&mask);
|
||||
|
||||
for (int i = 0 ; i < nsig ; i++)
|
||||
if (!__sigismember(&linux_state.blocked_signals, sigs[i])) {
|
||||
__sigaddset(&linux_state.blocked_signals, sigs[i]);
|
||||
__sigaddset(&mask, sigs[i]);
|
||||
maskset = true;
|
||||
}
|
||||
|
||||
if (maskset) {
|
||||
#if defined(__i386__)
|
||||
ret = INLINE_SYSCALL(sigprocmask, 3, SIG_BLOCK, &mask, NULL)
|
||||
#else
|
||||
ret = INLINE_SYSCALL(rt_sigprocmask, 4, SIG_BLOCK, &mask, NULL,
|
||||
sizeof(sigset_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IS_ERR(ret))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unblock_signals (int * sigs, int nsig)
|
||||
{
|
||||
bool maskset = false;
|
||||
int ret = 0;
|
||||
__sigset_t mask;
|
||||
__sigemptyset(&mask);
|
||||
for (int i = 0 ; i < nsig ; i++)
|
||||
if (__sigismember(&linux_state.blocked_signals, sigs[i])) {
|
||||
__sigdelset(&linux_state.blocked_signals, sigs[i]);
|
||||
__sigaddset(&mask, sigs[i]);
|
||||
maskset = true;
|
||||
}
|
||||
|
||||
if (maskset) {
|
||||
#if defined(__i386__)
|
||||
ret = INLINE_SYSCALL(sigprocmask, 3, SIG_UNBLOCK, &mask, NULL)
|
||||
#else
|
||||
ret = INLINE_SYSCALL(rt_sigprocmask, 4, SIG_UNBLOCK, &mask, NULL,
|
||||
sizeof(sigset_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IS_ERR(ret))
|
||||
return -PAL_ERROR_DENIED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct exception_handler {
|
||||
struct mutex_handle lock;
|
||||
int flags;
|
||||
PAL_UPCALL upcall;
|
||||
} __attribute__((aligned(sizeof(int))));
|
||||
|
||||
struct exception_event {
|
||||
int event_num;
|
||||
int flags;
|
||||
PAL_CONTEXT context;
|
||||
ucontext_t * uc;
|
||||
void * eframe;
|
||||
};
|
||||
|
||||
#define DECLARE_HANDLER_HEAD(event) \
|
||||
static struct exception_handler handler_##event = \
|
||||
{ .lock = MUTEX_HANDLE_INIT, \
|
||||
.upcall = NULL, \
|
||||
.flags = 0, };
|
||||
|
||||
DECLARE_HANDLER_HEAD(DivZero);
|
||||
DECLARE_HANDLER_HEAD(MemFault);
|
||||
DECLARE_HANDLER_HEAD(Illegal);
|
||||
DECLARE_HANDLER_HEAD(Quit);
|
||||
DECLARE_HANDLER_HEAD(Suspend);
|
||||
DECLARE_HANDLER_HEAD(Resume);
|
||||
DECLARE_HANDLER_HEAD(Failure);
|
||||
|
||||
struct exception_handler * pal_handlers [PAL_EVENT_NUM_BOUND] = {
|
||||
NULL, /* reserved */
|
||||
&handler_DivZero,
|
||||
&handler_MemFault,
|
||||
&handler_Illegal,
|
||||
&handler_Quit,
|
||||
&handler_Suspend,
|
||||
&handler_Resume,
|
||||
&handler_Failure,
|
||||
};
|
||||
typedef struct {
|
||||
PAL_IDX event_num;
|
||||
PAL_CONTEXT context;
|
||||
ucontext_t * uc;
|
||||
PAL_PTR eframe;
|
||||
} PAL_EVENT;
|
||||
|
||||
#define SIGNAL_MASK_TIME 1000
|
||||
|
||||
@@ -249,7 +129,7 @@ static int get_event_num (int signum)
|
||||
switch(signum) {
|
||||
case SIGFPE: return PAL_EVENT_DIVZERO;
|
||||
case SIGSEGV: case SIGBUS: return PAL_EVENT_MEMFAULT;
|
||||
case SIGILL: return PAL_EVENT_ILLEGAL;
|
||||
case SIGILL: case SIGSYS: return PAL_EVENT_ILLEGAL;
|
||||
case SIGTERM: return PAL_EVENT_QUIT;
|
||||
case SIGINT: return PAL_EVENT_SUSPEND;
|
||||
case SIGCONT: return PAL_EVENT_RESUME;
|
||||
@@ -257,13 +137,12 @@ static int get_event_num (int signum)
|
||||
}
|
||||
}
|
||||
|
||||
void _DkGenericEventTrigger (int event_num, PAL_UPCALL upcall,
|
||||
int flags, PAL_NUM arg, struct pal_frame * frame,
|
||||
void _DkGenericEventTrigger (PAL_IDX event_num, PAL_EVENT_HANDLER upcall,
|
||||
PAL_NUM arg, struct pal_frame * frame,
|
||||
ucontext_t * uc, void * eframe)
|
||||
{
|
||||
struct exception_event event;
|
||||
PAL_EVENT event;
|
||||
event.event_num = event_num;
|
||||
event.flags = flags;
|
||||
|
||||
if (uc)
|
||||
memcpy(&event.context, uc->uc_mcontext.gregs, sizeof(PAL_CONTEXT));
|
||||
@@ -280,6 +159,8 @@ void _DkGenericEventTrigger (int event_num, PAL_UPCALL upcall,
|
||||
event.context.rsp = frame->arch.rbp + sizeof(unsigned long) * 2;
|
||||
event.context.rbp = ((unsigned long *) frame->arch.rbp)[0];
|
||||
event.context.rip = ((unsigned long *) frame->arch.rbp)[1];
|
||||
/* making rax = 0 to tell the caller that this PAL call failed */
|
||||
event.context.rax = 0;
|
||||
}
|
||||
|
||||
event.uc = uc;
|
||||
@@ -292,12 +173,7 @@ static bool _DkGenericSignalHandle (int event_num, siginfo_t * info,
|
||||
struct pal_frame * frame,
|
||||
ucontext_t * uc, void * eframe)
|
||||
{
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
|
||||
_DkMutexLock(&handler->lock);
|
||||
PAL_UPCALL upcall = handler->upcall;
|
||||
int flags = handler->flags;
|
||||
_DkMutexUnlock(&handler->lock);
|
||||
PAL_EVENT_HANDLER upcall = _DkGetExceptionHandler(event_num);
|
||||
|
||||
if (upcall) {
|
||||
PAL_NUM arg = 0;
|
||||
@@ -307,8 +183,7 @@ static bool _DkGenericSignalHandle (int event_num, siginfo_t * info,
|
||||
event_num == PAL_EVENT_ILLEGAL)
|
||||
arg = (PAL_NUM) (info ? info->si_addr : 0);
|
||||
|
||||
_DkGenericEventTrigger(event_num, upcall, flags, arg, frame,
|
||||
uc, eframe);
|
||||
_DkGenericEventTrigger(event_num, upcall, arg, frame, uc, eframe);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -351,9 +226,9 @@ static void return_frame (struct pal_frame * frame, int err)
|
||||
__clear_frame(frame);
|
||||
arch_restore_frame(&frame->arch);
|
||||
|
||||
asm volatile ("xor %%rax, %%rax\r\n"
|
||||
asm volatile ("xor %rax, %rax\r\n"
|
||||
"leaveq\r\n"
|
||||
"retq\r\n" ::: "memory");
|
||||
"retq\r\n");
|
||||
}
|
||||
|
||||
static void _DkGenericSighandler (int signum, siginfo_t * info,
|
||||
@@ -417,14 +292,17 @@ static void _DkPipeSighandler (int signum, siginfo_t * info,
|
||||
|
||||
void _DkRaiseFailure (int error)
|
||||
{
|
||||
_DkMutexLock(&handler_Failure.lock);
|
||||
PAL_UPCALL upcall = handler_Failure.upcall;
|
||||
int flags = handler_Failure.flags;
|
||||
_DkMutexUnlock(&handler_Failure.lock);
|
||||
PAL_EVENT_HANDLER upcall = _DkGetExceptionHandler(PAL_EVENT_FAILURE);
|
||||
|
||||
if (upcall)
|
||||
_DkGenericEventTrigger(PAL_EVENT_FAILURE, upcall, flags, error,
|
||||
NULL, NULL, NULL);
|
||||
if (!upcall)
|
||||
return;
|
||||
|
||||
PAL_EVENT event;
|
||||
event.event_num = PAL_EVENT_FAILURE;
|
||||
event.uc = NULL;
|
||||
event.eframe = NULL;
|
||||
|
||||
(*upcall) ((PAL_PTR) &event, error, NULL);
|
||||
}
|
||||
|
||||
struct signal_ops {
|
||||
@@ -432,21 +310,19 @@ struct signal_ops {
|
||||
void (*handler) (int signum, siginfo_t * info, ucontext_t * uc);
|
||||
};
|
||||
|
||||
struct signal_ops on_signals[PAL_EVENT_NUM_BOUND] = {
|
||||
/* reserved */ { .signum = { 0 }, .handler = NULL },
|
||||
/* DivZero */ { .signum = { SIGFPE, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
/* MemFault */ { .signum = { SIGSEGV, SIGBUS, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
/* Illegal */ { .signum = { SIGILL, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
/* Quit */ { .signum = { SIGTERM, 0, 0 },
|
||||
.handler = _DkTerminateSighandler },
|
||||
/* Suspend */ { .signum = { SIGINT, 0 },
|
||||
.handler = _DkTerminateSighandler },
|
||||
/* Resume */ { .signum = { SIGCONT, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
/* Failure */ { .signum = { 0 }, .handler = NULL },
|
||||
struct signal_ops on_signals[] = {
|
||||
[PAL_EVENT_DIVZERO] = { .signum = { SIGFPE, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
[PAL_EVENT_MEMFAULT] = { .signum = { SIGSEGV, SIGBUS, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
[PAL_EVENT_ILLEGAL] = { .signum = { SIGILL, SIGSYS, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
[PAL_EVENT_QUIT] = { .signum = { SIGTERM, 0, 0 },
|
||||
.handler = _DkTerminateSighandler },
|
||||
[PAL_EVENT_SUSPEND] = { .signum = { SIGINT, 0 },
|
||||
.handler = _DkTerminateSighandler },
|
||||
[PAL_EVENT_RESUME] = { .signum = { SIGCONT, 0 },
|
||||
.handler = _DkGenericSighandler },
|
||||
};
|
||||
|
||||
static int _DkPersistentSighandlerSetup (int event_num)
|
||||
@@ -461,77 +337,6 @@ static int _DkPersistentSighandlerSetup (int event_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _DkPersistentEventUpcall (int event_num, PAL_UPCALL upcall,
|
||||
int flags)
|
||||
{
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
_DkMutexLock(&handler->lock);
|
||||
handler->upcall = upcall;
|
||||
handler->flags = flags;
|
||||
_DkMutexUnlock(&handler->lock);
|
||||
return _DkPersistentSighandlerSetup(event_num);
|
||||
}
|
||||
|
||||
static int _DkGenericEventUpcall (int event_num, PAL_UPCALL upcall,
|
||||
int flags)
|
||||
{
|
||||
int nsigs, * sigs = on_signals[event_num].signum;
|
||||
for (nsigs = 0 ; sigs[nsigs] ; nsigs++);
|
||||
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
int ret = 0;
|
||||
|
||||
_DkMutexLock(&handler->lock);
|
||||
handler->upcall = upcall;
|
||||
handler->flags = flags;
|
||||
_DkMutexUnlock(&handler->lock);
|
||||
|
||||
if (upcall)
|
||||
ret = set_sighandler(sigs, nsigs, on_signals[event_num].handler);
|
||||
else
|
||||
ret = block_signals(sigs, nsigs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _DkDummyEventUpcall (int event_num, PAL_UPCALL upcall,
|
||||
int flags)
|
||||
{
|
||||
struct exception_handler * handler = pal_handlers[event_num];
|
||||
_DkMutexLock(&handler->lock);
|
||||
handler->upcall = upcall;
|
||||
handler->flags = flags;
|
||||
_DkMutexUnlock(&handler->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef void (*PAL_UPCALL) (PAL_PTR, PAL_NUM, PAL_CONTEXT *);
|
||||
|
||||
int (*_DkExceptionHandlers[PAL_EVENT_NUM_BOUND])
|
||||
(int, PAL_UPCALL, int) = {
|
||||
/* reserved */ NULL,
|
||||
/* DivZero */ &_DkPersistentEventUpcall,
|
||||
/* MemFault */ &_DkPersistentEventUpcall,
|
||||
/* Illegal */ &_DkPersistentEventUpcall,
|
||||
/* Quit */ &_DkGenericEventUpcall,
|
||||
/* Suspend */ &_DkGenericEventUpcall,
|
||||
/* Resume */ &_DkGenericEventUpcall,
|
||||
/* Failure */ &_DkDummyEventUpcall,
|
||||
};
|
||||
|
||||
static void _DkCompatibilitySighandler (int signum, siginfo_t * info,
|
||||
ucontext_t * uc)
|
||||
{
|
||||
unsigned long args[6] = { uc->uc_mcontext.gregs[REG_RDI],
|
||||
uc->uc_mcontext.gregs[REG_RSI],
|
||||
uc->uc_mcontext.gregs[REG_RDX],
|
||||
uc->uc_mcontext.gregs[REG_R10],
|
||||
uc->uc_mcontext.gregs[REG_R8],
|
||||
uc->uc_mcontext.gregs[REG_R9] };
|
||||
uc->uc_mcontext.gregs[REG_RAX] =
|
||||
_DkHandleCompatibilityException(uc->uc_mcontext.gregs[REG_RAX], args);
|
||||
}
|
||||
|
||||
void signal_setup (void)
|
||||
{
|
||||
int ret, sig = SIGCHLD;
|
||||
@@ -541,22 +346,22 @@ void signal_setup (void)
|
||||
#endif
|
||||
set_sighandler(&sig, 1, NULL);
|
||||
|
||||
if ((ret = _DkPersistentEventUpcall(PAL_EVENT_DIVZERO, NULL, 0)) < 0)
|
||||
goto err;
|
||||
|
||||
if ((ret = _DkPersistentEventUpcall(PAL_EVENT_MEMFAULT, NULL, 0)) < 0)
|
||||
goto err;
|
||||
|
||||
if ((ret = _DkPersistentEventUpcall(PAL_EVENT_ILLEGAL, NULL, 0)) < 0)
|
||||
goto err;
|
||||
|
||||
sig = SIGPIPE;
|
||||
if ((ret = set_sighandler(&sig, 1, &_DkPipeSighandler)) < 0)
|
||||
goto err;
|
||||
|
||||
sig = SIGSYS;
|
||||
if ((ret = set_sighandler(&sig, 1, &_DkCompatibilitySighandler)) < 0)
|
||||
goto err;
|
||||
int events[] = {
|
||||
PAL_EVENT_DIVZERO,
|
||||
PAL_EVENT_MEMFAULT,
|
||||
PAL_EVENT_ILLEGAL,
|
||||
PAL_EVENT_QUIT,
|
||||
PAL_EVENT_SUSPEND,
|
||||
PAL_EVENT_RESUME,
|
||||
};
|
||||
|
||||
for (int e = 0 ; e < sizeof(events) / sizeof(events[0]) ; e++)
|
||||
if ((ret = _DkPersistentSighandlerSetup(events[e])) < 0)
|
||||
goto err;
|
||||
|
||||
return;
|
||||
err:
|
||||
@@ -565,7 +370,7 @@ err:
|
||||
|
||||
void _DkExceptionReturn (void * event)
|
||||
{
|
||||
struct exception_event * e = (struct exception_event *) event;
|
||||
PAL_EVENT * e = event;
|
||||
|
||||
if (e->eframe) {
|
||||
struct pal_frame * frame = (struct pal_frame *) e->eframe;
|
||||
@@ -586,16 +391,10 @@ void _DkExceptionReturn (void * event)
|
||||
_DkRaiseFailure(err);
|
||||
|
||||
__clear_frame(frame);
|
||||
e->context.rax = 0;
|
||||
}
|
||||
|
||||
if (e->uc) {
|
||||
/* copy the context back to ucontext */
|
||||
memcpy(e->uc->uc_mcontext.gregs, &e->context, sizeof(PAL_CONTEXT));
|
||||
|
||||
/* return to the frame of exception handler */
|
||||
asm volatile ("movq %0, %%rbp\r\n"
|
||||
"leaveq\r\n"
|
||||
"retq\r\n" :: "r"(e->eframe) : "memory");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ struct arch_frame {
|
||||
|
||||
#ifdef __x86_64__
|
||||
# define store_register(reg, var) \
|
||||
asm volatile ("movq %%" #reg ", %0" : "=g" (var) :: "memory");
|
||||
asm volatile ("movq %%" #reg ", %0" : "=a" (var) :: "memory");
|
||||
|
||||
# define store_register_in_frame(reg, f) store_register(reg, (f)->reg)
|
||||
|
||||
@@ -235,10 +235,10 @@ static inline
|
||||
void __store_frame (struct pal_frame * frame,
|
||||
void * func, const char * funcname)
|
||||
{
|
||||
arch_store_frame(&frame->arch)
|
||||
*(volatile void **) &frame->self = frame;
|
||||
frame->func = func;
|
||||
frame->funcname = funcname;
|
||||
arch_store_frame(&frame->arch)
|
||||
}
|
||||
|
||||
#define ENTER_PAL_CALL(name) \
|
||||
|
||||
@@ -230,11 +230,7 @@ extern struct pal_internal_state {
|
||||
|
||||
PAL_HANDLE console;
|
||||
|
||||
const char * syscall_sym_name;
|
||||
void * syscall_sym_addr;
|
||||
|
||||
unsigned long start_time;
|
||||
|
||||
#if PROFILING == 1
|
||||
unsigned long relocation_time;
|
||||
unsigned long linking_time;
|
||||
@@ -351,8 +347,7 @@ int _DkObjectsWaitAny (int count, PAL_HANDLE * handleArray, int timeout,
|
||||
PAL_HANDLE * polled);
|
||||
|
||||
/* DkException calls & structures */
|
||||
typedef void (*PAL_UPCALL) (PAL_PTR, PAL_NUM, PAL_CONTEXT *);
|
||||
int (*_DkExceptionHandlers[PAL_EVENT_NUM_BOUND]) (int, PAL_UPCALL, int);
|
||||
PAL_EVENT_HANDLER _DkGetExceptionHandler (PAL_NUM event_num);
|
||||
void _DkRaiseFailure (int error);
|
||||
void _DkExceptionReturn (void * event);
|
||||
|
||||
@@ -371,8 +366,6 @@ int _DkPhysicalMemoryCommit (PAL_HANDLE channel, int entries,
|
||||
int _DkPhysicalMemoryMap (PAL_HANDLE channel, int entries,
|
||||
PAL_PTR * addrs, PAL_NUM * sizes, PAL_FLG * prots);
|
||||
int _DkCpuIdRetrieve (unsigned int leaf, unsigned int subleaf, unsigned int values[4]);
|
||||
unsigned long _DkHandleCompatibilityException (unsigned long syscallno,
|
||||
unsigned long args[6]);
|
||||
|
||||
#define init_fail(exitcode, reason) \
|
||||
do { \
|
||||
|
||||
Reference in New Issue
Block a user