summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorGleb Natapov2009-04-21 16:45:06 +0200
committerAvi Kivity2009-06-10 10:48:47 +0200
commit0a5fff192388d2a74aa9ab5e0d394b745df9f225 (patch)
tree7d837d9673b746b3e869089b3753cf62361096dc /arch/x86/kvm/svm.c
parentKVM: sync_lapic_to_cr8() should always sync cr8 to V_TPR (diff)
downloadkernel-qcow2-linux-0a5fff192388d2a74aa9ab5e0d394b745df9f225.tar.gz
kernel-qcow2-linux-0a5fff192388d2a74aa9ab5e0d394b745df9f225.tar.xz
kernel-qcow2-linux-0a5fff192388d2a74aa9ab5e0d394b745df9f225.zip
KVM: Do not report TPR write to userspace if new value bigger or equal to a previous one.
Saves many exits to userspace in a case of IRQ chip in userspace. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 143818eff52e..e283a63b2bca 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1862,9 +1862,13 @@ static int emulate_on_interception(struct vcpu_svm *svm,
static int cr8_write_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
+ u8 cr8_prev = kvm_get_cr8(&svm->vcpu);
+ /* instruction emulation calls kvm_set_cr8() */
emulate_instruction(&svm->vcpu, NULL, 0, 0, 0);
if (irqchip_in_kernel(svm->vcpu.kvm))
return 1;
+ if (cr8_prev <= kvm_get_cr8(&svm->vcpu))
+ return 1;
kvm_run->exit_reason = KVM_EXIT_SET_TPR;
return 0;
}