mirror of
https://github.com/torvalds/linux.git
synced 2024-11-07 20:51:47 +00:00
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>
This commit is contained in:
parent
615d519305
commit
0a5fff1923
@ -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)
|
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);
|
emulate_instruction(&svm->vcpu, NULL, 0, 0, 0);
|
||||||
if (irqchip_in_kernel(svm->vcpu.kvm))
|
if (irqchip_in_kernel(svm->vcpu.kvm))
|
||||||
return 1;
|
return 1;
|
||||||
|
if (cr8_prev <= kvm_get_cr8(&svm->vcpu))
|
||||||
|
return 1;
|
||||||
kvm_run->exit_reason = KVM_EXIT_SET_TPR;
|
kvm_run->exit_reason = KVM_EXIT_SET_TPR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2724,13 +2724,18 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
|||||||
kvm_set_cr4(vcpu, kvm_register_read(vcpu, reg));
|
kvm_set_cr4(vcpu, kvm_register_read(vcpu, reg));
|
||||||
skip_emulated_instruction(vcpu);
|
skip_emulated_instruction(vcpu);
|
||||||
return 1;
|
return 1;
|
||||||
case 8:
|
case 8: {
|
||||||
kvm_set_cr8(vcpu, kvm_register_read(vcpu, reg));
|
u8 cr8_prev = kvm_get_cr8(vcpu);
|
||||||
skip_emulated_instruction(vcpu);
|
u8 cr8 = kvm_register_read(vcpu, reg);
|
||||||
if (irqchip_in_kernel(vcpu->kvm))
|
kvm_set_cr8(vcpu, cr8);
|
||||||
return 1;
|
skip_emulated_instruction(vcpu);
|
||||||
kvm_run->exit_reason = KVM_EXIT_SET_TPR;
|
if (irqchip_in_kernel(vcpu->kvm))
|
||||||
return 0;
|
return 1;
|
||||||
|
if (cr8_prev <= cr8)
|
||||||
|
return 1;
|
||||||
|
kvm_run->exit_reason = KVM_EXIT_SET_TPR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 2: /* clts */
|
case 2: /* clts */
|
||||||
|
Loading…
Reference in New Issue
Block a user