#ifdef CONFIG_SYMBIOTIC
// Symbiotic state
struct v3_sym_state sym_state;
+
+#ifdef CONFIG_SYMBIOTIC_SWAP
+ struct v3_sym_swap_state swap_state;
+#endif
#endif
v3_hypercall_map_t hcall_map;
#endif
-#ifdef CONFIG_SYMBIOTIC_SWAP
- struct v3_sym_swap_state swap_state;
-#endif
+
void * decoder_state;
void v3_yield(struct guest_info * info);
void v3_yield_cond(struct guest_info * info);
+void v3_print_cond(const char * fmt, ...);
void v3_interrupt_cpu(struct guest_info * vm, int logical_cpu);
v3_cfg_tree_t * cfg,
void * private_data),
void * priv_data);
+
int v3_dev_connect_net(struct guest_info * info,
char * frontend_name,
struct v3_dev_net_ops * ops,
int v3_is_vmx_capable();
void v3_init_vmx_cpu(int cpu_id);
+
int v3_start_vmx_guest(struct guest_info* info);
+int v3_vmx_enter(struct guest_info * info);
int v3_init_vmx_vmcs(struct guest_info * info, v3_vm_class_t vm_class);
// PrintGuestPageTables(info, info->shdw_pg_state.guest_cr3);
}
#ifdef CONFIG_SYMBIOTIC
-else if (evt->scan_code == 0x43) { // F9 Sym test
+ else if (evt->scan_code == 0x43) { // F9 Sym test
PrintDebug("Testing sym call\n");
sym_arg_t a0 = 0x1111;
sym_arg_t a1 = 0x2222;
V3_Print("Symcall Test Returned arg0=%x, arg1=%x, arg2=%x, arg3=%x, arg4=%x\n",
(uint32_t)a0, (uint32_t)a1, (uint32_t)a2, (uint32_t)a3, (uint32_t)a4);
- } else if (evt->scan_code == 0x42) { // F8 Sym test2
- PrintDebug("Testing sym call\n");
- sym_arg_t addr = 0;
- v3_sym_call1(info, SYMCALL_MEM_LOOKUP, &addr);
- }
+ }
#endif
+ else if (evt->scan_code == 0x42) { // F8 Sym test2
+ extern int v3_dbg_enable;
+
+ PrintDebug("Toggling Debugging\n");
+ v3_dbg_enable ^= 1;
+ }
+
addr_t irq_state = v3_lock_irqsave(state->kb_lock);
#include <palacios/vmm.h>
#include <palacios/vmm_dev_mgr.h>
#include <palacios/vmm_sym_swap.h>
+#include <palacios/vm_guest.h>
#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
uint32_t length = num_bytes;
- /*
- PrintDebug("SymSwap: Reading %d bytes to %p from %p\n", length,
- buf, (void *)(swap->swap_space + offset));
- */
+
+ PrintDebug("SymSwap: Reading %d bytes to %p from %p\n", length,
+ buf, (void *)(swap->swap_space + offset));
+
if (length % 4096) {
PrintError("Swapping in length that is not a page multiple\n");
}
#ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY
- if (vm->enable_telemetry) {
+ if (vm->enable_telemetry == 1) {
v3_add_telemetry_cb(vm, telemetry_cb, dev);
}
#endif
#include <palacios/vmm_sprintf.h>
+uint32_t v3_last_exit;
+
// This is a global pointer to the host's VMCB
static addr_t host_vmcbs[CONFIG_MAX_CPUS] = { [0 ... CONFIG_MAX_CPUS - 1] = 0};
v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[info->cpu_id]);
+
+ v3_last_exit = (uint32_t)(guest_ctrl->exit_code);
+
+ // v3_print_cond("SVM Returned: Exit Code: %x\n", (uint32_t)(guest_ctrl->exit_code));
+
rdtscll(tmp_tsc);
//PrintDebug("SVM Returned\n");
break;
}
+/*
if ((info->num_exits % 5000) == 0) {
V3_Print("SVM Exit number %d\n", (uint32_t)info->num_exits);
}
-
-
+*/
-
}
return 0;
}
info->rip += 3;
if (v3_handle_hypercall(info) == -1) {
+ PrintError("Error handling Hypercall\n");
return -1;
}
-
+
break;
case VMEXIT_INTR:
// handled by interrupt dispatch earlier
#include <palacios/vmm_instrument.h>
#include <palacios/vmm_ctrl_regs.h>
#include <palacios/vmm_lowlevel.h>
+#include <palacios/vmm_sprintf.h>
#ifdef CONFIG_SVM
#include <palacios/svm.h>
v3_cpu_arch_t v3_cpu_types[CONFIG_MAX_CPUS];
struct v3_os_hooks * os_hooks = NULL;
-
-
-
+int v3_dbg_enable = 0;
static struct guest_info * allocate_guest() {
-
-
void Init_V3(struct v3_os_hooks * hooks, int num_cpus) {
int i;
}
}
+
v3_cpu_arch_t v3_get_cpu_type(int cpu_id) {
return v3_cpu_types[cpu_id];
}
return info;
}
+
int v3_start_vm(struct guest_info * info, unsigned int cpu_mask) {
info->cpu_id = v3_get_cpu_id();
return -1;
}
-
return 0;
}
} while (0) \
+
void v3_yield_cond(struct guest_info * info) {
uint64_t cur_cycle;
rdtscll(cur_cycle);
}
}
+
/*
* unconditional cpu yield
* if the yielding thread is a guest context, the guest quantum is reset on resumption
+
+void v3_print_cond(const char * fmt, ...) {
+ if (v3_dbg_enable == 1) {
+ char buf[2048];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, 2048, fmt, ap);
+ va_end(ap);
+
+ V3_Print("%s", buf);
+ }
+}
+
+
+
+
void v3_interrupt_cpu(struct guest_info * info, int logical_cpu) {
extern struct v3_os_hooks * os_hooks;
-
-
int v3_vm_enter(struct guest_info * info) {
switch (v3_cpu_types[info->cpu_id]) {
#ifdef CONFIG_SVM
return v3_svm_enter(info);
break;
#endif
-#if CONFIG_VMX && 0
+#if CONFIG_VMX
case V3_VMX_CPU:
case V3_VMX_EPT_CPU:
return v3_vmx_enter(info);
return -1;
}
}
-
-
-
(error_code.user == 0) ) ) {
addr_t swp_pg_addr = 0;
- V3_Print("Page fault on swapped out page (vaddr=%p) (pte=%x) (error_code=%x)\n",
+ PrintDebug("Page fault on swapped out page (vaddr=%p) (pte=%x) (error_code=%x)\n",
(void *)fault_addr, *(uint32_t *)guest_pte, *(uint32_t *)&error_code);
swp_pg_addr = v3_get_swapped_pg_addr(info, shadow_pte, guest_pte);
- V3_Print("Swapped page address=%p\n", (void *)swp_pg_addr);
+ PrintDebug("Swapped page address=%p\n", (void *)swp_pg_addr);
if (swp_pg_addr != 0) {
shadow_pte->writable = swap_perms.write;
return 0;
}
+ } else {
+ PrintDebug("Not a sym swappable page\n");
}
}
#endif
static int sym_call_ret(struct guest_info * info, uint_t hcall_id, void * private_data) {
struct v3_sym_state * state = (struct v3_sym_state *)&(info->sym_state);
- // PrintError("Return from sym call\n");
+ // PrintError("Return from sym call (ID=%x)\n", hcall_id);
// v3_print_guest_state(info);
state->sym_call_returned = 1;
if (execute_symcall(info) == -1) {
PrintError("SYMCALL error\n");
return -1;
- }
+ }
// clear sym flags
state->sym_call_active = 0;
- // PrintDebug("restoring guest state\n");
+ // PrintError("restoring guest state\n");
// v3_print_guest_state(info);
return 0;
// we can leave the list_head structures and reuse them for the next round
list_for_each_entry_safe(shdw_ptr, tmp_shdw_ptr, shdw_ptr_list, node) {
- if (shadw_ptr == NULL) {
+ if (shdw_ptr == NULL) {
PrintError("Null shadow pointer in swap flush!! Probably crashing soon...\n");
}
}
int v3_get_vaddr_perms(struct guest_info * info, addr_t vaddr, pte32_t * guest_pte, pf_error_t * page_perms) {
- uint32_t pte_val = *(uint32_t *)guest_pte;
+ uint64_t pte_val = (uint64_t)*(uint32_t *)guest_pte;
// symcall to check if page is in cache or on swap disk
if (v3_sym_call3(info, SYMCALL_MEM_LOOKUP, (uint64_t *)&vaddr, (uint64_t *)&pte_val, (uint64_t *)page_perms) == -1) {
return -1;
}
- V3_Print("page perms = %x\n", *(uint32_t *)page_perms);
+ // V3_Print("page perms = %x\n", *(uint32_t *)page_perms);
return 0;
}
#ifdef CONFIG_TELEMETRY_GRANULARITY
#define DEFAULT_GRANULARITY CONFIG_TELEMETRY_GRANULARITY
#else
-#define DEFAULT_GRANULARITY 20000
+#define DEFAULT_GRANULARITY 50000
#endif
}
telemetry->prev_tsc = invoke_tsc;
+
+ V3_Print("%s Telemetry done\n", hdr_buf);
+
}
return -1;
}
+/*
if ((info->num_exits % 5000) == 0) {
- V3_Print("SVM Exit number %d\n", (uint32_t)info->num_exits);
+ V3_Print("VMX Exit number %d\n", (uint32_t)info->num_exits);
}
+*/
+
}
return 0;