From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: KVM: x86: use kvm_set_cr3/cr4 in ioctl_set_sregs
Date: Thu, 16 Apr 2009 12:23:56 +0300 [thread overview]
Message-ID: <49E6F92C.2000202@redhat.com> (raw)
In-Reply-To: <20090416091042.GA6709@amt.cnet>
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.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2009-04-16 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-15 22:10 KVM: x86: use kvm_set_cr3/cr4 in ioctl_set_sregs Marcelo Tosatti
2009-04-16 8:56 ` Avi Kivity
2009-04-16 9:10 ` Marcelo Tosatti
2009-04-16 9:23 ` Avi Kivity [this message]
2009-04-16 11:30 ` KVM: x86: check for cr3 validity " Marcelo Tosatti
2009-04-16 12:42 ` Avi Kivity
2009-04-16 12:49 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49E6F92C.2000202@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox