X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm_lowlevel.S;h=975fe9891deb2bb8a2c9c1ef5980a2abcf4de839;hb=058a3adde5893927ae056a1d8fbccd5191d2446f;hp=3a17df4c6dce1ee124055ba6171513621d7b166d;hpb=04977d080b9850506ced2523b6130abc517b61df;p=palacios.git diff --git a/palacios/src/palacios/svm_lowlevel.S b/palacios/src/palacios/svm_lowlevel.S index 3a17df4..975fe98 100644 --- a/palacios/src/palacios/svm_lowlevel.S +++ b/palacios/src/palacios/svm_lowlevel.S @@ -31,7 +31,7 @@ movl %edx, 40(%eax); \ movl %ecx, 48(%eax); \ pushl %ebx; \ - movl 4(%esp), %ebx; \ + movl 8(%esp), %ebx; \ movl %ebx, 56(%eax); \ popl %ebx; \ popl %eax; @@ -83,37 +83,134 @@ v3_svm_launch: #elif __V3_64BIT__ #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; + pushq %rax; \ + movq location, %rax; \ + movq %rdi, (%rax); \ + movq %rsi, 8(%rax); \ + movq %rbp, 16(%rax); \ + movq $0, 24(%rax); \ + movq %rbx, 32(%rax); \ + movq %rdx, 40(%rax); \ + movq %rcx, 48(%rax); \ + pushq %rbx; \ + movq 16(%rsp), %rbx; \ + movq %rbx, 56(%rax); \ + popq %rbx; \ + \ + movq %r8, 64(%rax); \ + movq %r9, 72(%rax); \ + movq %r10, 80(%rax); \ + movq %r11, 88(%rax); \ + movq %r12, 96(%rax); \ + movq %r13, 104(%rax); \ + movq %r14, 112(%rax); \ + movq %r15, 120(%rax); \ + popq %rax; #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; + push %rax; \ + mov location, %rax; \ + mov (%rax), %rdi; \ + mov 8(%rax), %rsi; \ + mov 16(%rax), %rbp; \ + mov 32(%rax), %rbx; \ + mov 40(%rax), %rdx; \ + mov 48(%rax), %rcx; \ + \ + mov 64(%rax), %r8; \ + mov 72(%rax), %r9; \ + mov 80(%rax), %r10; \ + mov 88(%rax), %r11; \ + mov 96(%rax), %r12; \ + mov 104(%rax), %r13; \ + mov 112(%rax), %r14; \ + mov 120(%rax), %r15; \ + pop %rax; + + + + +#define PUSHA \ + pushq %rbp; \ + pushq %rbx; \ + pushq %r8; \ + pushq %r9; \ + pushq %r10; \ + pushq %r11; \ + pushq %r12; \ + pushq %r13; \ + pushq %r14; \ + pushq %r15; + + +#define POPA \ + popq %r15; \ + popq %r14; \ + popq %r13; \ + popq %r12; \ + popq %r11; \ + popq %r10; \ + popq %r9; \ + popq %r8; \ + popq %rbx; \ + popq %rbp; + +// VMCB => RDI +// vm_regs => RSI +// ptr to fs => RDX +// ptr to gs => RCX +v3_svm_launch: + pushf; + push %fs; + push %gs; + PUSHA -v3_svm_launch: +// pushq %rdx // fs +// pushq %rcx // gs + + +// pushq (%rdx) +// pop %fs +// pushq (%rcx) +// pop %gs + + + + pushq %rsi + + movq %rdi, %rax + Restore_SVM_Registers(%rsi); + + + vmload; + vmrun; + vmsave; + + + Save_SVM_Registers(8(%rsp)); + + addq $8, %rsp + +// popq %rcx +// popq %rdx + +// push %fs +// popq %rax +// movq %rax, (%rdx) + +// push %gs +// popq %rax +// movq %rax, (%rcx) + + + POPA + pop %gs; + pop %fs; + popf; ret