From: Paul Mackerras <paulus@samba.org>
To: Scott Wood <scottwood@freescale.com>
Cc: Alexander Graf <agraf@suse.de>,
kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH] KVM: Add KVM_CAP_IRQ_ARCH capability
Date: Fri, 15 Mar 2013 09:19:17 +1100 [thread overview]
Message-ID: <20130314221917.GI9841@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <1363285238.28440.9@snotra>
On Thu, Mar 14, 2013 at 01:20:38PM -0500, Scott Wood wrote:
> On 03/13/2013 08:20:44 PM, Paul Mackerras wrote:
> >--- a/arch/powerpc/include/asm/kvm_host.h
> >+++ b/arch/powerpc/include/asm/kvm_host.h
> >@@ -373,6 +373,9 @@ struct kvmppc_booke_debug_reg {
> > struct kvm_vcpu_arch {
> > ulong host_stack;
> > u32 host_pid;
> >+
> >+ u32 intr_ctrler;
> >+
>
> That abbreviation seems a bit awkward, and we should also have a
> private-data pointer.
>
> How about:
>
> u32 irq_arch;
> void *irq_priv;
Regarding the irq_priv - in my patchset the XICS code adds its own
private data pointer. That has the advantage that it can be strongly
typed, and if it is non-NULL then I know it points to XICS data, not
the data for some other type of controller. As long as we are only
going to have a small number of IRQ architectures then it's feasible
to allow each to have its own data pointer, and we get the advantages
of strong typing.
> >+ switch (cap->args[0]) {
> >+ case 0: /* no interrupt controller */
> >+ break;
>
> s/0/KVM_IRQ_ARCH_NONE/
>
> ...at least so that this patch makes it clear where other type ids
> should
> be defined.
OK, whatever.
> >+ default:
> >+ r = -EINVAL;
> >+ }
> >+ if (!r) {
> >+ /*
> >+ * Make sure any state set up by the interrupt
> >+ * controller init routine is seen before this.
> >+ */
> >+ smp_wmb();
> >+ vcpu->arch.intr_ctrler = cap->args[0];
> >+ }
>
> Do we really need that wmb()? We're in vcpu context, right? If the
> vcpu
> migrates to another host cpu, that involves rescheduling which already
> has a sync. If the interrupt controller code we call here modifies data
> that will be seen from outside the vcpu, it's the responsibility of that
> code to use whatever locks, barriers, etc. are needed (and it's
> unlikely
> that vcpu->arch.intr_ctrler will be the relevant thing that it needs to
> order with).
OK, you're right, the generic KVM code serializes most vcpu ioctls,
including KVM_RUN and KVM_ENABLE_CAP, so the barrier isn't in fact
needed.
> This patch should also add a hook at vcpu destruction to call into the
> irq code.
You appear to have missed this hunk:
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 934413c..891603e 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -459,6 +459,12 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
hrtimer_cancel(&vcpu->arch.dec_timer);
tasklet_kill(&vcpu->arch.tasklet);
+ /* Release any per-vcpu irq controller state */
+ switch (vcpu->arch.intr_ctrler) {
+ default:
+ break;
+ }
+
kvmppc_remove_vcpu_debugfs(vcpu);
kvmppc_core_vcpu_free(vcpu);
}
Paul.
next prev parent reply other threads:[~2013-03-14 22:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-14 1:20 [PATCH] KVM: Add KVM_CAP_IRQ_ARCH capability Paul Mackerras
2013-03-14 18:20 ` Scott Wood
2013-03-14 18:33 ` Alexander Graf
2013-03-14 18:35 ` Scott Wood
2013-03-14 19:03 ` Alexander Graf
2013-03-14 19:10 ` Scott Wood
2013-03-14 21:46 ` Alexander Graf
2013-03-14 22:28 ` Paul Mackerras
2013-03-14 22:38 ` Scott Wood
2013-03-14 22:19 ` Paul Mackerras [this message]
2013-03-14 22:41 ` Scott Wood
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=20130314221917.GI9841@iris.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=scottwood@freescale.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