Sanitize vcoreid from untrusted sources
[akaros.git] / kern / include / ros / vmm.h
index 3db8cf3..fc0ac44 100644 (file)
@@ -2,36 +2,27 @@
  * Barret Rhoden <brho@cs.berkeley.edu>
  * See LICENSE for details.
  *
- * 64 bit KPT helpers */
+ * Arch-independent VMM kernel headers */
 
-#ifndef ROS_INC_VMM_H
-#define ROS_INC_VMM_H
+#pragma once
 
-#define        VMM_VMCALL_PRINTF       0x1     /* Enable VMCALL output console hack */
+#include <ros/arch/vmm.h>
 
-#define VMM_ALL_FLAGS  (VMM_VMCALL_PRINTF)
+/* VMCALL FUNCTION NUMBERS */
+#define VMCALL_PRINTC          0x1
+#define VMCALL_SMPBOOT         0x2
+#define VMCALL_GET_TSCFREQ     0x3
+#define VMCALL_TRACE_TF                0x4
 
-enum {
-       RESUME,
-       REG_RSP_RIP_CR3,
-       REG_RIP,
-       REG_ALL,
-};
+#define VMM_CTL_GET_EXITS              1
+#define VMM_CTL_SET_EXITS              2
+#define VMM_CTL_GET_FLAGS              3
+#define VMM_CTL_SET_FLAGS              4
 
-/* eventually, this is a system call. For now, it's #c/vmctl.
- * You fill in the blanks, and write the struct to #c/vmctl.
- * On return, i.e. vmexit, it's updated with the new values.
- */
-struct vmctl {
-       uint64_t command;
-       uint64_t cr3;
-       uint64_t gva;
-       uint64_t gpa;
-       uint64_t exit_qual;
-       int shutdown;
-       int ret_code;
-       int core;
-       struct hw_trapframe regs;
-};
+#define VMM_CTL_EXIT_HALT              (1 << 0)
+#define VMM_CTL_EXIT_PAUSE             (1 << 1)
+#define VMM_CTL_EXIT_MWAIT             (1 << 2)
+#define VMM_CTL_ALL_EXITS              ((1 << 3) - 1)
 
-#endif /* ROS_INC_VMM_H */
+#define VMM_CTL_FL_KERN_PRINTC         (1 << 0)
+#define VMM_CTL_ALL_FLAGS              (VMM_CTL_FL_KERN_PRINTC)