Skip to content

Commit 94686c3

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Radim Krčmář: - fix build without CONFIG_HAVE_KVM_IRQ_ROUTING - fix NULL access in x86 CR access - fix race with VMX posted interrups * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: VMX: remove WARN_ON_ONCE in kvm_vcpu_trigger_posted_interrupt KVM: VMX: do not change SN bit in vmx_update_pi_irte() KVM: x86: Fix the NULL pointer parameter in check_cr_write() Revert "KVM: Don't accept obviously wrong gsi values via KVM_IRQFD"
2 parents 12fcf66 + 5753743 commit 94686c3

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

arch/x86/kvm/emulate.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,10 +4102,12 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
41024102
ctxt->ops->get_msr(ctxt, MSR_EFER, &efer);
41034103
if (efer & EFER_LMA) {
41044104
u64 maxphyaddr;
4105-
u32 eax = 0x80000008;
4105+
u32 eax, ebx, ecx, edx;
41064106

4107-
if (ctxt->ops->get_cpuid(ctxt, &eax, NULL, NULL,
4108-
NULL, false))
4107+
eax = 0x80000008;
4108+
ecx = 0;
4109+
if (ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx,
4110+
&edx, false))
41094111
maxphyaddr = eax & 0xff;
41104112
else
41114113
maxphyaddr = 36;

arch/x86/kvm/vmx.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,21 +5077,30 @@ static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
50775077
int pi_vec = nested ? POSTED_INTR_NESTED_VECTOR : POSTED_INTR_VECTOR;
50785078

50795079
if (vcpu->mode == IN_GUEST_MODE) {
5080-
struct vcpu_vmx *vmx = to_vmx(vcpu);
5081-
50825080
/*
5083-
* Currently, we don't support urgent interrupt,
5084-
* all interrupts are recognized as non-urgent
5085-
* interrupt, so we cannot post interrupts when
5086-
* 'SN' is set.
5081+
* The vector of interrupt to be delivered to vcpu had
5082+
* been set in PIR before this function.
5083+
*
5084+
* Following cases will be reached in this block, and
5085+
* we always send a notification event in all cases as
5086+
* explained below.
5087+
*
5088+
* Case 1: vcpu keeps in non-root mode. Sending a
5089+
* notification event posts the interrupt to vcpu.
50875090
*
5088-
* If the vcpu is in guest mode, it means it is
5089-
* running instead of being scheduled out and
5090-
* waiting in the run queue, and that's the only
5091-
* case when 'SN' is set currently, warning if
5092-
* 'SN' is set.
5091+
* Case 2: vcpu exits to root mode and is still
5092+
* runnable. PIR will be synced to vIRR before the
5093+
* next vcpu entry. Sending a notification event in
5094+
* this case has no effect, as vcpu is not in root
5095+
* mode.
5096+
*
5097+
* Case 3: vcpu exits to root mode and is blocked.
5098+
* vcpu_block() has already synced PIR to vIRR and
5099+
* never blocks vcpu if vIRR is not cleared. Therefore,
5100+
* a blocked vcpu here does not wait for any requested
5101+
* interrupts in PIR, and sending a notification event
5102+
* which has no effect is safe here.
50935103
*/
5094-
WARN_ON_ONCE(pi_test_sn(&vmx->pi_desc));
50955104

50965105
apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec);
50975106
return true;
@@ -11911,12 +11920,8 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
1191111920

1191211921
if (set)
1191311922
ret = irq_set_vcpu_affinity(host_irq, &vcpu_info);
11914-
else {
11915-
/* suppress notification event before unposting */
11916-
pi_set_sn(vcpu_to_pi_desc(vcpu));
11923+
else
1191711924
ret = irq_set_vcpu_affinity(host_irq, NULL);
11918-
pi_clear_sn(vcpu_to_pi_desc(vcpu));
11919-
}
1192011925

1192111926
if (ret < 0) {
1192211927
printk(KERN_INFO "%s: failed to update PI IRTE\n",

virt/kvm/eventfd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,6 @@ kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
565565
{
566566
if (args->flags & ~(KVM_IRQFD_FLAG_DEASSIGN | KVM_IRQFD_FLAG_RESAMPLE))
567567
return -EINVAL;
568-
if (args->gsi >= KVM_MAX_IRQ_ROUTES)
569-
return -EINVAL;
570568

571569
if (args->flags & KVM_IRQFD_FLAG_DEASSIGN)
572570
return kvm_irqfd_deassign(kvm, args);

0 commit comments

Comments
 (0)