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

feat: adding vmcs to vcpu structure

parent 8909ea98
Branches
No related tags found
No related merge requests found
#include "vcpu.h"
#include "../debug/debug.h"
#include "../region/vxmon.h"
#include "linux/string.h"
#include "linux/slab.h"
#include <linux/errno.h>
int init_vcpu(struct vcpu_t *vcpu, struct vmxon_t *vmxon) {
int init_vcpu(struct vcpu_t *vcpu, unsigned long id) {
if (!vcpu) {
DEBUG_FMT("vcpu isn't allocated\n");
return -EFAULT;
}
struct vmxon_t *vmxon = alloc_vmxon();
if (!vmxon) {
DEBUG_FMT("vmxon region isn't allocated\n");
return -EFAULT;
DEBUG_FMT("VMXON region allocation failed\n");
return -ENOMEM;
}
struct vmcs_t *vmcs = alloc_vmcs();
if (!vmcs) {
DEBUG_FMT("VMCS region allocation failed\n");
return -ENOMEM;
}
vcpu->vmxon = vmxon;
vcpu->vmcs = vmcs;
vcpu->id = id;
return 0;
}
void destroy_vcpu(struct vcpu_t *vcpu) {
kfree(vcpu->vmxon);
kfree(vcpu->vmcs);
/*BUG: prolly won't change the pointer itself */
vcpu = NULL;
}
#pragma once
#include "../region/vmcs.h"
#include "../region/vxmon.h"
struct vcpu_t {
unsigned long id;
/*vmxon region has to be freed!*/
struct vmxon_t *vmxon;
/*vmcs region has to be freed!*/
struct vmcs_t *vmcs;
/*NOTE: prolly should store the PAs of pointers to avoid unnecessary
* address translations, although they should reside in the TLB by that
* point*/
};
int init_vcpu(struct vcpu_t *vcpu, struct vmxon_t *vmxon);
int init_vcpu(struct vcpu_t *vcpu, unsigned long id);
void destroy_vcpu(struct vcpu_t *vcpu);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment