Révision | 2d7137c10fafefe40a0a049ff8a7bd78b66e661f (tree) |
---|---|
l'heure | 2018-12-13 23:41:24 |
Auteur | Richard Henderson <richard.henderson@lina...> |
Commiter | Peter Maydell |
target/arm: Implement the ARMv8.1-LOR extension
Provide a trivial implementation with zero limited ordering regions,
which causes the LDLAR and STLLR instructions to devolve into the
LDAR and STLR instructions from the base ARMv8.0 instruction set.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20181210150501.7990-4-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
@@ -3340,6 +3340,11 @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | ||
3340 | 3340 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
3341 | 3341 | } |
3342 | 3342 | |
3343 | +static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) | |
3344 | +{ | |
3345 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; | |
3346 | +} | |
3347 | + | |
3343 | 3348 | /* |
3344 | 3349 | * Forward to the above feature tests given an ARMCPU pointer. |
3345 | 3350 | */ |
@@ -326,6 +326,7 @@ static void aarch64_max_initfn(Object *obj) | ||
326 | 326 | |
327 | 327 | t = cpu->isar.id_aa64mmfr1; |
328 | 328 | t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ |
329 | + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | |
329 | 330 | cpu->isar.id_aa64mmfr1 = t; |
330 | 331 | |
331 | 332 | /* Replicate the same data to the 32-bit id registers. */ |
@@ -1281,6 +1281,7 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
1281 | 1281 | { |
1282 | 1282 | /* Begin with base v8.0 state. */ |
1283 | 1283 | uint32_t valid_mask = 0x3fff; |
1284 | + ARMCPU *cpu = arm_env_get_cpu(env); | |
1284 | 1285 | |
1285 | 1286 | if (arm_el_is_aa64(env, 3)) { |
1286 | 1287 | value |= SCR_FW | SCR_AW; /* these two bits are RES1. */ |
@@ -1303,6 +1304,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
1303 | 1304 | valid_mask &= ~SCR_SMD; |
1304 | 1305 | } |
1305 | 1306 | } |
1307 | + if (cpu_isar_feature(aa64_lor, cpu)) { | |
1308 | + valid_mask |= SCR_TLOR; | |
1309 | + } | |
1306 | 1310 | |
1307 | 1311 | /* Clear all-context RES0 bits. */ |
1308 | 1312 | value &= valid_mask; |
@@ -3963,6 +3967,9 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
3963 | 3967 | */ |
3964 | 3968 | valid_mask &= ~HCR_TSC; |
3965 | 3969 | } |
3970 | + if (cpu_isar_feature(aa64_lor, cpu)) { | |
3971 | + valid_mask |= HCR_TLOR; | |
3972 | + } | |
3966 | 3973 | |
3967 | 3974 | /* Clear RES0 bits. */ |
3968 | 3975 | value &= valid_mask; |
@@ -5018,6 +5025,42 @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
5018 | 5025 | return pfr0; |
5019 | 5026 | } |
5020 | 5027 | |
5028 | +/* Shared logic between LORID and the rest of the LOR* registers. | |
5029 | + * Secure state has already been delt with. | |
5030 | + */ | |
5031 | +static CPAccessResult access_lor_ns(CPUARMState *env) | |
5032 | +{ | |
5033 | + int el = arm_current_el(env); | |
5034 | + | |
5035 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TLOR)) { | |
5036 | + return CP_ACCESS_TRAP_EL2; | |
5037 | + } | |
5038 | + if (el < 3 && (env->cp15.scr_el3 & SCR_TLOR)) { | |
5039 | + return CP_ACCESS_TRAP_EL3; | |
5040 | + } | |
5041 | + return CP_ACCESS_OK; | |
5042 | +} | |
5043 | + | |
5044 | +static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, | |
5045 | + bool isread) | |
5046 | +{ | |
5047 | + if (arm_is_secure_below_el3(env)) { | |
5048 | + /* Access ok in secure mode. */ | |
5049 | + return CP_ACCESS_OK; | |
5050 | + } | |
5051 | + return access_lor_ns(env); | |
5052 | +} | |
5053 | + | |
5054 | +static CPAccessResult access_lor_other(CPUARMState *env, | |
5055 | + const ARMCPRegInfo *ri, bool isread) | |
5056 | +{ | |
5057 | + if (arm_is_secure_below_el3(env)) { | |
5058 | + /* Access denied in secure mode. */ | |
5059 | + return CP_ACCESS_TRAP; | |
5060 | + } | |
5061 | + return access_lor_ns(env); | |
5062 | +} | |
5063 | + | |
5021 | 5064 | void register_cp_regs_for_features(ARMCPU *cpu) |
5022 | 5065 | { |
5023 | 5066 | /* Register all the coprocessor registers based on feature bits */ |
@@ -5759,6 +5802,38 @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
5759 | 5802 | define_one_arm_cp_reg(cpu, &sctlr); |
5760 | 5803 | } |
5761 | 5804 | |
5805 | + if (cpu_isar_feature(aa64_lor, cpu)) { | |
5806 | + /* | |
5807 | + * A trivial implementation of ARMv8.1-LOR leaves all of these | |
5808 | + * registers fixed at 0, which indicates that there are zero | |
5809 | + * supported Limited Ordering regions. | |
5810 | + */ | |
5811 | + static const ARMCPRegInfo lor_reginfo[] = { | |
5812 | + { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, | |
5813 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, | |
5814 | + .access = PL1_RW, .accessfn = access_lor_other, | |
5815 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | |
5816 | + { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, | |
5817 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, | |
5818 | + .access = PL1_RW, .accessfn = access_lor_other, | |
5819 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | |
5820 | + { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, | |
5821 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, | |
5822 | + .access = PL1_RW, .accessfn = access_lor_other, | |
5823 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | |
5824 | + { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, | |
5825 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, | |
5826 | + .access = PL1_RW, .accessfn = access_lor_other, | |
5827 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | |
5828 | + { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | |
5829 | + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | |
5830 | + .access = PL1_R, .accessfn = access_lorid, | |
5831 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | |
5832 | + REGINFO_SENTINEL | |
5833 | + }; | |
5834 | + define_arm_cp_regs(cpu, lor_reginfo); | |
5835 | + } | |
5836 | + | |
5762 | 5837 | if (cpu_isar_feature(aa64_sve, cpu)) { |
5763 | 5838 | define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); |
5764 | 5839 | if (arm_feature(env, ARM_FEATURE_EL2)) { |
@@ -2290,6 +2290,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
2290 | 2290 | } |
2291 | 2291 | return; |
2292 | 2292 | |
2293 | + case 0x8: /* STLLR */ | |
2294 | + if (!dc_isar_feature(aa64_lor, s)) { | |
2295 | + break; | |
2296 | + } | |
2297 | + /* StoreLORelease is the same as Store-Release for QEMU. */ | |
2298 | + /* fall through */ | |
2293 | 2299 | case 0x9: /* STLR */ |
2294 | 2300 | /* Generate ISS for non-exclusive accesses including LASR. */ |
2295 | 2301 | if (rn == 31) { |
@@ -2301,6 +2307,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
2301 | 2307 | disas_ldst_compute_iss_sf(size, false, 0), is_lasr); |
2302 | 2308 | return; |
2303 | 2309 | |
2310 | + case 0xc: /* LDLAR */ | |
2311 | + if (!dc_isar_feature(aa64_lor, s)) { | |
2312 | + break; | |
2313 | + } | |
2314 | + /* LoadLOAcquire is the same as Load-Acquire for QEMU. */ | |
2315 | + /* fall through */ | |
2304 | 2316 | case 0xd: /* LDAR */ |
2305 | 2317 | /* Generate ISS for non-exclusive accesses including LASR. */ |
2306 | 2318 | if (rn == 31) { |