On 21.11.2008, at 18:07, Avi Kivity wrote:
Alexander Graf wrote:
Neat trick. Have you looked at svm.c to see if we can cut out
extraneous instructions (or move them out of the gif=0 area)?
Could mean big savings.
Well for now I only emulate pre-vmrun and vmsave, because the
emulator breaks on lldt and set dr6 and ltr and ...
Yeah. We could move some of these out, and emulate the rest (ltr I
think is needed).
Then older versions of kvm would still break and other hypervisors
have a high chance of failing as well. It would be better to implement
the instructions in the emulator first, but I'm somewhat lost in that
code base.
Move to the regular x86 emulator, so if we extend it with debug
flag support, privilege checking, etc, we get that for svm as well.
Do you seriously want to have a callback to svm specific code in
the x86 emulator?
That's what kvm_x86_ops is for. We already emulate vendor specific
instructions (vmcall and vmmcall).
From what I can tell kvm_x86_ops tries to multiplex calls that happen
to be different on svm/vmx, but existent on both. SVM instructions
usually don't appear on VMX ;-).
I was thinking of doing that, but this way looked way cleaner to
me. I would actually rather use prefixes as hint on pattern matching.
So e.g. if we find a clgi instruction with some random prefix (or
somehow marked in other ways) we could just run a pattern that does
what the entry code would do. This way no emulation would be needed.
Smells like dynamic translation to me. I don't see how you could do
that generically -- it might work for one version of kvm, but not
for other hypervisors.
Yes, this would require one pattern for one series of kvm revisions.
As long as that particular code path doesn't change too much, we
should be fine. And usually it doesn't. We just have to take
paravirt_ops and the like from the equation.
static int nested_svm_vmexit_real(struct vcpu_svm *svm, void *arg1,
void *arg2, void *opaque)
{
@@ -1551,6 +1600,9 @@ static int nested_svm_vmexit(struct
vcpu_svm *svm)
kvm_mmu_reset_context(&svm->vcpu);
kvm_mmu_load(&svm->vcpu);
+ /* KVM calls vmsave after vmrun, so let's run it now if we
can */
+ nested_svm_emulate(svm, NULL);
+
Will also call stgi eventually, so it may make sense to loop here
too.
See above - I did that, it broke, I tried to debug it for ~2 days
and just figured I'll leave it as is for now.
Certainly, we can leave it for later.
The current version gives _huge_ savings already.
Can you quantify?
Subjective speedup was like three times. But I could be wrong. I
haven't measured it, since I wanted to have a "full GIF=0
emulation" (which I failed on) for measurement.
I'm off for a short weekend vacation - and be back on tuesday. I
probably will be mostly offline in between.
Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html