diff options
author | Avi Kivity <avi@qumranet.com> | 2008-07-17 11:04:30 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-10-15 04:15:15 -0400 |
commit | 313dbd49dc239205b96da79fba09f7637cf84f3c (patch) | |
tree | 4cc4989b88d23d9e351acd4759378774e789905c /arch/x86 | |
parent | 3b4bd7969f7b61a1ab455bff084ee4f0a2411055 (diff) |
KVM: VMX: Avoid vmwrite(HOST_RSP) when possible
Usually HOST_RSP retains its value across guest entries. Take advantage
of this and avoid a vmwrite() when this is so.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/vmx.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index fc8996b1043b..ddb49e34697b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -58,6 +58,7 @@ struct vmcs { | |||
58 | struct vcpu_vmx { | 58 | struct vcpu_vmx { |
59 | struct kvm_vcpu vcpu; | 59 | struct kvm_vcpu vcpu; |
60 | struct list_head local_vcpus_link; | 60 | struct list_head local_vcpus_link; |
61 | unsigned long host_rsp; | ||
61 | int launched; | 62 | int launched; |
62 | u8 fail; | 63 | u8 fail; |
63 | u32 idt_vectoring_info; | 64 | u32 idt_vectoring_info; |
@@ -2982,7 +2983,11 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
2982 | /* Store host registers */ | 2983 | /* Store host registers */ |
2983 | "push %%"R"dx; push %%"R"bp;" | 2984 | "push %%"R"dx; push %%"R"bp;" |
2984 | "push %%"R"cx \n\t" | 2985 | "push %%"R"cx \n\t" |
2986 | "cmp %%"R"sp, %c[host_rsp](%0) \n\t" | ||
2987 | "je 1f \n\t" | ||
2988 | "mov %%"R"sp, %c[host_rsp](%0) \n\t" | ||
2985 | __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" | 2989 | __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" |
2990 | "1: \n\t" | ||
2986 | /* Check if vmlaunch of vmresume is needed */ | 2991 | /* Check if vmlaunch of vmresume is needed */ |
2987 | "cmpl $0, %c[launched](%0) \n\t" | 2992 | "cmpl $0, %c[launched](%0) \n\t" |
2988 | /* Load guest registers. Don't clobber flags. */ | 2993 | /* Load guest registers. Don't clobber flags. */ |
@@ -3039,6 +3044,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
3039 | : : "c"(vmx), "d"((unsigned long)HOST_RSP), | 3044 | : : "c"(vmx), "d"((unsigned long)HOST_RSP), |
3040 | [launched]"i"(offsetof(struct vcpu_vmx, launched)), | 3045 | [launched]"i"(offsetof(struct vcpu_vmx, launched)), |
3041 | [fail]"i"(offsetof(struct vcpu_vmx, fail)), | 3046 | [fail]"i"(offsetof(struct vcpu_vmx, fail)), |
3047 | [host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp)), | ||
3042 | [rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])), | 3048 | [rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])), |
3043 | [rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])), | 3049 | [rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])), |
3044 | [rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])), | 3050 | [rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])), |