#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
+/* At this point the GPRs are already copied into the guest_info state */
+int v3_handle_atomic_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_info) {
+ struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data);
+
+ switch (exit_info->exit_reason) {
+ case VMEXIT_INTR_WINDOW:
+ // This is here because we touch the VMCS
+ vmcs_read(VMCS_PROC_CTRLS, &(vmx_info->pri_proc_ctrls.value));
+ vmx_info->pri_proc_ctrls.int_wndw_exit = 0;
+ vmcs_write(VMCS_PROC_CTRLS, vmx_info->pri_proc_ctrls.value);
+#ifdef CONFIG_DEBUG_INTERRUPTS
+ PrintDebug("Interrupts available again! (RIP=%llx)\n", info->rip);
+#endif
+ break;
+ }
+ return 0;
+}
/* At this point the GPRs are already copied into the guest_info state */
int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_info) {
- struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data);
-
/*
PrintError("Handling VMEXIT: %s (%u), %lu (0x%lx)\n",
v3_vmx_exit_code_to_str(exit_info->exit_reason),
v3_print_vmcs();
*/
-#ifdef CONFIG_VNET_PROFILE
- uint64_t start, end;
- rdtscll(start);
-#endif
#ifdef CONFIG_TELEMETRY
if (info->vm_info->enable_telemetry) {
}
break;
+
+ case VMEXIT_RDTSC:
+#ifdef CONFIG_DEBUG_TIME
+ PrintDebug("RDTSC\n");
+#endif
+ if (v3_handle_rdtsc(info) == -1) {
+ PrintError("Error Handling RDTSC instruction\n");
+ return -1;
+ }
+
+ break;
+
case VMEXIT_CPUID:
if (v3_handle_cpuid(info) == -1) {
PrintError("Error Handling CPUID instruction\n");
// Interrupts are handled outside switch
break;
case VMEXIT_INTR_WINDOW:
-
- vmcs_read(VMCS_PROC_CTRLS, &(vmx_info->pri_proc_ctrls.value));
- vmx_info->pri_proc_ctrls.int_wndw_exit = 0;
- vmcs_write(VMCS_PROC_CTRLS, vmx_info->pri_proc_ctrls.value);
-
-#ifdef CONFIG_DEBUG_INTERRUPTS
- PrintDebug("Interrupts available again! (RIP=%llx)\n", info->rip);
-#endif
-
+ // This is handled in the atomic part of the vmx code,
+ // not in the generic (interruptable) vmx handler
break;
default:
PrintError("Unhandled VMEXIT: %s (%u), %lu (0x%lx)\n",
return -1;
}
+
#ifdef CONFIG_TELEMETRY
if (info->vm_info->enable_telemetry) {
v3_telemetry_end_exit(info, exit_info->exit_reason);
}
#endif
-#ifdef CONFIG_VNET_PROFILE
- rdtscll(end);
- info->vnet_times.total_exit_time = end - start;
- if(info->vnet_times.print)
- PrintError("Vnet_profiling: total_exit_time: %ld, total_handle_time: %ld memcpy_time: %ld copy_from_guest: %ld copy_to_guest: %ld malloc_free: %ld, route_lookup: %ld\n",
- (long)info->vnet_times.total_exit_time,
- (long)info->vnet_times.total_handle_time,
- (long)info->vnet_times.memcpy_time,
- (long)info->vnet_times.time_copy_from_guest,
- (long)info->vnet_times.time_copy_to_guest,
- (long)info->vnet_times.time_mallocfree,
- (long)info->vnet_times.time_route_lookup);
-
- info->vnet_times.print = false;
-#endif
-
return 0;
}