#define CPUID_SVM_REV_AND_FEATURE_IDS_edx_svml 0x00000004
#define CPUID_SVM_REV_AND_FEATURE_IDS_edx_np 0x00000001
-
-#define EFER_MSR 0xc0000080
#define EFER_MSR_svm_enable 0x00001000
/************/
#include <palacios/vmm_config.h>
#include <palacios/vm_guest.h>
#include <palacios/vmm_instrument.h>
+#include <palacios/vmm_ctrl_regs.h>
+#include <palacios/vmm_lowlevel.h>
/* These should be the only global variables in Palacios */
PrintDebug("CPU has no virtualization Extensions\n");
}
}
+
+
+
+#ifdef __V3_32BIT__
+
+v3_cpu_mode_t v3_get_host_cpu_mode() {
+ uint32_t cr4_val;
+ struct cr4_32 * cr4;
+
+ __asm__ (
+ "movl %%cr4, %0; "
+ : "=r"(cr4_val)
+ );
+
+
+ cr4 = (struct cr4_32 *)&(cr4_val);
+
+ if (cr4->pae == 1) {
+ return PROTECTED_PAE;
+ } else {
+ return PROTECTED;
+ }
+}
+
+#elif __V3_64BIT__
+
+v3_cpu_mode_t v3_get_host_cpu_mode() {
+ return LONG;
+}
+
+#endif
+
int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
- // THIS IS VERY BAD
- v3_cpu_mode_t mode = LONG;
+ v3_cpu_mode_t mode = v3_get_host_cpu_mode()
PrintDebug("Nested PageFault: fault_addr=%p, error_code=%u\n",(void*)fault_addr, *(uint_t *)&error_code);