help
This turns on debugging for the halt instruction handler
+config DEBUG_MWAIT
+ bool "MWAIT/MONITOR"
+ default n
+ depends on DEBUG_ON
+ help
+ This turns on debugging for the mwait and monitor instruction handlers
+
config DEBUG_DEV_MGR
bool "Device Manager"
default n
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2012, Peter Dinda <pdinda@northwestern.edu>
+ * Copyright (c) 2012, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Peter Dinda <pdinda@northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __VMM_MWAIT_H
+#define __VMM_MWAIT_H
+
+#ifdef __V3VEE__
+
+#include <palacios/vm_guest.h>
+#include <palacios/vmm.h>
+
+
+int v3_handle_monitor(struct guest_info * info);
+int v3_handle_mwait(struct guest_info * info);
+
+#endif // ! __V3VEE__
+
+#endif
vmm_emulator.o \
vmm_excp.o \
vmm_halt.o \
+ vmm_mwait.o \
vmm_hashtable.o \
vmm_host_events.o \
vmm_hypercall.o \
#include <palacios/vmm_ctrl_regs.h>
#include <palacios/svm_io.h>
#include <palacios/vmm_halt.h>
+#include <palacios/vmm_mwait.h>
#include <palacios/svm_pause.h>
#include <palacios/svm_wbinvd.h>
#include <palacios/vmm_intr.h>
return -1;
}
break;
+
+ case SVM_EXIT_MONITOR:
+#ifdef V3_CONFIG_DEBUG_MWAIT
+ PrintDebug("Guest issuing MONITOR\n");
+#endif
+ if (v3_handle_monitor(info) == -1) {
+ return -1;
+ }
+ break;
+
+ case SVM_EXIT_MWAIT:
+ case SVM_EXIT_MWAIT_CONDITIONAL:
+#ifdef V3_CONFIG_DEBUG_MWAIT
+ PrintDebug("Guest issuing MWAIT\n");
+#endif
+ if (v3_handle_mwait(info) == -1) {
+ return -1;
+ }
+ break;
+
case SVM_EXIT_PAUSE:
// PrintDebug("Guest paused\n");
if (v3_handle_svm_pause(info) == -1) {
// Disable XSAVE (cpuid 0x01, ECX bit 26)
v3_cpuid_add_fields(vm, 0x01, 0, 0, 0, 0, (1 << 26), 0, 0, 0);
+ // Disable MONITOR/MWAIT (cpuid 0x01, ECX bit 3)
+ v3_cpuid_add_fields(vm, 0x01, 0, 0, 0, 0, (1 << 3), 0, 0, 0);
+
}
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2012, Peter Dinda <pdinda@northwestern.edu>
+ * Copyright (c) 2012, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Peter Dinda <pdinda@northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#include <palacios/vmm_mwait.h>
+
+#ifndef V3_CONFIG_DEBUG_MWAIT
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
+
+
+//
+// Currently we disallow mwait in the CPUID field, so we need to raise an exception
+//
+int v3_handle_mwait(struct guest_info * info)
+{
+ PrintDebug("Raising undefined opcode due to mwait instruction\n");
+
+ v3_raise_exception(info, UD_EXCEPTION );
+
+ return 0;
+}
+
+//
+// Currently we disallow mwait in the CPUID field, so we need to raise an exception
+//
+int v3_handle_monitor(struct guest_info * info)
+{
+ PrintDebug("Raising undefined opcode due to monitor instruction\n");
+
+ v3_raise_exception(info, UD_EXCEPTION );
+
+ return 0;
+}
vmx_state->exit_ctrls.save_preempt_timer = 1;
}
+ // we want it to use this when halting
vmx_state->pri_proc_ctrls.hlt_exit = 1;
+ // cpuid tells it that it does not have these instructions
+ vmx_state->pri_proc_ctrls.monitor_exit = 1;
+ vmx_state->pri_proc_ctrls.mwait_exit = 1;
+ // we don't need to handle a pause, although this is where
+ // we could pull out of a spin lock acquire or schedule to find its partner
vmx_state->pri_proc_ctrls.pause_exit = 0;
+
vmx_state->pri_proc_ctrls.tsc_offset = 1;
#ifdef V3_CONFIG_TIME_VIRTUALIZE_TSC
vmx_state->pri_proc_ctrls.rdtsc_exit = 1;
#include <palacios/vmx_ctrl_regs.h>
#include <palacios/vmx_assist.h>
#include <palacios/vmm_halt.h>
+#include <palacios/vmm_mwait.h>
#include <palacios/vmx_ept.h>
break;
+ case VMX_EXIT_MONITOR:
+ PrintDebug("Guest Executing monitor\n");
+
+ if (v3_handle_monitor(info) == -1) {
+ PrintError("Error handling monitor instruction\n");
+ return -1;
+ }
+
+ break;
+
+ case VMX_EXIT_MWAIT:
+ PrintDebug("Guest Executing mwait\n");
+
+ if (v3_handle_mwait(info) == -1) {
+ PrintError("Error handling mwait instruction\n");
+ return -1;
+ }
+
+ break;
case VMX_EXIT_PAUSE: