mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
cleanup and comments
This commit is contained in:
parent
aae4dcb937
commit
17f3ec78fc
2 changed files with 14 additions and 15 deletions
15
kernel/ibv.c
15
kernel/ibv.c
|
@ -34,24 +34,27 @@
|
|||
|
||||
#include <hermit/ibv.h> // GEHT
|
||||
|
||||
#define MAX_NUM_OF_IBV_DEVICES 16
|
||||
// TODO: Can/should we separate ibv_get_device_list into two KVM exit IOs to
|
||||
// allocate the right amount of memory?
|
||||
#define MAX_NUM_OF_IBV_DEVICES 16
|
||||
|
||||
typedef struct {
|
||||
// In:
|
||||
int *num_devices;
|
||||
// Out:
|
||||
struct ibv_device *dev_phys_ptr_list[MAX_NUM_OF_IBV_DEVICES];
|
||||
/*struct ibv_device **device_list;*/
|
||||
// TODO: Can we make the return type struct ibv_device**?
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
struct ibv_device** h_ibv_get_device_list(int *num_devices)
|
||||
{
|
||||
// num_devices can be mapped to physical memory right away.
|
||||
uhyve_ibv_get_device_list_t uhyve_args = {(int*) virt_to_phys((size_t) num_devices)};
|
||||
|
||||
// Allocate memory for return value.
|
||||
struct ibv_device *devs = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device));
|
||||
struct ibv_device **list_virt;
|
||||
list_virt = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device *)); // NUM + 1 ???
|
||||
struct ibv_device **list_virt = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device *));
|
||||
|
||||
// We keep a list of the virtual addresses, so we can return it later, and map
|
||||
// to physical addresses for the args struct passed to uhyve.
|
||||
for (int i = 0; i < MAX_NUM_OF_IBV_DEVICES; i++) {
|
||||
struct ibv_device* device_address = devs + i;
|
||||
list_virt[i] = device_address;
|
||||
|
|
|
@ -972,22 +972,18 @@ static int vcpu_loop(void)
|
|||
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);
|
||||
|
||||
// Call IBV function from hypervisor
|
||||
int num_devices;
|
||||
struct ibv_device **temp_dev_list = ibv_get_device_list(&num_devices);
|
||||
printf("uhyve.c: before memcpy num_devices.\n");
|
||||
memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));
|
||||
/*memcpy(args->num_devices, &num_devices, sizeof(num_devices));*/
|
||||
|
||||
printf("uhyve.c: before for loop.\n");
|
||||
// Copy number of devices to kernel memory
|
||||
memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));
|
||||
|
||||
for (int d = 0; d < num_devices; d++) { // TODO switch to num devices
|
||||
/*struct ibv_device* dest_device_guest = guest_mem + (size_t)args->first_device + d*sizeof(struct ibv_device);*/
|
||||
/*struct ibv_device* dest_device_guest = guest_mem + (size_t)args->first_device;*/
|
||||
/*memcpy(dest_device_guest, temp_dev_list[d], sizeof(struct ibv_device));*/
|
||||
printf("uhyve.c: before memcpy list[d].\n");
|
||||
// Copy array entry containing ibv_device struct to kernel memory
|
||||
memcpy(guest_mem + (size_t)args->dev_phys_ptr_list[d], temp_dev_list[d], sizeof(struct ibv_device));
|
||||
}
|
||||
|
||||
printf("uhyve.c: before break.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue