diff options
author | Avi Kivity <avi@redhat.com> | 2009-06-16 05:36:33 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:32:58 -0400 |
commit | b3dbf89e676e47ef3b10802f9aba5a8e04aba132 (patch) | |
tree | 22c22abc46306ab9d4d9f49f94a37da6a73685d1 /arch | |
parent | d3edefc0035669e8817d1d5c32ef03e882477323 (diff) |
KVM: SVM: Don't save/restore host cr2
The host never reads cr2 in process context, so are free to clobber it. The
vmx code does this, so we can safely remove the save/restore code.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/svm.c | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 060aa9f5571e..132be0c7c3eb 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -81,7 +81,6 @@ struct vcpu_svm { | |||
81 | 81 | ||
82 | u64 host_user_msrs[NR_HOST_SAVE_USER_MSRS]; | 82 | u64 host_user_msrs[NR_HOST_SAVE_USER_MSRS]; |
83 | u64 host_gs_base; | 83 | u64 host_gs_base; |
84 | unsigned long host_cr2; | ||
85 | 84 | ||
86 | u32 *msrpm; | 85 | u32 *msrpm; |
87 | struct vmcb *hsave; | 86 | struct vmcb *hsave; |
@@ -186,19 +185,6 @@ static inline void invlpga(unsigned long addr, u32 asid) | |||
186 | asm volatile (__ex(SVM_INVLPGA) :: "a"(addr), "c"(asid)); | 185 | asm volatile (__ex(SVM_INVLPGA) :: "a"(addr), "c"(asid)); |
187 | } | 186 | } |
188 | 187 | ||
189 | static inline unsigned long kvm_read_cr2(void) | ||
190 | { | ||
191 | unsigned long cr2; | ||
192 | |||
193 | asm volatile ("mov %%cr2, %0" : "=r" (cr2)); | ||
194 | return cr2; | ||
195 | } | ||
196 | |||
197 | static inline void kvm_write_cr2(unsigned long val) | ||
198 | { | ||
199 | asm volatile ("mov %0, %%cr2" :: "r" (val)); | ||
200 | } | ||
201 | |||
202 | static inline void force_new_asid(struct kvm_vcpu *vcpu) | 188 | static inline void force_new_asid(struct kvm_vcpu *vcpu) |
203 | { | 189 | { |
204 | to_svm(vcpu)->asid_generation--; | 190 | to_svm(vcpu)->asid_generation--; |
@@ -2527,7 +2513,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
2527 | fs_selector = kvm_read_fs(); | 2513 | fs_selector = kvm_read_fs(); |
2528 | gs_selector = kvm_read_gs(); | 2514 | gs_selector = kvm_read_gs(); |
2529 | ldt_selector = kvm_read_ldt(); | 2515 | ldt_selector = kvm_read_ldt(); |
2530 | svm->host_cr2 = kvm_read_cr2(); | ||
2531 | if (!is_nested(svm)) | 2516 | if (!is_nested(svm)) |
2532 | svm->vmcb->save.cr2 = vcpu->arch.cr2; | 2517 | svm->vmcb->save.cr2 = vcpu->arch.cr2; |
2533 | /* required for live migration with NPT */ | 2518 | /* required for live migration with NPT */ |
@@ -2614,8 +2599,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
2614 | vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp; | 2599 | vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp; |
2615 | vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip; | 2600 | vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip; |
2616 | 2601 | ||
2617 | kvm_write_cr2(svm->host_cr2); | ||
2618 | |||
2619 | kvm_load_fs(fs_selector); | 2602 | kvm_load_fs(fs_selector); |
2620 | kvm_load_gs(gs_selector); | 2603 | kvm_load_gs(gs_selector); |
2621 | kvm_load_ldt(ldt_selector); | 2604 | kvm_load_ldt(ldt_selector); |