public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>, kvm@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org, Scott Wood <scottwood@freescale.com>
Subject: [PATCH] KVM: Add KVM_CAP_IRQ_ARCH capability
Date: Thu, 14 Mar 2013 12:20:44 +1100	[thread overview]
Message-ID: <20130314012044.GA12273@drongo> (raw)

Setting this capability on a vcpu connects that vcpu to an interrupt
controller device.  The args[0] field of the argument kvm_enable_cap
struct specifies the overall architecture of the interrupt
controller.  The args[1] field specifies the CPU number for the vcpu
from the interrupt controller's point of view.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/include/asm/kvm_host.h |    3 +++
 arch/powerpc/kvm/powerpc.c          |   29 +++++++++++++++++++++++++++++
 include/uapi/linux/kvm.h            |    1 +
 3 files changed, 33 insertions(+)

diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index f4ba881..dd167e4 100644
--- 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;
+
 #ifdef CONFIG_PPC_BOOK3S
 	struct kvmppc_slb slb[64];
 	int slb_max;		/* 1 + index of last valid entry in slb[] */
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);
 }
@@ -791,6 +797,29 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
 		break;
 	}
 #endif
+	case KVM_CAP_IRQ_ARCH:
+		r = -EBUSY;
+		mutex_lock(&vcpu->kvm->lock);
+		/* disallow changing once set */
+		if (!vcpu->arch.intr_ctrler) {
+			r = 0;
+			switch (cap->args[0]) {
+			case 0:		/* no interrupt controller */
+				break;
+			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];
+			}
+		}
+		mutex_unlock(&vcpu->kvm->lock);
+		break;
 	default:
 		r = -EINVAL;
 		break;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 1f348e0..d875d37 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -663,6 +663,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_S390_CSS_SUPPORT 85
 #define KVM_CAP_PPC_EPR 86
 #define KVM_CAP_DEVICE_CTRL 87
+#define KVM_CAP_IRQ_ARCH 88
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
-- 
1.7.10.4

             reply	other threads:[~2013-03-14  1:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14  1:20 Paul Mackerras [this message]
2013-03-14 18:20 ` [PATCH] KVM: Add KVM_CAP_IRQ_ARCH capability 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
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=20130314012044.GA12273@drongo \
    --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