1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00
This commit is contained in:
Annika Wierichs 2018-01-19 10:20:01 +01:00
parent 021b397582
commit 83b8311fdc
3 changed files with 9 additions and 38 deletions

View file

@ -39,7 +39,6 @@
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) {
printf("LOG: UHYVE - call_ibv_get_device_list\n");
unsigned data = *((unsigned *)((size_t)run+run->io.data_offset));
uhyve_ibv_get_device_list_t * args = (uhyve_ibv_get_device_list_t *) (guest_mem + data);
@ -58,13 +57,9 @@ void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
// TODO: Tricky because char ptr isn't allocated in called function.
use_ib_mem_pool = true;
args->ret = ibv_get_device_name(args->device);
use_ib_mem_pool = false;
/* memcpy(args->ret, host_ret, sizeof(host_ret)); */
// TODO: Convert ptrs contained in return value.
// TODO: How to tell if ret needs to be deleted?
}
@ -74,21 +69,11 @@ void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
printf("LOG: UHYVE - call_ibv_open_device\n");
use_ib_mem_pool = true;
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
printf("LOG: UHYVE - call_ibv_open_device\n");
struct ibv_context * host_ret = ibv_open_device(args->device);
printf("LOG: UHYVE - call_ibv_open_device\n");
memcpy(args->ret, host_ret, sizeof(host_ret));
printf("LOG: UHYVE - call_ibv_open_device\n");
// TODO: Convert ptrs contained in return value.
free(host_ret);
printf("LOG: UHYVE - call_ibv_open_device\n");
use_ib_mem_pool = true;
args->ret = ibv_open_device(args->device);
use_ib_mem_pool = false;
}
@ -102,8 +87,9 @@ void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
int host_ret = ibv_query_port(args->context, args->port_num, args->port_attr);
args->ret = host_ret;
use_ib_mem_pool = true;
args->ret = ibv_query_port(args->context, args->port_num, args->port_attr);
use_ib_mem_pool = false;
}
@ -115,11 +101,10 @@ void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
printf("LOG: UHYVE - call_ibv_create_comp_channel");
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);
/*uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) get_data(run);*/
struct ibv_comp_channel * host_ret = ibv_create_comp_channel(args->context);
memcpy(args->ret, host_ret, sizeof(host_ret)); // TODO: This will only work for ABI ver > 2.
free(host_ret);
use_ib_mem_pool = true;
args->ret = ibv_create_comp_channel(args->context);
use_ib_mem_pool = false;
}

View file

@ -369,15 +369,6 @@ void * calloc(size_t nitems, size_t size)
size_t full_size = nitems * size; // TODO: check if multiplication overflow
if (init_real_calloc_active) {
/* dlsym_mem_len = full_size; */
/* dlsym_mem = mmap(NULL, dlsym_mem_len, PROT_READ | PROT_WRITE | PROT_EXEC, */
/* MAP_ANONYMOUS | MAP_SHARED, -1, 0); */
/* memset(dlsym_mem, 0, dlsym_mem_len); */
/* #ifdef IB_MEM_DEBUG */
/* printf("\treturn annonymous mapped dlsym_mem pointer: %p len: %lu\n", */
/* dlsym_mem, dlsym_mem_len); */
/* #endif */
/* result = dlsym_mem; */
#ifdef IB_MEM_DEBUG
printf("\treturn dlsym_mem_buffer.\n");
#endif

View file

@ -43,17 +43,12 @@
int main(int argc, char** argv)
{
/* printf("checking kernel outputs.\n"); */
int i, random;
// ---------------------------------------------------------------------------
struct ibv_device **dev_list;
int num_devices;
printf("\t\tib-test.c: before get dev list.\n");
dev_list = ibv_get_device_list(&num_devices);
struct ibv_device ** dev_list = ibv_get_device_list(&num_devices);
printf("\t\tib-test.c: after get device list -- ib-test.c: num devices: %d \n", num_devices);
printf("\t\tib-test.c: dev_list ptr: %p\n", dev_list);
/* printf("after get device list -- ib-test.c: ptr 1: %p\n", dev_list[0]); */