This turns on debugging support
+config DEBUG_SVM
+ bool "AMD SVM"
+ default n
+ depends on DEBUG_ON
+ help
+ This turns on debugging for the AMD SVM-specific code
+
+config DEBUG_VMX
+ bool "Intel VT"
+ default n
+ depends on DEBUG_ON
+ help
+ This turns on debugging for the Intel VT-specific code
+
+
config DEBUG_SHADOW_PAGING
bool "Shadow paging"
default n
struct v3_vm_info * vm_info;
- // the logical cpu this guest context is executing on
- int cpu_id;
+
+ // the logical cpu on which this core runs
+ uint32_t cpu_id;
};
int req_irq = get_highest_irr(apic);
int svc_irq = get_highest_isr(apic);
- PrintDebug("apic %u: core %u: req_irq=%d, svc_irq=%d\n",apic->lapic_id.val,info->cpu_id,req_irq,svc_irq);
+ // PrintDebug("apic %u: core %u: req_irq=%d, svc_irq=%d\n",apic->lapic_id.val,info->cpu_id,req_irq,svc_irq);
if ((req_irq >= 0) &&
(req_irq > svc_irq)) {
//V3_Print("Calling v3_svm_launch\n");
-#if 0
- if (info->cpu_id==1) {
- V3_Print("Entering Core 1\n");
- v3_print_guest_state(info);
- }
-#endif
-
v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[info->cpu_id]);
//V3_Print("SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip);
-#if 0
- if (info->cpu_id==1) {
- V3_Print("Exited Core 1, before handler\n");
- v3_print_guest_state(info);
- PrintDebugVMCB((vmcb_t*)(info->vmm_data));
- }
-#endif
-
-
if (v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2) != 0) {
PrintError("Error in SVM exit handler\n");
return -1;
}
-#if 0
- if (info->cpu_id==1) {
- V3_Print("Exited Core 1, after handler\n");
- v3_print_guest_state(info);
- PrintDebugVMCB((vmcb_t*)(info->vmm_data));
- }
-#endif
-
-
-
return 0;
}
#include <palacios/vmm_cpuid.h>
#include <palacios/vmm_direct_paging.h>
+#ifndef CONFIG_DEBUG_SVM
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
#ifdef CONFIG_TELEMETRY
#include <palacios/vmm_telemetry.h>
#endif
-#if 0
- if (info->cpu_id==1) {
- V3_Print("Core 1 SVM Exit: %s rip=0x%p\n", vmexit_code_to_str(exit_code), (void *) get_addr_linear(info, info->rip, &(info->segments.cs)));
- }
-#endif
//PrintDebug("SVM Returned: Exit Code: %x\n",exit_code);
switch (exit_code) {
PrintDebug("PageFault at %p (error=%d)\n",
(void *)fault_addr, *(uint_t *)error_code);
#endif
-#if 0
- if (info->cpu_id==1) {
- V3_Print("SVM Core 1: PageFault at %p (error=%d)\n",
- (void *)fault_addr, *(uint_t *)error_code);
- }
-#endif
if (info->shdw_pg_mode == SHADOW_PAGING) {
if (v3_handle_shadow_pagefault(info, fault_addr, *error_code) == -1) {
return -1;
} else
#endif
{
- PrintError("CPU has no virtualization Extensions\n");
+ PrintError("CPU has no virtualizationExtensions\n");
}
}
break;
#endif
default:
- PrintError("Attemping to enter a guest on an invalid CPU\n");
+ PrintError("Attempting to enter a guest on an invalid CPU\n");
return -1;
}
// should not happen
proc_to_use=get_next_core(cpu_mask,last_proc);
last_proc=proc_to_use;
+ // vm->cores[i].cpu_id=i;
+ // vm->cores[i].physical_cpu_id=proc_to_use;
+
PrintDebug("Starting virtual core %u on logical core %u\n",i,proc_to_use);
sprintf(tname,"core%u",i);
}
}
+ // vm->cores[0].cpu_id=0;
+ // vm->cores[0].physical_cpu_id=0;
+
// Finally launch the BSP on core 0
sprintf(tname,"core%u",0);
if (!os_hooks->start_thread_on_cpu(0,start_core,&(vm->cores[0]),tname)) {
return tmp_region;
} else if (region->core_id < tmp_region->core_id) {
p = &(*p)->rb_left;
- } else {
+ } else {
p = &(*p)->rb_right;
}
}
struct v3_mem_region * reg = NULL;
while (n) {
+
reg = rb_entry(n, struct v3_mem_region, tree_node);
if (guest_addr < reg->guest_start) {
} else if (guest_addr >= reg->guest_end) {
n = n->rb_right;
} else {
- if ((core_id == reg->core_id) ||
- (reg->core_id == V3_MEM_CORE_ANY)) {
- return reg;
- } else {
+ if (reg->core_id == V3_MEM_CORE_ANY) {
+ // found relevant region, it's available on all cores
+ return reg;
+ } else if (core_id==reg->core_id) {
+ // found relevant region, it's available on the indicated core
+ return reg;
+ } else if (core_id < reg->core_id) {
+ // go left, core too big
+ n = n->rb_left;
+ } else if (core_id > reg->core_id) {
+ // go right, core too small
n = n->rb_right;
+ } else {
+ PrintDebug("v3_get_mem_region: Impossible!\n");
+ return NULL;
}
}
}
// There is not registered region, so we check if its a valid address in the base region
if (guest_addr > vm->mem_map.base_region.guest_end) {
- PrintError("Guest Address Exceeds Base Memory Size (ga=%p), (limit=%p)\n",
- (void *)guest_addr, (void *)vm->mem_map.base_region.guest_end);
+ PrintError("Guest Address Exceeds Base Memory Size (ga=0x%p), (limit=0x%p) (core=0x%x)\n",
+ (void *)guest_addr, (void *)vm->mem_map.base_region.guest_end, core_id);
v3_print_mem_map(vm);
return NULL;
}
+
return &(vm->mem_map.base_region);
}
struct v3_mem_region * reg = &(vm->mem_map.base_region);
int i = 0;
- V3_Print("Memory Layout:\n");
+ V3_Print("Memory Layout (all cores):\n");
- V3_Print("Base Region: 0x%p - 0x%p -> 0x%p\n",
+ V3_Print("Base Region (all cores): 0x%p - 0x%p -> 0x%p\n",
(void *)(reg->guest_start),
(void *)(reg->guest_end - 1),
(void *)(reg->host_addr));
(void *)(reg->guest_end - 1),
(void *)(reg->host_addr));
- V3_Print("\t(flags=%x) (unhandled = 0x%p)\n",
- reg->flags.value,
- reg->unhandled);
+ V3_Print("\t(flags=0x%x) (core=0x%x) (unhandled = 0x%p)\n",
+ reg->flags.value,
+ reg->core_id,
+ reg->unhandled);
i++;
} while ((node = v3_rb_next(node)));
uint8_t sum;
struct mp_table_header *header;
- V3_Print("Checksuming mptable header and entries at %p\n",target);
header=(struct mp_table_header *)target;
sum=0;
sum+=((uint8_t *)target)[i];
}
if (sum==0) {
- V3_Print("Checksum passed\n");
return 1;
} else {
- V3_Print("Checksum FAILED\n");
+ // failed checksum
return 0;
}
}
uint8_t sum;
struct mp_floating_pointer *p;
- V3_Print("Checksuming mptable floating pointer at %p\n",target);
-
p=(struct mp_floating_pointer *)target;
sum=0;
for (i=0;i<p->length*16;i++) {
sum+=((uint8_t *)target)[i];
}
if (sum==0) {
- V3_Print("Checksum passed\n");
+ // passed
return 1;
} else {
- V3_Print("Checksum FAILED\n");
+ // failed
return 0;
}
}
}
p->checksum=(255-sum)+1;
- V3_Print("MP Floating Pointer written to %p\n",target);
-
return 0;
}
return -1;
}
- V3_Print("Starting mptable pointer, header, and entry construction for %u cores at %p\n",vm->num_cores,target);
+ V3_Print("Constructing mptable for %u cores at %p\n",vm->num_cores,target);
if (-1==write_pointer(target,BIOS_MP_TABLE_DEFAULT_LOCATION+sizeof(struct mp_floating_pointer))) {
PrintError("Unable to write mptable floating pointer, aborting.\n");
return -1;
}
- V3_Print("Done with mptable pointer, header, and entry construction\n");
return 0;
#include <palacios/vmx_io.h>
#include <palacios/vmx_msr.h>
+
+#ifndef CONFIG_DEBUG_VMX
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
+
+
static addr_t host_vmcs_ptrs[CONFIG_MAX_CPUS] = { [0 ... CONFIG_MAX_CPUS - 1] = 0};
#include <palacios/vmx_assist.h>
#include <palacios/vmm_halt.h>
+#ifndef CONFIG_DEBUG_VMX
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
+
#ifdef CONFIG_TELEMETRY
#include <palacios/vmm_telemetry.h>
#endif