Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


VMX is working for a 32-bit Linux kernel. It should also work for a 64-bit kernel...
[palacios.git] / palacios / include / palacios / vmm_lowlevel.h
index 4719cce..71af105 100644 (file)
 #include <palacios/vmm_types.h>
 
 
+#define CPUID_FEATURE_IDS 0x00000001
+#define CPUID_EXT_FEATURE_IDS 0x80000001
+
+
 #ifdef __V3_32BIT__
 
-void __inline__ v3_cpuid(uint_t target, uint_t * eax, uint_t * ebx, uint_t * ecx, uint_t * edx) {
-  __asm__ __volatile__ (
-                       "pushl %%ebx\n\t"
-                       "cpuid\n\t"
-                       "movl %%ebx, %%esi\n\t"
-                       "popl %%ebx\n\t"
-                       : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
-                       : "a" (target)
-                       );
-  return;
+static void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) {
+    __asm__ __volatile__ (
+                         "cpuid\n\t"
+                         : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
+                         : "0" (target), "2" (*ecx)
+                         );
+    return;
+}
+
+#elif __V3_64BIT__
+
+static void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) {
+    __asm__ __volatile__ (
+                         "cpuid\n\t"
+                         : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+                         : "0" (target), "2" (*ecx)
+                         );
+    return;
+}
+
+#endif
+
+
+static void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) {
+    __asm__ __volatile__ (
+                         "wrmsr"
+                         : 
+                         : "c" (msr), "d" (high_byte), "a" (low_byte)
+                         );
+
+
 }
 
 
 
+static void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) {
+    __asm__ __volatile__ (
+                         "rdmsr"
+                         : "=d" (*high_byte), "=a" (*low_byte) 
+                         : "c" (msr)
+                         );
+}
+
 
-void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) {
-  __asm__ __volatile__ (
-                       "wrmsr"
-                       : 
-                       : "c" (msr), "d" (high_byte), "a" (low_byte)
-                       );
 
+static void __inline__ v3_enable_ints() {
+    __asm__ __volatile__ ("sti");
+}
 
+static void __inline__ v3_disable_ints() {
+    __asm__ __volatile__ ("cli");
 }
 
 
 
-void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) {
-  __asm__ __volatile__ (
-                       "rdmsr"
-                       : "=d" (*high_byte), "=a" (*low_byte) 
-                       : "c" (msr)
-                       );
+
+#ifdef __V3_32BIT__
+
+static addr_t __inline__ v3_irq_save() {
+    addr_t state;
+
+    __asm__ __volatile__ ("pushf \n\t"
+                         "popl %0 \n\t"
+                         "cli \n\t"
+                         :"=g" (state)
+                         : 
+                         :"memory"
+                         ); 
+    return state;
+}
+
+static void __inline__ v3_irq_restore(addr_t state) {
+    __asm__ __volatile__("pushl %0 \n\t"
+                        "popfl \n\t"
+                        : 
+                        :"g" (state)
+                        :"memory", "cc"
+                        );
 }
 
+#elif __V3_64BIT__
 
+static addr_t __inline__ v3_irq_save() {
+    addr_t state; 
 
-void __inline__ v3_enable_ints() {
-  __asm__ __volatile__ ("sti");
+    __asm__ __volatile__ ("pushfq \n\t"
+                         "popq %0 \n\t"
+                         "cli \n\t"
+                         :"=g" (state)
+                         : 
+                         :"memory"
+                         ); 
+
+    return state;
 }
 
-void __inline__ v3_disable_ints() {
-  __asm__ __volatile__ ("cli");
+
+static void __inline__ v3_irq_restore(addr_t state) {
+    __asm__ __volatile__("pushq %0 \n\t"
+                        "popfq \n\t"
+                        : 
+                        :"g" (state)
+                        :"memory", "cc"
+                        );
 }
 
 #endif