diff options
author | Avi Kivity <avi@redhat.com> | 2011-01-06 11:09:12 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2011-03-17 12:08:26 -0400 |
commit | 40712faeb84dacfcb3925a88231daa08b3624d34 (patch) | |
tree | f2d916b387dcf6613a4a3a43d10f96b979eb17f2 /arch | |
parent | 1c696d0e1b7c10e1e8b34cb6c797329e3c33f262 (diff) |
KVM: VMX: Avoid atomic operation in vmx_vcpu_run
Instead of exchanging the guest and host rcx, have separate storage
for each. This allows us to avoid using the xchg instruction, which
is is a little slower than normal operations.
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 | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index da468c26639..ae4f02d4709 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -4022,6 +4022,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
4022 | asm( | 4022 | asm( |
4023 | /* Store host registers */ | 4023 | /* Store host registers */ |
4024 | "push %%"R"dx; push %%"R"bp;" | 4024 | "push %%"R"dx; push %%"R"bp;" |
4025 | "push %%"R"cx \n\t" /* placeholder for guest rcx */ | ||
4025 | "push %%"R"cx \n\t" | 4026 | "push %%"R"cx \n\t" |
4026 | "cmp %%"R"sp, %c[host_rsp](%0) \n\t" | 4027 | "cmp %%"R"sp, %c[host_rsp](%0) \n\t" |
4027 | "je 1f \n\t" | 4028 | "je 1f \n\t" |
@@ -4063,7 +4064,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
4063 | ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t" | 4064 | ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t" |
4064 | ".Lkvm_vmx_return: " | 4065 | ".Lkvm_vmx_return: " |
4065 | /* Save guest registers, load host registers, keep flags */ | 4066 | /* Save guest registers, load host registers, keep flags */ |
4066 | "xchg %0, (%%"R"sp) \n\t" | 4067 | "mov %0, %c[wordsize](%%"R"sp) \n\t" |
4068 | "pop %0 \n\t" | ||
4067 | "mov %%"R"ax, %c[rax](%0) \n\t" | 4069 | "mov %%"R"ax, %c[rax](%0) \n\t" |
4068 | "mov %%"R"bx, %c[rbx](%0) \n\t" | 4070 | "mov %%"R"bx, %c[rbx](%0) \n\t" |
4069 | "pop"Q" %c[rcx](%0) \n\t" | 4071 | "pop"Q" %c[rcx](%0) \n\t" |
@@ -4107,7 +4109,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) | |||
4107 | [r14]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R14])), | 4109 | [r14]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R14])), |
4108 | [r15]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R15])), | 4110 | [r15]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R15])), |
4109 | #endif | 4111 | #endif |
4110 | [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)) | 4112 | [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)), |
4113 | [wordsize]"i"(sizeof(ulong)) | ||
4111 | : "cc", "memory" | 4114 | : "cc", "memory" |
4112 | , R"ax", R"bx", R"di", R"si" | 4115 | , R"ax", R"bx", R"di", R"si" |
4113 | #ifdef CONFIG_X86_64 | 4116 | #ifdef CONFIG_X86_64 |