diff options
author | Avi Kivity <avi@redhat.com> | 2012-09-16 08:10:58 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-09-17 09:38:04 -0400 |
commit | b188c81f2e1a188ddda6a3d353e5b546c30a9b90 (patch) | |
tree | b6c688ec4788a1de55b1759199633d7980b40e44 /arch | |
parent | 83287ea420ced7242a704488aab0fcdcf2ced9ab (diff) |
KVM: VMX: 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')
-rw-r--r-- | arch/x86/kvm/vmx.c | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 5faf12ace546..30bcb953afee 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -6184,14 +6184,6 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx) | |||
6184 | msrs[i].host); | 6184 | msrs[i].host); |
6185 | } | 6185 | } |
6186 | 6186 | ||
6187 | #ifdef CONFIG_X86_64 | ||
6188 | #define R "r" | ||
6189 | #define Q "q" | ||
6190 | #else | ||
6191 | #define R "e" | ||
6192 | #define Q "l" | ||
6193 | #endif | ||
6194 | |||
6195 | static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | 6187 | static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) |
6196 | { | 6188 | { |
6197 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 6189 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
@@ -6240,30 +6232,30 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6240 | vmx->__launched = vmx->loaded_vmcs->launched; | 6232 | vmx->__launched = vmx->loaded_vmcs->launched; |
6241 | asm( | 6233 | asm( |
6242 | /* Store host registers */ | 6234 | /* Store host registers */ |
6243 | "push %%"R"dx; push %%"R"bp;" | 6235 | "push %%" _ASM_DX "; push %%" _ASM_BP ";" |
6244 | "push %%"R"cx \n\t" /* placeholder for guest rcx */ | 6236 | "push %%" _ASM_CX " \n\t" /* placeholder for guest rcx */ |
6245 | "push %%"R"cx \n\t" | 6237 | "push %%" _ASM_CX " \n\t" |
6246 | "cmp %%"R"sp, %c[host_rsp](%0) \n\t" | 6238 | "cmp %%" _ASM_SP ", %c[host_rsp](%0) \n\t" |
6247 | "je 1f \n\t" | 6239 | "je 1f \n\t" |
6248 | "mov %%"R"sp, %c[host_rsp](%0) \n\t" | 6240 | "mov %%" _ASM_SP ", %c[host_rsp](%0) \n\t" |
6249 | __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" | 6241 | __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" |
6250 | "1: \n\t" | 6242 | "1: \n\t" |
6251 | /* Reload cr2 if changed */ | 6243 | /* Reload cr2 if changed */ |
6252 | "mov %c[cr2](%0), %%"R"ax \n\t" | 6244 | "mov %c[cr2](%0), %%" _ASM_AX " \n\t" |
6253 | "mov %%cr2, %%"R"dx \n\t" | 6245 | "mov %%cr2, %%" _ASM_DX " \n\t" |
6254 | "cmp %%"R"ax, %%"R"dx \n\t" | 6246 | "cmp %%" _ASM_AX ", %%" _ASM_DX " \n\t" |
6255 | "je 2f \n\t" | 6247 | "je 2f \n\t" |
6256 | "mov %%"R"ax, %%cr2 \n\t" | 6248 | "mov %%" _ASM_AX", %%cr2 \n\t" |
6257 | "2: \n\t" | 6249 | "2: \n\t" |
6258 | /* Check if vmlaunch of vmresume is needed */ | 6250 | /* Check if vmlaunch of vmresume is needed */ |
6259 | "cmpl $0, %c[launched](%0) \n\t" | 6251 | "cmpl $0, %c[launched](%0) \n\t" |
6260 | /* Load guest registers. Don't clobber flags. */ | 6252 | /* Load guest registers. Don't clobber flags. */ |
6261 | "mov %c[rax](%0), %%"R"ax \n\t" | 6253 | "mov %c[rax](%0), %%" _ASM_AX " \n\t" |
6262 | "mov %c[rbx](%0), %%"R"bx \n\t" | 6254 | "mov %c[rbx](%0), %%" _ASM_BX " \n\t" |
6263 | "mov %c[rdx](%0), %%"R"dx \n\t" | 6255 | "mov %c[rdx](%0), %%" _ASM_DX " \n\t" |
6264 | "mov %c[rsi](%0), %%"R"si \n\t" | 6256 | "mov %c[rsi](%0), %%" _ASM_SI " \n\t" |
6265 | "mov %c[rdi](%0), %%"R"di \n\t" | 6257 | "mov %c[rdi](%0), %%" _ASM_DI " \n\t" |
6266 | "mov %c[rbp](%0), %%"R"bp \n\t" | 6258 | "mov %c[rbp](%0), %%" _ASM_BP " \n\t" |
6267 | #ifdef CONFIG_X86_64 | 6259 | #ifdef CONFIG_X86_64 |
6268 | "mov %c[r8](%0), %%r8 \n\t" | 6260 | "mov %c[r8](%0), %%r8 \n\t" |
6269 | "mov %c[r9](%0), %%r9 \n\t" | 6261 | "mov %c[r9](%0), %%r9 \n\t" |
@@ -6274,7 +6266,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6274 | "mov %c[r14](%0), %%r14 \n\t" | 6266 | "mov %c[r14](%0), %%r14 \n\t" |
6275 | "mov %c[r15](%0), %%r15 \n\t" | 6267 | "mov %c[r15](%0), %%r15 \n\t" |
6276 | #endif | 6268 | #endif |
6277 | "mov %c[rcx](%0), %%"R"cx \n\t" /* kills %0 (ecx) */ | 6269 | "mov %c[rcx](%0), %%" _ASM_CX " \n\t" /* kills %0 (ecx) */ |
6278 | 6270 | ||
6279 | /* Enter guest mode */ | 6271 | /* Enter guest mode */ |
6280 | "jne 1f \n\t" | 6272 | "jne 1f \n\t" |
@@ -6283,15 +6275,15 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6283 | "1: " __ex(ASM_VMX_VMRESUME) "\n\t" | 6275 | "1: " __ex(ASM_VMX_VMRESUME) "\n\t" |
6284 | "2: " | 6276 | "2: " |
6285 | /* Save guest registers, load host registers, keep flags */ | 6277 | /* Save guest registers, load host registers, keep flags */ |
6286 | "mov %0, %c[wordsize](%%"R"sp) \n\t" | 6278 | "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t" |
6287 | "pop %0 \n\t" | 6279 | "pop %0 \n\t" |
6288 | "mov %%"R"ax, %c[rax](%0) \n\t" | 6280 | "mov %%" _ASM_AX ", %c[rax](%0) \n\t" |
6289 | "mov %%"R"bx, %c[rbx](%0) \n\t" | 6281 | "mov %%" _ASM_BX ", %c[rbx](%0) \n\t" |
6290 | "pop"Q" %c[rcx](%0) \n\t" | 6282 | __ASM_SIZE(pop) " %c[rcx](%0) \n\t" |
6291 | "mov %%"R"dx, %c[rdx](%0) \n\t" | 6283 | "mov %%" _ASM_DX ", %c[rdx](%0) \n\t" |
6292 | "mov %%"R"si, %c[rsi](%0) \n\t" | 6284 | "mov %%" _ASM_SI ", %c[rsi](%0) \n\t" |
6293 | "mov %%"R"di, %c[rdi](%0) \n\t" | 6285 | "mov %%" _ASM_DI ", %c[rdi](%0) \n\t" |
6294 | "mov %%"R"bp, %c[rbp](%0) \n\t" | 6286 | "mov %%" _ASM_BP ", %c[rbp](%0) \n\t" |
6295 | #ifdef CONFIG_X86_64 | 6287 | #ifdef CONFIG_X86_64 |
6296 | "mov %%r8, %c[r8](%0) \n\t" | 6288 | "mov %%r8, %c[r8](%0) \n\t" |
6297 | "mov %%r9, %c[r9](%0) \n\t" | 6289 | "mov %%r9, %c[r9](%0) \n\t" |
@@ -6302,10 +6294,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6302 | "mov %%r14, %c[r14](%0) \n\t" | 6294 | "mov %%r14, %c[r14](%0) \n\t" |
6303 | "mov %%r15, %c[r15](%0) \n\t" | 6295 | "mov %%r15, %c[r15](%0) \n\t" |
6304 | #endif | 6296 | #endif |
6305 | "mov %%cr2, %%"R"ax \n\t" | 6297 | "mov %%cr2, %%" _ASM_AX " \n\t" |
6306 | "mov %%"R"ax, %c[cr2](%0) \n\t" | 6298 | "mov %%" _ASM_AX ", %c[cr2](%0) \n\t" |
6307 | 6299 | ||
6308 | "pop %%"R"bp; pop %%"R"dx \n\t" | 6300 | "pop %%" _ASM_BP "; pop %%" _ASM_DX " \n\t" |
6309 | "setbe %c[fail](%0) \n\t" | 6301 | "setbe %c[fail](%0) \n\t" |
6310 | ".pushsection .rodata \n\t" | 6302 | ".pushsection .rodata \n\t" |
6311 | ".global vmx_return \n\t" | 6303 | ".global vmx_return \n\t" |
@@ -6335,9 +6327,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6335 | [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)), | 6327 | [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)), |
6336 | [wordsize]"i"(sizeof(ulong)) | 6328 | [wordsize]"i"(sizeof(ulong)) |
6337 | : "cc", "memory" | 6329 | : "cc", "memory" |
6338 | , R"ax", R"bx", R"di", R"si" | ||
6339 | #ifdef CONFIG_X86_64 | 6330 | #ifdef CONFIG_X86_64 |
6331 | , "rax", "rbx", "rdi", "rsi" | ||
6340 | , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" | 6332 | , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" |
6333 | #else | ||
6334 | , "eax", "ebx", "edi", "esi" | ||
6341 | #endif | 6335 | #endif |
6342 | ); | 6336 | ); |
6343 | 6337 | ||
@@ -6389,9 +6383,6 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
6389 | vmx_complete_interrupts(vmx); | 6383 | vmx_complete_interrupts(vmx); |
6390 | } | 6384 | } |
6391 | 6385 | ||
6392 | #undef R | ||
6393 | #undef Q | ||
6394 | |||
6395 | static void vmx_free_vcpu(struct kvm_vcpu *vcpu) | 6386 | static void vmx_free_vcpu(struct kvm_vcpu *vcpu) |
6396 | { | 6387 | { |
6397 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 6388 | struct vcpu_vmx *vmx = to_vmx(vcpu); |