From: Andre Przywara <andre.przywara@arm.com>
To: Anup Patel <anup.patel@linaro.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"patches@apm.com" <patches@apm.com>,
Will Deacon <Will.Deacon@arm.com>,
Marc Zyngier <Marc.Zyngier@arm.com>,
"penberg@kernel.org" <penberg@kernel.org>,
"christoffer.dall@linaro.org" <christoffer.dall@linaro.org>,
"pranavkumar@linaro.org" <pranavkumar@linaro.org>
Subject: Re: [PATCH v4 4/4] kvmtool: ARM/ARM64: Provide PSCI-0.2 to guest when KVM supports it
Date: Tue, 30 Sep 2014 10:02:05 +0100 [thread overview]
Message-ID: <542A718D.1050407@arm.com> (raw)
In-Reply-To: <1411084676-8275-5-git-send-email-anup.patel@linaro.org>
Hi Anup,
this looks good now, only one minor formatting thing below.
On 19/09/14 00:57, 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 | 52 ++++++++++++++++++++++++++++++++++++++++++-----
> tools/kvm/arm/kvm-cpu.c | 5 +++++
> 2 files changed, 52 insertions(+), 5 deletions(-)
>
> diff --git a/tools/kvm/arm/fdt.c b/tools/kvm/arm/fdt.c
> index 186a718..a15450e 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];
>
> @@ -84,6 +85,34 @@ static void generate_irq_prop(void *fdt, u8 irq)
> _FDT(fdt_property(fdt, "interrupts", irq_prop, sizeof(irq_prop)));
> }
>
> +struct psci_fns {
> + u32 cpu_suspend;
> + u32 cpu_off;
> + u32 cpu_on;
> + u32 migrate;
> +};
> +
> +static struct psci_fns psci_0_1_fns = {
> + .cpu_suspend = KVM_PSCI_FN_CPU_SUSPEND,
> + .cpu_off = KVM_PSCI_FN_CPU_OFF,
> + .cpu_on = KVM_PSCI_FN_CPU_ON,
> + .migrate = KVM_PSCI_FN_MIGRATE,
> +};
> +
> +static struct psci_fns psci_0_2_aarch32_fns = {
> + .cpu_suspend = PSCI_0_2_FN_CPU_SUSPEND,
> + .cpu_off = PSCI_0_2_FN_CPU_OFF,
> + .cpu_on = PSCI_0_2_FN_CPU_ON,
> + .migrate = PSCI_0_2_FN_MIGRATE,
> +};
> +
> +static struct psci_fns psci_0_2_aarch64_fns = {
> + .cpu_suspend = PSCI_0_2_FN64_CPU_SUSPEND,
> + .cpu_off = PSCI_0_2_FN_CPU_OFF,
> + .cpu_on = PSCI_0_2_FN64_CPU_ON,
> + .migrate = PSCI_0_2_FN64_MIGRATE,
> +};
> +
> static int setup_fdt(struct kvm *kvm)
> {
> struct device_header *dev_hdr;
> @@ -93,6 +122,7 @@ static int setup_fdt(struct kvm *kvm)
> cpu_to_fdt64(kvm->arch.memory_guest_start),
> cpu_to_fdt64(kvm->ram_size),
> };
> + struct psci_fns *fns;
> void *fdt = staging_fdt;
> void *fdt_dest = guest_flat_to_host(kvm,
> kvm->arch.dtb_guest_start);
> @@ -162,12 +192,24 @@ static int setup_fdt(struct kvm *kvm)
>
> /* PSCI firmware */
> _FDT(fdt_begin_node(fdt, "psci"));
> - _FDT(fdt_property_string(fdt, "compatible", "arm,psci"));
> + 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)));
> + if (kvm->cfg.arch.aarch32_guest) {
> + fns = &psci_0_2_aarch32_fns;
> + } else {
> + fns = &psci_0_2_aarch64_fns;
> + }
You can remove the braces here.
Given that you fix that:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Thanks!
Andre
> + } else {
> + _FDT(fdt_property_string(fdt, "compatible", "arm,psci"));
> + fns = &psci_0_1_fns;
> + }
> _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_property_cell(fdt, "cpu_suspend", fns->cpu_suspend));
> + _FDT(fdt_property_cell(fdt, "cpu_off", fns->cpu_off));
> + _FDT(fdt_property_cell(fdt, "cpu_on", fns->cpu_on));
> + _FDT(fdt_property_cell(fdt, "migrate", fns->migrate));
> _FDT(fdt_end_node(fdt));
>
> /* Finalise. */
> diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
> index 6de5344..219de16 100644
> --- a/tools/kvm/arm/kvm-cpu.c
> +++ b/tools/kvm/arm/kvm-cpu.c
> @@ -56,6 +56,11 @@ 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");
>
> + /* 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);
> + }
> +
> /*
> * If preferred target ioctl successful then use preferred target
> * else try each and every target type.
>
prev parent reply other threads:[~2014-09-30 9:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 23:57 [PATCH v4 0/4] kvmtool: ARM/ARM64: Misc updates Anup Patel
2014-09-18 23:57 ` [PATCH v4 1/4] kvmtool: ARM: Use KVM_ARM_PREFERRED_TARGET vm ioctl to determine target cpu Anup Patel
2014-09-30 8:56 ` Andre Przywara
2014-10-01 10:24 ` Anup Patel
2014-09-18 23:57 ` [PATCH v4 2/4] kvmtool: ARM64: Add target type potenza for aarch64 Anup Patel
2014-09-29 17:00 ` Andre Przywara
2014-10-01 10:23 ` Anup Patel
2014-09-18 23:57 ` [PATCH v4 3/4] kvmtool: Handle exit reason KVM_EXIT_SYSTEM_EVENT Anup Patel
2014-09-30 9:04 ` Andre Przywara
2014-09-18 23:57 ` [PATCH v4 4/4] kvmtool: ARM/ARM64: Provide PSCI-0.2 to guest when KVM supports it Anup Patel
2014-09-30 9:02 ` Andre Przywara [this message]
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=542A718D.1050407@arm.com \
--to=andre.przywara@arm.com \
--cc=Marc.Zyngier@arm.com \
--cc=Will.Deacon@arm.com \
--cc=anup.patel@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=patches@apm.com \
--cc=penberg@kernel.org \
--cc=pranavkumar@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.