X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm.h;h=083644e2fe897559dc2801d0b13ec4d0314af0da;hb=c1810f8134ef829599525d30856970f0155da1f3;hp=0c10e84eb9ce3aa4e02d7fe67c5efdc848cb58ec;hpb=25aec1d035e5a740d8c1cb936d7633b6bb5751f1;p=palacios.git diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 0c10e84..083644e 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -21,16 +21,11 @@ #define __VMM_H__ -/*#include */ - -struct guest_info; #ifdef __V3VEE__ #include #include - -//#include #include @@ -38,32 +33,24 @@ struct guest_info; /* utility definitions */ +#define VM_NONE ((struct v3_vm_info *)0) +#define VCORE_NONE ((struct guest_info *)0) -#define V3_Print(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ - } while (0) +void *v3_get_host_vm(struct v3_vm_info *); +int v3_get_vcore(struct guest_info *); +#define V3_Print(vm, vcore, fmt, args...) \ + do { \ + extern struct v3_os_hooks * os_hooks; \ + if ((os_hooks) && (os_hooks)->print) { \ + (os_hooks)->print(v3_get_host_vm(vm), v3_get_vcore(vcore), (fmt), ##args); \ + } \ + } while (0) -#define PrintDebug(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ - } while (0) +#define PrintDebug(vm, vcore, fmt, args...) V3_Print(vm, vcore, "DEBUG: " fmt, ##args) -#define PrintError(fmt, args...) \ - do { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print("%s(%d): " fmt, __FILE__, __LINE__, ##args); \ - } \ - } while (0) +#define PrintError(vm, vcore, fmt, args...) V3_Print(vm, vcore, "ERROR at %s(%d): " fmt, __FILE__, __LINE__, ##args) @@ -126,7 +113,7 @@ struct guest_info; if ((os_hooks) && (os_hooks)->malloc) { \ var = (os_hooks)->malloc(size); \ } \ - if (!var) PrintError("MALLOC FAILURE. Memory LEAK!!\n"); \ + if (!var) PrintError(VM_NONE,VCORE_NONE,"MALLOC FAILURE. Memory LEAK!!\n"); \ var; \ }) @@ -228,11 +215,11 @@ struct guest_info; /* ** */ -#define V3_ASSERT(x) \ +#define V3_ASSERT(vm, vcore, x) \ do { \ extern struct v3_os_hooks * os_hooks; \ if (!(x)) { \ - PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \ + PrintDebug(vm, vcore, "Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \ __func__, #x, __FILE__, __LINE__, \ (ulong_t) __builtin_return_address(0)); \ while(1){ \ @@ -254,16 +241,23 @@ struct guest_info; } while (0) \ -#define V3_Yield_Timed(usec) \ +#define V3_Sleep(usec) \ do { \ extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->yield_cpu_timed) {\ - (os_hooks)->yield_cpu_timed(usec); \ + if ((os_hooks) && (os_hooks)->sleep_cpu) {\ + (os_hooks)->sleep_cpu(usec); \ } else { \ V3_Yield(); \ } \ } while (0) \ +#define V3_Wakeup(cpu) \ + do { \ + extern struct v3_os_hooks * os_hooks; \ + if ((os_hooks) && (os_hooks)->wakeup_cpu) { \ + (os_hooks)->wakeup_cpu(cpu); \ + } \ + } while (0) \ typedef enum v3_vm_class {V3_INVALID_VM, V3_PC_VM, V3_CRAY_VM} v3_vm_class_t; @@ -298,8 +292,12 @@ struct v3_vm_info; /* This will contain function pointers that provide OS services */ struct v3_os_hooks { - void (*print)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); + // the vm pointer is the host os's "priv_data" from v3_create_vm + // if vm is null, this is a general palacios printout + // if vm is not null, and vcore is negative, this is a general print form the vm + // if vm is not null, and vcore is non-negative, this is a print from a specific vcore + void (*print)(void *vm, int vcore, const char * format, ...) + __attribute__ ((format (printf, 3, 4))); void *(*allocate_pages)(int num_pages, unsigned int alignment); void (*free_pages)(void * page, int num_pages); @@ -315,10 +313,9 @@ struct v3_os_hooks { unsigned int (*get_cpu_khz)(void); - void (*yield_cpu)(void); - - void (*yield_cpu_timed)(unsigned int usec); + void (*sleep_cpu)(unsigned int usec); + void (*wakeup_cpu)(void *cpu); void *(*mutex_alloc)(void); void (*mutex_free)(void * mutex); @@ -352,9 +349,33 @@ struct v3_interrupt { }; +typedef enum {V3_VM_UNKNOWN, V3_VM_INVALID, V3_VM_RUNNING, V3_VM_STOPPED, V3_VM_PAUSED, V3_VM_ERROR, V3_VM_SIMULATING} v3_vm_state_t; +typedef enum {V3_VCORE_UNKNOWN, V3_VCORE_INVALID, V3_VCORE_RUNNING, V3_VCORE_STOPPED} v3_vcore_state_t; +typedef enum {V3_VCORE_CPU_UNKNOWN, V3_VCORE_CPU_REAL, V3_VCORE_CPU_PROTECTED, V3_VCORE_CPU_PROTECTED_PAE, V3_VCORE_CPU_LONG, V3_VCORE_CPU_LONG_32_COMPAT, V3_VCORE_CPU_LONG_16_COMPAT} v3_vcore_cpu_mode_t; + +typedef enum {V3_VCORE_MEM_STATE_UNKNOWN, V3_VCORE_MEM_STATE_SHADOW, V3_VCORE_MEM_STATE_NESTED} v3_vcore_mem_state_t; +typedef enum {V3_VCORE_MEM_MODE_UNKNOWN, V3_VCORE_MEM_MODE_PHYSICAL, V3_VCORE_MEM_MODE_VIRTUAL} v3_vcore_mem_mode_t; +struct v3_vcore_state { + v3_vcore_state_t state; + v3_vcore_cpu_mode_t cpu_mode; + v3_vcore_mem_state_t mem_state; + v3_vcore_mem_mode_t mem_mode; + unsigned long pcore; + void * last_rip; + unsigned long long num_exits; +}; + +struct v3_vm_state { + v3_vm_state_t state; + void * mem_base_paddr; + unsigned long long mem_size; + unsigned long num_vcores; + struct v3_vcore_state vcore[0]; +}; -void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus); +char *v3_lookup_option(char *name); +void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus, char *options); void Shutdown_V3( void ); @@ -365,14 +386,18 @@ int v3_pause_vm(struct v3_vm_info * vm); int v3_continue_vm(struct v3_vm_info * vm); int v3_simulate_vm(struct v3_vm_info * vm, unsigned int msecs); - int v3_save_vm(struct v3_vm_info * vm, char * store, char * url); int v3_load_vm(struct v3_vm_info * vm, char * store, char * url); +int v3_send_vm(struct v3_vm_info * vm, char * store, char * url); +int v3_receive_vm(struct v3_vm_info * vm, char * store, char * url); + int v3_move_vm_core(struct v3_vm_info * vm, int vcore_id, int target_cpu); int v3_free_vm(struct v3_vm_info * vm); +int v3_get_state_vm(struct v3_vm_info *vm, struct v3_vm_state *out); + int v3_deliver_irq(struct v3_vm_info * vm, struct v3_interrupt * intr);