Add Armv8-R AArch64 support
cover Add Armv8-R AArch64 support
Currently, we cannot boot Linux with boot-wrapper on Armv8-R AArch64:
1. The Armv8-R AArch64 profile does not support the EL3.
2. The Armv8-R AArch64 EL2 only supports a PMSA, which Linux does not support. So it's necessary to drop into EL1 before entering the kernel.
3. There is no EL2 booting code for Armv8-R AArch64 and no configuration for dropping to EL1 in boot-wrapper.
These patches enable boot-wrapper booting Linux with Armv8-R AArch64:
Patch 1 allows boot-wrapper to boot on more platforms. Patch 2 renames some labels as preparations for booting from lower EL. Patch 3 prepares for GICv3 initialization with EL2.
Patch 4 adds necessary EL2 registers.
Patch 5 adds auto-detection for Armv8-R AArch64 to drop into EL1 before entering the kernel.
Refs: Arm Architecture Reference Manual Supplement - Armv8, for Armv8-R AArch64 architecture profile
[https://developer.arm.com/documentation/ddi0600/latest/]
Jaxson Han (5):
Decouple V2M_SYS config by auto-detect dtb node
aarch64: Rename labels and prepare for lower EL booting
gic-v3: Prepare for gicv3 with EL2
aarch64: Prepare for booting with EL2
aarch64: Introduce EL2 boot code for Armv8-R AArch64
Makefile.am | 2 +- arch/aarch32/include/asm/gic-v3.h | 7 ++ arch/aarch64/boot.S | 105 ++++++++++++++++++++++++++---- arch/aarch64/include/asm/cpu.h | 3 + arch/aarch64/include/asm/gic-v3.h | 38 ++++++++++- arch/aarch64/psci.S | 13 ++-- arch/aarch64/spin.S | 8 +-- arch/aarch64/utils.S | 10 ++- gic-v3.c | 2 +- platform.c | 4 ++ 10 files changed, 162 insertions(+), 30 deletions(-)
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/5 Decouple V2M_SYS config by auto-detect dtb node
An auto-detect switch is added to make it an option to enable/disable 'arm,vexpress-sysreg', because not all platforms support this feature.
--- Makefile.am | 2 +- platform.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
Makefile.am +1 -1
@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w) DEFINES = -DCNTFRQ=$(CNTFRQ) DEFINES += -DCPU_IDS=$(CPU_IDS) DEFINES += -DNR_CPUS=$(NR_CPUS) -DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE) +DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), ) DEFINES += -DUART_BASE=$(UART_BASE) DEFINES += -DSTACK_SIZE=256
platform.c +4 -0
@@ -23,10 +23,12 @@#define PL011 (reg) ((void *)UART_BASE + PL011_##reg) +#ifdef SYSREGS_BASE #define V2M_SYS_CFGDATA 0xa0#define V2M_SYS_CFGCTRL 0xa4#define V2M_SYS (reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) +#endif static void print_string (const char *str) {
@@ -59,6 +61,7 @@ void init_platform(void)print_string ("Boot-wrapper v0.2\r\n\r\n" ); +#ifdef SYSREGS_BASE /* * CLCD output site MB */
@@ -66,4 +69,5 @@ void init_platform(void)/* START | WRITE | MUXFPGA | SITE_MB */ raw_writel ((1 <<31 ) | (1 <<30 ) | (7 <<20 ) | (0 <<16 ),V2M_SYS (CFGCTRL )); +#endif }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/5 aarch64: Rename labels and prepare for lower EL booting
In reply to Jaxson HanPrepare for booting from lower EL. Rename *_el3 relavant labels with *_el_max and *_no_el3 with *_keep_el. Since the original _no_el3 means "We neither do init sequence at this highest EL nor drop to lower EL when entering to kernel", we rename it with _keep_el to make it more clear for lower EL initialisation.
Also in jump_kernel, skip sctlr_el2 initialisation when CurrentEL < EL2.
--- arch/aarch64/boot.S | 54 +++++++++++++++++++++++++--------- arch/aarch64/include/asm/cpu.h | 3 ++ arch/aarch64/psci.S | 13 ++++---- arch/aarch64/spin.S | 8 ++--- 4 files changed, 54 insertions(+), 24 deletions(-)
arch/aarch64/boot.S +40 -14
@@ -12,7 +12,7 @@ .section .init .globl _start - .globl jump_kernel + .globl jump_kernel _start: cpuid x0, x1
@@ -22,20 +22,30 @@ _start: bl setup_stack /* - * EL3 initialisation + * Boot sequence + * If CurrentEL == EL3, then goto EL3 initialisation and drop to + * lower EL before entering the kernel. + * Else, no initialisation and keep the current EL before + * entering the kernel. */ mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 - b.eq 1f + beq el3_init + /* + * We stay in the current EL for entering the kernel + */ mov w0, #1 - ldr x1, =flag_no_el3 + ldr x1, =flag_keep_el str w0, [x1] - bl setup_stack - b start_no_el3 + b start_keep_el -1: mov x0, #0x30 // RES1 + /* + * EL3 initialisation + */ +el3_init: + mov x0, #0x30 // RES1 orr x0, x0, #(1 << 0) // Non-secure EL1 orr x0, x0, #(1 << 8) // HVC enable
@@ -93,13 +103,23 @@ _start: mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable full vector len msr ZCR_EL3, x0 // for EL2. -1: + /* + * Save SPSR_KERNEL into spsr_to_elx. + * The jump_kernel will load spsr_to_elx into spsr_el3 + */ +1: mov w0, #SPSR_KERNEL + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + +el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0 + isb bl gic_secure_init - b start_el3 + b start_el_max err_invalid_id: b .
@@ -119,14 +139,18 @@ jump_kernel: ldr x0, =SCTLR_EL1_RESET msr sctlr_el1, x0 + mrs x0, CurrentEL + cmp x0, #CURRENTEL_EL2 + b.lt 1f + ldr x0, =SCTLR_EL2_RESET msr sctlr_el2, x0 - cpuid x0, x1 +1: cpuid x0, x1 bl find_logical_id bl setup_stack // Reset stack pointer - ldr w0, flag_no_el3 + ldr w0, flag_keep_el cmp w0, #0 // Prepare Z flag mov x0, x20
@@ -135,9 +159,9 @@ jump_kernel: mov x3, x23 b.eq 1f - br x19 // No EL3 + br x19 // Keep current EL -1: mov x4, #SPSR_KERNEL +1: ldr w4, spsr_to_elx /* * If bit 0 of the kernel address is set, we're entering in AArch32
@@ -153,5 +177,7 @@ jump_kernel: .data .align 3 -flag_no_el3: +flag_keep_el: + .long 0 +spsr_to_elx: .long 0
arch/aarch64/include/asm/cpu.h +3 -0
@@ -11,6 +11,7 @@#define MPIDR_ID_BITS 0xff00ffffff +#define CURRENTEL_EL2 (2 << 2)#define CURRENTEL_EL3 (3 << 2)/*
@@ -24,6 +25,7 @@#define SPSR_I (1 << 7)/* IRQ masked */ #define SPSR_F (1 << 6)/* FIQ masked */ #define SPSR_T (1 << 5)/* Thumb */ +#define SPSR_EL1H (5 << 0)/* EL1 Handler mode */ #define SPSR_EL2H (9 << 0)/* EL2 Handler mode */ #define SPSR_HYP (0x1a << 0)/* M[3:0] = hyp, M[4] = AArch32 */
@@ -42,6 +44,7 @@#else #define SCTLR_EL1_RESET SCTLR_EL1_RES1#define SPSR_KERNEL (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL2H) +#define SPSR_KERNEL_EL1 (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL1H)#endif #ifndef __ASSEMBLY__
arch/aarch64/psci.S +7 -6
@@ -45,8 +45,8 @@ vector: .text - .globl start_no_el3 - .globl start_el3 + .globl start_keep_el + .globl start_el_max err_exception: b err_exception
@@ -101,7 +101,7 @@ smc_exit: eret -start_el3: +start_el_max: ldr x0, =vector bl setup_vector
@@ -111,10 +111,11 @@ start_el3: b psci_first_spin /* - * This PSCI implementation requires EL3. Without EL3 we'll only boot the - * primary cpu, all others will be trapped in an infinite loop. + * This PSCI implementation requires the highest EL(EL3 or Armv8-R EL2). + * Without the highest EL, we'll only boot the primary cpu, all others + * will be trapped in an infinite loop. */ -start_no_el3: +start_keep_el: cpuid x0, x1 bl find_logical_id cbz x0, psci_first_spin
arch/aarch64/spin.S +4 -4
@@ -11,11 +11,11 @@ .text - .globl start_no_el3 - .globl start_el3 + .globl start_keep_el + .globl start_el_max -start_el3: -start_no_el3: +start_el_max: +start_keep_el: cpuid x0, x1 bl find_logical_id
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 4/5 aarch64: Prepare for booting with EL2
In reply to Jaxson HanPrepare for allowing boot-wrapper to be entered in EL2.
--- arch/aarch64/utils.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/aarch64/utils.S +9 -1
@@ -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
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/5 gic-v3: Prepare for gicv3 with EL2
In reply to Jaxson HanThis is a preparation for allowing boot-wrapper configuring the gicv3 with EL2.
--- arch/aarch32/include/asm/gic-v3.h | 7 ++++++ arch/aarch64/include/asm/gic-v3.h | 38 ++++++++++++++++++++++++++++--- gic-v3.c | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-)
arch/aarch32/include/asm/gic-v3.h +7 -0
@@ -9,6 +9,8 @@#ifndef __ASM_AARCH32_GICV3_H#define __ASM_AARCH32_GICV3_H +#define ICC_CTLR_RESET (0UL) +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val;
@@ -26,4 +28,9 @@ static inline void gic_write_icc_ctlr(uint32_t val) asm volatile ("mcr p15, 6, %0, c12, c12, 4" : : "r" (val)); } +static inline void gic_init_icc_ctlr () +{ +gic_write_icc_ctlr (ICC_CTLR_RESET ); +} +#endif
arch/aarch64/include/asm/gic-v3.h +35 -3
@@ -15,21 +15,53 @@#define ICC_CTLR_EL3 "S3_6_C12_C12_4"#define ICC_PMR_EL1 "S3_0_C4_C6_0" +#define ICC_CTLR_EL3_RESET (0UL) +#define ICC_CTLR_EL1_RESET (0UL) + +static inline uint32_t current_el (void ) +{ +uint32_t val; + + asmvolatile ("mrs %0, CurrentEL" :"=r" (val)); +return val; +} +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val; - asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); + +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); +else + asmvolatile ("mrs %0, " ICC_SRE_EL2 :"=r" (val)); +return val; }static inline void gic_write_icc_sre (uint32_t val) { - asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +else + asmvolatile ("msr " ICC_SRE_EL2 ", %0" : :"r" (val)); } -static inline void gic_write_icc_ctlr (uint32_t val) +static inline void gic_write_icc_ctlr_el3 (uint32_t val) { asmvolatile ("msr " ICC_CTLR_EL3 ", %0" : :"r" (val)); } +static inline void gic_write_icc_ctlr_el1 (uint32_t val) +{ + asmvolatile ("msr " ICC_CTLR_EL1 ", %0" : :"r" (val)); +} + +static inline void gic_init_icc_ctlr () +{ +if (current_el () ==CURRENTEL_EL3 ) +gic_write_icc_ctlr_el3 (ICC_CTLR_EL3_RESET ); +else +gic_write_icc_ctlr_el1 (ICC_CTLR_EL1_RESET ); +} +#endif
gic-v3.c +1 -1
@@ -121,6 +121,6 @@ void gic_secure_init(void)gic_write_icc_sre (sre);isb (); -gic_write_icc_ctlr (0 ); +gic_init_icc_ctlr ();isb (); }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/5 aarch64: Introduce EL2 boot code for Armv8-R AArch64
In reply to Jaxson HanThe Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf (Armv8-R aarch64),
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.
--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
arch/aarch64/boot.S +51 -0
@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto + * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_init /* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]
@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_init + /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_el + + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64 support + msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4)) + and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2 + orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0
@@ -169,10 +212,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
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 1/5] Decouple V2M_SYS config by auto-detect dtb node
In reply to Jaxson HanOn Tue, 20 Apr 2021 15:24:34 +0800
Jaxson Han <[email protected]> wrote:
Hi,
Quoted 2 lines
An auto-detect switch is added to make it an option to enable/disable 'arm,vexpress-sysreg', because not all platforms support this feature.
The change itself is fine, only has the side effect of now printing an message about the missing node:
No matching devices found at ./findbase.pl line 37.
I will have a look if we can avoid this, or we drop this message in findbase.pl at all.
But for the sake of this patch:
Cheers,
Andre
Quoted 45 lines
Signed-off-by Jaxson Han <[email protected]>--- Makefile.am | 2 +- platform.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)Makefile.am +1
-1@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w) DEFINES = -DCNTFRQ=$(CNTFRQ) DEFINES += -DCPU_IDS=$(CPU_IDS) DEFINES += -DNR_CPUS=$(NR_CPUS) -DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE) +DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), ) DEFINES += -DUART_BASE=$(UART_BASE) DEFINES += -DSTACK_SIZE=256platform.c +3
-0@@ -23,10 +23,12 @@#define PL011 (reg) ((void *)UART_BASE + PL011_##reg) +#ifdef SYSREGS_BASE #define V2M_SYS_CFGDATA 0xa0#define V2M_SYS_CFGCTRL 0xa4#define V2M_SYS (reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) +#endif static void print_string (const char *str) {@@ -59,6 +61,7 @@ void init_platform(void)print_string ("Boot-wrapper v0.2\r\n\r\n" ); +#ifdef SYSREGS_BASE /* * CLCD output site MB */
platform.c void init_platform(void) · line 73
Quoted 5 lines
platform.c +1
-0@@ -66,4 +69,5 @@ void init_platform(void)/* START | WRITE | MUXFPGA | SITE_MB */ raw_writel ((1 <<31 ) | (1 <<30 ) | (7 <<20 ) | (0 <<16 ),V2M_SYS (CFGCTRL )); +#endif }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 2/5] aarch64: Rename labels and prepare for lower EL booting
In reply to Jaxson HanQuoted 5 lines · On Tue, 20 Apr 2021 15:24:35 +0800 Jaxson Han <[email protected]> wrote:
Prepare for booting from lower EL. Rename
*_el3relavant labels with*_el_maxand*_no_el3with*_keep_el. Since the original_no_el3means "We neither do init sequence at this highest EL nor drop to lower EL when entering to kernel", we rename it with_keep_elto make it more clear for lower EL initialisation.
So this cleanup and rename is fine, however the patch is hard to read since various other changes are mixed in.
Can you try to isolate this more? If this patch would just rename the labels, and wouldn't carry any functional change, it might be easier to reason about. At least the SPSR value change should be separate.
Some more below:
Quoted 38 lines
Also in
jump_kernel, skipsctlr_el2initialisation when CurrentEL < EL2.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 54 +++++++++++++++++++++++++--------- arch/aarch64/include/asm/cpu.h | 3 ++ arch/aarch64/psci.S | 13 ++++---- arch/aarch64/spin.S | 8 ++--- 4 files changed, 54 insertions(+), 24 deletions(-)arch/aarch64/boot.S +7
-3@@ -12,7 +12,7 @@ .section .init .globl _start - .globl jump_kernel + .globl jump_kernel _start: cpuid x0, x1@@ -22,20 +22,30 @@ _start: bl setup_stack /* - * EL3 initialisation + * Boot sequence + * If CurrentEL == EL3, then goto EL3 initialisation and drop to + * lower EL before entering the kernel. + * Else, no initialisation and keep the current EL before + * entering the kernel. */ mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 - b.eq 1f + beq el3_init
arch/aarch64/boot.S _start: · line 35
Quoted 10 lines
arch/aarch64/boot.S +4
-2+ /* + * We stay in the current EL for entering the kernel + */ mov w0, #1 - ldr x1, =flag_no_el3 + ldr x1, =flag_keep_el str w0, [x1] - bl setup_stack
I think this is indeed redundant, but can you either make this a separate patch or at least mention it in the commit message?
Quoted 15 lines
arch/aarch64/boot.S +6
-2- b start_no_el3 + b start_keep_el -1: mov x0, #0x30 // RES1 + /* + * EL3 initialisation + */ +el3_init: + mov x0, #0x30 // RES1 orr x0, x0, #(1 << 0) // Non-secure EL1 orr x0, x0, #(1 << 8) // HVC enable@@ -93,13 +103,23 @@ _start: mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable full vector len msr ZCR_EL3, x0 // for EL2.
arch/aarch64/boot.S _start: · line 113
Quoted 10 lines
arch/aarch64/boot.S +8
-1-1: + /* + * Save SPSR_KERNEL into spsr_to_elx. + * The jump_kernel will load spsr_to_elx into spsr_el3 + */ +1: mov w0, #SPSR_KERNEL + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init
This (and the other SPSR related changes below) should be in a separate patch.
arch/aarch64/boot.S _start: · line 118
Quoted 5 lines
arch/aarch64/boot.S +3
-0+ +el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0 + isb
Why this isb here? I don't see that we would require this?
Quoted 8 lines
arch/aarch64/boot.S +1
-1bl gic_secure_init - b start_el3 + b start_el_max err_invalid_id: b .
arch/aarch64/boot.S jump_kernel: · line 145
Quoted 7 lines
arch/aarch64/boot.S +4
-0@@ -119,14 +139,18 @@ jump_kernel: ldr x0, =SCTLR_EL1_RESET msr sctlr_el1, x0 + mrs x0, CurrentEL + cmp x0, #CURRENTEL_EL2 + b.lt 1f +
This is also a change which might be separate.
Cheers,
Andre
Quoted 111 lines
arch/aarch64/boot.S +7
-5ldr x0, =SCTLR_EL2_RESET msr sctlr_el2, x0 - cpuid x0, x1 +1: cpuid x0, x1 bl find_logical_id bl setup_stack // Reset stack pointer - ldr w0, flag_no_el3 + ldr w0, flag_keep_el cmp w0, #0 // Prepare Z flag mov x0, x20@@ -135,9 +159,9 @@ jump_kernel: mov x3, x23 b.eq 1f - br x19 // No EL3 + br x19 // Keep current EL -1: mov x4, #SPSR_KERNEL +1: ldr w4, spsr_to_elx /* * If bit 0 of the kernel address is set, we're entering in AArch32@@ -153,5 +177,7 @@ jump_kernel: .data .align 3 -flag_no_el3: +flag_keep_el: + .long 0 +spsr_to_elx: .long 0arch/aarch64/include/asm/cpu.h +3
-0@@ -11,6 +11,7 @@#define MPIDR_ID_BITS 0xff00ffffff +#define CURRENTEL_EL2 (2 << 2)#define CURRENTEL_EL3 (3 << 2)/* @@ -24,6 +25,7 @@#define SPSR_I (1 << 7)/* IRQ masked */ #define SPSR_F (1 << 6)/* FIQ masked */ #define SPSR_T (1 << 5)/* Thumb */ +#define SPSR_EL1H (5 << 0)/* EL1 Handler mode */ #define SPSR_EL2H (9 << 0)/* EL2 Handler mode */ #define SPSR_HYP (0x1a << 0)/* M[3:0] = hyp, M[4] = AArch32 */ @@ -42,6 +44,7 @@#else #define SCTLR_EL1_RESET SCTLR_EL1_RES1#define SPSR_KERNEL (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL2H) +#define SPSR_KERNEL_EL1 (SPSR_A | SPSR_D | SPSR_I | SPSR_F | SPSR_EL1H)#endif #ifndef __ASSEMBLY__arch/aarch64/psci.S +7
-6@@ -45,8 +45,8 @@ vector: .text - .globl start_no_el3 - .globl start_el3 + .globl start_keep_el + .globl start_el_max err_exception: b err_exception@@ -101,7 +101,7 @@ smc_exit: eret -start_el3: +start_el_max: ldr x0, =vector bl setup_vector@@ -111,10 +111,11 @@ start_el3: b psci_first_spin /* - * This PSCI implementation requires EL3. Without EL3 we'll only boot the - * primary cpu, all others will be trapped in an infinite loop. + * This PSCI implementation requires the highest EL(EL3 or Armv8-R EL2). + * Without the highest EL, we'll only boot the primary cpu, all others + * will be trapped in an infinite loop. */ -start_no_el3: +start_keep_el: cpuid x0, x1 bl find_logical_id cbz x0, psci_first_spinarch/aarch64/spin.S +0
-2@@ -11,11 +11,11 @@ .text - .globl start_no_el3 - .globl start_el3
arch/aarch64/spin.S line 21
Quoted 10 lines
arch/aarch64/spin.S +4
-2+ .globl start_keep_el + .globl start_el_max -start_el3: -start_no_el3: +start_el_max: +start_keep_el: cpuid x0, x1 bl find_logical_id
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 3/5] gic-v3: Prepare for gicv3 with EL2
In reply to Jaxson HanQuoted 2 lines · On Tue, 20 Apr 2021 15:24:36 +0800 Jaxson Han <[email protected]> wrote:
This is a preparation for allowing boot-wrapper configuring the gicv3 with EL2.
The GIC is always confusing, so can you please give some more background here? The introduction of ICC_SRE_EL2 looks straight-forward enough, but the change to the ICC_CTLR_RESET register deserves some comments, I guess.
Cheers,
Andre
Quoted 96 lines
Signed-off-by Jaxson Han <[email protected]>--- arch/aarch32/include/asm/gic-v3.h | 7 ++++++ arch/aarch64/include/asm/gic-v3.h | 38 ++++++++++++++++++++++++++++--- gic-v3.c | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-)arch/aarch32/include/asm/gic-v3.h +7
-0@@ -9,6 +9,8 @@#ifndef __ASM_AARCH32_GICV3_H#define __ASM_AARCH32_GICV3_H +#define ICC_CTLR_RESET (0UL) +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val;@@ -26,4 +28,9 @@ static inline void gic_write_icc_ctlr(uint32_t val) asm volatile ("mcr p15, 6, %0, c12, c12, 4" : : "r" (val)); } +static inline void gic_init_icc_ctlr () +{ +gic_write_icc_ctlr (ICC_CTLR_RESET ); +} +#endif arch/aarch64/include/asm/gic-v3.h +35
-3@@ -15,21 +15,53 @@#define ICC_CTLR_EL3 "S3_6_C12_C12_4"#define ICC_PMR_EL1 "S3_0_C4_C6_0" +#define ICC_CTLR_EL3_RESET (0UL) +#define ICC_CTLR_EL1_RESET (0UL) + +static inline uint32_t current_el (void ) +{ +uint32_t val; + + asmvolatile ("mrs %0, CurrentEL" :"=r" (val)); +return val; +} +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val; - asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); + +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); +else + asmvolatile ("mrs %0, " ICC_SRE_EL2 :"=r" (val)); +return val; }static inline void gic_write_icc_sre (uint32_t val) { - asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +else + asmvolatile ("msr " ICC_SRE_EL2 ", %0" : :"r" (val)); } -static inline void gic_write_icc_ctlr (uint32_t val) +static inline void gic_write_icc_ctlr_el3 (uint32_t val) { asmvolatile ("msr " ICC_CTLR_EL3 ", %0" : :"r" (val)); } +static inline void gic_write_icc_ctlr_el1 (uint32_t val) +{ + asmvolatile ("msr " ICC_CTLR_EL1 ", %0" : :"r" (val)); +} + +static inline void gic_init_icc_ctlr () +{ +if (current_el () ==CURRENTEL_EL3 ) +gic_write_icc_ctlr_el3 (ICC_CTLR_EL3_RESET ); +else +gic_write_icc_ctlr_el1 (ICC_CTLR_EL1_RESET ); +} +#endif gic-v3.c +0
-0
gic-v3.c void gic_secure_init(void) · line 126
Quoted 7 lines
gic-v3.c +1
-1@@ -121,6 +121,6 @@ void gic_secure_init(void)gic_write_icc_sre (sre);isb (); -gic_write_icc_ctlr (0 ); +gic_init_icc_ctlr ();isb (); }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 4/5] aarch64: Prepare for booting with EL2
In reply to Jaxson HanQuoted 3 lines · On Tue, 20 Apr 2021 15:24:37 +0800 Jaxson Han <[email protected]> wrote:
Prepare for allowing boot-wrapper to be entered in EL2.
Signed-off-by Jaxson Han <[email protected]>
Thanks,
Andre
Quoted 18 lines
--- arch/aarch64/utils.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)arch/aarch64/utils.S +2
-1@@ -37,10 +37,18 @@ find_logical_id: ret /* - * Setup EL3 vectors + * Setup EL3/EL2 vectors * x0: vector address */ setup_vector: + mrs x1, CurrentEL
arch/aarch64/utils.S find_logical_id: · line 54
Quoted 10 lines
arch/aarch64/utils.S +7
-0+ cmp x1, #CURRENTEL_EL2 + b.eq 1f + msr VBAR_EL3, x0 isb ret + +1: msr VBAR_EL2, x0 + isb + ret
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
In reply to Jaxson HanOn Tue, 20 Apr 2021 15:24:38 +0800
Jaxson Han <[email protected]> wrote:
Hi,
Quoted 29 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-R aarch64),
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)arch/aarch64/boot.S +1
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto
arch/aarch64/boot.S _start: · line 38
Quoted 10 lines
arch/aarch64/boot.S +4
-0+ * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_init
nitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for EL1 and b.eq for EL2 code. Saves you an extra cmp here.
Quoted 11 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_init
arch/aarch64/boot.S el3_init: · line 130
Quoted 10 lines
arch/aarch64/boot.S +10
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_el
Don't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the 0b0010 case.
arch/aarch64/boot.S el3_init: · line 143
Quoted 13 lines
arch/aarch64/boot.S +13
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64 support + msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))
Each feature only holds four bits, so the mask you shift should be 0xf.
arch/aarch64/boot.S el3_init: · line 147
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2
Shouldn't we force HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle very well? So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...
Rest looks alright.
Cheers,
Andre
Quoted 22 lines
arch/aarch64/boot.S +14
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,18 @@ jump_kernel: */ bfi x4, x19, #5, #1 + mrs x5, CurrentEL + cmp x5, #CURRENTEL_EL2 + b.eq 1f + msr elr_el3, x19
arch/aarch64/boot.S jump_kernel: · line 229
Quoted 10 lines
arch/aarch64/boot.S +4
-0msr spsr_el3, x4 eret +1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 1/5] Decouple V2M_SYS config by auto-detect dtb node
In reply to Andre PrzywaraHi Andre,
Quoted 17 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 7:30 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 1/5] DecoupleV2M_SYSconfig by auto- detect dtb nodeOn Tue, 20 Apr 2021 15:24:34 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 2 lines
An auto-detect switch is added to make it an option to enable/disable 'arm,vexpress-sysreg', because not all platforms support this feature.
Quoted 6 lines
The change itself is fine, only has the side effect of now printing an message about the missing node:
No matching devices found at ./findbase.pl line 37.I will have a look if we can avoid this, or we drop this message in findbase.pl at all.
Thanks, if you have any suggestions, please let me know:)
Quoted 7 lines
But for the sake of this patch:
Reviewed-by Andre Przywara <[email protected]>Cheers,
Andre
Thanks!
Jaxson
Quoted 41 lines
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc
Quoted 11 lines
Signed-off-by Jaxson Han <[email protected]>--- Makefile.am | 2 +- platform.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)Makefile.am +0
-0@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc-w)
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w)
Quoted 5 lines
Makefile.am +1
-1DEFINES = -DCNTFRQ=$(CNTFRQ) DEFINES += -DCPU_IDS=$(CPU_IDS) DEFINES += -DNR_CPUS=$(NR_CPUS) -DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE) +DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), )
Quoted 23 lines
Makefile.am +0
-0DEFINES += -DUART_BASE=$(UART_BASE) DEFINES += -DSTACK_SIZE=256platform.c +2
-0@@ -23,10 +23,12 @@#define PL011 (reg) ((void *)UART_BASE + PL011_##reg) +#ifdef SYSREGS_BASE #define V2M_SYS_CFGDATA 0xa0#define V2M_SYS_CFGCTRL 0xa4#define V2M_SYS (reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) +#endif static void print_string(const char *str) { @@ -59,6 +61,7 @@ voidinit_platform (void )
print_string("Boot-wrapper v0.2\r\n\r\n");
Quoted 10 lines
platform.c void init_platform(void) · line 73
Quoted 10 lines
platform.c +2
-0+#ifdef SYSREGS_BASE /* * CLCD output site MB */ @@ -66,4 +69,5 @@ void init_platform(void)/* START | WRITE | MUXFPGA | SITE_MB */ raw_writel ((1 <<31 ) | (1 <<30 ) | (7 <<20 ) | (0 <<16 ),V2M_SYS (CFGCTRL )); +#endif }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 2/5] aarch64: Rename labels and prepare for lower EL booting
In reply to Andre PrzywaraHi Andre,
Quoted 18 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 7:41 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 2/5] aarch64: Rename labels and prepare for lower EL bootingQuoted 5 lines · On Tue, 20 Apr 2021 15:24:35 +0800 Jaxson Han <[email protected]> wrote:
Prepare for booting from lower EL. Rename
*_el3relavant labels with*_el_maxand*_no_el3with*_keep_el. Since the original_no_el3means "We neither do init sequence at this highest EL nor drop to lower EL when entering to kernel", we rename it with_keep_elto make it more clear for lower EL initialisation.
Quoted 5 lines
So this cleanup and rename is fine, however the patch is hard to read since various other changes are mixed in.
Can you try to isolate this more? If this patch would just rename the labels, and wouldn't carry any functional change, it might be easier to reason about. At least the SPSR value change should be separate.
Yes, I will.
Quoted 50 lines
Some more below:
Quoted 47 lines
Also in
jump_kernel, skipsctlr_el2initialisation when CurrentEL < EL2.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 54 +++++++++++++++++++++++++--------- arch/aarch64/include/asm/cpu.h | 3 ++ arch/aarch64/psci.S | 13 ++++---- arch/aarch64/spin.S | 8 ++--- 4 files changed, 54 insertions(+), 24 deletions(-)arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0e47cf59..f7dbf3f 100644
arch/aarch64/boot.S +11
-4@@ -12,7 +12,7 @@ .section .init .globl _start - .globl jump_kernel + .globl jump_kernel _start: cpuid x0, x1@@ -22,20 +22,30 @@ _start: bl setup_stack /* - * EL3 initialisation + * Boot sequence + * If CurrentEL == EL3, then goto EL3 initialisation and drop to + * lower EL before entering the kernel. + * Else, no initialisation and keep the current EL before + * entering the kernel. */ mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 - b.eq 1f + beq el3_init + /* + * We stay in the current EL for entering the kernel + */ mov w0, #1 - ldr x1, =flag_no_el3 + ldr x1, =flag_keep_el str w0, [x1]
Quoted 4 lines
arch/aarch64/boot.S _start: · line 35
Quoted 1 line
arch/aarch64/boot.S +0
-1- bl setup_stackI think this is indeed redundant, but can you either make this a separate patch or at least mention it in the commit message?
Yes, I will make this separate.
Quoted 18 lines
Quoted 14 lines
arch/aarch64/boot.S +6
-2- b start_no_el3 + b start_keep_el -1: mov x0, #0x30 // RES1 + /* + * EL3 initialisation + */ +el3_init: + mov x0, #0x30 // RES1 orr x0, x0, #(1 << 0) // Non-secure EL1 orr x0, x0, #(1 << 8) // HVC enablearch/aarch64/boot.S _start: · line 103
Quoted 1 line
arch/aarch64/boot.S +0
-0@@ -93,13 +103,23 @@ _start: mov x0, #ZCR_EL3_LEN_MASK // SVE: Enable fullvector len
Quoted 2 lines
arch/aarch64/boot.S +0
-0msr ZCR_EL3, x0 // for EL2.
Quoted 12 lines
arch/aarch64/boot.S _start: · line 113
Quoted 9 lines
arch/aarch64/boot.S +8
-1-1: + /* + * Save SPSR_KERNEL into spsr_to_elx. + * The jump_kernel will load spsr_to_elx into spsr_el3 + */ +1: mov w0, #SPSR_KERNEL + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_initThis (and the other SPSR related changes below) should be in a separate patch.
Yes, I will
Quoted 8 lines
arch/aarch64/boot.S _start: · line 118
Quoted 6 lines
arch/aarch64/boot.S +3
-0+ +el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0 + isbWhy this isb here? I don't see that we would require this?
No need here. I'll remove it.
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-1bl gic_secure_init - b start_el3 + b start_el_max err_invalid_id: b .@@ -119,14 +139,18 @@ jump_kernel: ldr x0, =SCTLR_EL1_RESET msr sctlr_el1, x0
Quoted 6 lines
arch/aarch64/boot.S jump_kernel: · line 145
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ mrs x0, CurrentEL + cmp x0, #CURRENTEL_EL2 + b.lt 1f +This is also a change which might be separate.
Yes
Thanks,
Jaxson
Quoted 124 lines
Cheers,
AndreQuoted 47 lines
arch/aarch64/boot.S +7
-5ldr x0, =SCTLR_EL2_RESET msr sctlr_el2, x0 - cpuid x0, x1 +1: cpuid x0, x1 bl find_logical_id bl setup_stack // Reset stack pointer - ldr w0, flag_no_el3 + ldr w0, flag_keep_el cmp w0, #0 // Prepare Z flag mov x0, x20@@ -135,9 +159,9 @@ jump_kernel: mov x3, x23 b.eq 1f - br x19 // No EL3 + br x19 // Keep current EL -1: mov x4, #SPSR_KERNEL +1: ldr w4, spsr_to_elx /* * If bit 0 of the kernel address is set, we're entering in AArch32@@ -153,5 +177,7 @@ jump_kernel: .data .align 3 -flag_no_el3: +flag_keep_el: + .long 0 +spsr_to_elx: .long 0(quoted diff) +0
-0
b/arch/aarch64/include/asm/cpu.hindex ccb5397..2b3a0a4 100644arch/aarch64/include/asm/cpu.h +1
-0@@ -11,6 +11,7 @@#define MPIDR_ID_BITS 0xff00ffffff +#define CURRENTEL_EL2 (2 << 2)#define CURRENTEL_EL3 (3 << 2)/* arch/aarch64/include/asm/cpu.h line 30
Quoted 6 lines
arch/aarch64/include/asm/cpu.h +1
-0@@ -24,6 +25,7 @@#define SPSR_I (1 << 7)/* IRQ masked */ #define SPSR_F (1 << 6)/* FIQ masked */ #define SPSR_T (1 << 5)/* Thumb */ +#define SPSR_EL1H (5 << 0)/* EL1 Handler mode */ #define SPSR_EL2H (9 << 0)/* EL2 Handler mode */ #define SPSR_HYP (0x1a << 0)/* M[3:0] = hyp, M[4] = AArch32 */
arch/aarch64/include/asm/cpu.h line 46
Quoted 5 lines
arch/aarch64/include/asm/cpu.h +0
-0@@ -42,6 +44,7 @@#else #define SCTLR_EL1_RESET SCTLR_EL1_RES1#define SPSR_KERNEL (SPSR_A | SPSR_D | SPSR_I | SPSR_F |
SPSR_EL2H)arch/aarch64/include/asm/cpu.h line 47
Quoted 1 line
arch/aarch64/include/asm/cpu.h +1
-0+#define SPSR_KERNEL_EL1 (SPSR_A | SPSR_D | SPSR_I | SPSR_F |
SPSR_EL1H)Quoted 57 lines
arch/aarch64/include/asm/cpu.h +0
-0#endif #ifndef __ASSEMBLY__arch/aarch64/psci.S index renamed from arch/aarch64/psci.S +0
-001ebe7d..ae02fd6 100644
arch/aarch64/psci.S +3
-4@@ -45,8 +45,8 @@ vector: .text - .globl start_no_el3 - .globl start_el3 + .globl start_keep_el + .globl start_el_max err_exception: b err_exception@@ -101,7 +101,7 @@ smc_exit: eret -start_el3: +start_el_max: ldr x0, =vector bl setup_vector@@ -111,10 +111,11 @@ start_el3: b psci_first_spin /* - * This PSCI implementation requires EL3. Without EL3 we'll only bootthe
- * primary cpu, all others will be trapped in an infinite loop.
+ * This PSCI implementation requires the highest EL(EL3 or Armv8-R EL2).
+ * Without the highest EL, we'll only boot the primary cpu, all
+ others
+ * will be trapped in an infinite loop.
*/arch/aarch64/psci.S +1
-1-start_no_el3: +start_keep_el: cpuid x0, x1 bl find_logical_id cbz x0, psci_first_spinarch/aarch64/spin.S index renamed from arch/aarch64/spin.S +0
-072603cf..533177c 100644
arch/aarch64/spin.S +2
-2@@ -11,11 +11,11 @@ .text - .globl start_no_el3 - .globl start_el3 + .globl start_keep_el + .globl start_el_max
Quoted 7 lines
arch/aarch64/spin.S line 21
Quoted 7 lines
arch/aarch64/spin.S +2
-2-start_el3: -start_no_el3: +start_el_max: +start_keep_el: cpuid x0, x1 bl find_logical_id
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 3/5] gic-v3: Prepare for gicv3 with EL2
In reply to Andre PrzywaraHi Andre,
Quoted 11 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 7:48 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 3/5] gic-v3: Prepare for gicv3 with EL2On Tue, 20 Apr 2021 15:24:36 +0800
Jaxson Han <[email protected]> wrote:
Quoted 6 lines
Quoted 2 lines
This is a preparation for allowing boot-wrapper configuring the gicv3 with EL2.
The GIC is always confusing, so can you please give some more background here? The introduction of
ICC_SRE_EL2looks straight-forward enough, but the change to theICC_CTLR_RESETregister deserves some comments, I guess.
Right, I will put more details here.
Thanks,
Jaxson
Quoted 96 lines
Cheers,
AndreQuoted 4 lines
Signed-off-by Jaxson Han <[email protected]>--- arch/aarch32/include/asm/gic-v3.h | 7 ++++++
arch/aarch64/include/asm/gic-v3.h| 38 ++++++++++++++++++++++++++++---
Quoted 87 lines
gic-v3.c | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-)arch/aarch32/include/asm/gic-v3.h +6
-0@@ -9,6 +9,8 @@#ifndef __ASM_AARCH32_GICV3_H#define __ASM_AARCH32_GICV3_H +#define ICC_CTLR_RESET (0UL) +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val;@@ -26,4 +28,9 @@ static inline void gic_write_icc_ctlr(uint32_t val) asm volatile ("mcr p15, 6, %0, c12, c12, 4" : : "r" (val)); } +static inline void gic_init_icc_ctlr () { +gic_write_icc_ctlr (ICC_CTLR_RESET ); +} +#endif arch/aarch64/include/asm/gic-v3.h +31
-3@@ -15,21 +15,53 @@#define ICC_CTLR_EL3 "S3_6_C12_C12_4"#define ICC_PMR_EL1 "S3_0_C4_C6_0" +#define ICC_CTLR_EL3_RESET (0UL) +#define ICC_CTLR_EL1_RESET (0UL) + +static inline uint32_t current_el (void ) { +uint32_t val; + + asmvolatile ("mrs %0, CurrentEL" :"=r" (val)); +return val; +} +static inline uint32_t gic_read_icc_sre (void ) {uint32_t val; - asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); + +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("mrs %0, " ICC_SRE_EL3 :"=r" (val)); +else + asmvolatile ("mrs %0, " ICC_SRE_EL2 :"=r" (val)); +return val; }static inline void gic_write_icc_sre (uint32_t val) { - asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +if (current_el () ==CURRENTEL_EL3 ) + asmvolatile ("msr " ICC_SRE_EL3 ", %0" : :"r" (val)); +else + asmvolatile ("msr " ICC_SRE_EL2 ", %0" : :"r" (val)); } -static inline void gic_write_icc_ctlr (uint32_t val) +static inline void gic_write_icc_ctlr_el3 (uint32_t val) { asmvolatile ("msr " ICC_CTLR_EL3 ", %0" : :"r" (val)); } +static inline void gic_write_icc_ctlr_el1 (uint32_t val) { + asmvolatile ("msr " ICC_CTLR_EL1 ", %0" : :"r" (val)); } + +static inline void gic_init_icc_ctlr () { +if (current_el () ==CURRENTEL_EL3 ) +gic_write_icc_ctlr_el3 (ICC_CTLR_EL3_RESET ); +else +gic_write_icc_ctlr_el1 (ICC_CTLR_EL1_RESET ); +} +#endif gic-v3.c +0
-0@@ -121,6 +121,6 @@ void gic_secure_init(void)gic_write_icc_sre (sre);isb ();
Quoted 4 lines
gic-v3.c void gic_secure_init(void) · line 126
Quoted 4 lines
gic-v3.c +1
-1-gic_write_icc_ctlr (0 ); +gic_init_icc_ctlr ();isb (); }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
In reply to Andre PrzywaraHi Andre,
Quoted 49 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 20 Apr 2021 15:24:38 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 35 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-R aarch64),
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +3
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto + * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */
Quoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 5 lines
arch/aarch64/boot.S +2
-0mrs x0, CurrentEL cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for EL1 and b.eq for EL2 code. Saves you an extra cmp here.
Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_init
Quoted 14 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 10 lines
arch/aarch64/boot.S +10
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the 0b0010 case.
Yes, it should be checked, I will add it.
Quoted 10 lines
arch/aarch64/boot.S el3_init:
Quoted 9 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64support
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.
Yes, I will fix.
Quoted 10 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 5 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle very well? So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...
Right, we should force to set HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].
Thanks,
Jaxson
Quoted 32 lines
Rest looks alright.
Cheers,
AndreQuoted 25 lines
arch/aarch64/boot.S +14
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
Quoted 7 lines
arch/aarch64/boot.S jump_kernel: · line 229
Quoted 7 lines
arch/aarch64/boot.S +4
-0+1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
Hi Andre,
Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', we got a problem when compile the boot-wrapper with ' -march=armv8-r':
| ../git/arch/aarch64/boot.S:71: Error: selected processor does not support system register name 'scr_el3' | ../git/arch/aarch64/boot.S:73: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:84: Error: selected processor does not support system register name 'mdcr_el3' | ../git/arch/aarch64/boot.S:90: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:92: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:194: Error: selected processor does not support system register name 'elr_el3' | ../git/arch/aarch64/boot.S:195: Error: selected processor does not support system register name 'spsr_el3'
It seems we may need some #if macro to disable all _el3 registers, but it will break our auto-detection (users should add more compile/build parameter). So, may I ask your suggestions? :)
Cheers,
Jaxson
Quoted 170 lines
-----Original Message-----
From: Jaxson Han
Sent: Wednesday, April 28, 2021 11:44 AM
To: Andre Przywara <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Hi Andre,
Quoted 50 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 20 Apr 2021 15:24:38 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 36 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-R aarch64),
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +3
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto + * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentELQuoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 4 lines
arch/aarch64/boot.S +2
-0cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for
EL1 and b.eq for EL2 code. Saves you an extra cmp here.Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_initQuoted 14 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 10 lines
arch/aarch64/boot.S +10
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the 0b0010 case.
Yes, it should be checked, I will add it.
Quoted 10 lines
arch/aarch64/boot.S el3_init:
Quoted 9 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64support
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.Yes, I will fix.
Quoted 10 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 5 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle very well? So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...Right, we should force to set
HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].Thanks,
JaxsonQuoted 32 lines
Rest looks alright.
Cheers,
AndreQuoted 25 lines
arch/aarch64/boot.S +14
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S jump_kernel: · line 229
Quoted 7 lines
arch/aarch64/boot.S +4
-0+1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 1/5] Decouple V2M_SYS config by auto-detect dtb node
In reply to Jaxson HanOn Wed, 28 Apr 2021 03:23:18 +0000
Jaxson Han <[email protected]> wrote:
Hi Jaxson,
Quoted 19 lines
Hi Andre,
Quoted 17 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 7:30 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 1/5] DecoupleV2M_SYSconfig by auto- detect dtb nodeOn Tue, 20 Apr 2021 15:24:34 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 2 lines
An auto-detect switch is added to make it an option to enable/disable 'arm,vexpress-sysreg', because not all platforms support this feature.
Quoted 8 lines
Quoted 6 lines
The change itself is fine, only has the side effect of now printing an message about the missing node:
No matching devices found at ./findbase.pl line 37.I will have a look if we can avoid this, or we drop this message in findbase.pl at all.
Thanks, if you have any suggestions, please let me know:)
As Mark suggested, you can just add " 2> /dev/null" at the end of the findbase.pl call. That allows to do this warning suppression on a case-by-case base, and is preferred over dropping this message in general.
Cheers,
Andre
Quoted 53 lines
Quoted 8 lines
But for the sake of this patch:
Reviewed-by Andre Przywara <[email protected]>Cheers,
AndreThanks!
JaxsonQuoted 41 lines
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc
Quoted 11 lines
Signed-off-by Jaxson Han <[email protected]>--- Makefile.am | 2 +- platform.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)Makefile.am +0
-0@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc-w)
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w)
Quoted 5 lines
Makefile.am +1
-1DEFINES = -DCNTFRQ=$(CNTFRQ) DEFINES += -DCPU_IDS=$(CPU_IDS) DEFINES += -DNR_CPUS=$(NR_CPUS) -DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE) +DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), )
Quoted 23 lines
Makefile.am +0
-0DEFINES += -DUART_BASE=$(UART_BASE) DEFINES += -DSTACK_SIZE=256platform.c +2
-0@@ -23,10 +23,12 @@#define PL011 (reg) ((void *)UART_BASE + PL011_##reg) +#ifdef SYSREGS_BASE #define V2M_SYS_CFGDATA 0xa0#define V2M_SYS_CFGCTRL 0xa4#define V2M_SYS (reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) +#endif static void print_string(const char *str) { @@ -59,6 +61,7 @@ voidinit_platform (void )
print_string("Boot-wrapper v0.2\r\n\r\n");
Quoted 11 lines
Quoted 10 lines
platform.c void init_platform(void) · line 73
Quoted 10 lines
platform.c +2
-0+#ifdef SYSREGS_BASE /* * CLCD output site MB */ @@ -66,4 +69,5 @@ void init_platform(void)/* START | WRITE | MUXFPGA | SITE_MB */ raw_writel ((1 <<31 ) | (1 <<30 ) | (7 <<20 ) | (0 <<16 ),V2M_SYS (CFGCTRL )); +#endif }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
In reply to Jaxson HanQuoted 12 lines · On Mon, 10 May 2021 02:13:45 +0000 Jaxson Han <[email protected]> wrote:
Hi Andre,
Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', we got a problem when compile the boot-wrapper with ' -march=armv8-r':
| ../git/arch/aarch64/boot.S:71: Error: selected processor does not support system register name 'scr_el3' | ../git/arch/aarch64/boot.S:73: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:84: Error: selected processor does not support system register name 'mdcr_el3' | ../git/arch/aarch64/boot.S:90: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:92: Error: selected processor does not support system register name 'cptr_el3' | ../git/arch/aarch64/boot.S:194: Error: selected processor does not support system register name 'elr_el3' | ../git/arch/aarch64/boot.S:195: Error: selected processor does not support system register name 'spsr_el3'
Quoted 3 lines
It seems we may need some #if macro to disable all
_el3registers, but it will break our auto-detection (users should add more compile/build parameter). So, may I ask your suggestions? :)
Why do you need that in the first place? I think your version worked without it? At least Ubuntu's 9.3.0 compiled it just fine. Or does GCC 11 complain about some v8-r specific registers and you need to add this armv8-r to let them pass, sacrificing all EL3 registers on the way?
One solution could be to move all accesses to v8-r registers into a separate file, and only assemble/compile this with the v8-r switch. But this sounds like some serious plumbing in the code base.
What you could try as well is to use this "s3_0_c12_c12_5" like system register encoding style (this example is for ICC_SRE_EL1). The kernel uses this trick to avoid dependencies on gas knowing about all (new) system register names. Not sure if that is enough to trick gas into accepting it?
Hope that helps.
Cheers,
Andre
Quoted 174 lines
Cheers,
JaxsonQuoted 170 lines
-----Original Message-----
From: Jaxson Han
Sent: Wednesday, April 28, 2021 11:44 AM
To: Andre Przywara <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Hi Andre,
Quoted 50 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 20 Apr 2021 15:24:38 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 36 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-R aarch64),
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +3
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf, then goto + * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentELQuoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 4 lines
arch/aarch64/boot.S +2
-0cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for
EL1 and b.eq for EL2 code. Saves you an extra cmp here.Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_initQuoted 14 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 10 lines
arch/aarch64/boot.S +10
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1 + ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the 0b0010 case.
Yes, it should be checked, I will add it.
Quoted 10 lines
arch/aarch64/boot.S el3_init:
Quoted 9 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA: VMSAv8-64support
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.Yes, I will fix.
Quoted 10 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 5 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle very well? So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...Right, we should force to set
HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].Thanks,
JaxsonQuoted 32 lines
Rest looks alright.
Cheers,
AndreQuoted 25 lines
arch/aarch64/boot.S +14
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S jump_kernel: · line 229
Quoted 7 lines
arch/aarch64/boot.S +4
-0+1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 1/5] Decouple V2M_SYS config by auto-detect dtb node
In reply to Andre PrzywaraHi Andre,
Quoted 38 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, May 10, 2021 4:31 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 1/5] DecoupleV2M_SYSconfig by auto- detect dtb nodeOn Wed, 28 Apr 2021 03:23:18 +0000
Jaxson Han <[email protected]> wrote:Hi Jaxson,
Quoted 18 lines
Hi Andre,
Quoted 16 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 7:30 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 1/5] DecoupleV2M_SYSconfig by auto- detect dtb nodeOn Tue, 20 Apr 2021 15:24:34 +0800
Jaxson Han <[email protected]> wrote:Hi,
Quoted 2 lines
An auto-detect switch is added to make it an option to enable/disable 'arm,vexpress-sysreg', because not all platforms support
this feature.
Quoted 5 lines
Quoted 5 lines
The change itself is fine, only has the side effect of now printing an message about the missing node:
No matching devices found at ./findbase.pl line 37.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I will have a look if we can avoid this, or we drop this message in findbase.pl at all.
Thanks, if you have any suggestions, please let me know:)
As Mark suggested, you can just add " 2>
/dev/null" at the end of the findbase.pl call. That allows to do this warning suppression on a case-by-case base, and is preferred over dropping this message in general.
Got it, thanks for the information :)
Cheers,
Jaxson
Quoted 23 lines
Cheers,
AndreQuoted 19 lines
Quoted 8 lines
But for the sake of this patch:
Reviewed-by Andre Przywara <[email protected]>Cheers,
AndreThanks!
JaxsonQuoted 7 lines
Quoted 7 lines
Signed-off-by Jaxson Han <[email protected]>--- Makefile.am | 2 +- platform.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
Quoted 47 lines
Quoted 5 lines
Quoted 5 lines
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' |
Quoted 5 lines
Makefile.am index af694b7..e131207 renamed from Makefile.am +0
-0100644
Makefile.am +0
-0@@ -19,7 +19,7 @@ NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' |wc
Quoted 41 lines
Quoted 40 lines
-w)
Makefile.am NR_CPUS := $(shell echo $(CPU_IDS) | tr ',' ' ' | wc -w)
Quoted 5 lines
Makefile.am +1
-1DEFINES = -DCNTFRQ=$(CNTFRQ) DEFINES += -DCPU_IDS=$(CPU_IDS) DEFINES += -DNR_CPUS=$(NR_CPUS) -DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE) +DEFINES += $(if $(SYSREGS_BASE), -DSYSREGS_BASE=$(SYSREGS_BASE), )
Quoted 33 lines
Makefile.am +0
-0DEFINES += -DUART_BASE=$(UART_BASE) DEFINES += -DSTACK_SIZE=256platform.c +2
-0@@ -23,10 +23,12 @@#define PL011 (reg) ((void *)UART_BASE + PL011_##reg) +#ifdef SYSREGS_BASE #define V2M_SYS_CFGDATA 0xa0#define V2M_SYS_CFGCTRL 0xa4#define V2M_SYS (reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) +#endif static void print_string(const char *str) { @@ -59,6 +61,7 @@void
init_platform(void)platform.c +2
-0print_string ("Boot-wrapper v0.2\r\n\r\n" ); +#ifdef SYSREGS_BASE /* * CLCD output site MB */ @@ -66,4 +69,5 @@ void init_platform(void)/* START | WRITE | MUXFPGA | SITE_MB */ raw_writel ((1 <<31 ) | (1 <<30 ) | (7 <<20 ) | (0 <<16 ),V2M_SYS (CFGCTRL )); +#endif }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
In reply to Andre PrzywaraHi Andre,
Quoted 34 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, May 10, 2021 4:55 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Quoted 4 lines · On Mon, 10 May 2021 02:13:45 +0000 Jaxson Han <[email protected]> wrote:
Hi Andre,
Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', we got a problem when compile the boot-wrapper with '
-march=armv8-r':
Quoted 1 line
|
../git/arch/aarch64/boot.S:71: Error: selected processor does not supportsystem register name '
scr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:73: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:84: Error: selected processor does not supportsystem register name '
mdcr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:90: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:92: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:194: Error: selected processor does notsupport system register name '
elr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:195: Error: selected processor does notsupport system register name '
spsr_el3'Quoted 3 lines
It seems we may need some #if macro to disable all
_el3registers, but it will break our auto-detection (users should add more compile/build
Quoted 7 lines
parameter).
Quoted 1 line
So, may I ask your suggestions? :)
Why do you need that in the first place? I think your version worked without it? At least Ubuntu's 9.3.0 compiled it just fine.
Or does GCC 11 complain about some v8-r specific registers and you need to add this armv8-r to let them pass, sacrificing all EL3 registers on the way?
The problem comes from AIS yocto-bsp team. The reason they need this, I think, may be that they want to test this new option for v8-r since GCC 11 supports v8-r. Anyway, the current version works well. And I agree it's neither necessary nor first priority to solve this problem for boot-wrapper. But I think it's worth to discuss with you and see your suggestions :)
Quoted 11 lines
One solution could be to move all accesses to v8-r registers into a separate file, and only assemble/compile this with the v8-r switch. But this sounds like some serious plumbing in the code base.
What you could try as well is to use this "
s3_0_c12_c12_5" like system register encoding style (this example is forICC_SRE_EL1). The kernel uses this trick to avoid dependencies on gas knowing about all (new) system register names. Not sure if that is enough to trick gas into accepting it?Hope that helps.
Yes, it helps! Based on this, we could easily evaluate the efforts:)
Thanks,
Jaxson
Quoted 134 lines
Cheers,
AndreQuoted 39 lines
Cheers,
JaxsonQuoted 35 lines
-----Original Message-----
From: Jaxson Han
Sent: Wednesday, April 28, 2021 11:44 AM
To: Andre Przywara <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Hi Andre,
Quoted 24 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 20 Apr 2021 15:24:38 +0800 Jaxson Han <[email protected]> wrote:
Hi,
Quoted 10 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-Raarch64),
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
arch/aarch64/boot.S _start: · line 28
Quoted 9 lines
arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +1
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf,then goto
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +2
-0+ * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentELQuoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 4 lines
arch/aarch64/boot.S +2
-0cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for
EL1 and b.eq for EL2 code. Saves you an extra cmp here.Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_initQuoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +6
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the
0b0010 case.
Quoted 4 lines
Quoted 4 lines
Yes, it should be checked, I will add it.
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init:
Quoted 8 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA:VMSAv8-64
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
support
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.Yes, I will fix.
Quoted 1 line
Quoted 57 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle verywell?
Quoted 49 lines
Quoted 48 lines
Quoted 2 lines
So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...
Right, we should force to set
HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].Thanks,
JaxsonQuoted 39 lines
Rest looks alright.
Cheers,
AndreQuoted 32 lines
arch/aarch64/boot.S +18
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
On Tue, 11 May 2021 02:03:32 +0000
Jaxson Han <[email protected]> wrote:
Hi,
Quoted 42 lines
Quoted 34 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, May 10, 2021 4:55 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Quoted 4 lines · On Mon, 10 May 2021 02:13:45 +0000 Jaxson Han <[email protected]> wrote:
Hi Andre,
Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', we got a problem when compile the boot-wrapper with '
-march=armv8-r':
Quoted 1 line
|
../git/arch/aarch64/boot.S:71: Error: selected processor does not supportsystem register name '
scr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:73: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:84: Error: selected processor does not supportsystem register name '
mdcr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:90: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:92: Error: selected processor does not supportsystem register name '
cptr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:194: Error: selected processor does notsupport system register name '
elr_el3'Quoted 1 line
|
../git/arch/aarch64/boot.S:195: Error: selected processor does notsupport system register name '
spsr_el3'Quoted 3 lines
It seems we may need some #if macro to disable all
_el3registers, but it will break our auto-detection (users should add more compile/buildQuoted 7 lines
parameter).
Quoted 1 line
So, may I ask your suggestions? :)
Why do you need that in the first place? I think your version worked without it? At least Ubuntu's 9.3.0 compiled it just fine.
Or does GCC 11 complain about some v8-r specific registers and you need to add this armv8-r to let them pass, sacrificing all EL3 registers on the way?
Quoted 5 lines
The problem comes from AIS yocto-bsp team. The reason they need this, I think, may be that they want to test this new option for v8-r since GCC 11 supports v8-r. Anyway, the current version works well. And I agree it's neither necessary nor first priority to solve this problem for boot-wrapper. But I think it's worth to discuss with you and see your suggestions :)
Well, but each software package sets the stage for the compiler options it can or cannot accept. And since the boot-wrapper is still foremost a v8-A software, just compiling it with v8-r (or any other random switch) won't work. So it's just not valid to use that switch there - it's the task of the Makefile to set compiler options, any user choices have no guarantee of working anyway.
And out of curiosity: what did you expect from using that option?
Quoted 4 lines
Quoted 4 lines
One solution could be to move all accesses to v8-r registers into a separate file, and only assemble/compile this with the v8-r switch. But this sounds like some serious plumbing in the code base.
Quoted 8 lines
Quoted 6 lines
What you could try as well is to use this "
s3_0_c12_c12_5" like system register encoding style (this example is forICC_SRE_EL1). The kernel uses this trick to avoid dependencies on gas knowing about all (new) system register names. Not sure if that is enough to trick gas into accepting it?Hope that helps.
Yes, it helps! Based on this, we could easily evaluate the efforts:)
Did you change the EL3 registers this way? Was there any effect on the code?
Cheers,
Andre
Quoted 183 lines
Quoted 183 lines
Cheers,
AndreQuoted 39 lines
Cheers,
JaxsonQuoted 35 lines
-----Original Message-----
From: Jaxson Han
Sent: Wednesday, April 28, 2021 11:44 AM
To: Andre Przywara <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Hi Andre,
Quoted 24 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 20 Apr 2021 15:24:38 +0800 Jaxson Han <[email protected]> wrote:
Hi,
Quoted 10 lines
The Armv8-R AArch64 profile does not support the EL3 exception level. The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering the kernel.
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lower EL
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-Raarch64),
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
arch/aarch64/boot.S _start: · line 28
Quoted 9 lines
arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +1
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf,then goto
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +2
-0+ * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentELQuoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 4 lines
arch/aarch64/boot.S +2
-0cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for
EL1 and b.eq for EL2 code. Saves you an extra cmp here.Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_initQuoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +6
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the
0b0010 case.
Quoted 4 lines
Quoted 4 lines
Yes, it should be checked, I will add it.
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init:
Quoted 8 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA:VMSAv8-64
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
support
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.Yes, I will fix.
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle verywell?
Quoted 41 lines
Quoted 41 lines
Quoted 2 lines
So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...
Right, we should force to set
HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].Thanks,
JaxsonQuoted 32 lines
Rest looks alright.
Cheers,
AndreQuoted 25 lines
arch/aarch64/boot.S +14
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S jump_kernel: · line 229
Quoted 7 lines
arch/aarch64/boot.S +4
-0+1: msr elr_el2, x19 + msr spsr_el2, x4 + eret + .ltorg .data
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64
Hi Andre,
Quoted 73 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Tuesday, May 11, 2021 4:00 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64On Tue, 11 May 2021 02:03:32 +0000
Jaxson Han <[email protected]> wrote:Hi,
Quoted 9 lines
Quoted 9 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, May 10, 2021 4:55 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Quoted 7 lines
Quoted 7 lines
Quoted 4 lines · On Mon, 10 May 2021 02:13:45 +0000 Jaxson Han <[email protected]> wrote:
Hi Andre,
Since GCC 11 has been released and GCC 11 supports the ' -march=armv8-r', we got a problem when compile the boot-wrapper
with '
Quoted 26 lines
Quoted 26 lines
-march=armv8-r':
Quoted 2 lines
|
../git/arch/aarch64/boot.S:71: Error: selected processor does | not supportsystem register name '
scr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:73: Error: selected processor does | not supportsystem register name '
cptr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:84: Error: selected processor does | not supportsystem register name '
mdcr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:90: Error: selected processor does | not supportsystem register name '
cptr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:92: Error: selected processor does | not supportsystem register name '
cptr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:194: Error: selected processor does | notsupport system register name '
elr_el3'Quoted 2 lines
|
../git/arch/aarch64/boot.S:195: Error: selected processor does | notsupport system register name '
spsr_el3'Quoted 4 lines
It seems we may need some #if macro to disable all
_el3registers, but it will break our auto-detection (users should add more compile/buildQuoted 7 lines
Quoted 7 lines
parameter).
Quoted 1 line
So, may I ask your suggestions? :)
Why do you need that in the first place? I think your version worked without it? At least Ubuntu's 9.3.0 compiled it just fine.
Or does GCC 11 complain about some v8-r specific registers and you need to add this armv8-r to let them pass, sacrificing all EL3 registers onthe way?
Quoted 7 lines
The problem comes from AIS yocto-bsp team. The reason they need this, I think, may be that they want to test this new option for v8-r since GCC 11 supports v8-r. Anyway, the current version works well. And I agree it's neither necessary nor first priority to solve this problem for boot-wrapper. But I think it's worth to discuss with you and see your suggestions :)
Quoted 5 lines
Well, but each software package sets the stage for the compiler options it can or cannot accept. And since the boot-wrapper is still foremost a v8-A software, just compiling it with v8-r (or any other random switch) won't work. So it's just not valid to use that switch there - it's the task of the
Makefileto set compiler options, any user choices have no guarantee of working anyway.
I got it. And we decided remove this option, because it's almost no gain.
Quoted 2 lines
And out of curiosity: what did you expect from using that option?
At the very beginning, maybe, expecting reorganization of v8-r registers, or some optimizations?
But, since boot-wrapper does nothing but some inits, this option seems useless totally.
So, we remove it.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
One solution could be to move all accesses to v8-r registers into a separate file, and only assemble/compile this with the v8-r switch. But this sounds like some serious plumbing in the code base.
What you could try as well is to use this "
s3_0_c12_c12_5" like system register encoding style (this example is forICC_SRE_EL1). The kernel uses this trick to avoid dependencies on gas knowing about all (new) system register names. Not sure if that is enough to trick
Quoted 7 lines
gas into accepting it?
Quoted 4 lines
Quoted 2 lines
Hope that helps.
Yes, it helps! Based on this, we could easily evaluate the efforts:)
Did you change the EL3 registers this way? Was there any effect on the code?
No, I didn't. There's no need to try, I think, with so many efforts and no gain. :)
Thanks,
Andre
Quoted 131 lines
Cheers,
AndreQuoted 28 lines
Quoted 28 lines
Cheers,
AndreQuoted 24 lines
Cheers,
JaxsonQuoted 20 lines
-----Original Message-----
From: Jaxson Han
Sent: Wednesday, April 28, 2021 11:44 AM
To: Andre Przywara <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: RE: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Hi Andre,
Quoted 9 lines
-----Original Message-----
From: Andre Przywara <[email protected]>
Sent: Monday, April 26, 2021 8:36 PM
To: Jaxson Han <[email protected]>
Cc: Mark Rutland <[email protected]>; linux-arm- [email protected]; Wei Chen <[email protected]>
Subject: Re: [boot-wrapper PATCH 5/5] aarch64: Introduce EL2 boot code for Armv8-R AArch64Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
On Tue, 20 Apr 2021 15:24:38 +0800 Jaxson Han
<[email protected]>
wrote:Hi,
Quoted 1 line
The Armv8-R AArch64 profile does not support the EL3 exception
level.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
The Armv8-R AArch64 profile allows for an (optional) VMSAv8-64 MMU at EL1, which allows to run off-the-shelf Linux. However EL2 only supports a PMSA, which is not supported by Linux, so we need to drop into EL1 before entering
the kernel.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The boot sequence is:
If CurrentEL == EL3, then goto EL3 initialisation and drop to lowerEL
Quoted 82 lines
Quoted 82 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
before entering the kernel.
If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA ==0xf(Armv8-Raarch64),
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
then goto Armv8-R AArch64 initialisation and drop to EL1 before entering the kernel.
Else, no initialisation and keep the current EL before entering the
kernel.Signed-off-by Jaxson Han <[email protected]>--- arch/aarch64/boot.S | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
arch/aarch64/boot.S _start: · line 28
Quoted 9 lines
arch/aarch64/boot.S index renamed from arch/aarch64/boot.S +0
-0f7dbf3f..6961a2a 100644
arch/aarch64/boot.S +1
-0@@ -25,16 +25,22 @@ _start: * Boot sequence * If CurrentEL == EL3, then goto EL3 initialisation and drop to * lower EL before entering the kernel. + * If CurrentEL == EL2 && id_aa64mmfr0_el1.MSA == 0xf,then goto
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +2
-0+ * Armv8-R AArch64 initialisation and drop to EL1 before + * entering the kernel. * Else, no initialisation and keep the current EL before * entering the kernel. */ mrs x0, CurrentELQuoted 8 lines
arch/aarch64/boot.S _start: · line 38
Quoted 4 lines
arch/aarch64/boot.S +2
-0cmp x0, #CURRENTEL_EL3 beq el3_init + cmp x0, #CURRENTEL_EL2 + beq el2_initnitpick: I tend to compare against EL2, then use b.gt for EL3, b.lt for
EL1 and b.eq for EL2 code. Saves you an extra cmp here.Exactly, I will. Thanks!
Quoted 12 lines
Quoted 12 lines
arch/aarch64/boot.S +1
-0/* * We stay in the current EL for entering the kernel */ +keep_el: mov w0, #1 ldr x1, =flag_keep_el str w0, [x1]@@ -112,6 +118,43 @@ el3_init: str w0, [x1] b el_max_initQuoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/aarch64/boot.S +6
-0+ /* + * EL2 Armv8-R AArch64 initialisation + */ +el2_init: + /* Detect Armv8-R AArch64 */ + mrs x1, id_aa64mmfr0_el1Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init: · line 130
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ ubfx x1, x1, #48, #4 // MSA + /* 0xf means Armv8-R AArch64 */ + cmp x1, 0xf + bne keep_elDon't we need to also check bits[55:52], to have at least 0b0010? IIUC the support for VMSA in EL1&0 is optional, and should be checked before we proceed? VTCR_EL2[31] can only be set in the
0b0010 case.
Quoted 4 lines
Quoted 4 lines
Yes, it should be checked, I will add it.
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init: · line 138
Quoted 8 lines
arch/aarch64/boot.S +8
-0+ + mrs x0, midr_el1 + msr vpidr_el2, x0 + + mrs x0, mpidr_el1 + msr vmpidr_el2, x0 + + mov x0, #(1 << 31) // VTCR_MSA:VMSAv8-64
Quoted 1 line
Quoted 1 line
Quoted 1 line
support
Quoted 71 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/aarch64/boot.S el3_init: · line 143
Quoted 5 lines
arch/aarch64/boot.S +5
-0+ msr vtcr_el2, x0 + + /* Enable pointer authentication if present */ + mrs x1, id_aa64isar1_el1 + ldr x2, =(((0xff) << 24) | (0xff << 4))Each feature only holds four bits, so the mask you shift should be
0xf.Quoted 63 lines
Quoted 62 lines
Quoted 4 lines
Quoted 4 lines
Yes, I will fix.
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/aarch64/boot.S el3_init: · line 147
Quoted 4 lines
arch/aarch64/boot.S +4
-0+ and x1, x1, x2 + cbz x1, 1f + + mrs x0, hcr_el2Shouldn't we force
HCR_EL2, instead of modifying it? Just to make sure nothing unexpected traps into EL2, which we don't handle verywell?
Quoted 49 lines
Quoted 48 lines
Quoted 2 lines
So basically just set bit 31 (RES1), plus those two bits on top, if needed. But I also wonder about FIEN[47] and EnSCXT[53] ...
Right, we should force to set
HCR_EL2. The API and APK is needed. And I will also check if we need the FIEN[47] and EnSCXT[53].Thanks,
JaxsonQuoted 39 lines
Rest looks alright.
Cheers,
AndreQuoted 32 lines
arch/aarch64/boot.S +18
-0+ orr x0, x0, #(1 << 40) // AP key enable + orr x0, x0, #(1 << 41) // AP insn enable + msr hcr_el2, x0 + +1: isb + mov w0, #SPSR_KERNEL_EL1 + ldr x1, =spsr_to_elx + str w0, [x1] + b el_max_init + el_max_init: ldr x0, =CNTFRQ msr cntfrq_el0, x0@@ -169,10 +212,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
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel