aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2009-04-21 10:45:06 -0400
committerAvi Kivity <avi@redhat.com>2009-06-10 04:48:47 -0400
commit0a5fff192388d2a74aa9ab5e0d394b745df9f225 (patch)
tree7d837d9673b746b3e869089b3753cf62361096dc /arch/x86/kvm
parent615d5193055880d44db92b72403b7549251ac2a6 (diff)
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')
-rw-r--r--arch/x86/kvm/svm.c4
-rw-r--r--arch/x86/kvm/vmx.c19
2 files changed, 16 insertions, 7 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,
1862 1862
1863static int cr8_write_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1863static int cr8_write_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1864{ 1864{
1865 u8 cr8_prev = kvm_get_cr8(&svm->vcpu);
1866 /* instruction emulation calls kvm_set_cr8() */
1865 emulate_instruction(&svm->vcpu, NULL, 0, 0, 0); 1867 emulate_instruction(&svm->vcpu, NULL, 0, 0, 0);
1866 if (irqchip_in_kernel(svm->vcpu.kvm)) 1868 if (irqchip_in_kernel(svm->vcpu.kvm))
1867 return 1; 1869 return 1;
1870 if (cr8_prev <= kvm_get_cr8(&svm->vcpu))
1871 return 1;
1868 kvm_run->exit_reason = KVM_EXIT_SET_TPR; 1872 kvm_run->exit_reason = KVM_EXIT_SET_TPR;
1869 return 0; 1873 return 0;
1870} 1874}
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9162b4cd3410..51f804c8fe79 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2724,13 +2724,18 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2724 kvm_set_cr4(vcpu, kvm_register_read(vcpu, reg)); 2724 kvm_set_cr4(vcpu, kvm_register_read(vcpu, reg));
2725 skip_emulated_instruction(vcpu); 2725 skip_emulated_instruction(vcpu);
2726 return 1; 2726 return 1;
2727 case 8: 2727 case 8: {
2728 kvm_set_cr8(vcpu, kvm_register_read(vcpu, reg)); 2728 u8 cr8_prev = kvm_get_cr8(vcpu);
2729 skip_emulated_instruction(vcpu); 2729 u8 cr8 = kvm_register_read(vcpu, reg);
2730 if (irqchip_in_kernel(vcpu->kvm)) 2730 kvm_set_cr8(vcpu, cr8);
2731 return 1; 2731 skip_emulated_instruction(vcpu);
2732 kvm_run->exit_reason = KVM_EXIT_SET_TPR; 2732 if (irqchip_in_kernel(vcpu->kvm))
2733 return 0; 2733 return 1;
2734 if (cr8_prev <= cr8)
2735 return 1;
2736 kvm_run->exit_reason = KVM_EXIT_SET_TPR;
2737 return 0;
2738 }
2734 }; 2739 };
2735 break; 2740 break;
2736 case 2: /* clts */ 2741 case 2: /* clts */