kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates
@ 2014-08-05  8:49 Anup Patel
  2014-08-05  8:49 ` [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

This patchset updates KVMTOOL to use some of the features
supported by Linux-3.16 KVM ARM/ARM64, such as:

1. Target CPU == Host using KVM_ARM_PREFERRED_TARGET vm ioctl
2. Target CPU type Potenza for using KVMTOOL on X-Gene
3. PSCI v0.2 support for Aarch32 and Aarch64 guest
4. System event exit reason

Anup Patel (5):
  kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine
    target cpu
  kvmtool: ARM64: Fix compile error for aarch64
  kvmtool: ARM64: Add target type potenza for aarch64
  kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM
    supports it

 tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
 tools/kvm/arm/aarch64/kvm-cpu.c |   11 -----------
 tools/kvm/arm/fdt.c             |   39 +++++++++++++++++++++++++++++++++------
 tools/kvm/arm/kvm-cpu.c         |   26 +++++++++++++++++++++-----
 tools/kvm/kvm-cpu.c             |    6 ++++++
 5 files changed, 68 insertions(+), 23 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
@ 2014-08-05  8:49 ` Anup Patel
  2014-08-06 12:48   ` Will Deacon
  2014-08-05  8:49 ` [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64 Anup Patel
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

Instead, of trying out each and every target type we should use
KVM_ARM_PREFERRED_TARGET vm ioctl to determine target type
for KVM ARM/ARM64.

We bail-out target type returned by KVM_ARM_PREFERRED_TARGET vm ioctl
is not known to kvmtool.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 tools/kvm/arm/kvm-cpu.c |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
index aeaa4cf..7478f8f 100644
--- a/tools/kvm/arm/kvm-cpu.c
+++ b/tools/kvm/arm/kvm-cpu.c
@@ -34,6 +34,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	struct kvm_cpu *vcpu;
 	int coalesced_offset, mmap_size, err = -1;
 	unsigned int i;
+	struct kvm_vcpu_init preferred_init;
 	struct kvm_vcpu_init vcpu_init = {
 		.features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
 	};
@@ -46,6 +47,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	if (vcpu->vcpu_fd < 0)
 		die_perror("KVM_CREATE_VCPU ioctl");
 
+	err = ioctl(kvm->vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
+	if (err < 0)
+		die_perror("KVM_ARM_PREFERRED_TARGET ioctl");
+
 	mmap_size = ioctl(kvm->sys_fd, KVM_GET_VCPU_MMAP_SIZE, 0);
 	if (mmap_size < 0)
 		die_perror("KVM_GET_VCPU_MMAP_SIZE ioctl");
@@ -55,17 +60,22 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	if (vcpu->kvm_run == MAP_FAILED)
 		die("unable to mmap vcpu fd");
 
-	/* Find an appropriate target CPU type. */
+	/* Match preferred target CPU type. */
+	target = NULL;
 	for (i = 0; i < ARRAY_SIZE(kvm_arm_targets); ++i) {
 		if (!kvm_arm_targets[i])
 			continue;
-		target = kvm_arm_targets[i];
-		vcpu_init.target = target->id;
-		err = ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu_init);
-		if (!err)
+		if (kvm_arm_targets[i]->id == preferred_init.target) {
+			target = kvm_arm_targets[i];
 			break;
+		}
+	}
+	if (!target) {
+		die("preferred target not available\n");
 	}
 
+	vcpu_init.target = preferred_init.target;
+	err = ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu_init);
 	if (err || target->init(vcpu))
 		die("Unable to initialise ARM vcpu");
 
@@ -81,6 +91,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	vcpu->cpu_type		= target->id;
 	vcpu->cpu_compatible	= target->compatible;
 	vcpu->is_running	= true;
+
 	return vcpu;
 }
 
-- 
1.7.9.5


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

* [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
  2014-08-05  8:49 ` [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
@ 2014-08-05  8:49 ` Anup Patel
  2014-08-06 12:50   ` Will Deacon
  2014-08-05  8:49 ` [PATCH 3/5] kvmtool: ARM64: Add target type potenza " Anup Patel
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

The __ARM64_SYS_REG() macro is already defined in uapi/asm/kvm.h
of Linux-3.16-rcX hence remove it from arm/aarch64/kvm-cpu.c

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 tools/kvm/arm/aarch64/kvm-cpu.c |   11 -----------
 1 file changed, 11 deletions(-)

diff --git a/tools/kvm/arm/aarch64/kvm-cpu.c b/tools/kvm/arm/aarch64/kvm-cpu.c
index 71a2a3a..545171b 100644
--- a/tools/kvm/arm/aarch64/kvm-cpu.c
+++ b/tools/kvm/arm/aarch64/kvm-cpu.c
@@ -19,17 +19,6 @@
 	(((x) << KVM_REG_ARM64_SYSREG_ ## n ## _SHIFT) &	\
 	 KVM_REG_ARM64_SYSREG_ ## n ## _MASK)
 
-#define __ARM64_SYS_REG(op0,op1,crn,crm,op2)			\
-	(KVM_REG_ARM64 | KVM_REG_SIZE_U64		|	\
-	 KVM_REG_ARM64_SYSREG				|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op0, OP0)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op1, OP1)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(crn, CRN)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(crm, CRM)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op2, OP2))
-
-#define ARM64_SYS_REG(...)	__ARM64_SYS_REG(__VA_ARGS__)
-
 unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu)
 {
 	struct kvm_one_reg reg;
-- 
1.7.9.5


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

* [PATCH 3/5] kvmtool: ARM64: Add target type potenza for aarch64
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
  2014-08-05  8:49 ` [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
  2014-08-05  8:49 ` [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64 Anup Patel
@ 2014-08-05  8:49 ` Anup Patel
  2014-08-06 12:52   ` Will Deacon
  2014-08-05  8:49 ` [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT Anup Patel
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

The VCPU target type KVM_ARM_TARGET_XGENE_POTENZA is available
in latest Linux-3.16-rcX or higher hence register aarch64 target
type for it.

This patch enables us to run KVMTOOL on X-Gene Potenza host.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/kvm/arm/aarch64/arm-cpu.c b/tools/kvm/arm/aarch64/arm-cpu.c
index ce5ea2f..ce526e3 100644
--- a/tools/kvm/arm/aarch64/arm-cpu.c
+++ b/tools/kvm/arm/aarch64/arm-cpu.c
@@ -41,10 +41,17 @@ static struct kvm_arm_target target_cortex_a57 = {
 	.init		= arm_cpu__vcpu_init,
 };
 
+static struct kvm_arm_target target_potenza = {
+	.id		= KVM_ARM_TARGET_XGENE_POTENZA,
+	.compatible	= "arm,arm-v8",
+	.init		= arm_cpu__vcpu_init,
+};
+
 static int arm_cpu__core_init(struct kvm *kvm)
 {
 	return (kvm_cpu__register_kvm_arm_target(&target_aem_v8) ||
 		kvm_cpu__register_kvm_arm_target(&target_foundation_v8) ||
-		kvm_cpu__register_kvm_arm_target(&target_cortex_a57));
+		kvm_cpu__register_kvm_arm_target(&target_cortex_a57) ||
+		kvm_cpu__register_kvm_arm_target(&target_potenza));
 }
 core_init(arm_cpu__core_init);
-- 
1.7.9.5


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

* [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
                   ` (2 preceding siblings ...)
  2014-08-05  8:49 ` [PATCH 3/5] kvmtool: ARM64: Add target type potenza " Anup Patel
@ 2014-08-05  8:49 ` Anup Patel
  2014-08-06 12:53   ` Will Deacon
  2014-08-05  8:49 ` [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it Anup Patel
  2014-08-05  8:53 ` [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
  5 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

The KVM_EXIT_SYSTEM_EVENT exit reason was added to define
architecture independent system-wide events for a Guest.

Currently, it is used by in-kernel PSCI-0.2 emulation of
KVM ARM/ARM64 to inform user space about PSCI SYSTEM_OFF
or PSCI SYSTEM_RESET request.

For now, we simply treat all system-wide guest events as
same and shutdown the guest upon KVM_EXIT_SYSTEM_EVENT.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 tools/kvm/kvm-cpu.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index ee0a8ec..e20ee4b 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -160,6 +160,12 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
 			goto exit_kvm;
 		case KVM_EXIT_SHUTDOWN:
 			goto exit_kvm;
+		case KVM_EXIT_SYSTEM_EVENT:
+			/*
+			 * Treat both SHUTDOWN & RESET system events
+			 * as shutdown request.
+			 */
+			goto exit_kvm;
 		default: {
 			bool ret;
 
-- 
1.7.9.5


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

* [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
                   ` (3 preceding siblings ...)
  2014-08-05  8:49 ` [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT Anup Patel
@ 2014-08-05  8:49 ` Anup Patel
  2014-08-06 12:56   ` Will Deacon
  2014-08-05  8:53 ` [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
  5 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:49 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, patches, will.deacon, marc.zyngier, penberg,
	christoffer.dall, pranavkumar, Anup Patel

If in-kernel KVM support PSCI-0.2 emulation then we should set
KVM_ARM_VCPU_PSCI_0_2 feature for each guest VCPU and also
provide "arm,psci-0.2","arm,psci" as PSCI compatible string.

This patch updates kvm_cpu__arch_init() and setup_fdt() as
per above.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 tools/kvm/arm/fdt.c     |   39 +++++++++++++++++++++++++++++++++------
 tools/kvm/arm/kvm-cpu.c |    5 +++++
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/arm/fdt.c b/tools/kvm/arm/fdt.c
index 186a718..93849cf2 100644
--- a/tools/kvm/arm/fdt.c
+++ b/tools/kvm/arm/fdt.c
@@ -13,6 +13,7 @@
 #include <linux/byteorder.h>
 #include <linux/kernel.h>
 #include <linux/sizes.h>
+#include <linux/psci.h>
 
 static char kern_cmdline[COMMAND_LINE_SIZE];
 
@@ -162,12 +163,38 @@ static int setup_fdt(struct kvm *kvm)
 
 	/* PSCI firmware */
 	_FDT(fdt_begin_node(fdt, "psci"));
-	_FDT(fdt_property_string(fdt, "compatible", "arm,psci"));
-	_FDT(fdt_property_string(fdt, "method", "hvc"));
-	_FDT(fdt_property_cell(fdt, "cpu_suspend", KVM_PSCI_FN_CPU_SUSPEND));
-	_FDT(fdt_property_cell(fdt, "cpu_off", KVM_PSCI_FN_CPU_OFF));
-	_FDT(fdt_property_cell(fdt, "cpu_on", KVM_PSCI_FN_CPU_ON));
-	_FDT(fdt_property_cell(fdt, "migrate", KVM_PSCI_FN_MIGRATE));
+	if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
+		const char compatible[] = "arm,psci-0.2\0arm,psci";
+		_FDT(fdt_property(fdt, "compatible",
+				  compatible, sizeof(compatible)));
+		_FDT(fdt_property_string(fdt, "method", "hvc"));
+		if (kvm->cfg.arch.aarch32_guest) {
+			_FDT(fdt_property_cell(fdt, "cpu_suspend",
+					PSCI_0_2_FN_CPU_SUSPEND));
+			_FDT(fdt_property_cell(fdt, "cpu_off",
+					PSCI_0_2_FN_CPU_OFF));
+			_FDT(fdt_property_cell(fdt, "cpu_on",
+					PSCI_0_2_FN_CPU_ON));
+			_FDT(fdt_property_cell(fdt, "migrate",
+					PSCI_0_2_FN_MIGRATE));
+		} else {
+			_FDT(fdt_property_cell(fdt, "cpu_suspend",
+					PSCI_0_2_FN64_CPU_SUSPEND));
+			_FDT(fdt_property_cell(fdt, "cpu_off",
+					PSCI_0_2_FN_CPU_OFF));
+			_FDT(fdt_property_cell(fdt, "cpu_on",
+					PSCI_0_2_FN64_CPU_ON));
+			_FDT(fdt_property_cell(fdt, "migrate",
+					PSCI_0_2_FN64_MIGRATE));
+		}
+	} else {
+		_FDT(fdt_property_string(fdt, "compatible", "arm,psci"));
+		_FDT(fdt_property_string(fdt, "method", "hvc"));
+		_FDT(fdt_property_cell(fdt, "cpu_suspend", KVM_PSCI_FN_CPU_SUSPEND));
+		_FDT(fdt_property_cell(fdt, "cpu_off", KVM_PSCI_FN_CPU_OFF));
+		_FDT(fdt_property_cell(fdt, "cpu_on", KVM_PSCI_FN_CPU_ON));
+		_FDT(fdt_property_cell(fdt, "migrate", KVM_PSCI_FN_MIGRATE));
+	}
 	_FDT(fdt_end_node(fdt));
 
 	/* Finalise. */
diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
index 7478f8f..76c28a0 100644
--- a/tools/kvm/arm/kvm-cpu.c
+++ b/tools/kvm/arm/kvm-cpu.c
@@ -74,6 +74,11 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 		die("preferred target not available\n");
 	}
 
+	/* Set KVM_ARM_VCPU_PSCI_0_2 if available */
+	if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
+		vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2);
+	}
+
 	vcpu_init.target = preferred_init.target;
 	err = ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu_init);
 	if (err || target->init(vcpu))
-- 
1.7.9.5


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

* Re: [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates
  2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
                   ` (4 preceding siblings ...)
  2014-08-05  8:49 ` [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it Anup Patel
@ 2014-08-05  8:53 ` Anup Patel
  5 siblings, 0 replies; 23+ messages in thread
From: Anup Patel @ 2014-08-05  8:53 UTC (permalink / raw)
  To: kvmarm@lists.cs.columbia.edu
  Cc: kvm@vger.kernel.org, patches, Will Deacon, Marc Zyngier, penberg,
	Christoffer Dall, Pranavkumar Sawargaonkar, Anup Patel

On 5 August 2014 14:19, Anup Patel <anup.patel@linaro.org> wrote:
> This patchset updates KVMTOOL to use some of the features
> supported by Linux-3.16 KVM ARM/ARM64, such as:
>
> 1. Target CPU == Host using KVM_ARM_PREFERRED_TARGET vm ioctl
> 2. Target CPU type Potenza for using KVMTOOL on X-Gene
> 3. PSCI v0.2 support for Aarch32 and Aarch64 guest
> 4. System event exit reason
>
> Anup Patel (5):
>   kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine
>     target cpu
>   kvmtool: ARM64: Fix compile error for aarch64
>   kvmtool: ARM64: Add target type potenza for aarch64
>   kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT
>   kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM
>     supports it
>
>  tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
>  tools/kvm/arm/aarch64/kvm-cpu.c |   11 -----------
>  tools/kvm/arm/fdt.c             |   39 +++++++++++++++++++++++++++++++++------
>  tools/kvm/arm/kvm-cpu.c         |   26 +++++++++++++++++++++-----
>  tools/kvm/kvm-cpu.c             |    6 ++++++
>  5 files changed, 68 insertions(+), 23 deletions(-)
>
> --
> 1.7.9.5
>

Hi All,

This patchset is tested on X-Gene Mustang and Foundation v8 model.

Regards,
Anup

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

* Re: [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu
  2014-08-05  8:49 ` [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
@ 2014-08-06 12:48   ` Will Deacon
  2014-08-07  8:44     ` Anup Patel
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-06 12:48 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Tue, Aug 05, 2014 at 09:49:55AM +0100, Anup Patel wrote:
> Instead, of trying out each and every target type we should use
> KVM_ARM_PREFERRED_TARGET vm ioctl to determine target type
> for KVM ARM/ARM64.
> 
> We bail-out target type returned by KVM_ARM_PREFERRED_TARGET vm ioctl
> is not known to kvmtool.

-ENOPARSE

> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  tools/kvm/arm/kvm-cpu.c |   21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
> index aeaa4cf..7478f8f 100644
> --- a/tools/kvm/arm/kvm-cpu.c
> +++ b/tools/kvm/arm/kvm-cpu.c
> @@ -34,6 +34,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>  	struct kvm_cpu *vcpu;
>  	int coalesced_offset, mmap_size, err = -1;
>  	unsigned int i;
> +	struct kvm_vcpu_init preferred_init;
>  	struct kvm_vcpu_init vcpu_init = {
>  		.features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
>  	};
> @@ -46,6 +47,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>  	if (vcpu->vcpu_fd < 0)
>  		die_perror("KVM_CREATE_VCPU ioctl");
>  
> +	err = ioctl(kvm->vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
> +	if (err < 0)
> +		die_perror("KVM_ARM_PREFERRED_TARGET ioctl");

Is this ioctl always available? If not, I don't like dying here as that
could cause a regression under older hosts.

Will

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

* Re: [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-05  8:49 ` [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64 Anup Patel
@ 2014-08-06 12:50   ` Will Deacon
  2014-08-07  8:50     ` Anup Patel
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-06 12:50 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Tue, Aug 05, 2014 at 09:49:56AM +0100, Anup Patel wrote:
> The __ARM64_SYS_REG() macro is already defined in uapi/asm/kvm.h
> of Linux-3.16-rcX hence remove it from arm/aarch64/kvm-cpu.c

I've been carrying a similar patch in my kvmtool/arm branch, but upstream
kvmtool is still based on 3.13, so this isn't needed at the moment.

Do you have a need for Pekka to merge in the latest kernel sources?

Will

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

* Re: [PATCH 3/5] kvmtool: ARM64: Add target type potenza for aarch64
  2014-08-05  8:49 ` [PATCH 3/5] kvmtool: ARM64: Add target type potenza " Anup Patel
@ 2014-08-06 12:52   ` Will Deacon
  2014-08-07  8:56     ` Anup Patel
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-06 12:52 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Tue, Aug 05, 2014 at 09:49:57AM +0100, Anup Patel wrote:
> The VCPU target type KVM_ARM_TARGET_XGENE_POTENZA is available
> in latest Linux-3.16-rcX or higher hence register aarch64 target
> type for it.
> 
> This patch enables us to run KVMTOOL on X-Gene Potenza host.
> 
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/kvm/arm/aarch64/arm-cpu.c b/tools/kvm/arm/aarch64/arm-cpu.c
> index ce5ea2f..ce526e3 100644
> --- a/tools/kvm/arm/aarch64/arm-cpu.c
> +++ b/tools/kvm/arm/aarch64/arm-cpu.c
> @@ -41,10 +41,17 @@ static struct kvm_arm_target target_cortex_a57 = {
>  	.init		= arm_cpu__vcpu_init,
>  };
>  
> +static struct kvm_arm_target target_potenza = {
> +	.id		= KVM_ARM_TARGET_XGENE_POTENZA,
> +	.compatible	= "arm,arm-v8",
> +	.init		= arm_cpu__vcpu_init,
> +};

This implies you have the same PPIs for the arch-timer as the Cortex-A CPUs.
Is that right?

Will

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

* Re: [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  2014-08-05  8:49 ` [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT Anup Patel
@ 2014-08-06 12:53   ` Will Deacon
  2014-08-07  8:57     ` Anup Patel
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-06 12:53 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Tue, Aug 05, 2014 at 09:49:58AM +0100, Anup Patel wrote:
> The KVM_EXIT_SYSTEM_EVENT exit reason was added to define
> architecture independent system-wide events for a Guest.
> 
> Currently, it is used by in-kernel PSCI-0.2 emulation of
> KVM ARM/ARM64 to inform user space about PSCI SYSTEM_OFF
> or PSCI SYSTEM_RESET request.
> 
> For now, we simply treat all system-wide guest events as
> same and shutdown the guest upon KVM_EXIT_SYSTEM_EVENT.
> 
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  tools/kvm/kvm-cpu.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
> index ee0a8ec..e20ee4b 100644
> --- a/tools/kvm/kvm-cpu.c
> +++ b/tools/kvm/kvm-cpu.c
> @@ -160,6 +160,12 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
>  			goto exit_kvm;
>  		case KVM_EXIT_SHUTDOWN:
>  			goto exit_kvm;
> +		case KVM_EXIT_SYSTEM_EVENT:
> +			/*
> +			 * Treat both SHUTDOWN & RESET system events
> +			 * as shutdown request.
> +			 */
> +			goto exit_kvm;

Can we figure out whether this was a SHUTDOWN or RESET request? If so,
printing a message for the latter "RESET request received -- exiting KVM"
might be informative.

Will

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

* Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
  2014-08-05  8:49 ` [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it Anup Patel
@ 2014-08-06 12:56   ` Will Deacon
  2014-08-07  9:00     ` Anup Patel
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-06 12:56 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Tue, Aug 05, 2014 at 09:49:59AM +0100, Anup Patel wrote:
> If in-kernel KVM support PSCI-0.2 emulation then we should set
> KVM_ARM_VCPU_PSCI_0_2 feature for each guest VCPU and also
> provide "arm,psci-0.2","arm,psci" as PSCI compatible string.
> 
> This patch updates kvm_cpu__arch_init() and setup_fdt() as
> per above.
> 
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  tools/kvm/arm/fdt.c     |   39 +++++++++++++++++++++++++++++++++------
>  tools/kvm/arm/kvm-cpu.c |    5 +++++
>  2 files changed, 38 insertions(+), 6 deletions(-)

[...]

> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
> index 7478f8f..76c28a0 100644
> --- a/tools/kvm/arm/kvm-cpu.c
> +++ b/tools/kvm/arm/kvm-cpu.c
> @@ -74,6 +74,11 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>  		die("preferred target not available\n");
>  	}
>  
> +	/* Set KVM_ARM_VCPU_PSCI_0_2 if available */
> +	if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
> +		vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2);
> +	}

Where is this used?

Will

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

* Re: [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu
  2014-08-06 12:48   ` Will Deacon
@ 2014-08-07  8:44     ` Anup Patel
  2014-08-07  8:52       ` Peter Maydell
  0 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-07  8:44 UTC (permalink / raw)
  To: Will Deacon
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On 6 August 2014 18:18, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Aug 05, 2014 at 09:49:55AM +0100, Anup Patel wrote:
>> Instead, of trying out each and every target type we should use
>> KVM_ARM_PREFERRED_TARGET vm ioctl to determine target type
>> for KVM ARM/ARM64.
>>
>> We bail-out target type returned by KVM_ARM_PREFERRED_TARGET vm ioctl
>> is not known to kvmtool.
>
> -ENOPARSE

OK, I will fix the wordings here.

>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>  tools/kvm/arm/kvm-cpu.c |   21 ++++++++++++++++-----
>>  1 file changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
>> index aeaa4cf..7478f8f 100644
>> --- a/tools/kvm/arm/kvm-cpu.c
>> +++ b/tools/kvm/arm/kvm-cpu.c
>> @@ -34,6 +34,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>>       struct kvm_cpu *vcpu;
>>       int coalesced_offset, mmap_size, err = -1;
>>       unsigned int i;
>> +     struct kvm_vcpu_init preferred_init;
>>       struct kvm_vcpu_init vcpu_init = {
>>               .features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
>>       };
>> @@ -46,6 +47,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>>       if (vcpu->vcpu_fd < 0)
>>               die_perror("KVM_CREATE_VCPU ioctl");
>>
>> +     err = ioctl(kvm->vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
>> +     if (err < 0)
>> +             die_perror("KVM_ARM_PREFERRED_TARGET ioctl");
>
> Is this ioctl always available? If not, I don't like dying here as that
> could cause a regression under older hosts.

The KVM_ARM_PREFERRED_TARGET ioctl is available from 3.13 onwards.

I think we should first try KVM_ARM_PREFERRED_TARGET. If it fails then
we should fallback to old method of trying each and every target type.
What say?

--
Anup

>
> Will

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

* Re: [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-06 12:50   ` Will Deacon
@ 2014-08-07  8:50     ` Anup Patel
  2014-08-07  9:12       ` Will Deacon
  0 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-07  8:50 UTC (permalink / raw)
  To: Will Deacon
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On 6 August 2014 18:20, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Aug 05, 2014 at 09:49:56AM +0100, Anup Patel wrote:
>> The __ARM64_SYS_REG() macro is already defined in uapi/asm/kvm.h
>> of Linux-3.16-rcX hence remove it from arm/aarch64/kvm-cpu.c
>
> I've been carrying a similar patch in my kvmtool/arm branch, but upstream
> kvmtool is still based on 3.13, so this isn't needed at the moment.
>
> Do you have a need for Pekka to merge in the latest kernel sources?
>
> Will

Yes, we should syncup KVMTOOL with latest kernel sources.

I want to be able to shutdown VM when using KVMTOOL. To do
this we need to use PSCI-v0.2 from Guest kernel.

--
Anup

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

* Re: [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu
  2014-08-07  8:44     ` Anup Patel
@ 2014-08-07  8:52       ` Peter Maydell
  0 siblings, 0 replies; 23+ messages in thread
From: Peter Maydell @ 2014-08-07  8:52 UTC (permalink / raw)
  To: Anup Patel
  Cc: Will Deacon, kvm@vger.kernel.org, patches@apm.com,
	penberg@kernel.org, kvmarm@lists.cs.columbia.edu

On 7 August 2014 09:44, Anup Patel <anup.patel@linaro.org> wrote:
> The KVM_ARM_PREFERRED_TARGET ioctl is available from 3.13 onwards.
>
> I think we should first try KVM_ARM_PREFERRED_TARGET. If it fails then
> we should fallback to old method of trying each and every target type.

You don't need to try every target type, only the ones which
were implemented prior to PREFERRED_TARGET. So that's
just TARGET_CORTEX_A15 for 32 bit and TARGET_AEM_V8,
TARGET_FOUNDATION_V8 and TARGET_CORTEX_A57
for 64 bit.

thanks
-- PMM

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

* Re: [PATCH 3/5] kvmtool: ARM64: Add target type potenza for aarch64
  2014-08-06 12:52   ` Will Deacon
@ 2014-08-07  8:56     ` Anup Patel
  2014-08-07  9:01       ` Will Deacon
  0 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-07  8:56 UTC (permalink / raw)
  To: Will Deacon
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On 6 August 2014 18:22, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Aug 05, 2014 at 09:49:57AM +0100, Anup Patel wrote:
>> The VCPU target type KVM_ARM_TARGET_XGENE_POTENZA is available
>> in latest Linux-3.16-rcX or higher hence register aarch64 target
>> type for it.
>>
>> This patch enables us to run KVMTOOL on X-Gene Potenza host.
>>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>  tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/kvm/arm/aarch64/arm-cpu.c b/tools/kvm/arm/aarch64/arm-cpu.c
>> index ce5ea2f..ce526e3 100644
>> --- a/tools/kvm/arm/aarch64/arm-cpu.c
>> +++ b/tools/kvm/arm/aarch64/arm-cpu.c
>> @@ -41,10 +41,17 @@ static struct kvm_arm_target target_cortex_a57 = {
>>       .init           = arm_cpu__vcpu_init,
>>  };
>>
>> +static struct kvm_arm_target target_potenza = {
>> +     .id             = KVM_ARM_TARGET_XGENE_POTENZA,
>> +     .compatible     = "arm,arm-v8",
>> +     .init           = arm_cpu__vcpu_init,
>> +};
>
> This implies you have the same PPIs for the arch-timer as the Cortex-A CPUs.
> Is that right?

Currently, KVM ARM64 provides PPI27 as arch-time IRQ for all target types.

This will have to change if KVM ARM64 starts using different
arch-timer PPI based on target type.

--
Anup

>
> Will

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

* Re: [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  2014-08-06 12:53   ` Will Deacon
@ 2014-08-07  8:57     ` Anup Patel
  0 siblings, 0 replies; 23+ messages in thread
From: Anup Patel @ 2014-08-07  8:57 UTC (permalink / raw)
  To: Will Deacon
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On 6 August 2014 18:23, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Aug 05, 2014 at 09:49:58AM +0100, Anup Patel wrote:
>> The KVM_EXIT_SYSTEM_EVENT exit reason was added to define
>> architecture independent system-wide events for a Guest.
>>
>> Currently, it is used by in-kernel PSCI-0.2 emulation of
>> KVM ARM/ARM64 to inform user space about PSCI SYSTEM_OFF
>> or PSCI SYSTEM_RESET request.
>>
>> For now, we simply treat all system-wide guest events as
>> same and shutdown the guest upon KVM_EXIT_SYSTEM_EVENT.
>>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>  tools/kvm/kvm-cpu.c |    6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
>> index ee0a8ec..e20ee4b 100644
>> --- a/tools/kvm/kvm-cpu.c
>> +++ b/tools/kvm/kvm-cpu.c
>> @@ -160,6 +160,12 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
>>                       goto exit_kvm;
>>               case KVM_EXIT_SHUTDOWN:
>>                       goto exit_kvm;
>> +             case KVM_EXIT_SYSTEM_EVENT:
>> +                     /*
>> +                      * Treat both SHUTDOWN & RESET system events
>> +                      * as shutdown request.
>> +                      */
>> +                     goto exit_kvm;
>
> Can we figure out whether this was a SHUTDOWN or RESET request? If so,
> printing a message for the latter "RESET request received -- exiting KVM"
> might be informative.

OK, I will update this and make it more verbose.

--
Anup

>
> Will

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

* Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
  2014-08-06 12:56   ` Will Deacon
@ 2014-08-07  9:00     ` Anup Patel
  2014-08-07  9:09       ` Will Deacon
  0 siblings, 1 reply; 23+ messages in thread
From: Anup Patel @ 2014-08-07  9:00 UTC (permalink / raw)
  To: Will Deacon
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On 6 August 2014 18:26, Will Deacon <will.deacon@arm.com> wrote:
> On Tue, Aug 05, 2014 at 09:49:59AM +0100, Anup Patel wrote:
>> If in-kernel KVM support PSCI-0.2 emulation then we should set
>> KVM_ARM_VCPU_PSCI_0_2 feature for each guest VCPU and also
>> provide "arm,psci-0.2","arm,psci" as PSCI compatible string.
>>
>> This patch updates kvm_cpu__arch_init() and setup_fdt() as
>> per above.
>>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>  tools/kvm/arm/fdt.c     |   39 +++++++++++++++++++++++++++++++++------
>>  tools/kvm/arm/kvm-cpu.c |    5 +++++
>>  2 files changed, 38 insertions(+), 6 deletions(-)
>
> [...]
>
>> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
>> index 7478f8f..76c28a0 100644
>> --- a/tools/kvm/arm/kvm-cpu.c
>> +++ b/tools/kvm/arm/kvm-cpu.c
>> @@ -74,6 +74,11 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
>>               die("preferred target not available\n");
>>       }
>>
>> +     /* Set KVM_ARM_VCPU_PSCI_0_2 if available */
>> +     if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
>> +             vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2);
>> +     }
>
> Where is this used?

If we want to provide PSCI-0.2 to Guest then we should inform
in-kernel KVM ARM/ARM64 using init features.

By default KVM ARM/ARM64 provides PSCI-0.1 to Guest. If we don't set
this feature then Guest will get undefined exception for PSCI-0.2
calls.

--
Anup

>
> Will

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

* Re: [PATCH 3/5] kvmtool: ARM64: Add target type potenza for aarch64
  2014-08-07  8:56     ` Anup Patel
@ 2014-08-07  9:01       ` Will Deacon
  0 siblings, 0 replies; 23+ messages in thread
From: Will Deacon @ 2014-08-07  9:01 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Thu, Aug 07, 2014 at 09:56:28AM +0100, Anup Patel wrote:
> On 6 August 2014 18:22, Will Deacon <will.deacon@arm.com> wrote:
> > On Tue, Aug 05, 2014 at 09:49:57AM +0100, Anup Patel wrote:
> >> The VCPU target type KVM_ARM_TARGET_XGENE_POTENZA is available
> >> in latest Linux-3.16-rcX or higher hence register aarch64 target
> >> type for it.
> >>
> >> This patch enables us to run KVMTOOL on X-Gene Potenza host.
> >>
> >> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> >> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> >> ---
> >>  tools/kvm/arm/aarch64/arm-cpu.c |    9 ++++++++-
> >>  1 file changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/tools/kvm/arm/aarch64/arm-cpu.c b/tools/kvm/arm/aarch64/arm-cpu.c
> >> index ce5ea2f..ce526e3 100644
> >> --- a/tools/kvm/arm/aarch64/arm-cpu.c
> >> +++ b/tools/kvm/arm/aarch64/arm-cpu.c
> >> @@ -41,10 +41,17 @@ static struct kvm_arm_target target_cortex_a57 = {
> >>       .init           = arm_cpu__vcpu_init,
> >>  };
> >>
> >> +static struct kvm_arm_target target_potenza = {
> >> +     .id             = KVM_ARM_TARGET_XGENE_POTENZA,
> >> +     .compatible     = "arm,arm-v8",
> >> +     .init           = arm_cpu__vcpu_init,
> >> +};
> >
> > This implies you have the same PPIs for the arch-timer as the Cortex-A CPUs.
> > Is that right?
> 
> Currently, KVM ARM64 provides PPI27 as arch-time IRQ for all target types.
> 
> This will have to change if KVM ARM64 starts using different
> arch-timer PPI based on target type.

Oh, of course, these are virtual interrupt numbers. Ignore me!

Will

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

* Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
  2014-08-07  9:00     ` Anup Patel
@ 2014-08-07  9:09       ` Will Deacon
  0 siblings, 0 replies; 23+ messages in thread
From: Will Deacon @ 2014-08-07  9:09 UTC (permalink / raw)
  To: Anup Patel
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Thu, Aug 07, 2014 at 10:00:13AM +0100, Anup Patel wrote:
> On 6 August 2014 18:26, Will Deacon <will.deacon@arm.com> wrote:
> > On Tue, Aug 05, 2014 at 09:49:59AM +0100, Anup Patel wrote:
> >> If in-kernel KVM support PSCI-0.2 emulation then we should set
> >> KVM_ARM_VCPU_PSCI_0_2 feature for each guest VCPU and also
> >> provide "arm,psci-0.2","arm,psci" as PSCI compatible string.
> >>
> >> This patch updates kvm_cpu__arch_init() and setup_fdt() as
> >> per above.
> >>
> >> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> >> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> >> ---
> >>  tools/kvm/arm/fdt.c     |   39 +++++++++++++++++++++++++++++++++------
> >>  tools/kvm/arm/kvm-cpu.c |    5 +++++
> >>  2 files changed, 38 insertions(+), 6 deletions(-)
> >
> > [...]
> >
> >> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
> >> index 7478f8f..76c28a0 100644
> >> --- a/tools/kvm/arm/kvm-cpu.c
> >> +++ b/tools/kvm/arm/kvm-cpu.c
> >> @@ -74,6 +74,11 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
> >>               die("preferred target not available\n");
> >>       }
> >>
> >> +     /* Set KVM_ARM_VCPU_PSCI_0_2 if available */
> >> +     if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
> >> +             vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2);
> >> +     }
> >
> > Where is this used?
> 
> If we want to provide PSCI-0.2 to Guest then we should inform
> in-kernel KVM ARM/ARM64 using init features.
> 
> By default KVM ARM/ARM64 provides PSCI-0.1 to Guest. If we don't set
> this feature then Guest will get undefined exception for PSCI-0.2
> calls.

Gotcha, thanks for the explanation.

Will

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

* Re: [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-07  8:50     ` Anup Patel
@ 2014-08-07  9:12       ` Will Deacon
  2014-08-28  9:56         ` Pekka Enberg
  0 siblings, 1 reply; 23+ messages in thread
From: Will Deacon @ 2014-08-07  9:12 UTC (permalink / raw)
  To: Anup Patel, penberg
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, penberg@kernel.org,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Thu, Aug 07, 2014 at 09:50:52AM +0100, Anup Patel wrote:
> On 6 August 2014 18:20, Will Deacon <will.deacon@arm.com> wrote:
> > On Tue, Aug 05, 2014 at 09:49:56AM +0100, Anup Patel wrote:
> >> The __ARM64_SYS_REG() macro is already defined in uapi/asm/kvm.h
> >> of Linux-3.16-rcX hence remove it from arm/aarch64/kvm-cpu.c
> >
> > I've been carrying a similar patch in my kvmtool/arm branch, but upstream
> > kvmtool is still based on 3.13, so this isn't needed at the moment.
> >
> > Do you have a need for Pekka to merge in the latest kernel sources?
> >
> > Will
> 
> Yes, we should syncup KVMTOOL with latest kernel sources.
> 
> I want to be able to shutdown VM when using KVMTOOL. To do
> this we need to use PSCI-v0.2 from Guest kernel.

Ok. Pekka, could you merge in 3.16 to the kvmtool master branch please?
You'll need my patch below to resolve some ARM build fallout.

Cheers,

Will

--->8

>From e780359998667e3eb08d9d002398618a06a861b9 Mon Sep 17 00:00:00 2001
From: Will Deacon <will.deacon@arm.com>
Date: Tue, 13 May 2014 12:06:06 +0100
Subject: [PATCH] kvm tools: arm: remove register accessor macros now that they
 are in uapi

The kernel now exposes register accessor macros in the uapi/ headers
for arm and arm64, so use those instead (and avoid the compile failure
from the duplicate definitions).

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 tools/kvm/arm/aarch32/kvm-cpu.c | 15 +--------------
 tools/kvm/arm/aarch64/kvm-cpu.c | 15 ---------------
 2 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/tools/kvm/arm/aarch32/kvm-cpu.c b/tools/kvm/arm/aarch32/kvm-cpu.c
index 464b473dc936..95fb1da5ba3d 100644
--- a/tools/kvm/arm/aarch32/kvm-cpu.c
+++ b/tools/kvm/arm/aarch32/kvm-cpu.c
@@ -7,25 +7,12 @@
 #define ARM_CORE_REG(x)	(KVM_REG_ARM | KVM_REG_SIZE_U32 | KVM_REG_ARM_CORE | \
 			 KVM_REG_ARM_CORE_REG(x))
 
-#define ARM_CP15_REG_SHIFT_MASK(x,n)		\
-	(((x) << KVM_REG_ARM_ ## n ## _SHIFT) & KVM_REG_ARM_ ## n ## _MASK)
-
-#define __ARM_CP15_REG(op1,crn,crm,op2)			\
-	(KVM_REG_ARM | KVM_REG_SIZE_U32		|	\
-	 (15 << KVM_REG_ARM_COPROC_SHIFT)	|	\
-	 ARM_CP15_REG_SHIFT_MASK(op1, OPC1)	|	\
-	 ARM_CP15_REG_SHIFT_MASK(crn, 32_CRN)	|	\
-	 ARM_CP15_REG_SHIFT_MASK(crm, CRM)	|	\
-	 ARM_CP15_REG_SHIFT_MASK(op2, 32_OPC2))
-
-#define ARM_CP15_REG(...)	__ARM_CP15_REG(__VA_ARGS__)
-
 unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu)
 {
 	struct kvm_one_reg reg;
 	u32 mpidr;
 
-	reg.id = ARM_CP15_REG(ARM_CPU_ID, ARM_CPU_ID_MPIDR);
+	reg.id = ARM_CP15_REG32(ARM_CPU_ID, ARM_CPU_ID_MPIDR);
 	reg.addr = (u64)(unsigned long)&mpidr;
 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
 		die("KVM_GET_ONE_REG failed (get_mpidr vcpu%ld", vcpu->cpu_id);
diff --git a/tools/kvm/arm/aarch64/kvm-cpu.c b/tools/kvm/arm/aarch64/kvm-cpu.c
index 71a2a3a7789d..1b293748efd6 100644
--- a/tools/kvm/arm/aarch64/kvm-cpu.c
+++ b/tools/kvm/arm/aarch64/kvm-cpu.c
@@ -15,21 +15,6 @@
 #define ARM64_CORE_REG(x)	(KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
 				 KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x))
 
-#define ARM64_SYS_REG_SHIFT_MASK(x,n)				\
-	(((x) << KVM_REG_ARM64_SYSREG_ ## n ## _SHIFT) &	\
-	 KVM_REG_ARM64_SYSREG_ ## n ## _MASK)
-
-#define __ARM64_SYS_REG(op0,op1,crn,crm,op2)			\
-	(KVM_REG_ARM64 | KVM_REG_SIZE_U64		|	\
-	 KVM_REG_ARM64_SYSREG				|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op0, OP0)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op1, OP1)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(crn, CRN)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(crm, CRM)		|	\
-	 ARM64_SYS_REG_SHIFT_MASK(op2, OP2))
-
-#define ARM64_SYS_REG(...)	__ARM64_SYS_REG(__VA_ARGS__)
-
 unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu)
 {
 	struct kvm_one_reg reg;
-- 
2.0.1


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

* Re: [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-07  9:12       ` Will Deacon
@ 2014-08-28  9:56         ` Pekka Enberg
  2014-08-28 10:03           ` Will Deacon
  0 siblings, 1 reply; 23+ messages in thread
From: Pekka Enberg @ 2014-08-28  9:56 UTC (permalink / raw)
  To: Will Deacon, Anup Patel, penberg
  Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	patches@apm.com, Marc Zyngier, christoffer.dall@linaro.org,
	pranavkumar@linaro.org

On 08/07/2014 12:12 PM, Will Deacon wrote:
> Ok. Pekka, could you merge in 3.16 to the kvmtool master branch please?
> You'll need my patch below to resolve some ARM build fallout.

Done.

- Pekka

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

* Re: [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64
  2014-08-28  9:56         ` Pekka Enberg
@ 2014-08-28 10:03           ` Will Deacon
  0 siblings, 0 replies; 23+ messages in thread
From: Will Deacon @ 2014-08-28 10:03 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Anup Patel, penberg@kernel.org, kvmarm@lists.cs.columbia.edu,
	kvm@vger.kernel.org, patches@apm.com, Marc Zyngier,
	christoffer.dall@linaro.org, pranavkumar@linaro.org

On Thu, Aug 28, 2014 at 10:56:29AM +0100, Pekka Enberg wrote:
> On 08/07/2014 12:12 PM, Will Deacon wrote:
> > Ok. Pekka, could you merge in 3.16 to the kvmtool master branch please?
> > You'll need my patch below to resolve some ARM build fallout.
> 
> Done.

Thanks, Pekka! We'll give it a spin.

Will

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

end of thread, other threads:[~2014-08-28 10:03 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-05  8:49 [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel
2014-08-05  8:49 ` [PATCH 1/5] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
2014-08-06 12:48   ` Will Deacon
2014-08-07  8:44     ` Anup Patel
2014-08-07  8:52       ` Peter Maydell
2014-08-05  8:49 ` [PATCH 2/5] kvmtool: ARM64: Fix compile error for aarch64 Anup Patel
2014-08-06 12:50   ` Will Deacon
2014-08-07  8:50     ` Anup Patel
2014-08-07  9:12       ` Will Deacon
2014-08-28  9:56         ` Pekka Enberg
2014-08-28 10:03           ` Will Deacon
2014-08-05  8:49 ` [PATCH 3/5] kvmtool: ARM64: Add target type potenza " Anup Patel
2014-08-06 12:52   ` Will Deacon
2014-08-07  8:56     ` Anup Patel
2014-08-07  9:01       ` Will Deacon
2014-08-05  8:49 ` [PATCH 4/5] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT Anup Patel
2014-08-06 12:53   ` Will Deacon
2014-08-07  8:57     ` Anup Patel
2014-08-05  8:49 ` [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it Anup Patel
2014-08-06 12:56   ` Will Deacon
2014-08-07  9:00     ` Anup Patel
2014-08-07  9:09       ` Will Deacon
2014-08-05  8:53 ` [PATCH 0/5] kvmtool: ARM/ARM64: Misc updates Anup Patel

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