diff mbox series

[boot-wrapper,v2,7/8] aarch64: Prepare for booting with EL2

Message ID 20210521104807.138269-8-jaxson.han@arm.com (mailing list archive)
State New, archived
Headers show
Series Add Armv8-R AArch64 support | expand

Commit Message

Jaxson Han May 21, 2021, 10:48 a.m. UTC
Prepare for allowing boot-wrapper to be entered in EL2.
Detect current EL and set the corresponding EL registers.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
---
 arch/aarch64/boot.S  |  8 ++++++++
 arch/aarch64/utils.S | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Andre Przywara May 24, 2021, 9:33 a.m. UTC | #1
On Fri, 21 May 2021 18:48:06 +0800
Jaxson Han <jaxson.han@arm.com> wrote:

> Prepare for allowing boot-wrapper to be entered in EL2.
> Detect current EL and set the corresponding EL registers.
> 
> Signed-off-by: Jaxson Han <jaxson.han@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  arch/aarch64/boot.S  |  8 ++++++++
>  arch/aarch64/utils.S | 10 +++++++++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
> index 5600859..14fd9cf 100644
> --- a/arch/aarch64/boot.S
> +++ b/arch/aarch64/boot.S
> @@ -183,10 +183,18 @@ jump_kernel:
>  	 */
>  	bfi	x4, x19, #5, #1
>  
> +	mrs	x5, CurrentEL
> +	cmp	x5, #CURRENTEL_EL2
> +	b.eq	1f
> +
>  	msr	elr_el3, x19
>  	msr	spsr_el3, x4
>  	eret
>  
> +1:	msr	elr_el2, x19
> +	msr	spsr_el2, x4
> +	eret
> +
>  	.ltorg
>  
>  	.data
> diff --git a/arch/aarch64/utils.S b/arch/aarch64/utils.S
> index ae22ea7..94e9931 100644
> --- a/arch/aarch64/utils.S
> +++ b/arch/aarch64/utils.S
> @@ -37,10 +37,18 @@ find_logical_id:
>  	ret
>  
>  /*
> - * Setup EL3 vectors
> + * Setup EL3/EL2 vectors
>   * x0: vector address
>   */
>  setup_vector:
> +	mrs	x1, CurrentEL
> +	cmp	x1, #CURRENTEL_EL2
> +	b.eq	1f
> +
>  	msr	VBAR_EL3, x0
>  	isb
>  	ret
> +
> +1:	msr	VBAR_EL2, x0
> +	isb
> +	ret
diff mbox series

Patch

diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
index 5600859..14fd9cf 100644
--- a/arch/aarch64/boot.S
+++ b/arch/aarch64/boot.S
@@ -183,10 +183,18 @@  jump_kernel:
 	 */
 	bfi	x4, x19, #5, #1
 
+	mrs	x5, CurrentEL
+	cmp	x5, #CURRENTEL_EL2
+	b.eq	1f
+
 	msr	elr_el3, x19
 	msr	spsr_el3, x4
 	eret
 
+1:	msr	elr_el2, x19
+	msr	spsr_el2, x4
+	eret
+
 	.ltorg
 
 	.data
diff --git a/arch/aarch64/utils.S b/arch/aarch64/utils.S
index ae22ea7..94e9931 100644
--- a/arch/aarch64/utils.S
+++ b/arch/aarch64/utils.S
@@ -37,10 +37,18 @@  find_logical_id:
 	ret
 
 /*
- * Setup EL3 vectors
+ * Setup EL3/EL2 vectors
  * x0: vector address
  */
 setup_vector:
+	mrs	x1, CurrentEL
+	cmp	x1, #CURRENTEL_EL2
+	b.eq	1f
+
 	msr	VBAR_EL3, x0
 	isb
 	ret
+
+1:	msr	VBAR_EL2, x0
+	isb
+	ret