From 657678f0b2d18c1b439af2334d84a9ecd6acd7da Mon Sep 17 00:00:00 2001 From: Annika Wierichs Date: Sun, 12 Nov 2017 16:51:46 +0100 Subject: [PATCH] Hypervisor helper functions. --- include/hermit/ibv.h | 1 + tools/uhyve-ibv.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/hermit/ibv.h b/include/hermit/ibv.h index 348ba85f7..484819c94 100644 --- a/include/hermit/ibv.h +++ b/include/hermit/ibv.h @@ -40,6 +40,7 @@ extern "C" { #endif +// TODO: File necessary? //struct ibv_device** ibv_get_device_list(int *num_devices); diff --git a/tools/uhyve-ibv.c b/tools/uhyve-ibv.c index 384039111..041232788 100644 --- a/tools/uhyve-ibv.c +++ b/tools/uhyve-ibv.c @@ -57,6 +57,11 @@ const char* ibv_get_device_name(struct ibv_device *device); int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr); struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context); +inline unsigned get_parameter_data(struct kvm_run * run) { + unsigned data = guest_mem + *((unsigned*)((size_t)run+run->io.data_offset)); + return data; +} + void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) { unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); @@ -91,10 +96,16 @@ void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) { } -// Return done +void guest_to_host_ibv_create_comp_channel_t(struct uhyve_ibv_create_comp_channel_t * args, uint8_t * guest_mem) { + args->context += guest_mem; + args->ret += guest_mem; +} + + void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) { - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); - uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data); + unsigned data = get_parameter_data(run); + uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) data; + guest_to_host_ibv_create_comp_channel_t(args); struct ibv_comp_channel * host_ret = ibv_create_comp_channel(guest_mem+(size_t)args->context); host_ret->context -= guest_mem; // Should be in separate function.