Skip to content
Snippets Groups Projects
Commit 3056fd2a authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

wip: drawing up basic VMM structure

parent 5479548a
No related branches found
No related tags found
No related merge requests found
#include "vmm.h"
#include "../debug/debug.h"
#include "linux/gfp_types.h"
#include "linux/slab.h"
#include "linux/smp.h"
int init_vmm(struct vmm_t *ctx, unsigned long vcpu_count) {
if (!ctx) {
DEBUG_FMT("VMM context wasn't properly allocated!\n")
return -EFAULT;
}
ctx->vcpu_table = kzalloc(vcpu_count * sizeof(struct vcpu_t), GFP_KERNEL);
if (!ctx->vcpu_table) {
DEBUG_FMT("Allocation for the vcpu table has failed\n");
return -ENOMEM;
}
ctx->vcpu_count = vcpu_count;
int proc_id = smp_processor_id();
int ret = init_vcpu(&ctx->vcpu_table[proc_id], proc_id);
if (ret != 0) {
destroy_vmm(ctx);
DEBUG_FMT("vCPU[%d] initialization has failed\n", proc_id);
return ret;
}
DEBUG_FMT("VA of vCPU[%d]'s VMXON region: 0x%px\n", proc_id,
ctx->vcpu_table[proc_id].vmxon);
DEBUG_FMT("PA of vCPU[%d]'s VMXON region: 0x%lx\n", proc_id,
__pa(ctx->vcpu_table[proc_id].vmxon));
DEBUG_FMT("vCPU[%d]'s VMCS rev id: 0x%x\n", proc_id,
ctx->vcpu_table[proc_id].vmxon->vmcs_rev_id);
/*for (unsigned long i = 0; i < ctx->vcpu_count; i++) {*/
/* int ret = init_vcpu(&ctx->vcpu_table[i], );*/
/**/
/* if (ret != 0) {*/
/* destroy_vmm(ctx);*/
/* DEBUG_FMT("vCPU[%lu] initialization has failed\n", i);*/
/* return ret;*/
/* }*/
/**/
/* DEBUG_FMT("VA of vCPU[%lu]'s VMXON region: 0x%px\n", i,*/
/* ctx->vcpu_table[i].vmxon);*/
/* DEBUG_FMT("PA of vCPU[%lu]'s VMXON region: 0x%lx\n", i,*/
/* __pa(ctx->vcpu_table[i].vmxon));*/
/**/
/* DEBUG_FMT("vCPU[%lu]'s VMCS rev id: 0x%x\n", i,*/
/* ctx->vcpu_table[i].vmxon->vmcs_rev_id);*/
/*}*/
return 0;
}
void destroy_vmm(struct vmm_t *ctx) {
for (unsigned long i = 0; i < ctx->vcpu_count; i++) {
destroy_vcpu(&ctx->vcpu_table[i]);
}
kfree(ctx->vcpu_table);
/*BUG: prolly won't change the pointer itself */
ctx->vcpu_table = NULL;
}
#include "../vcpu/vcpu.h"
struct vmm_t {
/*vcpu_table has to be freed!*/
struct vcpu_t *vcpu_table;
unsigned long vcpu_count;
char stack[1 << 12];
};
int init_vmm(struct vmm_t *ctx, unsigned long vcpu_count);
void destroy_vmm(struct vmm_t *ctx);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment