target/arm: SB and PredInv extensions
v2 cover target/arm: SB and PredInv extensions
Changes since v2:
* Rebase on master, cherry-picking one required patch from the ARMv8.5-MemTag patch set.
* Use the same form of TB exit for SB as for ISB.
* Rename all the bits related to PredInv.
* Fix registration for PredInv cache flush special regs, and spell out why in a comment.
r~
Richard Henderson (3):
target/arm: Split out arm_sctlr
target/arm: Implement ARMv8.0-SB
target/arm: Implement ARMv8.0-PredRes
target/arm/cpu.h | 49 ++++++++++++++++++++++------- linux-user/elfload.c | 1 + target/arm/cpu.c | 2 ++ target/arm/cpu64.c | 4 +++ target/arm/helper.c | 63 ++++++++++++++++++++++++++++++++++---- target/arm/translate-a64.c | 14 +++++++++ target/arm/translate.c | 22 +++++++++++++ 7 files changed, 138 insertions(+), 17 deletions(-)
Signature · 1 line
2.17.2
PATCH v2 1/3 target/arm: Split out arm_sctlr
Minimize the number of places that will need updating when the virtual host extensions are added.
--- target/arm/cpu.h | 26 ++++++++++++++++---------- target/arm/helper.c | 8 ++------ 2 files changed, 18 insertions(+), 16 deletions(-)
target/arm/cpu.h +16 -10
@@ -3029,11 +3029,20 @@ static inline bool arm_sctlr_b(CPUARMState *env) (env->cp15.sctlr_el[1 ] &SCTLR_B ) !=0 ; } +static inline uint64_t arm_sctlr (CPUARMState *env,int el) +{ +if (el ==0 ) { +/* FIXME: ARMv8.1-VHE S2 translation regime. */ +return env->cp15.sctlr_el[1 ]; + }else { +return env->cp15.sctlr_el[el]; + } +} + +/* Return true if the processor is in big-endian mode. */ static inline bool arm_cpu_data_is_big_endian (CPUARMState *env) { -int cur_el; -/* In 32bit endianness is determined by looking at CPSR's E bit */ if (!is_a64 (env)) {return
@@ -3052,15 +3061,12 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)arm_sctlr_b (env) || #endif ((env->uncached_cpsr & CPSR_E) ? 1 : 0); + }else { +int cur_el =arm_current_el (env); +uint64_t sctlr =arm_sctlr (env, cur_el); + +return (sctlr & (cur_el ?SCTLR_EE :SCTLR_E0E )) !=0 ; } - - cur_el =arm_current_el (env); - -if (cur_el ==0 ) { -return (env->cp15.sctlr_el[1 ] &SCTLR_E0E ) !=0 ; - } - -return (env->cp15.sctlr_el[cur_el] &SCTLR_EE ) !=0 ; }#include "exec/cpu-all.h"
target/arm/helper.c +2 -6
@@ -12877,12 +12877,8 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags =FIELD_DP32 (flags,TBFLAG_A64 ,ZCR_LEN , zcr_len); } -if (current_el ==0 ) { -/* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr = env->cp15.sctlr_el[1 ]; - }else { - sctlr = env->cp15.sctlr_el[current_el]; - } + sctlr =arm_sctlr (env, current_el); +if (cpu_isar_feature (aa64_pauth, cpu)) {/* * In order to save space in flags, we record only whether
Signature · 1 line
2.17.2
PATCH v2 2/3 target/arm: Implement ARMv8.0-SB
In reply to Richard Henderson--- target/arm/cpu.h | 10 ++++++++++ linux-user/elfload.c | 1 + target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 ++ target/arm/translate-a64.c | 14 ++++++++++++++ target/arm/translate.c | 22 ++++++++++++++++++++++ 6 files changed, 50 insertions(+)
target/arm/cpu.h +10 -0
@@ -3289,6 +3289,11 @@ static inline bool isar_feature_aa32_dp(const ARMISARegisters *id)return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,DP ) !=0 ; } +static inline bool isar_feature_aa32_sb (const ARMISARegisters *id) +{ +return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SB ) !=0 ; +} +static inline bool isar_feature_aa32_fp16_arith (const ARMISARegisters *id) {/*
@@ -3387,6 +3392,11 @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; } +static inline bool isar_feature_aa64_sb (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
linux-user/elfload.c +1 -0
@@ -602,6 +602,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE_ID (aa64_fcma,ARM_HWCAP_A64_FCMA );GET_FEATURE_ID (aa64_sve,ARM_HWCAP_A64_SVE );GET_FEATURE_ID (aa64_pauth,ARM_HWCAP_A64_PACA |ARM_HWCAP_A64_PACG ); +GET_FEATURE_ID (aa64_sb,ARM_HWCAP_A64_SB );#undef GET_FEATURE_ID
target/arm/cpu.c +1 -0
@@ -2003,6 +2003,7 @@ static void arm_max_initfn(Object *obj) t = cpu->isar.id_isar6; t =FIELD_DP32 (t,ID_ISAR6 ,JSCVT ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,DP ,1 ); + t =FIELD_DP32 (t,ID_ISAR6 ,SB ,1 ); cpu->isar.id_isar6 = t; t = cpu->id_mmfr4;
target/arm/cpu64.c +2 -0
@@ -317,6 +317,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,API ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,SB ,1 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
@@ -347,6 +348,7 @@ static void aarch64_max_initfn(Object *obj) u = cpu->isar.id_isar6; u =FIELD_DP32 (u,ID_ISAR6 ,JSCVT ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,DP ,1 ); + u =FIELD_DP32 (u,ID_ISAR6 ,SB ,1 ); cpu->isar.id_isar6 = u;/*
target/arm/translate-a64.c +14 -0
@@ -1637,7 +1637,21 @@ static void handle_sync(DisasContext *s, uint32_t insn,reset_btype (s);gen_goto_tb (s,0 , s->pc);return ; + +case 7 :/* SB */ +if (crm !=0 || !dc_isar_feature (aa64_sb, s)) { + goto do_unallocated; + } +/* +* TODO: There is no speculation barrier opcode for TCG; +* MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc); +return ; +default : + do_unallocated:unallocated_encoding (s);return ; }
target/arm/translate.c +22 -0
@@ -9208,6 +9208,17 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)*/ gen_goto_tb (s,0 , s->pc & ~1 );return ; +case 7 :/* sb */ +if ((insn &0xf ) || !dc_isar_feature (aa32_sb, s)) { + goto illegal_op; + } +/* +* TODO: There is no speculation barrier opcode +* for TCG; MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc & ~1 ); +return ;default : goto illegal_op; }
@@ -11826,6 +11837,17 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)*/ gen_goto_tb (s,0 , s->pc & ~1 );break ; +case 7 :/* sb */ +if ((insn &0xf ) || !dc_isar_feature (aa32_sb, s)) { + goto illegal_op; + } +/* +* TODO: There is no speculation barrier opcode +* for TCG; MB and end the TB instead. +*/ +tcg_gen_mb (TCG_MO_ALL |TCG_BAR_SC ); +gen_goto_tb (s,0 , s->pc & ~1 ); +break ;default : goto illegal_op; }
Signature · 1 line
2.17.2
PATCH v2 3/3 target/arm: Implement ARMv8.0-PredRes
In reply to Richard HendersonThis is named "Execution and Data prediction restriction instructions" within the ARMv8.5 manual, and given the name "PredRes" by binutils.
--- target/arm/cpu.h | 13 ++++++++++- target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 ++ target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-)
target/arm/cpu.h +12 -1
@@ -1060,7 +1060,8 @@ void pmu_init(ARMCPU *cpu);#define SCTLR_R (1U << 9)/* up to v6; RAZ in v7 */ #define SCTLR_UMA (1U << 9)/* v8 onward, AArch64 only */ #define SCTLR_F (1U << 10)/* up to v6 */ -#define SCTLR_SW (1U << 10)/* v7, RES0 in v8 */ +#define SCTLR_SW (1U << 10)/* v7 */ +#define SCTLR_EnRCTX (1U << 10)/* in v8.0-PredInv */ #define SCTLR_Z (1U << 11)/* in v7, RES1 in v8 */ #define SCTLR_EOS (1U << 11)/* v8.5-ExS */ #define SCTLR_I (1U << 12)
@@ -3294,6 +3295,11 @@ static inline bool isar_feature_aa32_sb(const ARMISARegisters *id)return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SB ) !=0 ; } +static inline bool isar_feature_aa32_predinv (const ARMISARegisters *id) +{ +return FIELD_EX32 (id->id_isar6,ID_ISAR6 ,SPECRES ) !=0 ; +} +static inline bool isar_feature_aa32_fp16_arith (const ARMISARegisters *id) {/*
@@ -3397,6 +3403,11 @@ static inline bool isar_feature_aa64_sb(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SB ) !=0 ; } +static inline bool isar_feature_aa64_predinv (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64isar1,ID_AA64ISAR1 ,SPECRES ) !=0 ; +} +static inline bool isar_feature_aa64_fp16 (const ARMISARegisters *id) {/* We always set the AdvSIMD and FP fields identically wrt FP16. */
target/arm/cpu.c +1 -0
@@ -2004,6 +2004,7 @@ static void arm_max_initfn(Object *obj) t =FIELD_DP32 (t,ID_ISAR6 ,JSCVT ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,DP ,1 ); t =FIELD_DP32 (t,ID_ISAR6 ,SB ,1 ); + t =FIELD_DP32 (t,ID_ISAR6 ,SPECRES ,1 ); cpu->isar.id_isar6 = t; t = cpu->id_mmfr4;
target/arm/cpu64.c +2 -0
@@ -318,6 +318,7 @@ static void aarch64_max_initfn(Object *obj) t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA ,1 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI ,0 ); t =FIELD_DP64 (t,ID_AA64ISAR1 ,SB ,1 ); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,SPECRES ,1 ); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0;
@@ -349,6 +350,7 @@ static void aarch64_max_initfn(Object *obj) u =FIELD_DP32 (u,ID_ISAR6 ,JSCVT ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,DP ,1 ); u =FIELD_DP32 (u,ID_ISAR6 ,SB ,1 ); + u =FIELD_DP32 (u,ID_ISAR6 ,SPECRES ,1 ); cpu->isar.id_isar6 = u;/*
target/arm/helper.c +55 -0
67 lines not on this page · raw message
Signature · 1 line
2.17.2