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.


moved svm_lowlevel.asm over to gas syntax in svm_lowlevel.S
Jack Lange [Mon, 20 Oct 2008 22:58:12 +0000 (17:58 -0500)]
palacios/build/Makefile
palacios/src/palacios/svm.c
palacios/src/palacios/svm_lowlevel.S [new file with mode: 0644]
palacios/src/palacios/svm_lowlevel.asm [deleted file]

index 0918964..ad4787f 100644 (file)
@@ -254,11 +254,11 @@ ALL_TARGETS := vmm vm_kernel
 
 
 
-VMM_ASM_SRCS :=  svm_lowlevel.asm\
-#                      vmx_lowlevel.asm
-
+VMM_ASM_SRCS :=
 VMM_ASM_OBJS := $(VMM_ASM_SRCS:%.asm=palacios/%.o)
 
+VMM_GAS_SRCS := svm_lowlevel.s
+VMM_GAS_OBJS := $(VMM_GAS_SRCS:%.s=palacios/%.o)
 
 VMM_C_SRCS :=   vm_guest.c \
                svm.c svm_handler.c vmm.c vmm_util.c vmm_ctrl_regs.c \
@@ -275,16 +275,14 @@ VMM_C_SRCS :=   vm_guest.c \
 
 VMM_C_OBJS := $(VMM_C_SRCS:%.c=palacios/%.o)
 
-VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
+VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS) $(VMM_GAS_OBJS)
 
 
 
 XED_C_SRCS := v3-xed-compat.c
-
 XED_C_OBJS := $(XED_C_SRCS:%.c=xed/%.o)
 
 XED_GAS_SRCS := v3-udiv-compat.s
-
 XED_GAS_OBJS := $(XED_GAS_SRCS:%.s=xed/%.o)
 
 XED_OBJS := $(XED_C_OBJS) $(XED_GAS_OBJS)
@@ -340,6 +338,9 @@ TARGET_OBJCOPY := $(TARGET_CC_PREFIX)objcopy
 NASM := $(PROJECT_ROOT)/../devtools/bin/nasm
 #NASM := /opt/vmm-tools/bin/nasm
 
+CPP := cpp
+
+
 AS = as --32
 
 # Tool to build PFAT filesystem images.
@@ -397,6 +398,11 @@ palacios/%.o : palacios/%.c
 palacios/%.o : palacios/%.asm
        $(NASM) $(NASM_VMM_OPTS) $< -o palacios/$*.o
 
+palacios/%.o : palacios/%.S
+       $(CPP) $(CC_VMM_OPTS) $< | $(AS) -o palacios/$*.o
+
+
+
 devices/%.o : devices/%.c
        $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS) $< -o devices/$*.o
 
index e59e96a..1aca55b 100644 (file)
 
 
 
-
-extern uint_t launch_svm(vmcb_t * vmcb_addr);
-extern void safe_svm_launch(vmcb_t * vmcb_addr, struct v3_gprs * gprs);
-
-extern void STGI();
-extern void CLGI();
-
 extern uint_t Get_CR3();
 
 
 
-
-
+extern void v3_stgi();
+extern void v3_clgi();
+extern int v3_svm_launch(vmcb_t * vmcb, struct v3_gprs * vm_regs);
 
 
 
@@ -306,14 +300,14 @@ static int start_svm_guest(struct guest_info *info) {
 
 
     v3_enable_ints();
-    CLGI();
+    v3_clgi();
 
     //    PrintDebug("SVM Entry to rip=%x...\n", info->rip);
 
     rdtscll(info->time_state.cached_host_tsc);
     guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
 
-    safe_svm_launch((vmcb_t*)(info->vmm_data), &(info->vm_regs));
+    v3_svm_launch((vmcb_t*)(info->vmm_data), &(info->vm_regs));
 
     rdtscll(tmp_tsc);
     //PrintDebug("SVM Returned\n");
@@ -322,7 +316,7 @@ static int start_svm_guest(struct guest_info *info) {
     v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc);
     num_exits++;
 
-    STGI();
+    v3_stgi();
 
     if ((num_exits % 25) == 0) {
       PrintDebug("SVM Exit number %d\n", num_exits);
diff --git a/palacios/src/palacios/svm_lowlevel.S b/palacios/src/palacios/svm_lowlevel.S
new file mode 100644 (file)
index 0000000..9b201b1
--- /dev/null
@@ -0,0 +1,94 @@
+#;  -*- fundamental -*-
+
+
+.text
+.align 4
+
+.globl v3_svm_launch
+.globl v3_stgi
+.globl v3_clgi
+
+#define SVM_ERROR .dword 0xffffffff
+#define SVM_SUCCESS .dword 0x00000000
+
+#define vmrun .byte 0x0f,0x01,0xd8
+#define vmload .byte 0x0F,0x01,0xDA
+#define vmsave .byte 0x0F,0x01,0xDB
+#define stgi   .byte 0x0F,0x01,0xDC
+#define clgi   .byte 0x0F,0x01,0xDD
+
+
+#ifdef __V3_32BIT__
+
+#define Save_SVM_Registers(location)   \
+       pushl   %eax;                   \
+       movl    location, %eax;         \
+       movl    %edi, (%eax);           \
+       movl    %esi, 8(%eax);          \
+       movl    %ebp, 16(%eax);         \
+       movl    $0, 24(%eax);           \
+       movl    %ebx, 32(%eax);         \
+       movl    %edx, 40(%eax);         \
+       movl    %ecx, 48(%eax);         \
+       pushl   %ebx;                   \
+       movl    4(%esp), %ebx;          \
+       movl    %ebx, 56(%eax);         \
+       popl    %ebx;                   \
+       popl    %eax;                   
+       
+
+#define Restore_SVM_Registers(location) \
+       pushl   %eax;                   \
+       movl    location, %eax;         \
+       movl    (%eax), %edi;           \
+       movl    8(%eax), %esi;          \
+       movl    16(%eax), %ebp;         \
+       movl    32(%eax), %ebx;         \
+       movl    40(%eax), %edx;         \
+       movl    48(%eax), %ecx;         \
+       popl    %eax;
+
+
+
+#elif __V3_64BIT__
+
+#endif
+
+
+v3_stgi:
+       stgi;
+       ret;
+
+v3_clgi:
+       clgi;
+       ret;
+       
+       
+v3_svm_launch:
+       push    %ebp;
+       movl    %esp, %ebp;
+       pushf;
+       push    %fs;
+       push    %gs;
+       pusha;
+
+       pushl   12(%ebp);
+       pushl   8(%ebp);
+
+       Restore_SVM_Registers(8(%esp));
+       popl    %eax;
+
+       vmload;
+       vmrun;
+       vmsave;
+
+       Save_SVM_Registers(4(%esp));
+
+       addl    $4, %esp;
+
+       popa;
+       pop     %gs;
+       pop     %fs;
+       popf;
+       pop     %ebp;
+       ret
diff --git a/palacios/src/palacios/svm_lowlevel.asm b/palacios/src/palacios/svm_lowlevel.asm
deleted file mode 100644 (file)
index f12e140..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-;  -*- fundamental -*-
-;; 
-;; 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 SVM_ASM
-%define SVM_ASM
-
-;%include "defs.asm"
-%include "vmm_symbol.asm"
-
-SVM_ERROR equ 0xFFFFFFFF
-SVM_SUCCESS equ 0x00000000
-
-
-
-EXPORT safe_svm_launch
-
-EXPORT STGI
-EXPORT CLGI
-
-
-
-;; These need to be kept similar with the svm return values in svm.h
-SVM_HANDLER_SUCCESS  equ 0x00
-SVM_HANDLER_ERROR equ  0x1
-SVM_HANDLER_HALT equ 0x2
-
-[BITS 32]
-
-
-; Save and restore registers needed by SVM
-%macro Save_SVM_Registers 1
-       push    eax
-       mov     eax, dword %1
-       mov     [eax], edi
-       mov     [eax + 8], esi
-       mov     [eax + 16], ebp
-       mov     [eax + 24], dword 0             ;; esp
-       mov     [eax + 32], ebx
-       mov     [eax + 40], edx
-       mov     [eax + 48], ecx
-
-       push    ebx
-       mov     ebx, [esp + 4]
-       mov     [eax + 56], ebx         ;; eax
-       pop     ebx
-
-       pop     eax
-%endmacro
-
-
-%macro Restore_SVM_Registers 1
-       push    eax
-       mov     eax, dword %1
-       mov     edi, [eax]
-       mov     esi, [eax + 8]
-       mov     ebp, [eax + 16]
-;;     mov     esp, [eax + 24]
-       mov     ebx, [eax + 32]
-       mov     edx, [eax + 40]
-       mov     ecx, [eax + 48]
-;;     mov     eax, [eax + 56]
-       pop     eax
-%endmacro
-
-%macro vmrun 0
-       db      00fh, 001h, 0d8h
-%endmacro
-
-%macro vmsave 0
-       db      00fh, 001h, 0dbh
-%endmacro
-
-%macro vmload 0
-       db      00fh, 001h, 0dah
-%endmacro
-
-%macro stgi 0
-       db      00fh, 001h, 0dch
-%endmacro
-
-%macro clgi 0
-       db      00fh, 001h, 0ddh
-%endmacro
-
-;VMRUN  equ db 0Fh, 01h, D8h
-;VMLOAD equ db 0x0F,0x01,0xDA
-;VMSAVE equ db 0x0F,0x01,0xDB
-;STGI   equ db 0x0F,0x01,0xDC
-;CLGI   equ db 0x0F,0x01,0xDD
-
-
-
-align 8
-CLGI:
-       clgi
-       ret
-
-align 8
-STGI:
-       stgi
-       ret
-
-
-
-
-;; Need to check this..
-;; save_svm_launch(rax, struct guest_gprs * regs)
-align 8
-safe_svm_launch:
-       push    ebp
-       mov     ebp, esp
-       pushf
-       push    fs
-       push    gs
-       pusha                                   ;; Save Host state
-
-
-       push    dword [ebp + 12]                ;; pointer to the guest GPR save area
-       push    dword [ebp + 8]                 ;; pointer to the VMCB pointer
-
-;;     mov     eax, [esp + 4]                  ;; mov guest GPR pointer to eax
-
-       ;; this is plus 8 because we push eax in the macro
-       Restore_SVM_Registers [esp + 8]         ;; Restore Guest GPR state
-       pop     eax                             ;; pop VMCB pointer into eax
-
-       vmload
-       vmrun
-       vmsave
-
-;;     pop     eax                             ;; pop Guest GPR pointer into eax
-       ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
-       Save_SVM_Registers  [esp+4]             ;; save guest GPRs
-       
-       add     esp, 4                          ;; skip past the gpr ptr
-       
-       popa                                    ;; Restore Host state
-       pop     gs
-       pop     fs
-       popf
-       pop     ebp
-       ret
-
-
-
-%endif
-
-