aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
Diffstat (limited to 'executor')
-rw-r--r--executor/common_fuchsia.h91
-rw-r--r--executor/defs.h4
-rw-r--r--executor/syscalls.h4
3 files changed, 56 insertions, 43 deletions
diff --git a/executor/common_fuchsia.h b/executor/common_fuchsia.h
index 646173eba..b537705e4 100644
--- a/executor/common_fuchsia.h
+++ b/executor/common_fuchsia.h
@@ -31,7 +31,6 @@
#include <zircon/syscalls/debug.h>
#include <zircon/syscalls/exception.h>
#include <zircon/syscalls/object.h>
-#include <zircon/syscalls/port.h>
static __thread int skip_segv;
static __thread jmp_buf segv_env;
@@ -46,49 +45,69 @@ static void segv_handler(void)
doexit(SIGSEGV);
}
+static zx_status_t update_exception_thread_regs(zx_handle_t exception)
+{
+ zx_handle_t thread;
+ zx_status_t status = zx_exception_get_thread(exception, &thread);
+ if (status != ZX_OK) {
+ debug("zx_exception_get_thread failed: %d\n", status);
+ return status;
+ }
+
+ zx_thread_state_general_regs_t regs;
+ status = zx_thread_read_state(thread, ZX_THREAD_STATE_GENERAL_REGS,
+ &regs, sizeof(regs));
+ if (status != ZX_OK) {
+ debug("zx_thread_read_state failed: %d (%d)\n",
+ (int)sizeof(regs), status);
+ } else {
+#if GOARCH_amd64
+ regs.rip = (uint64)(void*)&segv_handler;
+#elif GOARCH_arm64
+ regs.pc = (uint64)(void*)&segv_handler;
+#else
+#error "unsupported arch"
+#endif
+ status = zx_thread_write_state(thread, ZX_THREAD_STATE_GENERAL_REGS, &regs, sizeof(regs));
+ if (status != ZX_OK) {
+ debug("zx_thread_write_state failed: %d\n", status);
+ }
+ }
+
+ zx_handle_close(thread);
+ return status;
+}
+
static void* ex_handler(void* arg)
{
- zx_handle_t port = (zx_handle_t)(long)arg;
+ zx_handle_t exception_channel = (zx_handle_t)(long)arg;
for (int i = 0; i < 10000; i++) {
- zx_port_packet_t packet = {};
- zx_status_t status = zx_port_wait(port, ZX_TIME_INFINITE, &packet);
+ zx_status_t status = zx_object_wait_one(exception_channel, ZX_CHANNEL_READABLE, ZX_TIME_INFINITE, NULL);
if (status != ZX_OK) {
- debug("zx_port_wait failed: %d\n", status);
+ debug("zx_object_wait_one failed: %d\n", status);
continue;
}
- debug("got exception packet: type=%d status=%d tid=%llu\n",
- packet.type, packet.status, (unsigned long long)(packet.exception.tid));
- zx_handle_t thread;
- status = zx_object_get_child(zx_process_self(), packet.exception.tid,
- ZX_RIGHT_SAME_RIGHTS, &thread);
+
+ zx_exception_info_t info;
+ zx_handle_t exception;
+ status = zx_channel_read(exception_channel, 0, &info, &exception, sizeof(info), 1, NULL, NULL);
if (status != ZX_OK) {
- debug("zx_object_get_child failed: %d\n", status);
+ debug("zx_channel_read failed: %d\n", status);
continue;
}
- zx_thread_state_general_regs_t regs;
- status = zx_thread_read_state(thread, ZX_THREAD_STATE_GENERAL_REGS,
- &regs, sizeof(regs));
+
+ debug("got exception: type=%d tid=%llu\n", info.type, (unsigned long long)(info.tid));
+ status = update_exception_thread_regs(exception);
if (status != ZX_OK) {
- debug("zx_thread_read_state failed: %d (%d)\n",
- (int)sizeof(regs), status);
- } else {
-#if GOARCH_amd64
- regs.rip = (uint64)(void*)&segv_handler;
-#elif GOARCH_arm64
- regs.pc = (uint64)(void*)&segv_handler;
-#else
-#error "unsupported arch"
-#endif
- status = zx_thread_write_state(thread, ZX_THREAD_STATE_GENERAL_REGS, &regs, sizeof(regs));
- if (status != ZX_OK) {
- debug("zx_thread_write_state failed: %d\n", status);
- }
+ debug("failed to update exception thread registers: %d\n", status);
}
- status = zx_task_resume_from_exception(thread, port, 0);
+
+ uint32 state = ZX_EXCEPTION_STATE_HANDLED;
+ status = zx_object_set_property(exception, ZX_PROP_EXCEPTION_STATE, &state, sizeof(state));
if (status != ZX_OK) {
- debug("zx_task_resume_from_exception failed: %d\n", status);
+ debug("zx_object_set_property(ZX_PROP_EXCEPTION_STATE) failed: %d\n", status);
}
- zx_handle_close(thread);
+ zx_handle_close(exception);
}
doexit(1);
return 0;
@@ -97,13 +116,11 @@ static void* ex_handler(void* arg)
static void install_segv_handler(void)
{
zx_status_t status;
- zx_handle_t port;
- if ((status = zx_port_create(0, &port)) != ZX_OK)
- fail("zx_port_create failed: %d", status);
- if ((status = zx_task_bind_exception_port(zx_process_self(), port, 0, 0)) != ZX_OK)
- fail("zx_task_bind_exception_port failed: %d", status);
+ zx_handle_t exception_channel;
+ if ((status = zx_task_create_exception_channel(zx_process_self(), 0, &exception_channel)) != ZX_OK)
+ fail("zx_task_create_exception_channel failed: %d", status);
pthread_t th;
- if (pthread_create(&th, 0, ex_handler, (void*)(long)port))
+ if (pthread_create(&th, 0, ex_handler, (void*)(long)exception_channel))
fail("pthread_create failed");
}
diff --git a/executor/defs.h b/executor/defs.h
index 993956828..765b88112 100644
--- a/executor/defs.h
+++ b/executor/defs.h
@@ -45,7 +45,7 @@
#if GOARCH_amd64
#define GOARCH "amd64"
-#define SYZ_REVISION "bdf3b9df3ff1d16e7a61432e4f19a866479775e2"
+#define SYZ_REVISION "329fe6a047fa9d6a9ad388c2e46e5d3dc9ab6c72"
#define SYZ_EXECUTOR_USES_FORK_SERVER 0
#define SYZ_EXECUTOR_USES_SHMEM 0
#define SYZ_PAGE_SIZE 4096
@@ -55,7 +55,7 @@
#if GOARCH_arm64
#define GOARCH "arm64"
-#define SYZ_REVISION "42bf2ab2b8b1b89317ed03575f5c42aec66d7a62"
+#define SYZ_REVISION "e0903c549d1df4deee6c6891fa0b9220464983d4"
#define SYZ_EXECUTOR_USES_FORK_SERVER 0
#define SYZ_EXECUTOR_USES_SHMEM 0
#define SYZ_PAGE_SIZE 4096
diff --git a/executor/syscalls.h b/executor/syscalls.h
index e608c9970..0d81a1481 100644
--- a/executor/syscalls.h
+++ b/executor/syscalls.h
@@ -1597,9 +1597,7 @@ const call_t syscalls[] = {
{"zx_system_get_num_cpus", 0, (syscall_t)zx_system_get_num_cpus},
{"zx_system_get_physmem", 0, (syscall_t)zx_system_get_physmem},
{"zx_system_get_version", 0, (syscall_t)zx_system_get_version},
- {"zx_task_bind_exception_port", 0, (syscall_t)zx_task_bind_exception_port},
{"zx_task_create_exception_channel", 0, (syscall_t)zx_task_create_exception_channel},
- {"zx_task_resume_from_exception", 0, (syscall_t)zx_task_resume_from_exception},
{"zx_thread_create", 0, (syscall_t)zx_thread_create},
{"zx_thread_exit", 0, (syscall_t)zx_thread_exit},
{"zx_thread_read_state", 0, (syscall_t)zx_thread_read_state},
@@ -2004,9 +2002,7 @@ const call_t syscalls[] = {
{"zx_system_get_num_cpus", 0, (syscall_t)zx_system_get_num_cpus},
{"zx_system_get_physmem", 0, (syscall_t)zx_system_get_physmem},
{"zx_system_get_version", 0, (syscall_t)zx_system_get_version},
- {"zx_task_bind_exception_port", 0, (syscall_t)zx_task_bind_exception_port},
{"zx_task_create_exception_channel", 0, (syscall_t)zx_task_create_exception_channel},
- {"zx_task_resume_from_exception", 0, (syscall_t)zx_task_resume_from_exception},
{"zx_thread_create", 0, (syscall_t)zx_thread_create},
{"zx_thread_exit", 0, (syscall_t)zx_thread_exit},
{"zx_thread_read_state", 0, (syscall_t)zx_thread_read_state},