]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: Refactor SVM version of vcpu_activate_vmm
authorJan Kiszka <jan.kiszka@siemens.com>
Sat, 4 Apr 2015 11:27:59 +0000 (13:27 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 10 Apr 2015 07:00:53 +0000 (09:00 +0200)
We can reduce the assembly required in vcpu_activate_vmm by reordering
svm_vmexit to svm_vmentry, i.e. pulling the VM entry logic to the front.
Moreover, RAX can be loaded directly. There is furthermore no need to
declare clobbered variables as we won't return from the assembly block,
which is already declared via __builtin_unreachable.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/x86/include/asm/svm.h
hypervisor/arch/x86/svm-vmexit.S
hypervisor/arch/x86/svm.c

index 89f88c65cb7b73624897924d85b9bdcc08cf4b60..8e6c73d3ffb4c531796850cf5f7fca94c192d64d 100644 (file)
@@ -350,6 +350,4 @@ struct vmcb {
        u64 res16[301];
 } __attribute__((packed));
 
-void svm_vmexit(void);
-
 #endif
index 77c884d76cbd48db89400c814c8648eedf94af8c..e5d5fdd0b0bb3a6e028b00a53f10c9210d2b70d7 100644 (file)
 
 #include <asm/asm-defines.h>
 
-/* SVM VM-exit handling */
-       .globl svm_vmexit
-svm_vmexit:
+/* SVM VM entry and handling of VM exit */
+       .globl svm_vmentry
+svm_vmentry:
+       vmload %rax
+       vmrun %rax
+       vmsave %rax
+
        /* XXX: GIF is always cleared here */
        push -PERCPU_STACK_END+PERCPU_VMCB_RAX(%rsp)
        push %rcx
@@ -55,8 +59,4 @@ svm_vmexit:
        pop %rcx
        pop -PERCPU_STACK_END+PERCPU_VMCB_RAX(%rsp)
 
-       vmload %rax
-       vmrun %rax
-       vmsave %rax
-
-       jmp svm_vmexit
+       jmp svm_vmentry
index 5804f7065224b567a757c1320e23791fe7ea9032..7355aabbc12c9f6ed20286e9cdb5a36044673c6c 100644 (file)
@@ -432,17 +432,10 @@ void __attribute__((noreturn)) vcpu_activate_vmm(struct per_cpu *cpu_data)
                "mov 0x18(%%rdi),%%r12\n\t"
                "mov 0x20(%%rdi),%%rbx\n\t"
                "mov 0x28(%%rdi),%%rbp\n\t"
-               "mov %0, %%rax\n\t"
-               "vmload %%rax\n\t"
-               "vmrun %%rax\n\t"
-               "vmsave %%rax\n\t"
-               /* Restore hypervisor stack */
-               "mov %2, %%rsp\n\t"
-               "jmp svm_vmexit"
+               "mov %2,%%rsp\n\t"
+               "jmp svm_vmentry"
                : /* no output */
-               : "m" (vmcb_pa), "D" (cpu_data->linux_reg), "m" (host_stack)
-               : "memory", "r15", "r14", "r13", "r12",
-                 "rbx", "rbp", "rax", "cc");
+               : "D" (cpu_data->linux_reg), "a" (vmcb_pa), "m" (host_stack));
        __builtin_unreachable();
 }