diff options
author | Avi Kivity <avi@redhat.com> | 2012-09-16 08:10:59 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-09-17 09:38:05 -0400 |
commit | 7454766f7bead388251aedee35a478356a7f4e72 (patch) | |
tree | 7d06cebf2c67d0a84d9204f9b03733f54548ba22 /arch/x86 | |
parent | b188c81f2e1a188ddda6a3d353e5b546c30a9b90 (diff) |
KVM: SVM: Make use of asm.h
Use macros for bitness-insensitive register names, instead of
rolling our own.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/svm.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 611c72875fb9..818fceb3091e 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -3782,12 +3782,6 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu) | |||
3782 | svm_complete_interrupts(svm); | 3782 | svm_complete_interrupts(svm); |
3783 | } | 3783 | } |
3784 | 3784 | ||
3785 | #ifdef CONFIG_X86_64 | ||
3786 | #define R "r" | ||
3787 | #else | ||
3788 | #define R "e" | ||
3789 | #endif | ||
3790 | |||
3791 | static void svm_vcpu_run(struct kvm_vcpu *vcpu) | 3785 | static void svm_vcpu_run(struct kvm_vcpu *vcpu) |
3792 | { | 3786 | { |
3793 | struct vcpu_svm *svm = to_svm(vcpu); | 3787 | struct vcpu_svm *svm = to_svm(vcpu); |
@@ -3814,13 +3808,13 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) | |||
3814 | local_irq_enable(); | 3808 | local_irq_enable(); |
3815 | 3809 | ||
3816 | asm volatile ( | 3810 | asm volatile ( |
3817 | "push %%"R"bp; \n\t" | 3811 | "push %%" _ASM_BP "; \n\t" |
3818 | "mov %c[rbx](%[svm]), %%"R"bx \n\t" | 3812 | "mov %c[rbx](%[svm]), %%" _ASM_BX " \n\t" |
3819 | "mov %c[rcx](%[svm]), %%"R"cx \n\t" | 3813 | "mov %c[rcx](%[svm]), %%" _ASM_CX " \n\t" |
3820 | "mov %c[rdx](%[svm]), %%"R"dx \n\t" | 3814 | "mov %c[rdx](%[svm]), %%" _ASM_DX " \n\t" |
3821 | "mov %c[rsi](%[svm]), %%"R"si \n\t" | 3815 | "mov %c[rsi](%[svm]), %%" _ASM_SI " \n\t" |
3822 | "mov %c[rdi](%[svm]), %%"R"di \n\t" | 3816 | "mov %c[rdi](%[svm]), %%" _ASM_DI " \n\t" |
3823 | "mov %c[rbp](%[svm]), %%"R"bp \n\t" | 3817 | "mov %c[rbp](%[svm]), %%" _ASM_BP " \n\t" |
3824 | #ifdef CONFIG_X86_64 | 3818 | #ifdef CONFIG_X86_64 |
3825 | "mov %c[r8](%[svm]), %%r8 \n\t" | 3819 | "mov %c[r8](%[svm]), %%r8 \n\t" |
3826 | "mov %c[r9](%[svm]), %%r9 \n\t" | 3820 | "mov %c[r9](%[svm]), %%r9 \n\t" |
@@ -3833,20 +3827,20 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) | |||
3833 | #endif | 3827 | #endif |
3834 | 3828 | ||
3835 | /* Enter guest mode */ | 3829 | /* Enter guest mode */ |
3836 | "push %%"R"ax \n\t" | 3830 | "push %%" _ASM_AX " \n\t" |
3837 | "mov %c[vmcb](%[svm]), %%"R"ax \n\t" | 3831 | "mov %c[vmcb](%[svm]), %%" _ASM_AX " \n\t" |
3838 | __ex(SVM_VMLOAD) "\n\t" | 3832 | __ex(SVM_VMLOAD) "\n\t" |
3839 | __ex(SVM_VMRUN) "\n\t" | 3833 | __ex(SVM_VMRUN) "\n\t" |
3840 | __ex(SVM_VMSAVE) "\n\t" | 3834 | __ex(SVM_VMSAVE) "\n\t" |
3841 | "pop %%"R"ax \n\t" | 3835 | "pop %%" _ASM_AX " \n\t" |
3842 | 3836 | ||
3843 | /* Save guest registers, load host registers */ | 3837 | /* Save guest registers, load host registers */ |
3844 | "mov %%"R"bx, %c[rbx](%[svm]) \n\t" | 3838 | "mov %%" _ASM_BX ", %c[rbx](%[svm]) \n\t" |
3845 | "mov %%"R"cx, %c[rcx](%[svm]) \n\t" | 3839 | "mov %%" _ASM_CX ", %c[rcx](%[svm]) \n\t" |
3846 | "mov %%"R"dx, %c[rdx](%[svm]) \n\t" | 3840 | "mov %%" _ASM_DX ", %c[rdx](%[svm]) \n\t" |
3847 | "mov %%"R"si, %c[rsi](%[svm]) \n\t" | 3841 | "mov %%" _ASM_SI ", %c[rsi](%[svm]) \n\t" |
3848 | "mov %%"R"di, %c[rdi](%[svm]) \n\t" | 3842 | "mov %%" _ASM_DI ", %c[rdi](%[svm]) \n\t" |
3849 | "mov %%"R"bp, %c[rbp](%[svm]) \n\t" | 3843 | "mov %%" _ASM_BP ", %c[rbp](%[svm]) \n\t" |
3850 | #ifdef CONFIG_X86_64 | 3844 | #ifdef CONFIG_X86_64 |
3851 | "mov %%r8, %c[r8](%[svm]) \n\t" | 3845 | "mov %%r8, %c[r8](%[svm]) \n\t" |
3852 | "mov %%r9, %c[r9](%[svm]) \n\t" | 3846 | "mov %%r9, %c[r9](%[svm]) \n\t" |
@@ -3857,7 +3851,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) | |||
3857 | "mov %%r14, %c[r14](%[svm]) \n\t" | 3851 | "mov %%r14, %c[r14](%[svm]) \n\t" |
3858 | "mov %%r15, %c[r15](%[svm]) \n\t" | 3852 | "mov %%r15, %c[r15](%[svm]) \n\t" |
3859 | #endif | 3853 | #endif |
3860 | "pop %%"R"bp" | 3854 | "pop %%" _ASM_BP |
3861 | : | 3855 | : |
3862 | : [svm]"a"(svm), | 3856 | : [svm]"a"(svm), |
3863 | [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)), | 3857 | [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)), |
@@ -3878,9 +3872,11 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) | |||
3878 | [r15]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_R15])) | 3872 | [r15]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_R15])) |
3879 | #endif | 3873 | #endif |
3880 | : "cc", "memory" | 3874 | : "cc", "memory" |
3881 | , R"bx", R"cx", R"dx", R"si", R"di" | ||
3882 | #ifdef CONFIG_X86_64 | 3875 | #ifdef CONFIG_X86_64 |
3876 | , "rbx", "rcx", "rdx", "rsi", "rdi" | ||
3883 | , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15" | 3877 | , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15" |
3878 | #else | ||
3879 | , "ebx", "ecx", "edx", "esi", "edi" | ||
3884 | #endif | 3880 | #endif |
3885 | ); | 3881 | ); |
3886 | 3882 | ||
@@ -3940,8 +3936,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) | |||
3940 | mark_all_clean(svm->vmcb); | 3936 | mark_all_clean(svm->vmcb); |
3941 | } | 3937 | } |
3942 | 3938 | ||
3943 | #undef R | ||
3944 | |||
3945 | static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) | 3939 | static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) |
3946 | { | 3940 | { |
3947 | struct vcpu_svm *svm = to_svm(vcpu); | 3941 | struct vcpu_svm *svm = to_svm(vcpu); |