From: Steve Rutherford <srutherford@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v5 4/4] KVM: x86: Add support for local interrupt requests from userspace
Date: Tue, 28 Jul 2015 12:06:35 -0700 [thread overview]
Message-ID: <20150728190635.GA7460@google.com> (raw)
In-Reply-To: <55B7A6AE.5070001@redhat.com>
On Tue, Jul 28, 2015 at 05:58:38PM +0200, Paolo Bonzini wrote:
>
>
> On 28/07/2015 01:17, Steve Rutherford wrote:
> > return kvm->arch.vpic;
> > }
> >
> > +static inline int pic_in_kernel(struct kvm *kvm)
> > +{
> > + int ret;
> > +
> > + ret = (pic_irqchip(kvm) != NULL);
> > + smp_rmb();
>
> What does this memory barrier pair with? I don't think it's necessary.
To be honest, it's probably not necessary. I couldn't find why
irqchip_in_kernel (which this function is more or less a copy of)
needed it's memory barrier, so I cargo culted this one in.
>
> > + return ret;
> > +}
> > +
> > static inline int irqchip_split(struct kvm *kvm)
> > {
> > return kvm->arch.irqchip_split;
>
>
> > @@ -5819,13 +5828,24 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
> > kvm_run->flags = is_smm(vcpu) ? KVM_RUN_X86_SMM : 0;
> > kvm_run->cr8 = kvm_get_cr8(vcpu);
> > kvm_run->apic_base = kvm_get_apic_base(vcpu);
> > - if (irqchip_in_kernel(vcpu->kvm))
> > + if (irqchip_in_kernel(vcpu->kvm) && pic_in_kernel(vcpu->kvm))
> > kvm_run->ready_for_interrupt_injection = 1;
> > - else
> > + else if (irqchip_in_kernel(vcpu->kvm)) {
> > + int ready_for_interrupt_injection =
> > + kvm_apic_accept_pic_intr(vcpu);
> > +
> > + if (!kvm_run->ready_for_interrupt_injection &&
> > + ready_for_interrupt_injection)
> > + kvm_make_request(KVM_REQ_PIC_UNMASK_EXIT, vcpu);
> > +
> > + kvm_run->ready_for_interrupt_injection =
> > + ready_for_interrupt_injection;
> > + } else {
> > kvm_run->ready_for_interrupt_injection =
> > kvm_arch_interrupt_allowed(vcpu) &&
> > !kvm_cpu_has_interrupt(vcpu) &&
> > !kvm_event_needs_reinjection(vcpu);
> > + }
> > }
> >
> > static void update_cr8_intercept(struct kvm_vcpu *vcpu)
>
> Why is this necessary? Could it just set
> kvm_run->ready_for_interrupt_injection as in the pic_in_kernel case?
The goal is to couple the interrupt ack cycle as closely as possible
with the injection of the local interrupt (which occur more or less
atomically on real hardware). The idea is to only ever attempt to
inject local interrupts when the CPU/APIC is ready to immediately
accept.
If the CPU is ignoring the PIC, the interrupt acknowledge cycle should
not be performed, even if the PIC is high. This patch uses the
ready_for_interrupt_injection flag to let userspace whether or not the
cpu is paying attention to the PIC at the moment.
When the PIC is high and the CPU transitions from ignoring the PIC to
paying attention to the PIC, it should (per real hardware)
immediately trigger an interrupt acknowledge cycle (which requires
bouncing up to userspace).
Steve
>
> Paolo
next prev parent reply other threads:[~2015-07-28 19:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 23:17 [PATCH v5 1/4] KVM: x86: Split the APIC from the rest of IRQCHIP Steve Rutherford
2015-07-27 23:17 ` [PATCH v5 2/4] KVM: x86: Add KVM exit for IOAPIC EOIs Steve Rutherford
2015-07-27 23:17 ` [PATCH v5 3/4] KVM: x86: Add EOI exit bitmap inference Steve Rutherford
2015-07-29 12:38 ` Paolo Bonzini
2015-07-29 20:27 ` Steve Rutherford
2015-07-30 6:23 ` Jan Kiszka
2015-07-30 6:27 ` Steve Rutherford
2015-07-27 23:17 ` [PATCH v5 4/4] KVM: x86: Add support for local interrupt requests from userspace Steve Rutherford
2015-07-28 15:58 ` Paolo Bonzini
2015-07-28 19:06 ` Steve Rutherford [this message]
2015-07-28 22:05 ` Paolo Bonzini
2015-07-29 0:50 ` Steve Rutherford
2015-07-29 10:21 ` Paolo Bonzini
2015-07-29 10:15 ` Paolo Bonzini
2015-07-29 12:56 ` [PATCH v5 1/4] KVM: x86: Split the APIC from the rest of IRQCHIP Paolo Bonzini
2015-07-30 3:04 ` Steve Rutherford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150728190635.GA7460@google.com \
--to=srutherford@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).