From: cdall@cs.columbia.edu (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs
Date: Wed, 3 Apr 2013 16:16:10 -0700 [thread overview]
Message-ID: <20130403231610.GH29227@gmail.com> (raw)
In-Reply-To: <1364909115-3810-8-git-send-email-marc.zyngier@arm.com>
On Tue, Apr 02, 2013 at 02:25:15PM +0100, Marc Zyngier wrote:
> Now that we have the necessary infrastructure to boot a hotplugged CPU
> at any point in time, wire a CPU notifier that will perform the HYP
> init for the incoming CPU.
>
> Note that this depends on the platform code and/or firmware to boot the
> incoming CPU with HYP mode enabled and return to the kernel by following
> the normal boot path (HYP stub installed).
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/kvm/arm.c | 47 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index f0f3290..6cc076e 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -793,8 +793,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
> }
> }
>
> -static void cpu_init_hyp_mode(void *vector)
> +static void cpu_init_hyp_mode(void *dummy)
> {
> + phys_addr_t init_vector_addr = virt_to_phys(__kvm_hyp_init);
> unsigned long long boot_pgd_ptr;
> unsigned long long pgd_ptr;
> unsigned long hyp_stack_ptr;
> @@ -802,7 +803,7 @@ static void cpu_init_hyp_mode(void *vector)
> unsigned long vector_ptr;
>
> /* Switch from the HYP stub to our own HYP init vector */
> - __hyp_set_vectors((unsigned long)vector);
> + __hyp_set_vectors(init_vector_addr);
>
> boot_pgd_ptr = (unsigned long long)kvm_mmu_get_boot_httbr();
> pgd_ptr = (unsigned long long)kvm_mmu_get_httbr();
> @@ -813,12 +814,28 @@ static void cpu_init_hyp_mode(void *vector)
> __cpu_init_hyp_mode(boot_pgd_ptr, pgd_ptr, hyp_stack_ptr, vector_ptr);
> }
>
> +static int hyp_init_cpu_notify(struct notifier_block *self,
> + unsigned long action, void *cpu)
> +{
> + switch (action) {
> + case CPU_STARTING:
> + case CPU_STARTING_FROZEN:
> + cpu_init_hyp_mode(NULL);
> + break;
> + }
> +
> + return NOTIFY_OK;
> +}
> +
> +static struct notifier_block hyp_init_cpu_nb = {
> + .notifier_call = hyp_init_cpu_notify,
> +};
> +
> /**
> * Inits Hyp-mode on all online CPUs
> */
> static int init_hyp_mode(void)
> {
> - phys_addr_t init_phys_addr;
> int cpu;
> int err = 0;
>
> @@ -851,19 +868,6 @@ static int init_hyp_mode(void)
> }
>
> /*
> - * Execute the init code on each CPU.
> - *
> - * Note: The stack is not mapped yet, so don't do anything else than
> - * initializing the hypervisor mode on each CPU using a local stack
> - * space for temporary storage.
> - */
> - init_phys_addr = virt_to_phys(__kvm_hyp_init);
> - for_each_online_cpu(cpu) {
> - smp_call_function_single(cpu, cpu_init_hyp_mode,
> - (void *)(long)init_phys_addr, 1);
> - }
> -
> - /*
> * Map the Hyp-code called directly from the host
> */
> err = create_hyp_mappings(__kvm_hyp_code_start, __kvm_hyp_code_end);
> @@ -908,6 +912,11 @@ static int init_hyp_mode(void)
> }
>
> /*
> + * Execute the init code on each CPU.
> + */
> + on_each_cpu(cpu_init_hyp_mode, NULL, 1);
> +
> + /*
> * Init HYP view of VGIC
> */
> err = kvm_vgic_hyp_init();
> @@ -963,6 +972,12 @@ int kvm_arch_init(void *opaque)
> if (err)
> goto out_err;
>
> + err = register_cpu_notifier(&hyp_init_cpu_nb);
> + if (err) {
> + kvm_err("Cannot register HYP init CPU notifier (%d)\n", err);
> + goto out_err;
> + }
> +
> kvm_coproc_table_init();
> return 0;
> out_err:
> --
> 1.8.1.4
>
>
Acked-by: Christoffer Dall <cdall@cs.columbia.edu>
WARNING: multiple messages have this Message-ID (diff)
From: Christoffer Dall <cdall@cs.columbia.edu>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
kvmarm@lists.cs.columbia.edu, catalin.marinas@arm.com,
will.deacon@arm.com
Subject: Re: [PATCH 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs
Date: Wed, 3 Apr 2013 16:16:10 -0700 [thread overview]
Message-ID: <20130403231610.GH29227@gmail.com> (raw)
In-Reply-To: <1364909115-3810-8-git-send-email-marc.zyngier@arm.com>
On Tue, Apr 02, 2013 at 02:25:15PM +0100, Marc Zyngier wrote:
> Now that we have the necessary infrastructure to boot a hotplugged CPU
> at any point in time, wire a CPU notifier that will perform the HYP
> init for the incoming CPU.
>
> Note that this depends on the platform code and/or firmware to boot the
> incoming CPU with HYP mode enabled and return to the kernel by following
> the normal boot path (HYP stub installed).
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/kvm/arm.c | 47 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index f0f3290..6cc076e 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -793,8 +793,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
> }
> }
>
> -static void cpu_init_hyp_mode(void *vector)
> +static void cpu_init_hyp_mode(void *dummy)
> {
> + phys_addr_t init_vector_addr = virt_to_phys(__kvm_hyp_init);
> unsigned long long boot_pgd_ptr;
> unsigned long long pgd_ptr;
> unsigned long hyp_stack_ptr;
> @@ -802,7 +803,7 @@ static void cpu_init_hyp_mode(void *vector)
> unsigned long vector_ptr;
>
> /* Switch from the HYP stub to our own HYP init vector */
> - __hyp_set_vectors((unsigned long)vector);
> + __hyp_set_vectors(init_vector_addr);
>
> boot_pgd_ptr = (unsigned long long)kvm_mmu_get_boot_httbr();
> pgd_ptr = (unsigned long long)kvm_mmu_get_httbr();
> @@ -813,12 +814,28 @@ static void cpu_init_hyp_mode(void *vector)
> __cpu_init_hyp_mode(boot_pgd_ptr, pgd_ptr, hyp_stack_ptr, vector_ptr);
> }
>
> +static int hyp_init_cpu_notify(struct notifier_block *self,
> + unsigned long action, void *cpu)
> +{
> + switch (action) {
> + case CPU_STARTING:
> + case CPU_STARTING_FROZEN:
> + cpu_init_hyp_mode(NULL);
> + break;
> + }
> +
> + return NOTIFY_OK;
> +}
> +
> +static struct notifier_block hyp_init_cpu_nb = {
> + .notifier_call = hyp_init_cpu_notify,
> +};
> +
> /**
> * Inits Hyp-mode on all online CPUs
> */
> static int init_hyp_mode(void)
> {
> - phys_addr_t init_phys_addr;
> int cpu;
> int err = 0;
>
> @@ -851,19 +868,6 @@ static int init_hyp_mode(void)
> }
>
> /*
> - * Execute the init code on each CPU.
> - *
> - * Note: The stack is not mapped yet, so don't do anything else than
> - * initializing the hypervisor mode on each CPU using a local stack
> - * space for temporary storage.
> - */
> - init_phys_addr = virt_to_phys(__kvm_hyp_init);
> - for_each_online_cpu(cpu) {
> - smp_call_function_single(cpu, cpu_init_hyp_mode,
> - (void *)(long)init_phys_addr, 1);
> - }
> -
> - /*
> * Map the Hyp-code called directly from the host
> */
> err = create_hyp_mappings(__kvm_hyp_code_start, __kvm_hyp_code_end);
> @@ -908,6 +912,11 @@ static int init_hyp_mode(void)
> }
>
> /*
> + * Execute the init code on each CPU.
> + */
> + on_each_cpu(cpu_init_hyp_mode, NULL, 1);
> +
> + /*
> * Init HYP view of VGIC
> */
> err = kvm_vgic_hyp_init();
> @@ -963,6 +972,12 @@ int kvm_arch_init(void *opaque)
> if (err)
> goto out_err;
>
> + err = register_cpu_notifier(&hyp_init_cpu_nb);
> + if (err) {
> + kvm_err("Cannot register HYP init CPU notifier (%d)\n", err);
> + goto out_err;
> + }
> +
> kvm_coproc_table_init();
> return 0;
> out_err:
> --
> 1.8.1.4
>
>
Acked-by: Christoffer Dall <cdall@cs.columbia.edu>
next prev parent reply other threads:[~2013-04-03 23:16 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 13:25 [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 1/7] ARM: KVM: simplify HYP mapping population Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 23:13 ` Christoffer Dall
2013-04-03 23:13 ` Christoffer Dall
2013-04-04 12:35 ` Marc Zyngier
2013-04-04 12:35 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 2/7] ARM: KVM: fix HYP mapping limitations around zero Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-03 23:14 ` Christoffer Dall
2013-04-04 12:40 ` Marc Zyngier
2013-04-04 12:40 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 3/7] ARM: KVM: move to a KVM provided HYP idmap Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 9:43 ` Will Deacon
2013-04-03 9:43 ` Will Deacon
2013-04-03 9:46 ` Marc Zyngier
2013-04-03 9:46 ` Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-03 23:14 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 4/7] ARM: KVM: enforce page alignment for identity mapped code Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 9:50 ` Will Deacon
2013-04-03 9:50 ` Will Deacon
2013-04-03 10:00 ` Marc Zyngier
2013-04-03 10:00 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 10:47 ` Marc Zyngier
2013-04-04 10:47 ` Marc Zyngier
2013-04-04 15:32 ` Christoffer Dall
2013-04-04 15:32 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 5/7] ARM: KVM: parametrize HYP page table freeing Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-03 23:15 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 6/7] ARM: KVM: switch to a dual-step HYP init code Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 10:07 ` Will Deacon
2013-04-03 10:07 ` Will Deacon
2013-04-03 10:38 ` Marc Zyngier
2013-04-03 10:38 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 11:05 ` Marc Zyngier
2013-04-04 11:05 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 12:52 ` Marc Zyngier
2013-04-04 12:52 ` Marc Zyngier
2013-04-04 22:10 ` Geoff Levand
2013-04-04 22:10 ` Geoff Levand
2013-04-05 9:08 ` Marc Zyngier
2013-04-05 9:08 ` Marc Zyngier
2013-04-05 16:46 ` Geoff Levand
2013-04-05 16:46 ` Geoff Levand
2013-04-05 16:54 ` Marc Zyngier
2013-04-05 16:54 ` Marc Zyngier
2013-04-18 15:54 ` Russell King - ARM Linux
2013-04-18 15:54 ` Russell King - ARM Linux
2013-04-18 16:01 ` Marc Zyngier
2013-04-18 16:01 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs Marc Zyngier
2013-04-02 13:25 ` Marc Zyngier
2013-04-03 23:16 ` Christoffer Dall [this message]
2013-04-03 23:16 ` Christoffer Dall
2013-04-03 23:18 ` [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Christoffer Dall
2013-04-03 23:18 ` 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=20130403231610.GH29227@gmail.com \
--to=cdall@cs.columbia.edu \
--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 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.