#include <palacios/vmx.h>
+#define VMXASSIST_GDT 0x10000
+#define VMXASSIST_TSS 0x40000
+#define VMXASSIST_START 0xd0000
+#define VMXASSIST_1to1_PT 0xde000 // We'll shove this at the end, and pray to god VMXASSIST doesn't mess with it
int v3_vmxassist_ctx_switch(struct guest_info * info);
}
- if (vm->num_cores>1 && !v3_find_dev(vm,"apic")) {
- PrintError("palacios: VM has more than one core, but no device named \"apic\"!\n");
- return -1;
- }
-
- if (v3_find_dev(vm,"apic")) {
- if (!v3_find_dev(vm,"ioapic")) {
- PrintError("palacios: VM cores have apics, but there is no device named \"ioapic\"!\n");
- }
+ if (vm->num_cores > 1) {
if (v3_inject_mptable(vm) == -1) {
PrintError("Failed to inject mptable during configuration\n");
return -1;
- }
+ }
}
-
return 0;
}
int v3_invalidate_nested_addr(struct guest_info * info, addr_t inv_addr) {
+
+#ifdef __V3_64BIT__
v3_cpu_mode_t mode = LONG;
+#else
+ v3_cpu_mode_t mode = PROTECTED;
+#endif
switch(mode) {
case REAL:
return 0;
} else if (pde[pde_index].large_page) {
pde[pde_index].present = 0;
+ pde[pde_index].writable = 0;
+ pde[pde_index].user_page = 0;
return 0;
}
pte = V3_VAddr((void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr));
pte[pte_index].present = 0;
+ pte[pte_index].writable = 0;
+ pte[pte_index].user_page = 0;
return 0;
}
return 0;
} else if (pdpe[pdpe_index].large_page == 1) { // 1GiB
pdpe[pdpe_index].present = 0;
+ pdpe[pdpe_index].writable = 0;
+ pdpe[pdpe_index].user_page = 0;
return 0;
}
return 0;
} else if (pde[pde_index].large_page == 1) { // 2MiB
pde[pde_index].present = 0;
+ pde[pde_index].writable = 0;
+ pde[pde_index].user_page = 0;
return 0;
}
pte = V3_VAddr((void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr));
pte[pte_index].present = 0; // 4KiB
+ pte[pte_index].writable = 0;
+ pte[pte_index].user_page = 0;
return 0;
}
vmx_state->pri_proc_ctrls.hlt_exit = 1;
- vmx_state->pri_proc_ctrls.invlpg_exit = 1;
- vmx_state->pri_proc_ctrls.pause_exit = 1;
+
+ vmx_state->pri_proc_ctrls.pause_exit = 0;
vmx_state->pri_proc_ctrls.tsc_offset = 1;
#ifdef CONFIG_TIME_VIRTUALIZE_TSC
vmx_state->pri_proc_ctrls.rdtsc_exit = 1;
vmx_state->pri_proc_ctrls.cr3_ld_exit = 1;
vmx_state->pri_proc_ctrls.cr3_str_exit = 1;
+ vmx_state->pri_proc_ctrls.invlpg_exit = 1;
+
/* Add page fault exits */
vmx_state->excp_bmap.pf = 1;
// vmx_state->pinbased_ctrls |= NMI_EXIT;
- /* Add CR exits */
- //vmx_state->pri_proc_ctrls.cr3_ld_exit = 1;
- //vmx_state->pri_proc_ctrls.cr3_str_exit = 1;
+ /* Disable CR exits */
+ vmx_state->pri_proc_ctrls.cr3_ld_exit = 0;
+ vmx_state->pri_proc_ctrls.cr3_str_exit = 0;
+
+ vmx_state->pri_proc_ctrls.invlpg_exit = 0;
/* Add page fault exits */
- vmx_state->excp_bmap.pf = 1; // This should never happen..., enabled to catch bugs
+ // vmx_state->excp_bmap.pf = 1; // This should never happen..., enabled to catch bugs
// Setup VMX Assist
v3_vmxassist_init(core, vmx_state);
int i = 0;
// For now we will assume that unrestricted guest mode is assured w/ EPT
+
core->vm_regs.rsp = 0x00;
core->rip = 0xfff0;
core->vm_regs.rdx = 0x00000f00;
vmx_state->exit_ctrls.ld_efer = 1;
vmx_state->exit_ctrls.save_efer = 1;
+ /* Disable shadow paging stuff */
+ vmx_state->pri_proc_ctrls.cr3_ld_exit = 0;
+ vmx_state->pri_proc_ctrls.cr3_str_exit = 0;
+
+ vmx_state->pri_proc_ctrls.invlpg_exit = 0;
+
if (v3_init_ept(core, &hw_info) == -1) {
PrintError("Error initializing EPT\n");
#define PrintDebug(fmt, args...)
#endif
-#define VMXASSIST_GDT 0x10000
-#define VMXASSIST_TSS 0x40000
-#define VMXASSIST_START 0xd0000
-#define VMXASSIST_1to1_PT 0xde000 // We'll shove this at the end, and pray to god VMXASSIST doesn't mess with it
+
#define VMXASSIST_MAGIC 0x17101966
#include <palacios/vmm_direct_paging.h>
#include <palacios/vmm_ctrl_regs.h>
+#if 0
#ifndef CONFIG_DEBUG_VMX
#undef PrintDebug
#define PrintDebug(fmt, args...)
#endif
+#endif
static v3_reg_t * get_reg_ptr(struct guest_info * info, struct vmx_exit_cr_qual * cr_qual);
static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_val, struct vmx_exit_info * exit_info);
guest_cr0->pg = 1;
guest_cr0->ne = 1;
- if (paging_transition) {
+ if ((paging_transition)) {
// Paging transition
if (v3_get_vm_mem_mode(info) == VIRTUAL_MEM) {
// PrintDebug("Activating Shadow Page tables\n");
- if (v3_activate_shadow_pt(info) == -1) {
- PrintError("Failed to activate shadow page tables\n");
- return -1;
+ if (info->shdw_pg_mode == SHADOW_PAGING) {
+ if (v3_activate_shadow_pt(info) == -1) {
+ PrintError("Failed to activate shadow page tables\n");
+ return -1;
+ }
}
- } else if (v3_activate_passthrough_pt(info) == -1) {
- PrintError("Failed to activate passthrough page tables\n");
- return -1;
+ } else {
+
+ if (info->shdw_pg_mode == SHADOW_PAGING) {
+ if (v3_activate_passthrough_pt(info) == -1) {
+ PrintError("Failed to activate passthrough page tables\n");
+ return -1;
+ }
+ } else {
+ // This is hideous... Let's hope that the 1to1 page table has not been nuked...
+ info->ctrl_regs.cr3 = VMXASSIST_1to1_PT;
+ }
}
}
}