Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
On 6 August 2014 18:26, Will Deacon will.dea...@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 pranavku...@linaro.org Signed-off-by: Anup Patel anup.pa...@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 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
On Thu, Aug 07, 2014 at 10:00:13AM +0100, Anup Patel wrote: On 6 August 2014 18:26, Will Deacon will.dea...@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 pranavku...@linaro.org Signed-off-by: Anup Patel anup.pa...@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 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
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 pranavku...@linaro.org Signed-off-by: Anup Patel anup.pa...@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 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/5] kvmtool: ARM/ARM64: Provide PSCI-0.2 guest when in-kernel KVM supports it
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 pranavku...@linaro.org Signed-off-by: Anup Patel anup.pa...@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 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html