X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm_lowlevel.S;h=45c55756c73532f9c411f47eff9847302e8d1901;hp=5616b7f7066b6e4612e3408696c64aff417e97db;hb=660d3c512aa3299ede91a0b2e24d8b5cde6306da;hpb=3574c981404a1c812d369132db09ec2a27d59a5d diff --git a/palacios/src/palacios/svm_lowlevel.S b/palacios/src/palacios/svm_lowlevel.S index 5616b7f..45c5575 100644 --- a/palacios/src/palacios/svm_lowlevel.S +++ b/palacios/src/palacios/svm_lowlevel.S @@ -1,6 +1,5 @@ #; -*- fundamental -*- - .text .align 4 @@ -18,8 +17,13 @@ #define clgi .byte 0x0F,0x01,0xDD +#define SVM_VM_HSAVE_PA_MSR .dword 0xc0010117 + + #ifdef __V3_32BIT__ +// Note that RAX is saved in the VMCB, so we don't touch it here + #define Save_SVM_Registers(location) \ pushl %eax; \ movl location, %eax; \ @@ -30,10 +34,6 @@ movl %ebx, 32(%eax); \ movl %edx, 40(%eax); \ movl %ecx, 48(%eax); \ - pushl %ebx; \ - movl 8(%esp), %ebx; \ - movl %ebx, 56(%eax); \ - popl %ebx; \ popl %eax; @@ -49,14 +49,17 @@ popl %eax; +// 32 bit GCC passes arguments via stack + v3_svm_launch: push %ebp; movl %esp, %ebp; pushf; - push %fs; - push %gs; pusha; + movl 16(%ebp), %eax; + vmsave; + pushl 12(%ebp); pushl 8(%ebp); @@ -72,9 +75,14 @@ v3_svm_launch: addl $4, %esp; popa; - pop %gs; - pop %fs; popf; + + movl 16(%ebp), %eax; + vmload; + + // We don't detect failures here, so just return 0 + xorl %eax, %eax + pop %ebp; ret @@ -82,6 +90,8 @@ v3_svm_launch: #elif __V3_64BIT__ +// Note that RAX is saved in the VMCB, so we don't touch it here + #define Save_SVM_Registers(location) \ pushq %rax; \ movq location, %rax; \ @@ -92,10 +102,6 @@ v3_svm_launch: 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); \ @@ -156,27 +162,26 @@ v3_svm_launch: popq %rbx; \ popq %rbp; + +// Note that this is only for 64 bit GCC, 32 bit GCC passes via stack // VMCB => RDI // vm_regs => RSI +// HOST VMCB => RDX v3_svm_launch: pushf; - push %fs; - push %gs; PUSHA - - - + pushq %rdx; + movq %rdx, %rax; + vmsave; - pushq %rsi + pushq %rsi movq %rdi, %rax Restore_SVM_Registers(%rsi); - - vmload; vmrun; vmsave; @@ -187,12 +192,10 @@ v3_svm_launch: addq $8, %rsp - - + popq %rax; + vmload; POPA - pop %gs; - pop %fs; popf; ret