linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [GIT PULL 02/36] KVM: arm/arm64: vgic: add init entry to VGIC KVM device
Date: Fri, 23 Jan 2015 11:02:31 +0100	[thread overview]
Message-ID: <1422007385-14730-3-git-send-email-christoffer.dall@linaro.org> (raw)
In-Reply-To: <1422007385-14730-1-git-send-email-christoffer.dall@linaro.org>

From: Eric Auger <eric.auger@linaro.org>

Since the advent of VGIC dynamic initialization, this latter is
initialized quite late on the first vcpu run or "on-demand", when
injecting an IRQ or when the guest sets its registers.

This initialization could be initiated explicitly much earlier
by the users-space, as soon as it has provided the requested
dimensioning parameters.

This patch adds a new entry to the VGIC KVM device that allows
the user to manually request the VGIC init:
- a new KVM_DEV_ARM_VGIC_GRP_CTRL group is introduced.
- Its first attribute is KVM_DEV_ARM_VGIC_CTRL_INIT

The rationale behind introducing a group is to be able to add other
controls later on, if needed.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 Documentation/virtual/kvm/devices/arm-vgic.txt | 11 +++++++++++
 arch/arm/include/uapi/asm/kvm.h                |  2 ++
 arch/arm64/include/uapi/asm/kvm.h              |  2 ++
 virt/kvm/arm/vgic.c                            | 14 +++++++++++++-
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/virtual/kvm/devices/arm-vgic.txt b/Documentation/virtual/kvm/devices/arm-vgic.txt
index df8b0c7..30f5427 100644
--- a/Documentation/virtual/kvm/devices/arm-vgic.txt
+++ b/Documentation/virtual/kvm/devices/arm-vgic.txt
@@ -81,3 +81,14 @@ Groups:
     -EINVAL: Value set is out of the expected range
     -EBUSY: Value has already be set, or GIC has already been initialized
             with default values.
+
+  KVM_DEV_ARM_VGIC_GRP_CTRL
+  Attributes:
+    KVM_DEV_ARM_VGIC_CTRL_INIT
+      request the initialization of the VGIC, no additional parameter in
+      kvm_device_attr.addr.
+  Errors:
+    -ENXIO: VGIC not properly configured as required prior to calling
+     this attribute
+    -ENODEV: no online VCPU
+    -ENOMEM: memory shortage when allocating vgic internal data
diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 09ee408..0db25bc 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -175,6 +175,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT	0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK	(0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS	3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL       4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT    0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT		24
diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h
index 8e38878..480af34 100644
--- a/arch/arm64/include/uapi/asm/kvm.h
+++ b/arch/arm64/include/uapi/asm/kvm.h
@@ -161,6 +161,8 @@ struct kvm_arch_memory_slot {
 #define   KVM_DEV_ARM_VGIC_OFFSET_SHIFT	0
 #define   KVM_DEV_ARM_VGIC_OFFSET_MASK	(0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)
 #define KVM_DEV_ARM_VGIC_GRP_NR_IRQS	3
+#define KVM_DEV_ARM_VGIC_GRP_CTRL	4
+#define   KVM_DEV_ARM_VGIC_CTRL_INIT	0
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT		24
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index b8d57e8..c84f53df 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -2302,7 +2302,14 @@ static int vgic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
 
 		return ret;
 	}
-
+	case KVM_DEV_ARM_VGIC_GRP_CTRL: {
+		switch (attr->attr) {
+		case KVM_DEV_ARM_VGIC_CTRL_INIT:
+			r = vgic_init(dev->kvm);
+			return r;
+		}
+		break;
+	}
 	}
 
 	return -ENXIO;
@@ -2381,6 +2388,11 @@ static int vgic_has_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
 		return vgic_has_attr_regs(vgic_cpu_ranges, offset);
 	case KVM_DEV_ARM_VGIC_GRP_NR_IRQS:
 		return 0;
+	case KVM_DEV_ARM_VGIC_GRP_CTRL:
+		switch (attr->attr) {
+		case KVM_DEV_ARM_VGIC_CTRL_INIT:
+			return 0;
+		}
 	}
 	return -ENXIO;
 }
-- 
2.1.2.330.g565301e.dirty

  parent reply	other threads:[~2015-01-23 10:02 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 10:02 [GIT PULL 00/36] KVM/ARM changes for 3.20 Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 01/36] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Christoffer Dall
2015-01-23 10:02 ` Christoffer Dall [this message]
2015-01-23 10:02 ` [GIT PULL 03/36] arm/arm64: KVM: add tracing support for arm64 exit handler Christoffer Dall
2015-01-23 11:35   ` Mark Rutland
2015-01-23 12:01     ` Paolo Bonzini
2015-01-23 12:49       ` Paolo Bonzini
2015-01-23 12:55         ` Christoffer Dall
2015-01-23 13:41         ` Mark Rutland
2015-01-23 10:02 ` [GIT PULL 04/36] ARM: KVM: extend WFI tracepoint to differentiate between wfi and wfe Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 05/36] KVM: Add architecture-defined TLB flush support Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 06/36] KVM: Add generic support for dirty page logging Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 07/36] KVM: x86: switch to kvm_get_dirty_log_protect Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 08/36] KVM: arm: Add ARMv7 API to flush TLBs Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 09/36] KVM: arm: Add initial dirty page locking support Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 10/36] KVM: arm: dirty logging write protect support Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 11/36] KVM: arm: page logging 2nd stage fault handling Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 12/36] KVM: arm64: ARMv8 header changes for page logging Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 13/36] KVM: arm64: Add HYP interface to flush VM Stage 1/2 TLB entries Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 14/36] KVM: arm/arm64: Enable Dirty Page logging for ARMv8 Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 15/36] arm/arm64: KVM: rework MPIDR assignment and add accessors Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 16/36] arm/arm64: KVM: pass down user space provided GIC type into vGIC code Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 17/36] arm/arm64: KVM: refactor vgic_handle_mmio() function Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 18/36] arm/arm64: KVM: wrap 64 bit MMIO accesses with two 32 bit ones Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 19/36] arm/arm64: KVM: introduce per-VM ops Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 20/36] arm/arm64: KVM: move kvm_register_device_ops() into vGIC probing Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 21/36] arm/arm64: KVM: dont rely on a valid GICH base address Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 22/36] arm/arm64: KVM: make the maximum number of vCPUs a per-VM value Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 23/36] arm/arm64: KVM: make the value of ICC_SRE_EL1 a per-VM variable Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 24/36] arm/arm64: KVM: refactor MMIO accessors Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 25/36] arm/arm64: KVM: refactor/wrap vgic_set/get_attr() Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 26/36] arm/arm64: KVM: add vgic.h header file Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 27/36] arm/arm64: KVM: split GICv2 specific emulation code from vgic.c Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 28/36] arm/arm64: KVM: add opaque private pointer to MMIO data Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 29/36] arm/arm64: KVM: add virtual GICv3 distributor emulation Christoffer Dall
2015-01-23 10:02 ` [GIT PULL 30/36] arm64: GICv3: introduce symbolic names for GICv3 ICC_SGI1R_EL1 fields Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 31/36] arm64: KVM: add SGI generation register emulation Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 32/36] arm/arm64: KVM: enable kernel side of GICv3 emulation Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 33/36] arm/arm64: KVM: allow userland to request a virtual GICv3 Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 34/36] arm/arm64: KVM: force alignment of VGIC dist/CPU/redist addresses Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 35/36] arm/arm64: KVM: Fixup incorrect config symbol in comment Christoffer Dall
2015-01-23 10:03 ` [GIT PULL 36/36] KVM: Remove unused config symbol Christoffer Dall

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=1422007385-14730-3-git-send-email-christoffer.dall@linaro.org \
    --to=christoffer.dall@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).