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.


added locking primitives
Jack Lange [Fri, 5 Jun 2009 22:02:23 +0000 (17:02 -0500)]
palacios/build/Makefile
palacios/include/palacios/vmm.h
palacios/include/palacios/vmm_lock.h [new file with mode: 0644]
palacios/include/palacios/vmm_lowlevel.h
palacios/src/palacios/vmm_lock.c [new file with mode: 0644]

index ba09371..4bfad21 100644 (file)
@@ -306,6 +306,7 @@ VMM_OBJS := \
        palacios/vmm_direct_paging.o \
        palacios/vmm_ringbuffer.o \
        palacios/vmm_hypercall.o \
+       palacios/vmm_lock.o \
        $(OBJ_FILES)
 
 #              vmx.c vmcs_gen.c vmcs.c
@@ -343,6 +344,7 @@ DEVICES_OBJS := \
        devices/ram_hd.o \
        devices/i440fx.o \
        devices/piix3.o \
+       devices/net_cd.o \
 
 #      devices/ne2k.o  \
 #      devices/cdrom.o \
index 256cb64..92ba208 100644 (file)
@@ -260,6 +260,11 @@ struct v3_os_hooks {
     void (*start_kernel_thread)(int (*fn)(void * arg), void * arg, char * thread_name); 
 
     void (*yield_cpu)(void); 
+
+    void *(*mutex_alloc)(void);
+    void (*mutex_free)(void * mutex);
+    void (*mutex_lock)(void * mutex, int must_spin);
+    void (*mutex_unlock)(void * mutex);
 };
 
 
@@ -282,6 +287,8 @@ struct v3_vm_config {
     
     int use_ram_cd;
     int use_ram_hd;
+    int use_net_cd;
+    int use_net_hd;
 
     void * ramdisk;
     int ramdisk_size;
diff --git a/palacios/include/palacios/vmm_lock.h b/palacios/include/palacios/vmm_lock.h
new file mode 100644 (file)
index 0000000..575bb81
--- /dev/null
@@ -0,0 +1,42 @@
+/* 
+ * 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) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __VMM_LOCK_H__
+#define __VMM_LOCK_H__
+
+#ifdef __V3VEE__
+#include <palacios/vmm_types.h>
+
+typedef addr_t v3_lock_t;
+
+int v3_lock_init(v3_lock_t * lock);
+void v3_lock_deinit(v3_lock_t * lock);
+
+
+void v3_lock(v3_lock_t lock);
+void v3_unlock(v3_lock_t lock);
+
+
+addr_t v3_lock_irqsave(v3_lock_t lock);
+void v3_unlock_irqrestore(v3_lock_t lock, addr_t irq_state);
+
+
+#endif
+
+#endif
index 687069f..7863d19 100644 (file)
@@ -81,3 +81,57 @@ static void __inline__ v3_disable_ints() {
     __asm__ __volatile__ ("cli");
 }
 
+
+
+
+#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" (x)
+                         : 
+                         :"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; 
+
+    __asm__ __volatile__ ("pushfq \n\t"
+                         "popq %0 \n\t"
+                         "cli \n\t"
+                         :"=g" (state)
+                         : 
+                         :"memory"
+                         ); 
+
+    return state;
+}
+
+
+static void __inline__ v3_irq_restore(addr_t state) {
+    __asm__ __volatile__("pushq %0 \n\t"
+                        "popfq \n\t"
+                        : 
+                        :"g" (state)
+                        :"memory", "cc"
+                        );
+}
+
+#endif
diff --git a/palacios/src/palacios/vmm_lock.c b/palacios/src/palacios/vmm_lock.c
new file mode 100644 (file)
index 0000000..c2bdba7
--- /dev/null
@@ -0,0 +1,62 @@
+/* 
+ * 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) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.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.h>
+#include <palacios/vmm_lock.h>
+#include <palacios/vmm_lowlevel.h>
+
+
+extern struct v3_os_hooks * os_hooks;
+
+
+int v3_lock_init(v3_lock_t * lock) {
+    *lock = (addr_t)(os_hooks->mutex_alloc());
+
+    if (!(*lock)) {
+       return -1;
+    }
+
+    return 0;
+}
+
+
+void v3_lock_deinit(v3_lock_t * lock) {
+    os_hooks->mutex_free((void *)*lock);
+    *lock = 0;
+}
+
+void v3_lock(v3_lock_t lock) {
+    os_hooks->mutex_lock((void *)lock, 0);    
+}
+
+void v3_unlock(v3_lock_t lock) {
+    os_hooks->mutex_unlock((void *)lock);
+}
+
+addr_t v3_lock_irqsave(v3_lock_t lock) {
+    addr_t irq_state = v3_irq_save();
+    os_hooks->mutex_lock((void *)lock, 1);
+    return irq_state;
+}
+
+
+void v3_unlock_irqrestore(v3_lock_t lock, addr_t irq_state) {
+    os_hooks->mutex_unlock((void *)lock);
+    v3_irq_restore(irq_state);
+}