target-arm: Initial ARMv8 extended EL support
v2 cover target-arm: Initial ARMv8 extended EL support
These patches add extended EL support for ARMv8. Specifically the following changes were made:
- Fix issue in RVBAR_EL1 CP register definition
- Add missing RVBAR_ELx CP register definitions
- Add missing SP_ELx CP register definitions
- Add reset support to start in highest EL
---
v1 -> v2
- Added case to allow secure EL1 Linux boot
- Added check for booting Linux into EL2 if enabled
- Removed extraneous SCR.NS setting on reset
- Fixed incorrect EL feature check
- Fixed incorrect RVBAR naming
- Reverted sp_el0_access function naming
Greg Bellows (4):
target-arm: Fix RVBAR_EL1 register encoding
target-arm: Add extended RVBAR support
target-arm: Change reset to highest available EL
target-arm: Add missing SP_ELx register definition
hw/arm/boot.c | 22 ++++++++++++++++++++-- target-arm/cpu.c | 9 ++++++++- target-arm/helper.c | 39 +++++++++++++++++++++++++++++++++------ 3 files changed, 61 insertions(+), 9 deletions(-)
--
1.8.3.2
PATCH v2 1/4 target-arm: Fix RVBAR_EL1 register encoding
Fix the RVBAR_EL1 CP register opc2 encoding from 2 to 1
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
@@ -3055,7 +3055,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) };ARMCPRegInfo rvbar = { .name ="RVBAR_EL1" , .state =ARM_CP_STATE_AA64 , - .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =2 , + .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =1 , .type =ARM_CP_CONST , .access =PL1_R , .resetvalue = cpu->rvbar };define_one_arm_cp_reg (cpu, &rvbar);
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH V2 1/4] target-arm: Fix RVBAR_EL1 register encoding
Quoted 12 lines · Greg Bellows
Fix the
RVBAR_EL1CP register opc2 encoding from 2 to 1Signed-off-by Greg Bellows <[email protected]>--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/helper.c +0
-0
target-arm/helper.c void register_cp_regs_for_features(ARMCPU *cpu)
Quoted 9 lines
target-arm/helper.c +1
-2@@ -3055,7 +3055,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) };ARMCPRegInfo rvbar = { .name ="RVBAR_EL1" , .state =ARM_CP_STATE_AA64 , - .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =2 , + .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =1 , .type =ARM_CP_CONST , .access =PL1_R , .resetvalue = cpu->rvbar };define_one_arm_cp_reg (cpu, &rvbar); --
thanks
-- PMM
PATCH v2 2/4 target-arm: Add extended RVBAR support
In reply to Greg BellowsAdded RVBAR_EL2 and RVBAR_EL3 CP register support. All RVBAR_EL# registers point to the same location and only the highest EL version exists at any one time.
--- target-arm/helper.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
target-arm/helper.c +25 -6
@@ -3053,17 +3053,30 @@ void register_cp_regs_for_features(ARMCPU *cpu) .resetvalue = cpu->mvfr2 }, REGINFO_SENTINEL }; -ARMCPRegInfo rvbar = { - .name ="RVBAR_EL1" , .state =ARM_CP_STATE_AA64 , - .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =1 , - .type =ARM_CP_CONST , .access =PL1_R , .resetvalue = cpu->rvbar - }; -define_one_arm_cp_reg (cpu, &rvbar); +/* RVBAR_EL1 is only implemented if EL1 is the highest EL */ +if (!arm_feature (env,ARM_FEATURE_EL3 ) && + !arm_feature (env,ARM_FEATURE_EL2 )) { +ARMCPRegInfo rvbar = { + .name ="RVBAR_EL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =0 , .crn =12 , .crm =0 , .opc2 =1 , + .type =ARM_CP_CONST , .access =PL1_R , .resetvalue = cpu->rvbar + }; +define_one_arm_cp_reg (cpu, &rvbar); + }define_arm_cp_regs (cpu, v8_idregs);define_arm_cp_regs (cpu, v8_cp_reginfo); }if (arm_feature (env,ARM_FEATURE_EL2 )) {define_arm_cp_regs (cpu, v8_el2_cp_reginfo); +/* RVBAR_EL2 is only implemented if EL2 is the highest EL */ +if (!arm_feature (env,ARM_FEATURE_EL3 )) { +ARMCPRegInfo rvbar = { + .name ="RVBAR_EL2" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =4 , .crn =12 , .crm =0 , .opc2 =1 , + .type =ARM_CP_CONST , .access =PL2_R , .resetvalue = cpu->rvbar + }; +define_one_arm_cp_reg (cpu, &rvbar); + } }else {/* If EL2 is missing but higher ELs are enabled, we need to * register the no_el2 reginfos.
@@ -3074,6 +3087,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) }if (arm_feature (env,ARM_FEATURE_EL3 )) {define_arm_cp_regs (cpu, el3_cp_reginfo); +ARMCPRegInfo rvbar = { + .name ="RVBAR_EL3" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =6 , .crn =12 , .crm =0 , .opc2 =1 , + .type =ARM_CP_CONST , .access =PL3_R , .resetvalue = cpu->rvbar + }; +define_one_arm_cp_reg (cpu, &rvbar); }if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new
Signature · 1 line
1.8.3.2
PATCH v2 3/4 target-arm: Change reset to highest available EL
In reply to Greg BellowsUpdate to arm_cpu_reset() to reset into the highest available exception level based on the set ARM features.
---
v1 -> v2
- Added Linux boot into secure EL1
- Added reset to EL2 if enabled
- Removed extraneous SCR.NS reset
- Fixed incorrect feature check
--- hw/arm/boot.c | 22 ++++++++++++++++++++-- target-arm/cpu.c | 9 ++++++++- 2 files changed, 28 insertions(+), 3 deletions(-)
hw/arm/boot.c +20 -2
@@ -463,8 +463,26 @@ static void do_cpu_reset(void *opaque)* (SCR.NS = 0), we change that here if non-secure boot has been * requested. */ -if (arm_feature (env,ARM_FEATURE_EL3 ) && !info->secure_boot) { - env->cp15.scr_el3 |=SCR_NS ; +if (arm_feature (env,ARM_FEATURE_EL3 )) { +/* AArch64 is defined to come out of reset into EL3 if enabled. +* If we are booting Linux then we need to adjust our EL as +* Linux expects us to be in EL2 or EL1. AArch32 resets into +* SVC, which Linux expects, so no privilege/exception level to +* adjust. +*/ +if (env->aarch64) { +if (arm_feature (env,ARM_FEATURE_EL2 )) { + env->pstate = PSTATE_MODE_EL2h; + }else { + env->pstate = PSTATE_MODE_EL1h; + } + } + +/* Set to non-secure if not a secure boot */ +if (!info->secure_boot) { +/* Linux expects non-secure state */ + env->cp15.scr_el3 |=SCR_NS ; + } }if (CPU (cpu) == first_cpu) {
target-arm/cpu.c +8 -1
@@ -113,7 +113,14 @@ static void arm_cpu_reset(CPUState *s)/* and to the FP/Neon instructions */ env->cp15.c1_coproc =deposit64 (env->cp15.c1_coproc,20 ,2 ,3 );#else - env->pstate = PSTATE_MODE_EL1h; +/* Reset into the highest available EL */ +if (arm_feature (env,ARM_FEATURE_EL3 )) { + env->pstate = PSTATE_MODE_EL3h; + }else if (arm_feature (env,ARM_FEATURE_EL2 )) { + env->pstate = PSTATE_MODE_EL2h; + }else { + env->pstate = PSTATE_MODE_EL1h; + } env->pc = cpu->rvbar;#endif }else {
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH V2 3/4] target-arm: Change reset to highest available EL
Quoted 7 lines · Greg Bellows
Update to
arm_cpu_reset()to reset into the highest available exception level based on the set ARM features.Signed-off-by Greg Bellows <[email protected]>---
Quoted 8 lines
v1 -> v2
- Added Linux boot into secure EL1
- Added reset to EL2 if enabled
- Removed extraneous SCR.NS reset
- Fixed incorrect feature check--- hw/arm/boot.c | 22 ++++++++++++++++++++-- target-arm/cpu.c | 9 ++++++++-
thanks
-- PMM
PATCH v2 4/4 target-arm: Add missing SP_ELx register definition
In reply to Greg BellowsAdded CP register definitions for SP_EL1 and SP_EL2.
---
v1 -> v2
- Remove unnecessary accessfn for SP_EL1/2
- Revert SP_EL0 accessfn name to sp_el0_access
--- target-arm/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target-arm/helper.c +8 -0
@@ -2329,6 +2329,10 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_RW, .accessfn = sp_el0_access, .type = ARM_CP_NO_MIGRATE, .fieldoffset = offsetof(CPUARMState, sp_el[0]) }, + { .name = "SP_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL2_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[1]) }, { .name = "SPSel", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 0, .type = ARM_CP_NO_MIGRATE,
@@ -2410,6 +2414,10 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .access = PL2_RW, .writefn = vbar_write, .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[2]), .resetvalue = 0 }, + { .name = "SP_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL3_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[2]) },REGINFO_SENTINEL };
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH V2 4/4] target-arm: Add missing SP_ELx register definition
Quoted 30 lines · Greg Bellows
Added CP register definitions for
SP_EL1andSP_EL2.Signed-off-by Greg Bellows <[email protected]>Reviewed-by Peter Maydell <[email protected]>---
v1 -> v2
- Remove unnecessary accessfn for SP_EL1/2
- RevertSP_EL0accessfn name tosp_el0_access--- target-arm/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+)target-arm/helper.c +4
-0@@ -2329,6 +2329,10 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_RW, .accessfn = sp_el0_access, .type = ARM_CP_NO_MIGRATE, .fieldoffset = offsetof(CPUARMState, sp_el[0]) }, + { .name = "SP_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL2_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[1]) }, { .name = "SPSel", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 0, .type = ARM_CP_NO_MIGRATE,
target-arm/helper.c static const ARMCPRegInfo v8_el2_cp_reginfo[] = { · line 2422
Quoted 9 lines
target-arm/helper.c +4
-0@@ -2410,6 +2414,10 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .access = PL2_RW, .writefn = vbar_write, .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[2]), .resetvalue = 0 }, + { .name = "SP_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL3_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[2]) },REGINFO_SENTINEL };
As I was assembling my target-arm queue I found that this patch and the 'split ARM_CP_NO_MIGRATE' patch semantically conflict; since this patch happened to be earlier in the queue than that one, I've resolved this by adding changes to the 'split' patch which change these ARM_CP_NO_MIGRATE uses to ARM_CP_ALIAS, in line with how we handled the SP_EL0 regdef.
thanks
-- PMM
Re: [Qemu-devel] [PATCH V2 4/4] target-arm: Add missing SP_ELx register definition
Quoted 48 lines · Peter Maydell
Quoted 30 lines · Greg Bellows
Added CP register definitions for
SP_EL1andSP_EL2.Signed-off-by Greg Bellows <[email protected]>Reviewed-by Peter Maydell <[email protected]>---
v1 -> v2
- Remove unnecessary accessfn for SP_EL1/2
- RevertSP_EL0accessfn name tosp_el0_access--- target-arm/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+)target-arm/helper.c +4
-0@@ -2329,6 +2329,10 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_RW, .accessfn = sp_el0_access, .type = ARM_CP_NO_MIGRATE, .fieldoffset = offsetof(CPUARMState, sp_el[0]) }, + { .name = "SP_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL2_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[1]) }, { .name = "SPSel", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 0, .type = ARM_CP_NO_MIGRATE,target-arm/helper.c static const ARMCPRegInfo v8_el2_cp_reginfo[] = { · line 2422
Quoted 9 lines
target-arm/helper.c +4
-0@@ -2410,6 +2414,10 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .access = PL2_RW, .writefn = vbar_write, .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[2]), .resetvalue = 0 }, + { .name = "SP_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 1, .opc2 = 0, + .access = PL3_RW, .type = ARM_CP_NO_MIGRATE, + .fieldoffset = offsetof(CPUARMState, sp_el[2]) },REGINFO_SENTINEL };As I was assembling my target-arm queue I found that this patch and the 'split
ARM_CP_NO_MIGRATE' patch semantically conflict; since this patch happened to be earlier in the queue than that one, I've resolved this by adding changes to the 'split' patch which change theseARM_CP_NO_MIGRATEuses toARM_CP_ALIAS, in line with how we handled theSP_EL0regdef.
Quoted 3 lines
thanks
-- PMM
That makes sense.
Quoted 24 lines · Greg Bellows
These patches add extended EL support for ARMv8. Specifically the following changes were made:
- Fix issue in
RVBAR_EL1CP register definition
- Add missingRVBAR_ELxCP register definitions
- Add missingSP_ELxCP register definitions
- Add reset support to start in highest EL---
v1 -> v2
- Added case to allow secure EL1 Linux boot
- Added check for booting Linux into EL2 if enabled
- Removed extraneous SCR.NS setting on reset
- Fixed incorrect EL feature check
- Fixed incorrect RVBAR naming
- Revertedsp_el0_accessfunction namingGreg Bellows (4):
target-arm: FixRVBAR_EL1register encoding
target-arm: Add extended RVBAR support
target-arm: Change reset to highest available EL
target-arm: Add missingSP_ELxregister definition
Quoted 9 lines
hw/arm/boot.c | 22 ++++++++++++++++++++-- target-arm/cpu.c | 9 ++++++++- target-arm/helper.c | 39 +++++++++++++++++++++++++++++++++------ 3 files changed, 61 insertions(+), 9 deletions(-)--
1.8.3.2
Hi!
Are we going to have AArch64 Virtualization support soon?
Thanks,
Sergey
+Edgar
Quoted 36 lines · Sergey Fedorov
Quoted 1 line · Greg Bellows
These patches add extended EL support for ARMv8. Specifically the
following
Quoted 23 lines
changes were made:
- Fix issue in
RVBAR_EL1CP register definition
- Add missingRVBAR_ELxCP register definitions
- Add missingSP_ELxCP register definitions
- Add reset support to start in highest EL---
v1 -> v2
- Added case to allow secure EL1 Linux boot
- Added check for booting Linux into EL2 if enabled
- Removed extraneous SCR.NS setting on reset
- Fixed incorrect EL feature check
- Fixed incorrect RVBAR naming
- Revertedsp_el0_accessfunction namingGreg Bellows (4):
target-arm: FixRVBAR_EL1register encoding
target-arm: Add extended RVBAR support
target-arm: Change reset to highest available EL
target-arm: Add missingSP_ELxregister definitionQuoted 9 lines
hw/arm/boot.c | 22 ++++++++++++++++++++-- target-arm/cpu.c | 9 ++++++++- target-arm/helper.c | 39 +++++++++++++++++++++++++++++++++------ 3 files changed, 61 insertions(+), 9 deletions(-)--
1.8.3.2
Quoted 7 lines
Hi!
Are we going to have AArch64 Virtualization support soon?
Thanks,
Sergey
Hi Sergey,
I am only working on adding AArch64 EL3 support but I copied Edgar who I believe is working on EL2 support. I don't know what his timeline is.
Greg