All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 05/13] arm64: kvm: allows kvm cpu hotplug
Date: Tue, 26 Apr 2016 17:26:04 +0100	[thread overview]
Message-ID: <571F969C.80200@arm.com> (raw)
In-Reply-To: <1461604250-12789-6-git-send-email-james.morse@arm.com>

Hi James,

On 25/04/16 18:10, James Morse wrote:
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> 
> The current kvm implementation on arm64 does cpu-specific initialization
> at system boot, and has no way to gracefully shutdown a core in terms of
> kvm. This prevents kexec from rebooting the system at EL2.
> 
> This patch adds a cpu tear-down function and also puts an existing cpu-init
> code into a separate function, kvm_arch_hardware_disable() and
> kvm_arch_hardware_enable() respectively.
> We don't need the arm64 specific cpu hotplug hook any more.
> 
> Since this patch modifies common code between arm and arm64, one stub
> definition, __cpu_reset_hyp_mode(), is added on arm side to avoid
> compilation errors.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> [Rebase, added separate VHE init/exit path, changed resets use of
>  kvm_call_hyp() to the __version, en/disabled hardware in init_subsystems(),
>  added icache maintenance to __kvm_hyp_reset() and removed lr restore, removed
>  guest-enter after teardown handling]
> Signed-off-by: James Morse <james.morse@arm.com>
> 
> CC: Marc Zyngier <marc.zyngier@arm.com>
> ---
> N.B. this patch conflicts with 06a71a24bae5 ("arm64: KVM: unregister notifiers
> in hyp mode teardown path") in v4.6-rc4. See the cover letter for details.
> 
> Changes since v7:
>  * Moved the kvm-torn-down guest entry handling into handle_exit(),
>  * Added an exception type for hyp-stub to return to any kvm_call_hyp() caller
> 
>  arch/arm/include/asm/kvm_host.h   |  10 +++-
>  arch/arm/include/asm/kvm_mmu.h    |   1 +
>  arch/arm/kvm/arm.c                | 119 +++++++++++++++++++++++---------------
>  arch/arm/kvm/mmu.c                |   5 ++
>  arch/arm64/include/asm/kvm_asm.h  |   3 +
>  arch/arm64/include/asm/kvm_host.h |  13 ++++-
>  arch/arm64/include/asm/kvm_mmu.h  |   1 +
>  arch/arm64/kernel/hyp-stub.S      |   5 +-
>  arch/arm64/kvm/handle_exit.c      |   7 +++
>  arch/arm64/kvm/hyp-init.S         |  38 ++++++++++++
>  arch/arm64/kvm/reset.c            |  14 +++++
>  11 files changed, 164 insertions(+), 52 deletions(-)

If you moved these hunks:

> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index eb7490d232a0..a88da136f332 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -22,6 +22,8 @@
>  
>  #define ARM_EXCEPTION_IRQ	  0
>  #define ARM_EXCEPTION_TRAP	  1
> +/* The hyp-stub will return this for any kvm_call_hyp() call */
> +#define ARM_EXCEPTION_HYP_GONE	  2
>  
>  #define KVM_ARM64_DEBUG_DIRTY_SHIFT	0
>  #define KVM_ARM64_DEBUG_DIRTY		(1 << KVM_ARM64_DEBUG_DIRTY_SHIFT)
> diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
> index 894fb40fb378..8727f4490772 100644
> --- a/arch/arm64/kernel/hyp-stub.S
> +++ b/arch/arm64/kernel/hyp-stub.S
> @@ -23,6 +23,7 @@
>  
>  #include <asm/assembler.h>
>  #include <asm/kvm_arm.h>
> +#include <asm/kvm_asm.h>
>  #include <asm/ptrace.h>
>  #include <asm/virt.h>
>  
> @@ -70,8 +71,8 @@ el1_sync:
>  	msr	vbar_el2, x1
>  	b	9f
>  
> -	/* Unrecognised call type */
> -2:	mov     x0, xzr
> +	/* Someone called kvm_call_hyp() against the hyp-stub... */
> +2:	mov     x0, #ARM_EXCEPTION_HYP_GONE
>  
>  9:	eret
>  ENDPROC(el1_sync)
> diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
> index eba89e42f0ed..3246c4aba5b1 100644
> --- a/arch/arm64/kvm/handle_exit.c
> +++ b/arch/arm64/kvm/handle_exit.c
> @@ -186,6 +186,13 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
>  		exit_handler = kvm_get_exit_handler(vcpu);
>  
>  		return exit_handler(vcpu, run);
> +	case ARM_EXCEPTION_HYP_GONE:
> +		/*
> +		 * EL2 has been reset to the hyp-stub. This happens when a guest
> +		 * is pre-empted by kvm_reboot()'s shutdown call.
> +		 */
> +		run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> +		return 0;
>  	default:
>  		kvm_pr_unimpl("Unsupported exception type: %d",
>  			      exception_index);

to a separate patch (just before this one), I'd be quite happy.

So for this patch and the future one:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2016-04-26 16:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 17:10 [PATCH v8 00/13] arm64: kernel: Add support for hibernate/suspend-to-disk James Morse
2016-04-25 17:10 ` [PATCH v8 01/13] arm64: Fold proc-macros.S into assembler.h James Morse
2016-04-25 17:10 ` [PATCH v8 02/13] arm64: Cleanup SCTLR flags James Morse
2016-04-25 17:10 ` [PATCH v8 03/13] arm64: kvm: Move lr save/restore from do_el2_call into EL1 James Morse
2016-04-25 17:10 ` [PATCH v8 04/13] arm64: hyp/kvm: Make hyp-stub extensible James Morse
2016-04-25 17:10 ` [PATCH v8 05/13] arm64: kvm: allows kvm cpu hotplug James Morse
2016-04-26 16:26   ` Marc Zyngier [this message]
2016-04-25 17:10 ` [PATCH v8 06/13] arm64: kernel: Rework finisher callback out of __cpu_suspend_enter() James Morse
2016-04-26 10:44   ` Catalin Marinas
2016-04-25 17:10 ` [PATCH v8 07/13] arm64: Change cpu_resume() to enable mmu early then access sleep_sp by va James Morse
2016-04-25 17:10 ` [PATCH v8 08/13] arm64: kernel: Include _AC definition in page.h James Morse
2016-04-25 17:10 ` [PATCH v8 09/13] arm64: Promote KERNEL_START/KERNEL_END definitions to a header file James Morse
2016-04-25 17:10 ` [PATCH v8 10/13] arm64: Add new asm macro copy_page James Morse
2016-04-25 17:10 ` [PATCH v8 11/13] PM / Hibernate: Call flush_icache_range() on pages restored in-place James Morse
2016-04-25 17:10 ` [PATCH v8 12/13] arm64: kernel: Add support for hibernate/suspend-to-disk James Morse
2016-04-26 14:39   ` Catalin Marinas
2016-04-25 17:10 ` [PATCH v8 13/13] arm64: hibernate: Refuse to hibernate if the boot cpu is offline James Morse

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=571F969C.80200@arm.com \
    --to=marc.zyngier@arm.com \
    --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.