target/arm: MVE preliminaries
cover target/arm: MVE preliminaries
This patchset is a collection of easy preliminary MVE patches, which I send out now just to try to avoid the MVE patchset landing as one enormous series. These patches:
* update feature checks on existing insns that should now check "if FP or MVE" rather than just "if FP"
* fixes a minor non-guest-visible issue in fp_sysreg_checks()
* adds support for reading and writing the MVE VPR register
* makes FPSCR.LTPSIZE writable if MVE
* makes FPSCR.QC exist for MVE
None of this code will be "live" yet, as no CPU sets the MVE ID register fields.
The last patch is not MVE related but I've had it kicking about in a private branch for a while now and it would be nice to have it upstream even though we don't have an immediate in-tree use. It just makes the NS VTOR configurable by the board/SoC the same way the S VTOR already is, which then matches the hardware.
thanks
-- PMM
Peter Maydell (9):
target/arm: Add isar feature check functions for MVE target/arm: Update feature checks for insns which are "MVE or FP" target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp target/arm: Fix return values in fp_sysreg_checks() target/arm: Implement M-profile VPR register
target/arm: Make FPSCR.LTPSIZE writable for MVE target/arm: Enable FPSCR.QC bit for MVE
target/arm: Allow board models to specify initial NS VTOR
include/hw/arm/armv7m.h | 2 + target/arm/cpu.h | 33 ++++++++- hw/arm/armv7m.c | 7 ++ target/arm/cpu.c | 10 +++ target/arm/machine.c | 20 ++++++ target/arm/translate-vfp.c | 140 ++++++++++++++++++++++++++----------- target/arm/vfp_helper.c | 12 ++-- 7 files changed, 179 insertions(+), 45 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/9 target/arm: Add isar feature check functions for MVE
Add the isar feature check functions we will need for v8.1M MVE:
* a check for MVE present: this corresponds to the pseudocode's CheckDecodeFaults(ExtType_Mve)
* a check for the optional floating-point part of MVE: this corresponds to CheckDecodeFaults(ExtType_MveFp)
--- target/arm/cpu.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
target/arm/cpu.h +22 -0
@@ -3801,6 +3801,28 @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) } } +static inline bool isar_feature_aa32_mve (const ARMISARegisters *id) +{ +/* +* Return true if MVE is supported (either integer or floating point). +* We must check for M-profile as the MVFR1 field means something +* else for A-profile. +*/ +return isar_feature_aa32_mprofile (id) && +FIELD_EX32 (id->mvfr1,MVFR1 ,MVE ) >0 ; +} + +static inline bool isar_feature_aa32_mve_fp (const ARMISARegisters *id) +{ +/* +* Return true if MVE is supported (either integer or floating point). +* We must check for M-profile as the MVFR1 field means something +* else for A-profile. +*/ +return isar_feature_aa32_mprofile (id) && +FIELD_EX32 (id->mvfr1,MVFR1 ,MVE ) >=2 ; +} +static inline bool isar_feature_aa32_vfp_simd (const ARMISARegisters *id) {/*
Signature · 1 line
2.20.1
Re: [PATCH 1/9] target/arm: Add isar feature check functions for MVE
Quoted 8 lines · Peter Maydell
Add the isar feature check functions we will need for v8.1M MVE:
* a check for MVE present: this corresponds to the pseudocode'sCheckDecodeFaults(ExtType_Mve)
* a check for the optional floating-point part of MVE: this corresponds toCheckDecodeFaults(ExtType_MveFp)Signed-off-by Peter Maydell<[email protected]>---
r~
PATCH 2/9 target/arm: Update feature checks for insns which are "MVE or FP"
In reply to Peter MaydellSome v8M instructions are present if either the floating point extension or MVE is implemented. Update our implementation of them to check for MVE as well as for FP.
This is all the insns which use CheckDecodeFaults(ExtType_MveOrFp) or CheckDecodeFaults(ExtType_MveOrDpFp) in their pseudocode, which are essentially the loads and stores, moves and sysreg accesses, except for VMOV_reg_sp and VMOV_reg_dp, which we handle in subsequent patches because they need a refactor to provide a place to put the new MVE check.
--- target/arm/translate-vfp.c | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-)
target/arm/translate-vfp.c +29 -19
@@ -543,11 +543,16 @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a)/* VMOV scalar to general purpose register */ TCGv_i32 tmp; -/* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ -if (a->size ==MO_32 - ? !dc_isar_feature (aa32_fpsp_v2, s) - : !arm_dc_feature (s,ARM_FEATURE_NEON )) { -return false; +/* +* SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has +* all sizes, whether the CPU has fp or not. +*/ +if (!dc_isar_feature (aa32_mve, s)) { +if (a->size ==MO_32 + ? !dc_isar_feature (aa32_fpsp_v2, s) + : !arm_dc_feature (s,ARM_FEATURE_NEON )) { +return false; + } }/* UNDEF accesses to D16-D31 if they don't exist */
@@ -571,11 +576,16 @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a)/* VMOV general purpose register to scalar */ TCGv_i32 tmp; -/* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ -if (a->size ==MO_32 - ? !dc_isar_feature (aa32_fpsp_v2, s) - : !arm_dc_feature (s,ARM_FEATURE_NEON )) { -return false; +/* +* SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has +* all sizes, whether the CPU has fp or not. +*/ +if (!dc_isar_feature (aa32_mve, s)) { +if (a->size ==MO_32 + ? !dc_isar_feature (aa32_fpsp_v2, s) + : !arm_dc_feature (s,ARM_FEATURE_NEON )) { +return false; + } }/* UNDEF accesses to D16-D31 if they don't exist */
@@ -671,7 +681,7 @@ typedef enum FPSysRegCheckResult {static FPSysRegCheckResult fp_sysreg_checks (DisasContext *s,int regno) { -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return FPSysRegCheckFailed; }
@@ -1254,7 +1264,7 @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) {TCGv_i32 tmp; -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1287,7 +1297,7 @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) {TCGv_i32 tmp; -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1329,7 +1339,7 @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a)* floating point register. Note that this does not require support * for double precision arithmetic. */ -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1368,7 +1378,7 @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a)uint32_t offset;TCGv_i32 addr, tmp; -if (!dc_isar_feature (aa32_fp16_arith, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1403,7 +1413,7 @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a)uint32_t offset;TCGv_i32 addr, tmp; -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1439,7 +1449,7 @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a)TCGv_i64 tmp;/* Note that this does not require support for double arithmetic. */ -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1479,7 +1489,7 @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a)TCGv_i32 addr, tmp;int i, n; -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
@@ -1557,7 +1567,7 @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a)int i, n;/* Note that this does not require support for double arithmetic. */ -if (!dc_isar_feature (aa32_fpsp_v2, s)) { +if (!dc_isar_feature (aa32_fpsp_v2, s) && !dc_isar_feature (aa32_mve, s)) {return false; }
Signature · 1 line
2.20.1
Re: [PATCH 2/9] target/arm: Update feature checks for insns which are "MVE or FP"
Quoted 11 lines · Peter Maydell
Some v8M instructions are present if either the floating point extension or MVE is implemented. Update our implementation of them to check for MVE as well as for FP.
This is all the insns which use
CheckDecodeFaults(ExtType_MveOrFp)orCheckDecodeFaults(ExtType_MveOrDpFp)in their pseudocode, which are essentially the loads and stores, moves and sysreg accesses, except forVMOV_reg_spandVMOV_reg_dp, which we handle in subsequent patches because they need a refactor to provide a place to put the new MVE check.
Quoted 4 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-vfp.c | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-)
r~
PATCH 3/9 target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp
In reply to Peter MaydellThe do_vfp_2op_sp() and do_vfp_2op_dp() functions currently check whether floating point is supported via the aa32_fpdp_v2 and aa32_fpsp_v2 isar checks. For v8.1M MVE support, the VMOV_reg trans functions (but not any of the others) need to update this to also allow the insn if MVE is implemented. Move the check out of the do_ function and into its callsites (which are all implemented via the DO_VFP_2OP macro), so we have a place to change the check for the VMOV insns.
--- target/arm/translate-vfp.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
target/arm/translate-vfp.c +19 -18
@@ -1925,9 +1925,7 @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)int veclen = s->vec_len;TCGv_i32 f0, fd; -if (!dc_isar_feature (aa32_fpsp_v2, s)) { -return false; - } +/* Note that the caller must check the aa32_fpsp_v2 feature. */ if (!dc_isar_feature (aa32_fpshvec, s) && (veclen !=0 || s->vec_stride !=0 )) {
@@ -2002,6 +2000,8 @@ static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm)*/ TCGv_i32 f0; +/* Note that the caller must check the aa32_fp16_arith feature */ +if (!dc_isar_feature (aa32_fp16_arith, s)) {return false; }
@@ -2030,9 +2030,7 @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm)int veclen = s->vec_len;TCGv_i64 f0, fd; -if (!dc_isar_feature (aa32_fpdp_v2, s)) { -return false; - } +/* Note that the caller must check the aa32_fpdp_v2 feature. */ /* UNDEF accesses to D16-D31 if they don't exist */ if (!dc_isar_feature (aa32_simd_r32, s) && ((vd | vm) &0x10 )) {
@@ -2810,23 +2808,26 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a)return true; } -#define DO_VFP_2OP (INSN ,PREC ,FN ) \ +#define DO_VFP_2OP (INSN ,PREC ,FN ,CHECK ) \ static bool trans_##INSN##_##PREC(DisasContext *s, \ arg_##INSN##_##PREC *a) \ { \ + if (!dc_isar_feature(CHECK, s)) { \ + return false; \ + } \ return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ } -DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32) -DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64) +DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32, aa32_fpsp_v2) +DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64, aa32_fpdp_v2) -DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh) -DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss) -DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd) +DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh, aa32_fp16_arith) +DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss, aa32_fpsp_v2) +DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd, aa32_fpdp_v2) -DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh) -DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs) -DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd) +DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh, aa32_fp16_arith) +DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs, aa32_fpsp_v2) +DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd, aa32_fpdp_v2)static void gen_VSQRT_hp (TCGv_i32 vd,TCGv_i32 vm) {
@@ -2843,9 +2844,9 @@ static void gen_VSQRT_dp(TCGv_i64 vd, TCGv_i64 vm)gen_helper_vfp_sqrtd (vd, vm, cpu_env); } -DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp) -DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp) -DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp) +DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp, aa32_fp16_arith) +DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp, aa32_fpsp_v2) +DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp, aa32_fpdp_v2)static bool trans_VCMP_hp (DisasContext *s,arg_VCMP_sp *a) {
Signature · 1 line
2.20.1
Re: [PATCH 3/9] target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp
Quoted 9 lines · Peter Maydell
The
do_vfp_2op_sp()anddo_vfp_2op_dp()functions currently check whether floating point is supported via theaa32_fpdp_v2andaa32_fpsp_v2isar checks. For v8.1M MVE support, theVMOV_regtrans functions (but not any of the others) need to update this to also allow the insn if MVE is implemented. Move the check out of thedo_function and into its callsites (which are all implemented via theDO_VFP_2OPmacro), so we have a place to change the check for the VMOV insns.
Quoted 4 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-vfp.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
r~
PATCH 4/9 target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp
In reply to Peter MaydellSplit out the handling of VMOV_reg_sp and VMOV_reg_dp so that we can permit the insns if either FP or MVE are present.
--- target/arm/translate-vfp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
target/arm/translate-vfp.c +13 -2
@@ -2818,8 +2818,19 @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ } -DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32, aa32_fpsp_v2) -DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64, aa32_fpdp_v2) +#define DO_VFP_VMOV (INSN ,PREC ,FN ) \ + static bool trans_##INSN##_##PREC(DisasContext *s, \ + arg_##INSN##_##PREC *a) \ + { \ + if (!dc_isar_feature(aa32_fp##PREC##_v2, s) && \ + !dc_isar_feature(aa32_mve, s)) { \ + return false; \ + } \ + return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ + } + +DO_VFP_VMOV(VMOV_reg, sp, tcg_gen_mov_i32) +DO_VFP_VMOV(VMOV_reg, dp, tcg_gen_mov_i64) DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh, aa32_fp16_arith)DO_VFP_2OP (VABS , sp, gen_helper_vfp_abss, aa32_fpsp_v2)
Signature · 1 line
2.20.1
Re: [PATCH 4/9] target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp
Quoted 7 lines · Peter Maydell
Split out the handling of
VMOV_reg_spandVMOV_reg_dpso that we can permit the insns if either FP or MVE are present.Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-vfp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
r~
PATCH 5/9 target/arm: Fix return values in fp_sysreg_checks()
In reply to Peter MaydellThe fp_sysreg_checks() function is supposed to be returning an FPSysRegCheckResult, which is an enum with three possible values. However, three places in the function "return false" (a hangover from a previous iteration of the design where the function just returned a bool). Make these return FPSysRegCheckFailed instead (for no functional change, since both false and FPSysRegCheckFailed are zero).
--- target/arm/translate-vfp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/translate-vfp.c +3 -3
@@ -691,16 +691,16 @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)break ;case ARM_VFP_FPSCR_NZCVQC :if (!arm_dc_feature (s,ARM_FEATURE_V8_1M )) { -return false; +return FPSysRegCheckFailed; }break ;case ARM_VFP_FPCXT_S :case ARM_VFP_FPCXT_NS :if (!arm_dc_feature (s,ARM_FEATURE_V8_1M )) { -return false; +return FPSysRegCheckFailed; }if (!s->v8m_secure) { -return false; +return FPSysRegCheckFailed; }break ;default :
Signature · 1 line
2.20.1
Re: [PATCH 5/9] target/arm: Fix return values in fp_sysreg_checks()
Quoted 8 lines · Peter Maydell
The
fp_sysreg_checks()function is supposed to be returning an FPSysRegCheckResult, which is an enum with three possible values. However, three places in the function "return false" (a hangover from a previous iteration of the design where the function just returned a bool). Make these return FPSysRegCheckFailed instead (for no functional change, since both false and FPSysRegCheckFailed are zero).
Quoted 4 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/translate-vfp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
r~
PATCH 6/9 target/arm: Implement M-profile VPR register
In reply to Peter MaydellIf MVE is implemented for an M-profile CPU then it has a VPR register, which tracks predication information.
Implement the read and write handling of this register, and the migration of its state.
--- target/arm/cpu.h | 6 ++++++ target/arm/machine.c | 19 +++++++++++++++++++ target/arm/translate-vfp.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+)
target/arm/cpu.h +6 -0
@@ -564,6 +564,7 @@ typedef struct CPUARMState {uint32_t cpacr[M_REG_NUM_BANKS ];uint32_t nsacr;int ltpsize; +uint32_t vpr; } v7m;/* Information associated with an exception about to be taken:
@@ -1760,6 +1761,11 @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) R_V7M_FPCCR_UFRDY_MASK | \ R_V7M_FPCCR_ASPEN_MASK) +/* v7M VPR bits */ +FIELD(V7M_VPR, P0, 0, 16) +FIELD(V7M_VPR, MASK01, 16, 4) +FIELD (V7M_VPR ,MASK23 ,20 ,4 ) +/* * System register ID fields. */
target/arm/machine.c +19 -0
@@ -318,6 +318,24 @@ static const VMStateDescription vmstate_m_fp = { } }; +static bool mve_needed (void *opaque) +{ +ARMCPU *cpu = opaque; + +return cpu_isar_feature (aa32_mve, cpu); +} + +static const VMStateDescription vmstate_m_mve = { + .name ="cpu/m/mve" , + .version_id =1 , + .minimum_version_id =1 , + .needed = mve_needed, + .fields = (VMStateField []) { +VMSTATE_UINT32 (env.v7m.vpr,ARMCPU ), +VMSTATE_END_OF_LIST () + }, +}; +static const VMStateDescription vmstate_m = { .name ="cpu/m" , .version_id =4 ,
@@ -344,6 +362,7 @@ static const VMStateDescription vmstate_m = { &vmstate_m_other_sp, &vmstate_m_v8m, &vmstate_m_fp, + &vmstate_m_mve, NULL } };
target/arm/translate-vfp.c +38 -0
@@ -703,6 +703,12 @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)return FPSysRegCheckFailed; }break ; +case ARM_VFP_VPR : +case ARM_VFP_P0 : +if (!dc_isar_feature (aa32_mve, s)) { +return FPSysRegCheckFailed; + } +break ;default :return FPSysRegCheckFailed; }
@@ -817,6 +823,25 @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,tcg_temp_free_i32 (sfpa);break ; } +case ARM_VFP_VPR : +/* Behaves as NOP if not privileged */ +if (IS_USER (s)) { +break ; + } + tmp =loadfn (s, opaque); +store_cpu_field (tmp, v7m.vpr); +break ; +case ARM_VFP_P0 : + { +TCGv_i32 vpr; + tmp =loadfn (s, opaque); + vpr =load_cpu_field (v7m.vpr); +tcg_gen_deposit_i32 (vpr, vpr, tmp, +R_V7M_VPR_P0_SHIFT ,R_V7M_VPR_P0_LENGTH ); +store_cpu_field (vpr, v7m.vpr); +tcg_temp_free_i32 (tmp); +break ; + }default :g_assert_not_reached (); }
@@ -935,6 +960,19 @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,tcg_temp_free_i32 (fpscr);break ; } +case ARM_VFP_VPR : +/* Behaves as NOP if not privileged */ +if (IS_USER (s)) { +break ; + } + tmp =load_cpu_field (v7m.vpr); +storefn (s, opaque, tmp); +break ; +case ARM_VFP_P0 : + tmp =load_cpu_field (v7m.vpr); +tcg_gen_extract_i32 (tmp, tmp,R_V7M_VPR_P0_SHIFT ,R_V7M_VPR_P0_LENGTH ); +storefn (s, opaque, tmp); +break ;default :g_assert_not_reached (); }
Signature · 1 line
2.20.1
Re: [PATCH 6/9] target/arm: Implement M-profile VPR register
Quoted 6 lines · Peter Maydell
If MVE is implemented for an M-profile CPU then it has a VPR register, which tracks predication information.
Implement the read and write handling of this register, and the migration of its state.
Quoted 6 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/cpu.h | 6 ++++++ target/arm/machine.c | 19 +++++++++++++++++++ target/arm/translate-vfp.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+)
r~
PATCH 7/9 target/arm: Make FPSCR.LTPSIZE writable for MVE
In reply to Peter MaydellThe M-profile FPSCR has an LTPSIZE field, but if MVE is not implemented it is read-only and always reads as 4; this is how QEMU currently handles it.
Make the field writable when MVE is implemented.
We can safely add the field to the MVE migration struct because currently no CPUs enable MVE and so the migration struct is never used.
--- target/arm/cpu.h | 3 ++- target/arm/machine.c | 1 + target/arm/vfp_helper.c | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-)
target/arm/cpu.h +2 -1
@@ -563,7 +563,7 @@ typedef struct CPUARMState {uint32_t fpdscr[M_REG_NUM_BANKS ];uint32_t cpacr[M_REG_NUM_BANKS ];uint32_t nsacr; -int ltpsize; +uint32_t ltpsize;uint32_t vpr; } v7m;
@@ -1561,6 +1561,7 @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val);#define FPCR_LTPSIZE_SHIFT 16/* LTPSIZE, M-profile only */ #define FPCR_LTPSIZE_MASK (7 << FPCR_LTPSIZE_SHIFT) +#define FPCR_LTPSIZE_LENGTH 3#define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V)#define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC)
target/arm/machine.c +1 -0
@@ -332,6 +332,7 @@ static const VMStateDescription vmstate_m_mve = { .needed = mve_needed, .fields = (VMStateField []) {VMSTATE_UINT32 (env.v7m.vpr,ARMCPU ), +VMSTATE_UINT32 (env.v7m.ltpsize,ARMCPU ),VMSTATE_END_OF_LIST () }, };
target/arm/vfp_helper.c +6 -3
@@ -195,8 +195,10 @@ uint32_t vfp_get_fpscr(CPUARMState *env)void HELPER (vfp_set_fpscr )(CPUARMState *env,uint32_t val) { +ARMCPU *cpu =env_archcpu (env); +/* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ -if (!cpu_isar_feature (any_fp16,env_archcpu (env))) { +if (!cpu_isar_feature (any_fp16, cpu)) { val &= ~FPCR_FZ16 ; }
@@ -210,11 +212,12 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)* because in v7A no-short-vector-support cores still had to * allow Stride/Len to be written with the only effect that * some insns are required to UNDEF if the guest sets them. -* -* TODO: if M-profile MVE implemented, set LTPSIZE. */ env->vfp.vec_len =extract32 (val,16 ,3 ); env->vfp.vec_stride =extract32 (val,20 ,2 ); + }else if (cpu_isar_feature (aa32_mve, cpu)) { + env->v7m.ltpsize =extract32 (val,FPCR_LTPSIZE_SHIFT , +FPCR_LTPSIZE_LENGTH ); }if (arm_feature (env,ARM_FEATURE_NEON )) {
Signature · 1 line
2.20.1
Re: [PATCH 7/9] target/arm: Make FPSCR.LTPSIZE writable for MVE
Quoted 10 lines · Peter Maydell
The M-profile FPSCR has an LTPSIZE field, but if MVE is not implemented it is read-only and always reads as 4; this is how QEMU currently handles it.
Make the field writable when MVE is implemented.
We can safely add the field to the MVE migration struct because currently no CPUs enable MVE and so the migration struct is never used.
Quoted 6 lines
Signed-off-by Peter Maydell<[email protected]>--- target/arm/cpu.h | 3 ++- target/arm/machine.c | 1 + target/arm/vfp_helper.c | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-)
r~
PATCH 8/9 target/arm: Enable FPSCR.QC bit for MVE
In reply to Peter MaydellMVE has an FPSCR.QC bit similar to the A-profile Neon one; when MVE is implemented make the bit writeable.
--- target/arm/vfp_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target/arm/vfp_helper.c +2 -1
@@ -220,7 +220,8 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) FPCR_LTPSIZE_LENGTH); } -if (arm_feature (env,ARM_FEATURE_NEON )) { +if (arm_feature (env,ARM_FEATURE_NEON ) || +cpu_isar_feature (aa32_mve, cpu)) {/* * The bit we set within fpscr_q is arbitrary; the register as a * whole being zero/non-zero is what counts.
Signature · 1 line
2.20.1
Re: [PATCH 8/9] target/arm: Enable FPSCR.QC bit for MVE
Quoted 7 lines · Peter Maydell
MVE has an FPSCR.QC bit similar to the A-profile Neon one; when MVE is implemented make the bit writeable.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/vfp_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
r~
Re: [PATCH 8/9] target/arm: Enable FPSCR.QC bit for MVE
Quoted 11 lines · Richard Henderson
Quoted 7 lines · Peter Maydell
MVE has an FPSCR.QC bit similar to the A-profile Neon one; when MVE is implemented make the bit writeable.
Signed-off-by Peter Maydell<[email protected]>--- target/arm/vfp_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Richard Henderson <[email protected]>
There's a followon bit to this patch which I didn't notice at first, which is that the handling of ARM_VFP_FPSCR_NZCVQC in the "fp_sysreg" code also needs to be updated to read/write the QC bit (currently it has TODO comments about this.) Given that this patch is currently a one-liner I think I'll just respin it as a single patch with all the accesses to QC fixed.
thanks
-- PMM
PATCH 9/9 target/arm: Allow board models to specify initial NS VTOR
In reply to Peter MaydellCurrently we allow board models to specify the initial value of the Secure VTOR register, using an init-svtor property on the TYPE_ARMV7M object which is plumbed through to the CPU. Allow board models to also specify the initial value of the Non-secure VTOR via a similar init-nsvtor property.
---
I admit to not having a publicly-visible use for this yet, but it does bring the NSVTOR into line with both our handling of the SVTOR and also with the hardware, which allows both to be set via reset-time config signal inputs, as seen eg on the Cortex-M55:
https://developer.arm.com/documentation/101051/0002/Signal-descriptions/Reset-configuration-signals?lang=en
--- include/hw/arm/armv7m.h | 2 ++ target/arm/cpu.h | 2 ++ hw/arm/armv7m.c | 7 +++++++ target/arm/cpu.c | 10 ++++++++++ 4 files changed, 21 insertions(+)
include/hw/arm/armv7m.h +2 -0
@@ -46,6 +46,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M)* devices will be automatically layered on top of this view.) * + Property "idau": IDAU interface (forwarded to CPU object) * + Property "init-svtor": secure VTOR reset value (forwarded to CPU object) +* + Property "init-nsvtor": non-secure VTOR reset value (forwarded to CPU object) * + Property "vfp": enable VFP (forwarded to CPU object) * + Property "dsp": enable DSP (forwarded to CPU object) * + Property "enable-bitband": expose bitbanded IO
@@ -69,6 +70,7 @@ struct ARMv7MState {MemoryRegion *board_memory;Object *idau;uint32_t init_svtor; +uint32_t init_nsvtor;bool enable_bitband;bool start_powered_off;bool vfp;
target/arm/cpu.h +2 -0
@@ -869,6 +869,8 @@ struct ARMCPU {/* For v8M, initial value of the Secure VTOR */ uint32_t init_svtor; +/* For v8M, initial value of the Non-secure VTOR */ +uint32_t init_nsvtor;/* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type.
hw/arm/armv7m.c +7 -0
@@ -176,6 +176,12 @@ static void armv7m_realize(DeviceState *dev, Error **errp)return ; } } +if (object_property_find (OBJECT (s->cpu),"init-nsvtor" )) { +if (!object_property_set_uint (OBJECT (s->cpu),"init-nsvtor" , + s->init_nsvtor, errp)) { +return ; + } + }if (object_property_find (OBJECT (s->cpu),"start-powered-off" )) {if (!object_property_set_bool (OBJECT (s->cpu),"start-powered-off" , s->start_powered_off, errp)) {
@@ -254,6 +260,7 @@ static Property armv7m_properties[] = { MemoryRegion *), DEFINE_PROP_LINK("idau", ARMv7MState, idau, TYPE_IDAU_INTERFACE, Object *),DEFINE_PROP_UINT32 ("init-svtor" , ARMv7MState, init_svtor,0 ), +DEFINE_PROP_UINT32 ("init-nsvtor" , ARMv7MState, init_nsvtor,0 ),DEFINE_PROP_BOOL ("enable-bitband" , ARMv7MState, enable_bitband, false),DEFINE_PROP_BOOL ("start-powered-off" , ARMv7MState, start_powered_off, false),
target/arm/cpu.c +10 -0
@@ -327,6 +327,7 @@ static void arm_cpu_reset(DeviceState *dev) env->regs[14 ] =0xffffffff ; env->v7m.vecbase[M_REG_S ] = cpu->init_svtor &0xffffff80 ; + env->v7m.vecbase[M_REG_NS ] = cpu->init_nsvtor &0xffffff80 ;/* Load the initial SP and PC from offset 0 and 4 in the vector table */ vecbase = env->v7m.vecbase[env->v7m.secure];
@@ -1272,6 +1273,15 @@ void arm_cpu_post_init(Object *obj) &cpu->init_svtor, OBJ_PROP_FLAG_READWRITE); } +if (arm_feature (&cpu->env,ARM_FEATURE_M )) { +/* +* Initial value of the NS VTOR (for cores without the Security +* extension, this is the only VTOR) +*/ +object_property_add_uint32_ptr (obj,"init-nsvtor" , + &cpu->init_nsvtor, +OBJ_PROP_FLAG_READWRITE ); + }qdev_property_add_static (DEVICE (obj), &arm_cpu_cfgend_property);
Signature · 1 line
2.20.1
Re: [PATCH 9/9] target/arm: Allow board models to specify initial NS VTOR
Quoted 13 lines · Peter Maydell
Currently we allow board models to specify the initial value of the Secure VTOR register, using an init-svtor property on the
TYPE_ARMV7Mobject which is plumbed through to the CPU. Allow board models to also specify the initial value of the Non-secure VTOR via a similar init-nsvtor property.Signed-off-by Peter Maydell<[email protected]>---
I admit to not having a publicly-visible use for this yet, but it does bring the NSVTOR into line with both our handling of the SVTOR and also with the hardware, which allows both to be set via reset-time config signal inputs, as seen eg on the Cortex-M55:
https://developer.arm.com/documentation/101051/0002/Signal-descriptions/Reset-configuration-signals?lang=en
Quoted 6 lines
--- include/hw/arm/armv7m.h | 2 ++ target/arm/cpu.h | 2 ++ hw/arm/armv7m.c | 7 +++++++ target/arm/cpu.c | 10 ++++++++++ 4 files changed, 21 insertions(+)
r~
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH 0/9] target/arm: MVE preliminaries
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
5714b29 target/arm: Allow board models to specify initial NS VTOR 0a91c4d target/arm: Enable FPSCR.QC bit for MVE
d47da78 target/arm: Make FPSCR.LTPSIZE writable for MVE
6c7229a target/arm: Implement M-profile VPR register
47dbed2 target/arm: Fix return values in fp_sysreg_checks() 4b36a72 target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp dbefafd target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp 493a859 target/arm: Update feature checks for insns which are "MVE or FP" 633fa0c target/arm: Add isar feature check functions for MVE
=== OUTPUT BEGIN ===
1/9 Checking commit 633fa0c8de0b (target/arm: Add isar feature check functions for MVE) 2/9 Checking commit 493a859c1d72 (target/arm: Update feature checks for insns which are "MVE or FP") 3/9 Checking commit dbefafdfeff3 (target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp) 4/9 Checking commit 4b36a72b4fd7 (target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp)
ERROR: spaces required around that '*' (ctx:WxV)
#28: FILE: target/arm/translate-vfp.c:2823:
+ arg_##INSN##_##PREC *a) \
^total: 1 errors, 0 warnings, 21 lines checked
Patch 4/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/9 Checking commit 47dbed22cf5a (target/arm: Fix return values in fp_sysreg_checks()) 6/9 Checking commit 6c7229aab445 (target/arm: Implement M-profile VPR register) 7/9 Checking commit d47da78456e0 (target/arm: Make FPSCR.LTPSIZE writable for MVE) 8/9 Checking commit 0a91c4deb285 (target/arm: Enable FPSCR.QC bit for MVE) 9/9 Checking commit 5714b29a3b6e (target/arm: Allow board models to specify initial NS VTOR)
WARNING: line over 80 characters
#55: FILE: include/hw/arm/armv7m.h:49:
+ * + Property "init-nsvtor": non-secure VTOR reset value (forwarded to CPU object)
total: 0 errors, 1 warnings, 63 lines checked
Patch 9/9 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]