Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-15 Thread Lai Jiangshan
On Thu, Apr 15, 2021 at 2:07 PM Paolo Bonzini wrote: > > On 15/04/21 02:59, Lai Jiangshan wrote: > > The next call to inject_pending_event() will reach here AT FIRST with > > vcpu->arch.exception.injected==false and vcpu->arch.exception.pending==false > > > >> ... if (!vcpu->arch.excepti

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-14 Thread Paolo Bonzini
On 15/04/21 02:59, Lai Jiangshan wrote: The next call to inject_pending_event() will reach here AT FIRST with vcpu->arch.exception.injected==false and vcpu->arch.exception.pending==false ... if (!vcpu->arch.exception.pending) { if (vcpu->arch.nmi_injected) {

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-14 Thread Lai Jiangshan
On Thu, Apr 15, 2021 at 12:58 AM Paolo Bonzini wrote: > > On 14/04/21 04:28, Lai Jiangshan wrote: > > On Tue, Apr 13, 2021 at 8:15 PM Paolo Bonzini wrote: > >> > >> On 13/04/21 13:03, Lai Jiangshan wrote: > >>> This patch claims that it has a place to > >>> stash the IRQ when EFLAGS.IF=0, but inj

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-14 Thread Paolo Bonzini
On 14/04/21 04:28, Lai Jiangshan wrote: On Tue, Apr 13, 2021 at 8:15 PM Paolo Bonzini wrote: On 13/04/21 13:03, Lai Jiangshan wrote: This patch claims that it has a place to stash the IRQ when EFLAGS.IF=0, but inject_pending_event() seams to ignore EFLAGS.IF and queues the IRQ to the guest di

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-13 Thread Lai Jiangshan
On Tue, Apr 13, 2021 at 8:15 PM Paolo Bonzini wrote: > > On 13/04/21 13:03, Lai Jiangshan wrote: > > This patch claims that it has a place to > > stash the IRQ when EFLAGS.IF=0, but inject_pending_event() seams to ignore > > EFLAGS.IF and queues the IRQ to the guest directly in the first branch >

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-13 Thread Paolo Bonzini
On 13/04/21 13:03, Lai Jiangshan wrote: This patch claims that it has a place to stash the IRQ when EFLAGS.IF=0, but inject_pending_event() seams to ignore EFLAGS.IF and queues the IRQ to the guest directly in the first branch of using "kvm_x86_ops.set_irq(vcpu)". This is only true for pure-use

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-13 Thread Paolo Bonzini
On 12/04/21 23:43, Sean Christopherson wrote: where kvm_arch_interrupt_allowed() checks EFLAGS.IF (and an edge case related to nested virtualization). KVM also captures EFLAGS.IF in vcpu->run->if_flag. For whatever reason, QEMU checks both vcpu->run flags before injecting an IRQ, maybe to handle

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-13 Thread Lai Jiangshan
On Tue, Apr 13, 2021 at 5:43 AM Sean Christopherson wrote: > > On Fri, Apr 09, 2021, Lai Jiangshan wrote: > > On Fri, Nov 27, 2020 at 7:26 PM Paolo Bonzini wrote: > > > > > > kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are > > > a hodge-podge of conditions, hacked together t

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-12 Thread Sean Christopherson
On Fri, Apr 09, 2021, Lai Jiangshan wrote: > On Fri, Nov 27, 2020 at 7:26 PM Paolo Bonzini wrote: > > > > kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are > > a hodge-podge of conditions, hacked together to get something that > > more or less works. But what is actually neede

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-09 Thread Lai Jiangshan
On Fri, Nov 27, 2020 at 7:26 PM Paolo Bonzini wrote: > > kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are > a hodge-podge of conditions, hacked together to get something that > more or less works. But what is actually needed is much simpler; > in both cases the fundamental qu

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2020-11-27 Thread Filippo Sironi
On 11/27/20 12:21 PM, Paolo Bonzini wrote: kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are a hodge-podge of conditions, hacked together to get something that more or less works. But what is actually needed is much simpler; in both cases the fundamental question is, do we

[PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2020-11-27 Thread Paolo Bonzini
kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are a hodge-podge of conditions, hacked together to get something that more or less works. But what is actually needed is much simpler; in both cases the fundamental question is, do we have a place to stash an interrupt if userspace