KVM: Fix OSXSAVE after migration
PATCH 1/1 KVM: Fix OSXSAVE after migration
CPUID's OSXSAVE is a mirror of CR4.OSXSAVE bit. We need to update the CPUID after migration.
--- arch/x86/kvm/x86.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kvm/x86.c +2 -0
@@ -5585,6 +5585,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, mmu_reset_needed |=kvm_read_cr4 (vcpu) != sregs->cr4; kvm_x86_ops->set_cr4 (vcpu, sregs->cr4); +if (sregs->cr4 &X86_CR4_OSXSAVE ) +update_cpuid (vcpu);if (!is_long_mode (vcpu) &&is_pae (vcpu)) {load_pdptrs (vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); mmu_reset_needed =1 ;
Signature · 1 line
1.7.0.1
Avi Kivity
AppliedQuoted 3 lines · Sheng Yang
CPUID's OSXSAVE is a mirror of CR4.OSXSAVE bit. We need to update the CPUID after migration.
Applied, thanks.
arch/x86/kvm/x86.c int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, · line 5592
Quoted 9 lines
arch/x86/kvm/x86.c +2
-0@@ -5585,6 +5585,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, mmu_reset_needed |=kvm_read_cr4 (vcpu) != sregs->cr4; kvm_x86_ops->set_cr4 (vcpu, sregs->cr4); +if (sregs->cr4&X86_CR4_OSXSAVE ) +update_cpuid (vcpu);if (!is_long_mode (vcpu)&&is_pae (vcpu)) {load_pdptrs (vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); mmu_reset_needed =1 ;
We really should use kvm_set_crX() here.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 15 lines · On Wednesday 08 December 2010 18:33:43 Avi Kivity wrote:
Quoted 2 lines · Sheng Yang
CPUID's OSXSAVE is a mirror of CR4.OSXSAVE bit. We need to update the CPUID after migration.
Applied, thanks.
Quoted 9 lines
arch/x86/kvm/x86.c +2
-0@@ -5585,6 +5585,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, mmu_reset_needed |=kvm_read_cr4 (vcpu) != sregs->cr4; kvm_x86_ops->set_cr4 (vcpu, sregs->cr4); +if (sregs->cr4&X86_CR4_OSXSAVE ) +update_cpuid (vcpu);
Quoted 6 lines
Quoted 4 lines
if (!is_long_mode(vcpu)&& is_pae(vcpu)) { load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); mmu_reset_needed = 1;We really should use
kvm_set_crX()here.
Yeah, I suppose we use ops->set_cr4() here because we don't need to all kinds of check and operation for the value(which should already be done by other S/R code), so I just add update_cpuid() here.
--
regards
Yang, Sheng
Quoted 11 lines · Sheng Yang
Quoted 6 lines
Quoted 4 lines
if (!is_long_mode(vcpu)&& is_pae(vcpu)) { load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); mmu_reset_needed = 1;We really should use
kvm_set_crX()here.Yeah, I suppose we use
ops->set_cr4()here because we don't need to all kinds of check and operation for the value(which should already be done by other S/R code), so I just addupdate_cpuid()here.
IIRC the reason is that there are ordering constraints for kvm_set_crX (and kvm_set_efer). We should do a kvm_set_crs() which sets them all at once.
Signature · 1 line
error compiling committee.c: too many arguments to function