From 68f74353b2f4bcecb4f8c6975f3e2375ba6b2c76 Mon Sep 17 00:00:00 2001 From: Steffen Schulz Date: Wed, 18 Aug 2021 10:31:43 -0700 Subject: [PATCH] record worker_id in state and report via KAFL_HYPERCALL_GET_HOST_CONFIG Modifies elements of host_config_t - update guest agent struct! --- nyx/hypercall/configuration.c | 3 ++- nyx/hypercall/configuration.h | 1 + nyx/interface.c | 1 + nyx/state/state.c | 3 ++- nyx/state/state.h | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nyx/hypercall/configuration.c b/nyx/hypercall/configuration.c index 3b54415653..bd04f27a42 100644 --- a/nyx/hypercall/configuration.c +++ b/nyx/hypercall/configuration.c @@ -24,6 +24,7 @@ void handle_hypercall_kafl_get_host_config(struct kvm_run *run, CPUState *cpu, u config.bitmap_size = GET_GLOBAL_STATE()->shared_bitmap_size; config.ijon_bitmap_size = GET_GLOBAL_STATE()->shared_ijon_bitmap_size; config.payload_buffer_size = GET_GLOBAL_STATE()->shared_payload_buffer_size; + config.worker_id = GET_GLOBAL_STATE()->worker_id; write_virtual_memory(vaddr, (uint8_t*)&config, sizeof(host_config_t), cpu); GET_GLOBAL_STATE()->get_host_config_done = true; @@ -101,4 +102,4 @@ void handle_hypercall_kafl_set_agent_config(struct kvm_run *run, CPUState *cpu, exit(1); } GET_GLOBAL_STATE()->set_agent_config_done = true; -} \ No newline at end of file +} diff --git a/nyx/hypercall/configuration.h b/nyx/hypercall/configuration.h index 4bb0440be2..3c4e9ea0f0 100644 --- a/nyx/hypercall/configuration.h +++ b/nyx/hypercall/configuration.h @@ -19,6 +19,7 @@ typedef struct host_config_s{ uint32_t bitmap_size; uint32_t ijon_bitmap_size; uint32_t payload_buffer_size; + uint32_t worker_id; /* more to come */ } __attribute__((packed)) host_config_t; diff --git a/nyx/interface.c b/nyx/interface.c index af4b431212..c1e6a8d137 100644 --- a/nyx/interface.c +++ b/nyx/interface.c @@ -374,6 +374,7 @@ static void nyx_realize(DeviceState *dev, Error **errp){ if(s->cow_primary_size){ set_global_cow_cache_primary_size(s->cow_primary_size); } + GET_GLOBAL_STATE()->worker_id = s->worker_id; if (!s->workdir || !verify_workdir_state(s, errp)){ fprintf(stderr, "[QEMU-Nyx] Error: work dir...\n"); diff --git a/nyx/state/state.c b/nyx/state/state.c index 3edcbe2618..1389fe5a66 100644 --- a/nyx/state/state.c +++ b/nyx/state/state.c @@ -45,6 +45,7 @@ void state_init_global(void){ global_state.nyx_fdl = false; global_state.workdir_path = NULL; + global_state.worker_id = 0xffff; global_state.fast_reload_enabled = false; global_state.fast_reload_mode = false; @@ -234,4 +235,4 @@ void set_payload_pages(uint64_t* payload_pages, uint32_t pages){ void set_workdir_path(char* workdir){ assert(workdir && !global_state.workdir_path); assert(asprintf(&global_state.workdir_path, "%s", workdir) != -1); -} \ No newline at end of file +} diff --git a/nyx/state/state.h b/nyx/state/state.h index 6970119157..fabc05f72b 100644 --- a/nyx/state/state.h +++ b/nyx/state/state.h @@ -49,6 +49,7 @@ typedef struct qemu_nyx_state_s{ bool nyx_fdl; char* workdir_path; + uint32_t worker_id; /* FAST VM RELOAD */ bool fast_reload_enabled;