linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] VGIC early initialization initiated by user-space
@ 2014-12-15 17:43 Eric Auger
  2014-12-15 17:43 ` [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Eric Auger
  2014-12-15 17:43 ` [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device Eric Auger
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Auger @ 2014-12-15 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

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 series now allows the user space to explicitly request the VGIC init,
when the dimensioning parameters have been set: number of IRQs, number of
vCPUs. The target state is "initialized".

- the first patch file changes the error returned by vgic_init when no
  online vcpu can be found.
- the second adds a new entry to the VGIC KVM device that allows
  the user-space 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

Applies on top of Christoffer's series:
"[PATCH v2 0/6] Fix vgic initialization problems"

- can be found at:
  http://git.linaro.org/people/eric.auger/linux.git,
  branch kvmarm-next-vgic-early-init-v3-official)

v2 -> v3:
- in KVM_DEV_ARM_VGIC_GRP_CTRL: vgic_init is called in place of former
  kvm_vgic_init. Means this control moves the VGIC in initialized state
  and not in ready state as before.
- "[PATCH v2 3/4] KVM: arm/arm64: check vgic_initialized before VCPU creation"
  removed since included in Christoffer's
  "arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized"
- [PATCH v2 4/4] KVM: arm/arm64: vgic: check vgic_initialized in
  KVM_DEV_ARM_VGIC_GRP_ADDR removed since I noticed vgic_ioaddr_assign
  would return -EEXIST in case vgic_map_resources were already been called.
- rewording in cover letter

v1 -> v2:
- 1, 3, 4 patch files added
- some rewording in vgic device documentation


Eric Auger (2):
  KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu
  KVM: arm/arm64: vgic: add init entry to VGIC KVM device

 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                            | 16 ++++++++++++++--
 4 files changed, 29 insertions(+), 2 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu
  2014-12-15 17:43 [PATCH v3 0/2] VGIC early initialization initiated by user-space Eric Auger
@ 2014-12-15 17:43 ` Eric Auger
  2015-01-11 12:40   ` Christoffer Dall
  2014-12-15 17:43 ` [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device Eric Auger
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Auger @ 2014-12-15 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

To be more explicit on vgic initialization failure, -ENODEV is
returned by vgic_init when no online vcpus can be found at init.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v2 -> v3: vgic_init_maps was renamed into vgic_init
---
 virt/kvm/arm/vgic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index e373b76..d61a61f 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1809,7 +1809,7 @@ static int vgic_init(struct kvm *kvm)
 
 	nr_cpus = dist->nr_cpus = atomic_read(&kvm->online_vcpus);
 	if (!nr_cpus)		/* No vcpus? Can't be good... */
-		return -EINVAL;
+		return -ENODEV;
 
 	/*
 	 * If nobody configured the number of interrupts, use the
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device
  2014-12-15 17:43 [PATCH v3 0/2] VGIC early initialization initiated by user-space Eric Auger
  2014-12-15 17:43 ` [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Eric Auger
@ 2014-12-15 17:43 ` Eric Auger
  2015-01-11 12:39   ` Christoffer Dall
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Auger @ 2014-12-15 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

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>

---

v2 -> v3:
- kvm_vgic_init replaced vgic_init. This means the target state now
  is initialized and no more "ready"

v1 -> v2:
- some rewording in arm-vgic.txt and in the commit message
---
 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 d61a61f..f7acda0 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;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device
  2014-12-15 17:43 ` [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device Eric Auger
@ 2015-01-11 12:39   ` Christoffer Dall
  0 siblings, 0 replies; 5+ messages in thread
From: Christoffer Dall @ 2015-01-11 12:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Dec 15, 2014 at 06:43:33PM +0100, Eric Auger wrote:
> 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>
> 
This looks good to me:

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu
  2014-12-15 17:43 ` [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Eric Auger
@ 2015-01-11 12:40   ` Christoffer Dall
  0 siblings, 0 replies; 5+ messages in thread
From: Christoffer Dall @ 2015-01-11 12:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Dec 15, 2014 at 06:43:32PM +0100, Eric Auger wrote:
> To be more explicit on vgic initialization failure, -ENODEV is
> returned by vgic_init when no online vcpus can be found at init.
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-11 12:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-15 17:43 [PATCH v3 0/2] VGIC early initialization initiated by user-space Eric Auger
2014-12-15 17:43 ` [PATCH v3 1/2] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Eric Auger
2015-01-11 12:40   ` Christoffer Dall
2014-12-15 17:43 ` [PATCH v3 2/2] KVM: arm/arm64: vgic: add init entry to VGIC KVM device Eric Auger
2015-01-11 12:39   ` Christoffer Dall

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).