From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/10] arm64: Add EL2 switch to soft_restart
Date: Fri, 24 Oct 2014 11:57:24 +0100 [thread overview]
Message-ID: <20141024105724.GF24265@leverpostej> (raw)
In-Reply-To: <d878ad0595c9372fcbbf5e299b3949f2b59d8968.1414099246.git.geoff@infradead.org>
On Fri, Oct 24, 2014 at 12:10:58AM +0100, Geoff Levand wrote:
> When a CPU is reset it needs to be put into the exception level it had when it
> entered the kernel. Update cpu_reset() to accept an argument el2_switch which
> signals cpu_reset() to enter the soft reset address at EL2. If el2_switch is
> not set the soft reset address will be entered at EL1.
>
> Update cpu_soft_restart() and soft_restart() to pass the return of
> is_hyp_mode_available() as the el2_switch value to cpu_reset(). Also update the
> comments of cpu_reset(), cpu_soft_restart() and soft_restart() to reflect this
> change.
This will blow up without warning with KVM, and I think we need to
address that first.
Mark.
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
> arch/arm64/include/asm/proc-fns.h | 4 ++--
> arch/arm64/kernel/process.c | 6 ++++-
> arch/arm64/mm/proc.S | 47 +++++++++++++++++++++++++++++----------
> 3 files changed, 42 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm64/include/asm/proc-fns.h b/arch/arm64/include/asm/proc-fns.h
> index 9a8fd84..339394d 100644
> --- a/arch/arm64/include/asm/proc-fns.h
> +++ b/arch/arm64/include/asm/proc-fns.h
> @@ -32,8 +32,8 @@ extern void cpu_cache_off(void);
> extern void cpu_do_idle(void);
> extern void cpu_do_switch_mm(unsigned long pgd_phys, struct mm_struct *mm);
> extern void cpu_reset(unsigned long addr) __attribute__((noreturn));
> -void cpu_soft_restart(phys_addr_t cpu_reset,
> - unsigned long addr) __attribute__((noreturn));
> +void cpu_soft_restart(phys_addr_t cpu_reset, unsigned long el2_switch,
> + unsigned long addr) __attribute__((noreturn));
> extern void cpu_do_suspend(struct cpu_suspend_ctx *ptr);
> extern u64 cpu_do_resume(phys_addr_t ptr, u64 idmap_ttbr);
>
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index bf66922..0a3414b 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -50,6 +50,7 @@
> #include <asm/mmu_context.h>
> #include <asm/processor.h>
> #include <asm/stacktrace.h>
> +#include <asm/virt.h>
>
> #ifdef CONFIG_CC_STACKPROTECTOR
> #include <linux/stackprotector.h>
> @@ -60,7 +61,10 @@ EXPORT_SYMBOL(__stack_chk_guard);
> void soft_restart(unsigned long addr)
> {
> setup_mm_for_reboot();
> - cpu_soft_restart(virt_to_phys(cpu_reset), addr);
> +
> + cpu_soft_restart(virt_to_phys(cpu_reset), is_hyp_mode_available(),
> + addr);
> +
> /* Should never get here */
> BUG();
> }
> diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
> index 4e778b1..7467199 100644
> --- a/arch/arm64/mm/proc.S
> +++ b/arch/arm64/mm/proc.S
> @@ -25,6 +25,7 @@
> #include <asm/hwcap.h>
> #include <asm/pgtable-hwdef.h>
> #include <asm/pgtable.h>
> +#include <asm/virt.h>
>
> #include "proc-macros.S"
>
> @@ -59,27 +60,48 @@ ENTRY(cpu_cache_off)
> ENDPROC(cpu_cache_off)
>
> /*
> - * cpu_reset(loc)
> + * cpu_reset(el2_switch, loc) - Helper for cpu_soft_restart.
> *
> - * Perform a soft reset of the system. Put the CPU into the same state
> - * as it would be if it had been reset, and branch to what would be the
> - * reset vector. It must be executed with the flat identity mapping.
> + * @cpu_reset: Physical address of the cpu_reset routine.
> + * @el2_switch: Flag to indicate a swich to EL2 is needed.
> + * @addr: Location to jump to for soft reset.
> *
> - * - loc - location to jump to for soft reset
> + * Put the CPU into the same state as it would be if it had been reset, and
> + * branch to what would be the reset vector. It must be executed with the
> + * flat identity mapping.
> */
> +
> .align 5
> +
> ENTRY(cpu_reset)
> - mrs x1, sctlr_el1
> - bic x1, x1, #1
> - msr sctlr_el1, x1 // disable the MMU
> + mrs x2, sctlr_el1
> + bic x2, x2, #1
> + msr sctlr_el1, x2 // disable the MMU
> isb
> - ret x0
> +
> + cbz x0, 1f // el2_switch?
> + mov x0, x1
> + mov x1, xzr
> + mov x2, xzr
> + mov x3, xzr
> + hvc #HVC_CALL_FUNC // no return
> +
> +1: ret x1
> ENDPROC(cpu_reset)
>
> +/*
> + * cpu_soft_restart(cpu_reset, el2_switch, addr) - Perform a cpu soft reset.
> + *
> + * @cpu_reset: Physical address of the cpu_reset routine.
> + * @el2_switch: Flag to indicate a swich to EL2 is needed, passed to cpu_reset.
> + * @addr: Location to jump to for soft reset, passed to cpu_reset.
> + *
> + */
> +
> ENTRY(cpu_soft_restart)
> - /* Save address of cpu_reset() and reset address */
> - mov x19, x0
> - mov x20, x1
> + mov x19, x0 // cpu_reset
> + mov x20, x1 // el2_switch
> + mov x21, x2 // addr
>
> /* Turn D-cache off */
> bl cpu_cache_off
> @@ -88,6 +110,7 @@ ENTRY(cpu_soft_restart)
> bl flush_cache_all
>
> mov x0, x20
> + mov x1, x21
> ret x19
> ENDPROC(cpu_soft_restart)
>
> --
> 1.9.1
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
next prev parent reply other threads:[~2014-10-24 10:57 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 23:10 [PATCH 00/10] arm64 kexec kernel patches V5 Geoff Levand
2014-10-23 23:10 ` [PATCH 08/10] arm64/kexec: Add core kexec support Geoff Levand
2014-10-24 10:28 ` Mark Rutland
2014-11-13 2:19 ` Geoff Levand
2014-11-17 16:38 ` Mark Rutland
2014-11-17 20:20 ` Geoff Levand
2014-11-07 11:01 ` Arun Chandran
2014-11-12 21:54 ` Geoff Levand
2014-11-13 9:52 ` Arun Chandran
2014-11-17 3:52 ` Dave Young
2014-10-23 23:10 ` [PATCH 02/10] arm64: Convert hcalls to use ISS field Geoff Levand
2014-10-23 23:10 ` [PATCH 04/10] arm64: Add EL2 switch to soft_restart Geoff Levand
2014-10-24 10:57 ` Mark Rutland [this message]
2014-10-31 23:47 ` Geoff Levand
2014-10-23 23:10 ` [PATCH 01/10] arm64/kvm: Fix assembler compatibility of macros Geoff Levand
2014-10-24 9:24 ` Mark Rutland
2014-10-27 12:13 ` Will Deacon
2014-10-27 12:45 ` Christoffer Dall
2014-10-31 23:06 ` [PATCH V2 " Geoff Levand
2014-10-23 23:10 ` [PATCH 07/10] arm64: Move proc-macros.S to include/asm Geoff Levand
2014-10-23 23:10 ` [PATCH 03/10] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2014-10-23 23:10 ` [PATCH 05/10] arm64: Convert dts to use reserved-memory nodes Geoff Levand
2014-10-24 10:51 ` Mark Rutland
2014-10-24 10:59 ` Grant Likely
2014-10-24 12:27 ` Mark Rutland
2014-10-24 14:45 ` Grant Likely
2014-10-31 23:44 ` Geoff Levand
2014-11-03 20:02 ` Mark Rutland
2014-11-03 22:26 ` Rob Herring
2014-11-04 11:35 ` Mark Rutland
2014-11-04 11:37 ` Grant Likely
2014-10-23 23:10 ` [PATCH 06/10] arm64: Update booting.txt to " Geoff Levand
2014-10-24 10:54 ` Mark Rutland
2014-10-24 11:04 ` Grant Likely
2014-10-24 12:18 ` Mark Rutland
2014-10-24 13:54 ` Grant Likely
2014-10-24 14:10 ` Mark Rutland
2014-10-24 14:47 ` Grant Likely
2014-10-23 23:10 ` [PATCH 10/10] arm64/kexec: Add pr_devel output Geoff Levand
2014-10-23 23:10 ` [PATCH 09/10] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2014-10-24 10:31 ` Mark Rutland
2014-10-31 23:50 ` Geoff Levand
2014-11-03 20:05 ` Mark Rutland
2014-11-04 1:49 ` Geoff Levand
2014-10-31 7:52 ` [PATCH 00/10] arm64 kexec kernel patches V5 Dave Young
2014-10-31 23:25 ` Geoff Levand
2014-11-06 2:01 ` Dave Young
2014-11-13 8:37 ` Dave Young
2014-11-13 23:50 ` Geoff Levand
2014-11-17 3:49 ` Dave Young
2014-11-03 19:46 ` Mark Rutland
2014-11-06 1:56 ` Dave Young
2014-11-06 15:08 ` Mark Rutland
2014-11-07 0:41 ` Grant Likely
2014-11-07 10:16 ` Mark Rutland
2014-11-07 10:41 ` Ard Biesheuvel
2014-11-07 10:45 ` Ard Biesheuvel
2014-11-07 10:46 ` Ard Biesheuvel
2014-11-07 11:35 ` Mark Rutland
2014-11-07 11:42 ` Ard Biesheuvel
2014-11-07 22:34 ` Grant Likely
2014-11-06 12:16 ` Arun Chandran
2014-11-06 15:28 ` Mark Rutland
2014-11-06 16:13 ` Arun Chandran
2014-11-06 18:25 ` Geoff Levand
2014-11-07 6:26 ` Arun Chandran
2014-11-06 18:39 ` Mark Rutland
2014-11-07 6:36 ` Arun Chandran
2014-11-10 7:17 ` Dave Young
2014-11-10 8:35 ` Arun Chandran
2014-11-10 9:24 ` Dave Young
2014-11-12 9:56 ` Dave Young
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=20141024105724.GF24265@leverpostej \
--to=mark.rutland@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox