Re: [PATCH] kvm: x86: svm: remove SVM_EXIT_READ_CR* intercepts
From: Radim KrÄmÃÅ
Date: Mon Mar 16 2015 - 13:35:35 EST
2015-03-16 11:16-0500, Joel Schopp:
> On 03/12/2015 04:20 PM, Radim KrÄmÃÅ wrote:
> > 2015-03-12 15:17-0500, Joel Schopp:
> >> There isn't really a valid reason for kvm to intercept cr* reads
> >> on svm hardware. The current kvm code just ends up returning
> >> the register
> > There is no need to intercept CR* if the value that the guest should see
> > is equal to what we set there, but that is not always the case:
> > - CR0 might differ from what the guest should see because of lazy fpu
> Based on our previous conversations I understand why we have to trap the
> write to the CR0 ts bit for lazy fpu, but don't understand why that
> should affect a read.
KVM keeps one CR0 with guest's state (svm.vcpu.arch.cr0) and a second
one that is loaded to hardware CR0 on VMRUN (svm.vmcb->save.cr0);
these two might not match.
If we didn't intercept read, it would return hardware CR0, so the guest
could do CLTS (change svm.vcpu.arch.cr0) and read CR0.TS = 1, because of
lazy FPU.
Correct emulation is what we want.
> > CR2 and CR8 already aren't intercepted, so it looks like only CR0 and
> > CR4 could use some optimizations.
> I'll send out a v2 with these less aggressive optimizations.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/