aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
authorDaniele Buono <dbuono@linux.vnet.ibm.com>2020-05-29 16:51:19 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2020-06-23 15:46:05 +0100
commit58ebc2c31337734a8a79b0566b31b19040deb2ea (patch)
tree0d085b3db59d811a055a23bea18537aa60da5d14 /include/qemu
parentddd633e525fec68437d04b074130aedc9d461331 (diff)
downloadqemu-58ebc2c31337734a8a79b0566b31b19040deb2ea.zip
qemu-58ebc2c31337734a8a79b0566b31b19040deb2ea.tar.gz
qemu-58ebc2c31337734a8a79b0566b31b19040deb2ea.tar.bz2
coroutine: support SafeStack in ucontext backend
LLVM's SafeStack instrumentation does not yet support programs that make use of the APIs in ucontext.h With the current implementation of coroutine-ucontext, the resulting binary is incorrect, with different coroutines sharing the same unsafe stack and producing undefined behavior at runtime. This fix allocates an additional unsafe stack area for each coroutine, and sets the new unsafe stack pointer before calling swapcontext() in qemu_coroutine_new. This is the only place where the pointer needs to be manually updated, since sigsetjmp/siglongjmp are already instrumented by LLVM to properly support SafeStack. The additional stack is then freed in qemu_coroutine_delete. Signed-off-by: Daniele Buono <dbuono@linux.vnet.ibm.com> Message-id: 20200529205122.714-2-dbuono@linux.vnet.ibm.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/coroutine_int.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qemu/coroutine_int.h b/include/qemu/coroutine_int.h
index bd6b046..1da1485 100644
--- a/include/qemu/coroutine_int.h
+++ b/include/qemu/coroutine_int.h
@@ -28,6 +28,11 @@
#include "qemu/queue.h"
#include "qemu/coroutine.h"
+#ifdef CONFIG_SAFESTACK
+/* Pointer to the unsafe stack, defined by the compiler */
+extern __thread void *__safestack_unsafe_stack_ptr;
+#endif
+
#define COROUTINE_STACK_SIZE (1 << 20)
typedef enum {