From: Jack Lange Date: Tue, 15 Dec 2009 22:01:08 +0000 (-0600) Subject: debugging tweaks and minor fixes X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.releases.git;a=commitdiff_plain;h=cfcc5717f659b3ed2954f41cf363d3bceae8dc84 debugging tweaks and minor fixes --- diff --git a/palacios/include/palacios/vm_guest.h b/palacios/include/palacios/vm_guest.h index 38e2a71..7b849d3 100644 --- a/palacios/include/palacios/vm_guest.h +++ b/palacios/include/palacios/vm_guest.h @@ -178,6 +178,10 @@ struct guest_info { #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; @@ -211,9 +215,7 @@ struct guest_info { #endif -#ifdef CONFIG_SYMBIOTIC_SWAP - struct v3_sym_swap_state swap_state; -#endif + void * decoder_state; diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 87d50ed..fb89f28 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -196,6 +196,7 @@ v3_cpu_mode_t v3_get_host_cpu_mode(); 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); diff --git a/palacios/include/palacios/vmm_dev_mgr.h b/palacios/include/palacios/vmm_dev_mgr.h index 9cc1ff0..8c80ffa 100644 --- a/palacios/include/palacios/vmm_dev_mgr.h +++ b/palacios/include/palacios/vmm_dev_mgr.h @@ -188,6 +188,7 @@ int v3_dev_add_net_frontend(struct guest_info * info, 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, diff --git a/palacios/include/palacios/vmx.h b/palacios/include/palacios/vmx.h index 70e877f..a37ead8 100644 --- a/palacios/include/palacios/vmx.h +++ b/palacios/include/palacios/vmx.h @@ -239,7 +239,9 @@ struct vmx_data { 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); diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index cf61967..a6ba864 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -332,7 +332,7 @@ static int key_event_handler(struct guest_info * info, // 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; @@ -345,12 +345,15 @@ else if (evt->scan_code == 0x43) { // F9 Sym test 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); diff --git a/palacios/src/devices/sym_swap.c b/palacios/src/devices/sym_swap.c index 49b0f32..ab1a589 100644 --- a/palacios/src/devices/sym_swap.c +++ b/palacios/src/devices/sym_swap.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY @@ -146,10 +147,10 @@ static int swap_read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * pri 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"); @@ -314,7 +315,7 @@ static int swap_init(struct guest_info * vm, v3_cfg_tree_t * cfg) { } #ifdef CONFIG_SYMBIOTIC_SWAP_TELEMETRY - if (vm->enable_telemetry) { + if (vm->enable_telemetry == 1) { v3_add_telemetry_cb(vm, telemetry_cb, dev); } #endif diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 7dcd68d..fa1f3ec 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -44,6 +44,8 @@ #include +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}; @@ -467,6 +469,11 @@ int v3_svm_enter(struct guest_info * info) { 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"); @@ -583,13 +590,12 @@ int v3_start_svm_guest(struct guest_info *info) { break; } +/* if ((info->num_exits % 5000) == 0) { V3_Print("SVM Exit number %d\n", (uint32_t)info->num_exits); } - - +*/ - } return 0; } diff --git a/palacios/src/palacios/svm_handler.c b/palacios/src/palacios/svm_handler.c index 9c20ae6..dbca7a8 100644 --- a/palacios/src/palacios/svm_handler.c +++ b/palacios/src/palacios/svm_handler.c @@ -208,9 +208,10 @@ int v3_handle_svm_exit(struct guest_info * info, addr_t exit_code, addr_t exit_i 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 diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 90118eb..7077d66 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef CONFIG_SVM #include @@ -36,9 +37,7 @@ 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() { @@ -72,8 +71,6 @@ static void init_cpu(void * arg) { - - void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { int i; @@ -101,6 +98,7 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { } } + v3_cpu_arch_t v3_get_cpu_type(int cpu_id) { return v3_cpu_types[cpu_id]; } @@ -122,6 +120,7 @@ struct guest_info * v3_create_vm(void * cfg) { return info; } + int v3_start_vm(struct guest_info * info, unsigned int cpu_mask) { info->cpu_id = v3_get_cpu_id(); @@ -146,7 +145,6 @@ int v3_start_vm(struct guest_info * info, unsigned int cpu_mask) { return -1; } - return 0; } @@ -190,6 +188,7 @@ v3_cpu_mode_t v3_get_host_cpu_mode() { } while (0) \ + void v3_yield_cond(struct guest_info * info) { uint64_t cur_cycle; rdtscll(cur_cycle); @@ -205,6 +204,7 @@ void v3_yield_cond(struct guest_info * info) { } } + /* * unconditional cpu yield * if the yielding thread is a guest context, the guest quantum is reset on resumption @@ -220,6 +220,23 @@ void v3_yield(struct guest_info * info) { + +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; @@ -243,8 +260,6 @@ unsigned int v3_get_cpu_id() { - - int v3_vm_enter(struct guest_info * info) { switch (v3_cpu_types[info->cpu_id]) { #ifdef CONFIG_SVM @@ -253,7 +268,7 @@ int v3_vm_enter(struct guest_info * info) { 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); @@ -264,6 +279,3 @@ int v3_vm_enter(struct guest_info * info) { return -1; } } - - - diff --git a/palacios/src/palacios/vmm_shadow_paging_32.h b/palacios/src/palacios/vmm_shadow_paging_32.h index 256f0de..c358c3c 100644 --- a/palacios/src/palacios/vmm_shadow_paging_32.h +++ b/palacios/src/palacios/vmm_shadow_paging_32.h @@ -257,12 +257,12 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault (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; @@ -282,6 +282,8 @@ static int handle_pte_shadow_pagefault_32(struct guest_info * info, addr_t fault return 0; } + } else { + PrintDebug("Not a sym swappable page\n"); } } #endif diff --git a/palacios/src/palacios/vmm_sym_iface.c b/palacios/src/palacios/vmm_sym_iface.c index 1242cb4..8395955 100644 --- a/palacios/src/palacios/vmm_sym_iface.c +++ b/palacios/src/palacios/vmm_sym_iface.c @@ -238,7 +238,7 @@ static int sym_call_err(struct guest_info * info, uint_t hcall_id, void * privat 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; @@ -325,7 +325,7 @@ int v3_sym_call(struct guest_info * info, if (execute_symcall(info) == -1) { PrintError("SYMCALL error\n"); return -1; - } + } // clear sym flags state->sym_call_active = 0; @@ -348,7 +348,7 @@ int v3_sym_call(struct guest_info * info, - // PrintDebug("restoring guest state\n"); + // PrintError("restoring guest state\n"); // v3_print_guest_state(info); return 0; diff --git a/palacios/src/palacios/vmm_sym_swap.c b/palacios/src/palacios/vmm_sym_swap.c index 0fbb853..56e0014 100644 --- a/palacios/src/palacios/vmm_sym_swap.c +++ b/palacios/src/palacios/vmm_sym_swap.c @@ -168,7 +168,7 @@ int v3_swap_flush(struct guest_info * info) { // 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"); } @@ -187,7 +187,7 @@ int v3_swap_flush(struct guest_info * info) { } 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) { @@ -195,7 +195,7 @@ int v3_get_vaddr_perms(struct guest_info * info, addr_t vaddr, pte32_t * guest_p return -1; } - V3_Print("page perms = %x\n", *(uint32_t *)page_perms); + // V3_Print("page perms = %x\n", *(uint32_t *)page_perms); return 0; } diff --git a/palacios/src/palacios/vmm_telemetry.c b/palacios/src/palacios/vmm_telemetry.c index 2d88d8b..898850a 100644 --- a/palacios/src/palacios/vmm_telemetry.c +++ b/palacios/src/palacios/vmm_telemetry.c @@ -27,7 +27,7 @@ #ifdef CONFIG_TELEMETRY_GRANULARITY #define DEFAULT_GRANULARITY CONFIG_TELEMETRY_GRANULARITY #else -#define DEFAULT_GRANULARITY 20000 +#define DEFAULT_GRANULARITY 50000 #endif @@ -223,4 +223,7 @@ void v3_print_telemetry(struct guest_info * info) { } telemetry->prev_tsc = invoke_tsc; + + V3_Print("%s Telemetry done\n", hdr_buf); + } diff --git a/palacios/src/palacios/vmx.c b/palacios/src/palacios/vmx.c index 29f1ccf..81d333e 100644 --- a/palacios/src/palacios/vmx.c +++ b/palacios/src/palacios/vmx.c @@ -702,9 +702,12 @@ int v3_start_vmx_guest(struct guest_info* info) { 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;