Message ID | 20090416091042.GA6709@amt.cnet (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Marcelo Tosatti wrote: > Humpf. And something like this? Or GP# instead of triple fault? > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 148cde2..3e63bac 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3986,7 +3986,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, > > vcpu->arch.cr2 = sregs->cr2; > mmu_reset_needed |= vcpu->arch.cr3 != sregs->cr3; > - vcpu->arch.cr3 = sregs->cr3; > + if (gfn_to_memslot(vcpu->kvm, sregs->cr3 >> PAGE_SHIFT)) > + vcpu->arch.cr3 = sregs->cr3; > + else > + set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests); > > kvm_set_cr8(vcpu, sregs->cr8); > Well, that plugs the hole. Triple fault is better than #GP IMO. We're still missing checks on reserved bits, etc., but that can come later.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 148cde2..3e63bac 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3986,7 +3986,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, vcpu->arch.cr2 = sregs->cr2; mmu_reset_needed |= vcpu->arch.cr3 != sregs->cr3; - vcpu->arch.cr3 = sregs->cr3; + if (gfn_to_memslot(vcpu->kvm, sregs->cr3 >> PAGE_SHIFT)) + vcpu->arch.cr3 = sregs->cr3; + else + set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests); kvm_set_cr8(vcpu, sregs->cr8);