Skip to contentSkip to conversation

target/arm: Pull TLBI insns out to their own source file

PATCH In review Peter Maydell 2 participants 22 messages Dec 10, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover target/arm: Pull TLBI insns out to their own source file

target/arm/helper.c is very large and unwieldy at nearly 13,000 lines. One subset of code that we can pull out into its own file is the cpreg arrays and corresponding functions for the TLBI instructions: these mostly stand separately from the other code in the file and have few shared functions or other interactions with it. They make up about 10% of the existing helper.c code.

Because these are instructions they are only relevant for TCG and we can make the new file only be built for CONFIG_TCG.

I split the move up into multiple pieces in the hope of making it easier to review that way; but in the end the code should all have wound up in the new file in the same order it was in helper.c. (Hopefully this will make any backporting of patches to stable branches smoother; it does mean that in some cases the order of functions remains slightly odd.)

This is hardly the most urgent cleanup in the codebase; and there are other parts that could probably be pulled out (maybe the PMU emulation, and the timer/counter emulation?). But I did the TLBI stuff because FEAT_XS is about to add more TLB ops, so it felt worthwhile to move the code out to a new file first.

thanks
-- PMM

Peter Maydell (10):
target/arm: Move some TLBI insns to their own source file target/arm: Move TLBI insns for AArch32 EL2 to tlbi_insn_helper.c target/arm: Move AArch64 TLBI insns from v8_cp_reginfo[] target/arm: Move the AArch64 EL2 TLBI insns target/arm: Move AArch64 EL3 TLBI insns
target/arm: Move TLBI range insns
target/arm: Move the TLBI OS insns to tlb-insns.c. target/arm: Move small helper functions to tlb-insns.c target/arm: Move RME TLB insns to tlb-insns.c target/arm: Simplify condition for tlbi_el2_cp_reginfo[]

 target/arm/internals.h     |    9 +
 target/arm/helper.c        | 1208 +---------------------------------
 target/arm/tcg-stubs.c     |    5 +
 target/arm/tcg/tlb-insns.c | 1266 ++++++++++++++++++++++++++++++++++++
 target/arm/tcg/meson.build |    1 +
 5 files changed, 1284 insertions(+), 1205 deletions(-)
 create mode 100644 target/arm/tcg/tlb-insns.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/10 target/arm: Move some TLBI insns to their own source file

target/arm/helper.c is very large and unwieldy. One subset of code that we can pull out into its own file is the cpreg arrays and corresponding functions for the TLBI instructions.

Because these are instructions they are only relevant for TCG and we can make the new file only be built for CONFIG_TCG.

In this commit we move the AArch32 instructions from:
not_v7_cp_reginfo[]
v7_cp_reginfo[]
v7mp_cp_reginfo[]
v8_cp_reginfo[]
into a new file target/arm/tcg/tlb-insns.c.

A few small functions are used both by functions we haven't yet moved across and by functions we have already moved. We temporarily make these global with a prototype in cpregs.h; when the move of all TLBI insns is complete these will return to being file-local.

For CONFIG_TCG, this is just moving code around. For a KVM only build, these cpregs will no longer be added to the cpregs hashtable for the CPU. However this should not be a behaviour change, because:
* we never try to migration sync or otherwise include ARM_CP_NO_RAW cpregs
* for migration we treat the kernel's list of system registers as the authoritative one, so these TLBI insns were never in it anyway
The no-tcg stub of define_tlb_insn_regs() therefore does nothing.

---
 target/arm/cpregs.h        |  14 +++
 target/arm/internals.h     |   3 +
 target/arm/helper.c        | 231 ++--------------------------------
 target/arm/tcg-stubs.c     |   5 +
 target/arm/tcg/tlb-insns.c | 246 +++++++++++++++++++++++++++++++++++++
 target/arm/tcg/meson.build |   1 +
 6 files changed, 280 insertions(+), 220 deletions(-)
 create mode 100644 target/arm/tcg/tlb-insns.c
target/arm/cpregs.h +14 -0
index cc7c54378f4..26c27dc5cb6 100644
@@ -1134,4 +1134,18 @@ static inline bool arm_cpreg_traps_in_nv(const ARMCPRegInfo *ri)
     return ri->opc1 == 4 || ri->opc1 == 5;
 }
 
+/*
+ * Temporary declarations of functions until the move to tlb_insn_helper.c
+ * is complete and we can make the functions static again
+ */
+CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
+                           bool isread);
+CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri,
+                             bool isread);
+bool tlb_force_broadcast(CPUARMState *env);
+void tlbimva_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                       uint64_t value);
+void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                          uint64_t value);
+
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/internals.h +3 -0
index e37f459af35..2adedb94777 100644
@@ -1727,6 +1727,9 @@ static inline uint64_t pauth_ptr_mask(ARMVAParameters param)
 /* Add the cpreg definitions for debug related system registers */
 void define_debug_regs(ARMCPU *cpu);
 
+/* Add the cpreg definitions for TLBI instructions */
+void define_tlb_insn_regs(ARMCPU *cpu);
+
 /* Effective value of MDCR_EL2 */
 static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env)
 {
target/arm/helper.c +11 -220

306 lines not on this page · raw message

target/arm/tcg-stubs.c +5 -0
index 152b172e243..f3f45d54f28 100644
@@ -25,3 +25,8 @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome,
 void assert_hflags_rebuild_correctly(CPUARMState *env)
 {
 }
+
+/* TLBI insns are only used by TCG, so we don't need to do anything for KVM */
+void define_tlb_insn_regs(ARMCPU *cpu)
+{
+}
target/arm/tcg/tlb-insns.c new file +246 -0

246 lines not on this page · raw message

target/arm/tcg/meson.build +1 -0
index 508932a249f..09238989c5a 100644
@@ -39,6 +39,7 @@ arm_ss.add(files(
   'op_helper.c',
   'tlb_helper.c',
   'vec_helper.c',
+  'tlb-insns.c',
 ))
 
 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
Signature · 1 line
2.34.1
Reviewed-by on v1 1/10
#2 lore raw

Re: [PATCH 01/10] target/arm: Move some TLBI insns to their own source file

Quoted 29 lines · Peter Maydell

target/arm/helper.c is very large and unwieldy. One subset of code that we can pull out into its own file is the cpreg arrays and corresponding functions for the TLBI instructions.

Because these are instructions they are only relevant for TCG and we can make the new file only be built for CONFIG_TCG.

In this commit we move the AArch32 instructions from:
not_v7_cp_reginfo[]
v7_cp_reginfo[]
v7mp_cp_reginfo[]
v8_cp_reginfo[]
into a new file target/arm/tcg/tlb-insns.c.

A few small functions are used both by functions we haven't yet moved across and by functions we have already moved. We temporarily make these global with a prototype in cpregs.h; when the move of all TLBI insns is complete these will return to being file-local.

For CONFIG_TCG, this is just moving code around. For a KVM only build, these cpregs will no longer be added to the cpregs hashtable for the CPU. However this should not be a behaviour change, because:
* we never try to migration sync or otherwise include ARM_CP_NO_RAW cpregs
* for migration we treat the kernel's list of system registers as the authoritative one, so these TLBI insns were never in it anyway
The no-tcg stub of define_tlb_insn_regs() therefore does nothing.

Quoted 1 line

r~

#3 lore raw

PATCH 2/10 target/arm: Move TLBI insns for AArch32 EL2 to tlbi_insn_helper.c

In reply to Peter Maydell

Move the AArch32 TLBI insns for AArch32 EL2 to tlbi_insn_helper.c. To keep this as an obviously pure code-movement, we retain the same condition for registering tlbi_el2_cp_reginfo that we use for el2_cp_reginfo. We'll be able to simplify this condition later, since the need to define the reginfo for EL3-without-EL2 doesn't apply for the TLBI ops specifically.

This move brings all the uses of tlbimva_hyp_write() and tlbimva_hyp_is_write() back into a single file, so we can move those also, and make them file-local again.

The helper alle1_tlbmask() is an exception to the pattern that we only need to make these functions global temporarily, because once this refactoring is complete it will be called by both code in helper.c (vttbr_write()) and by code in tlb-insns.c. We therefore put its prototype in a permanent home in internals.h.

---
 target/arm/cpregs.h        |  4 --
 target/arm/internals.h     |  6 +++
 target/arm/helper.c        | 74 +--------------------------------
 target/arm/tcg/tlb-insns.c | 85 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 77 deletions(-)
target/arm/cpregs.h +0 -4
index 26c27dc5cb6..851cd045b2c 100644
@@ -1143,9 +1143,5 @@ CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
 CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri,
                              bool isread);
 bool tlb_force_broadcast(CPUARMState *env);
-void tlbimva_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                       uint64_t value);
-void tlbimva_hyp_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                          uint64_t value);
 
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/internals.h +6 -0
index 2adedb94777..c3a5b1385f1 100644
@@ -1820,4 +1820,10 @@ uint64_t gt_get_countervalue(CPUARMState *env);
  * and CNTVCT_EL0 (this will be either 0 or the value of CNTVOFF_EL2).
  */
 uint64_t gt_virt_cnt_offset(CPUARMState *env);
+
+/*
+ * Return mask of ARMMMUIdxBit values corresponding to an "invalidate
+ * all EL1" scope; this covers stage 1 and stage 2.
+ */
+int alle1_tlbmask(CPUARMState *env);
 #endif
target/arm/helper.c +1 -73

92 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +85 -0

107 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 2/10
#4 lore raw

Re: [PATCH 02/10] target/arm: Move TLBI insns for AArch32 EL2 to tlbi_insn_helper.c

Quoted 17 lines · Peter Maydell

Move the AArch32 TLBI insns for AArch32 EL2 to tlbi_insn_helper.c. To keep this as an obviously pure code-movement, we retain the same condition for registering tlbi_el2_cp_reginfo that we use for el2_cp_reginfo. We'll be able to simplify this condition later, since the need to define the reginfo for EL3-without-EL2 doesn't apply for the TLBI ops specifically.

This move brings all the uses of tlbimva_hyp_write() and tlbimva_hyp_is_write() back into a single file, so we can move those also, and make them file-local again.

The helper alle1_tlbmask() is an exception to the pattern that we only need to make these functions global temporarily, because once this refactoring is complete it will be called by both code in helper.c (vttbr_write()) and by code in tlb-insns.c. We therefore put its prototype in a permanent home in internals.h.

Quoted 6 lines
---
  target/arm/cpregs.h        |  4 --
  target/arm/internals.h     |  6 +++
  target/arm/helper.c        | 74 +--------------------------------
  target/arm/tcg/tlb-insns.c | 85 ++++++++++++++++++++++++++++++++++++++

Subject has an out-of-date filename.

r~

#5 lore raw

Re: [PATCH 02/10] target/arm: Move TLBI insns for AArch32 EL2 to tlbi_insn_helper.c

Quoted 19 lines · Richard Henderson
Quoted 17 lines · Peter Maydell

Move the AArch32 TLBI insns for AArch32 EL2 to tlbi_insn_helper.c. To keep this as an obviously pure code-movement, we retain the same condition for registering tlbi_el2_cp_reginfo that we use for el2_cp_reginfo. We'll be able to simplify this condition later, since the need to define the reginfo for EL3-without-EL2 doesn't apply for the TLBI ops specifically.

This move brings all the uses of tlbimva_hyp_write() and tlbimva_hyp_is_write() back into a single file, so we can move those also, and make them file-local again.

The helper alle1_tlbmask() is an exception to the pattern that we only need to make these functions global temporarily, because once this refactoring is complete it will be called by both code in helper.c (vttbr_write()) and by code in tlb-insns.c. We therefore put its prototype in a permanent home in internals.h.

Quoted 8 lines
Quoted 6 lines
---
  target/arm/cpregs.h        |  4 --
  target/arm/internals.h     |  6 +++
  target/arm/helper.c        | 74 +--------------------------------
  target/arm/tcg/tlb-insns.c | 85 ++++++++++++++++++++++++++++++++++++++

Subject has an out-of-date filename.

Yep; as you've probably guessed I changed my mind part way through about the best name for it ;-)

-- PMM

#6 lore raw

PATCH 3/10 target/arm: Move AArch64 TLBI insns from v8_cp_reginfo[]

In reply to Peter Maydell

Move the AArch64 TLBI insns that are declared in v8_cp_reginfo[] into tlb-insns.c.

---
 target/arm/cpregs.h        |  11 +++
 target/arm/helper.c        | 182 +++----------------------------------
 target/arm/tcg/tlb-insns.c | 160 ++++++++++++++++++++++++++++++++
 3 files changed, 182 insertions(+), 171 deletions(-)
target/arm/cpregs.h +11 -0
index 851cd045b2c..a14f5bb6c98 100644
@@ -1143,5 +1143,16 @@ CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
 CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri,
                              bool isread);
 bool tlb_force_broadcast(CPUARMState *env);
+int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
+                       uint64_t addr);
+int vae1_tlbbits(CPUARMState *env, uint64_t addr);
+int vae1_tlbmask(CPUARMState *env);
+int ipas2e1_tlbmask(CPUARMState *env, int64_t value);
+void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                               uint64_t value);
+void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                             uint64_t value);
+void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                            uint64_t value);
 
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/helper.c +11 -171

254 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +160 -0

172 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 3/10
#7 lore raw

Re: [PATCH 03/10] target/arm: Move AArch64 TLBI insns from v8_cp_reginfo[]

Quoted 9 lines · Peter Maydell

Move the AArch64 TLBI insns that are declared in v8_cp_reginfo[] into tlb-insns.c.

---
  target/arm/cpregs.h        |  11 +++
  target/arm/helper.c        | 182 +++----------------------------------
  target/arm/tcg/tlb-insns.c | 160 ++++++++++++++++++++++++++++++++
  3 files changed, 182 insertions(+), 171 deletions(-)

r~

#8 lore raw

PATCH 4/10 target/arm: Move the AArch64 EL2 TLBI insns

In reply to Peter Maydell

Move the AArch64 EL2 TLBI insn definitions that were in el2_cp_reginfo[] across to tlb-insns.c.

---
 target/arm/cpregs.h        |  7 +++++
 target/arm/helper.c        | 61 ++++----------------------------------
 target/arm/tcg/tlb-insns.c | 49 ++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 55 deletions(-)
target/arm/cpregs.h +7 -0
index a14f5bb6c98..57446ae1b52 100644
@@ -1146,13 +1146,20 @@ bool tlb_force_broadcast(CPUARMState *env);
 int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
                        uint64_t addr);
 int vae1_tlbbits(CPUARMState *env, uint64_t addr);
+int vae2_tlbbits(CPUARMState *env, uint64_t addr);
 int vae1_tlbmask(CPUARMState *env);
+int vae2_tlbmask(CPUARMState *env);
 int ipas2e1_tlbmask(CPUARMState *env, int64_t value);
+int e2_tlbmask(CPUARMState *env);
 void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                                uint64_t value);
 void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                              uint64_t value);
 void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                             uint64_t value);
+void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                             uint64_t value);
+void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                            uint64_t value);
 
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/helper.c +6 -55

109 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +49 -0

61 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 4/10
#9 lore raw

Re: [PATCH 04/10] target/arm: Move the AArch64 EL2 TLBI insns

Quoted 9 lines · Peter Maydell

Move the AArch64 EL2 TLBI insn definitions that were in el2_cp_reginfo[] across to tlb-insns.c.

---
  target/arm/cpregs.h        |  7 +++++
  target/arm/helper.c        | 61 ++++----------------------------------
  target/arm/tcg/tlb-insns.c | 49 ++++++++++++++++++++++++++++++
  3 files changed, 62 insertions(+), 55 deletions(-)

r~

#10 lore raw

PATCH 5/10 target/arm: Move AArch64 EL3 TLBI insns

In reply to Peter Maydell

Move the AArch64 EL3 TLBI insns from el3_cp_reginfo[] across to tlb-insns.c.

---
 target/arm/cpregs.h        |  4 +++
 target/arm/helper.c        | 56 +++-----------------------------------
 target/arm/tcg/tlb-insns.c | 54 ++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 52 deletions(-)
target/arm/cpregs.h +4 -0
index 57446ae1b52..722ac5bb884 100644
@@ -1161,5 +1161,9 @@ void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                              uint64_t value);
 void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
                             uint64_t value);
+void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                            uint64_t value);
+void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
+                             uint64_t value);
 
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/helper.c +4 -52

86 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +54 -0

76 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 5/10
#11 lore raw

Re: [PATCH 05/10] target/arm: Move AArch64 EL3 TLBI insns

Quoted 9 lines · Peter Maydell

Move the AArch64 EL3 TLBI insns from el3_cp_reginfo[] across to tlb-insns.c.

---
  target/arm/cpregs.h        |  4 +++
  target/arm/helper.c        | 56 +++-----------------------------------
  target/arm/tcg/tlb-insns.c | 54 ++++++++++++++++++++++++++++++++++++
  3 files changed, 62 insertions(+), 52 deletions(-)

r~

#12 lore raw

PATCH 6/10 target/arm: Move TLBI range insns

In reply to Peter Maydell

Move the TLBI invalidate-range insns across to tlb-insns.c.

---
 target/arm/cpregs.h        |   2 +
 target/arm/helper.c        | 330 +------------------------------------
 target/arm/tcg/tlb-insns.c | 329 ++++++++++++++++++++++++++++++++++++
 3 files changed, 333 insertions(+), 328 deletions(-)
target/arm/cpregs.h +2 -0
index 722ac5bb884..fe838bcfd97 100644
@@ -1142,6 +1142,8 @@ CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
                            bool isread);
 CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri,
                              bool isread);
+CPAccessResult access_ttlbos(CPUARMState *env, const ARMCPRegInfo *ri,
+                             bool isread);
 bool tlb_force_broadcast(CPUARMState *env);
 int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
                        uint64_t addr);
target/arm/helper.c +2 -328

354 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +329 -0

345 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 6/10
#13 lore raw

Re: [PATCH 06/10] target/arm: Move TLBI range insns

Quoted 8 lines · Peter Maydell

Move the TLBI invalidate-range insns across to tlb-insns.c.

---
  target/arm/cpregs.h        |   2 +
  target/arm/helper.c        | 330 +------------------------------------
  target/arm/tcg/tlb-insns.c | 329 ++++++++++++++++++++++++++++++++++++
  3 files changed, 333 insertions(+), 328 deletions(-)

r~

#14 lore raw

PATCH 7/10 target/arm: Move the TLBI OS insns to tlb-insns.c.

In reply to Peter Maydell

Move the TLBI OS insns across to tlb-insns.c.

---
 target/arm/helper.c        | 80 --------------------------------------
 target/arm/tcg/tlb-insns.c | 80 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 80 deletions(-)
target/arm/helper.c +0 -80
index 376aa9aecd5..3f7d56e809f 100644
@@ -7116,83 +7116,6 @@ static const ARMCPRegInfo pauth_reginfo[] = {
       .fieldoffset = offsetof(CPUARMState, keys.apib.hi) },
 };
 
-static const ARMCPRegInfo tlbios_reginfo[] = {
-    { .name = "TLBI_VMALLE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 0,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .fgt = FGT_TLBIVMALLE1OS,
-      .writefn = tlbi_aa64_vmalle1is_write },
-    { .name = "TLBI_VAE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 1,
-      .fgt = FGT_TLBIVAE1OS,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_vae1is_write },
-    { .name = "TLBI_ASIDE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 2,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .fgt = FGT_TLBIASIDE1OS,
-      .writefn = tlbi_aa64_vmalle1is_write },
-    { .name = "TLBI_VAAE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 3,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .fgt = FGT_TLBIVAAE1OS,
-      .writefn = tlbi_aa64_vae1is_write },
-    { .name = "TLBI_VALE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 5,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .fgt = FGT_TLBIVALE1OS,
-      .writefn = tlbi_aa64_vae1is_write },
-    { .name = "TLBI_VAALE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 7,
-      .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
-      .fgt = FGT_TLBIVAALE1OS,
-      .writefn = tlbi_aa64_vae1is_write },
-    { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0,
-      .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
-      .writefn = tlbi_aa64_alle2is_write },
-    { .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1,
-      .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
-      .writefn = tlbi_aa64_vae2is_write },
-   { .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4,
-      .access = PL2_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_alle1is_write },
-    { .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5,
-      .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
-      .writefn = tlbi_aa64_vae2is_write },
-    { .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6,
-      .access = PL2_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_alle1is_write },
-    { .name = "TLBI_IPAS2E1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 0,
-      .access = PL2_W, .type = ARM_CP_NOP },
-    { .name = "TLBI_RIPAS2E1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 3,
-      .access = PL2_W, .type = ARM_CP_NOP },
-    { .name = "TLBI_IPAS2LE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 4,
-      .access = PL2_W, .type = ARM_CP_NOP },
-    { .name = "TLBI_RIPAS2LE1OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 7,
-      .access = PL2_W, .type = ARM_CP_NOP },
-    { .name = "TLBI_ALLE3OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 0,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_alle3is_write },
-    { .name = "TLBI_VAE3OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 1,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_vae3is_write },
-    { .name = "TLBI_VALE3OS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_vae3is_write },
-};
-
 static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri)
 {
     Error *err = NULL;
@@ -9066,9 +8989,6 @@ void register_cp_regs_for_features(ARMCPU *cpu)
     if (cpu_isar_feature(aa64_rndr, cpu)) {
         define_arm_cp_regs(cpu, rndr_reginfo);
     }
-    if (cpu_isar_feature(aa64_tlbios, cpu)) {
-        define_arm_cp_regs(cpu, tlbios_reginfo);
-    }
     /* Data Cache clean instructions up to PoP */
     if (cpu_isar_feature(aa64_dcpop, cpu)) {
         define_one_arm_cp_reg(cpu, dcpop_reg);
target/arm/tcg/tlb-insns.c +80 -0

91 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 7/10
#15 lore raw

Re: [PATCH 07/10] target/arm: Move the TLBI OS insns to tlb-insns.c.

Quoted 7 lines · Peter Maydell

Move the TLBI OS insns across to tlb-insns.c.

---
  target/arm/helper.c        | 80 --------------------------------------
  target/arm/tcg/tlb-insns.c | 80 ++++++++++++++++++++++++++++++++++++++
  2 files changed, 80 insertions(+), 80 deletions(-)

r~

#16 lore raw

PATCH 8/10 target/arm: Move small helper functions to tlb-insns.c

In reply to Peter Maydell

The remaining functions that we temporarily made global are now used only from callsits in tlb-insns.c; move them across and make them file-local again.

---
 target/arm/cpregs.h        |  34 ------
 target/arm/helper.c        | 220 -------------------------------------
 target/arm/tcg/tlb-insns.c | 220 +++++++++++++++++++++++++++++++++++++
 3 files changed, 220 insertions(+), 254 deletions(-)
target/arm/cpregs.h +0 -34
index fe838bcfd97..cc7c54378f4 100644
@@ -1134,38 +1134,4 @@ static inline bool arm_cpreg_traps_in_nv(const ARMCPRegInfo *ri)
     return ri->opc1 == 4 || ri->opc1 == 5;
 }
 
-/*
- * Temporary declarations of functions until the move to tlb_insn_helper.c
- * is complete and we can make the functions static again
- */
-CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri,
-                           bool isread);
-CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri,
-                             bool isread);
-CPAccessResult access_ttlbos(CPUARMState *env, const ARMCPRegInfo *ri,
-                             bool isread);
-bool tlb_force_broadcast(CPUARMState *env);
-int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
-                       uint64_t addr);
-int vae1_tlbbits(CPUARMState *env, uint64_t addr);
-int vae2_tlbbits(CPUARMState *env, uint64_t addr);
-int vae1_tlbmask(CPUARMState *env);
-int vae2_tlbmask(CPUARMState *env);
-int ipas2e1_tlbmask(CPUARMState *env, int64_t value);
-int e2_tlbmask(CPUARMState *env);
-void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                               uint64_t value);
-void tlbi_aa64_alle1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                             uint64_t value);
-void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                            uint64_t value);
-void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                             uint64_t value);
-void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                            uint64_t value);
-void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                            uint64_t value);
-void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                             uint64_t value);
-
 #endif /* TARGET_ARM_CPREGS_H */
target/arm/helper.c +0 -220

238 lines not on this page · raw message

target/arm/tcg/tlb-insns.c +220 -0

262 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 8/10
#17 lore raw

Re: [PATCH 08/10] target/arm: Move small helper functions to tlb-insns.c

Quoted 10 lines · Peter Maydell

The remaining functions that we temporarily made global are now used only from callsits in tlb-insns.c; move them across and make them file-local again.

---
  target/arm/cpregs.h        |  34 ------
  target/arm/helper.c        | 220 -------------------------------------
  target/arm/tcg/tlb-insns.c | 220 +++++++++++++++++++++++++++++++++++++
  3 files changed, 220 insertions(+), 254 deletions(-)

r~

#18 lore raw

PATCH 9/10 target/arm: Move RME TLB insns to tlb-insns.c

In reply to Peter Maydell

Move the FEAT_RME specific TLB insns across to tlb-insns.c.

---
 target/arm/helper.c        | 38 --------------------------------
 target/arm/tcg/tlb-insns.c | 45 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 38 deletions(-)
target/arm/helper.c +0 -38
index cd9f8650316..910ae62c476 100644
@@ -6525,14 +6525,6 @@ static const ARMCPRegInfo sme_reginfo[] = {
       .type = ARM_CP_CONST, .resetvalue = 0 },
 };
 
-static void tlbi_aa64_paall_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                                  uint64_t value)
-{
-    CPUState *cs = env_cpu(env);
-
-    tlb_flush(cs);
-}
-
 static void gpccr_write(CPUARMState *env, const ARMCPRegInfo *ri,
                         uint64_t value)
 {
@@ -6550,14 +6542,6 @@ static void gpccr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
                                      env_archcpu(env)->reset_l0gptsz);
 }
 
-static void tlbi_aa64_paallos_write(CPUARMState *env, const ARMCPRegInfo *ri,
-                                    uint64_t value)
-{
-    CPUState *cs = env_cpu(env);
-
-    tlb_flush_all_cpus_synced(cs);
-}
-
 static const ARMCPRegInfo rme_reginfo[] = {
     { .name = "GPCCR_EL3", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 1, .opc2 = 6,
@@ -6569,28 +6553,6 @@ static const ARMCPRegInfo rme_reginfo[] = {
     { .name = "MFAR_EL3", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 6, .crn = 6, .crm = 0, .opc2 = 5,
       .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mfar_el3) },
-    { .name = "TLBI_PAALL", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 4,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_paall_write },
-    { .name = "TLBI_PAALLOS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 4,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_paallos_write },
-    /*
-     * QEMU does not have a way to invalidate by physical address, thus
-     * invalidating a range of physical addresses is accomplished by
-     * flushing all tlb entries in the outer shareable domain,
-     * just like PAALLOS.
-     */
-    { .name = "TLBI_RPALOS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 7,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_paallos_write },
-    { .name = "TLBI_RPAOS", .state = ARM_CP_STATE_AA64,
-      .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 3,
-      .access = PL3_W, .type = ARM_CP_NO_RAW,
-      .writefn = tlbi_aa64_paallos_write },
     { .name = "DC_CIPAPA", .state = ARM_CP_STATE_AA64,
       .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 1,
       .access = PL3_W, .type = ARM_CP_NOP },
target/arm/tcg/tlb-insns.c +45 -0

56 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 9/10
#19 lore raw

Re: [PATCH 09/10] target/arm: Move RME TLB insns to tlb-insns.c

Quoted 7 lines · Peter Maydell

Move the FEAT_RME specific TLB insns across to tlb-insns.c.

---
  target/arm/helper.c        | 38 --------------------------------
  target/arm/tcg/tlb-insns.c | 45 ++++++++++++++++++++++++++++++++++++++
  2 files changed, 45 insertions(+), 38 deletions(-)

r~

#20 lore raw

PATCH 10/10 target/arm: Simplify condition for tlbi_el2_cp_reginfo[]

In reply to Peter Maydell

We currently register the tlbi_el2_cp_reginfo[] TLBI insns if EL2 is implemented, or if EL3 and v8 is implemented. This is a copy of the logic used for el2_cp_reginfo[], but for the specific case of the TLBI insns we can simplify it. This is because we do not need the "if EL2 does not exist but EL3 does then EL2 registers should exist and be RAZ/WI" handling here: all our cpregs are for instructions, which UNDEF when EL3 exists and EL2 does not.

Simplify the condition down to just "if EL2 exists". This is not a behaviour change because:
* for AArch64 insns we marked them with ARM_CP_EL3_NO_EL2_UNDEF, which meant that define_arm_cp_regs() would ignore them if EL2 wasn't present
* for AArch32 insns, the .access = PL2_W meant that if EL2 was not present the only way to get at them was from AArch32 EL3; but we have no CPUs which have ARM_FEATURE_V8 but start in AArch32

---
 target/arm/tcg/tlb-insns.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
target/arm/tcg/tlb-insns.c +1 -3
index d20d32624da..0f67294edc4 100644
@@ -1246,9 +1246,7 @@ void define_tlb_insn_regs(ARMCPU *cpu)
      * ops (i.e. matching the condition for el2_cp_reginfo[] in
      * helper.c), but we will be able to simplify this later.
      */
-    if (arm_feature(env, ARM_FEATURE_EL2)
-        || (arm_feature(env, ARM_FEATURE_EL3)
-            && arm_feature(env, ARM_FEATURE_V8))) {
+    if (arm_feature(env, ARM_FEATURE_EL2)) {
         define_arm_cp_regs(cpu, tlbi_el2_cp_reginfo);
     }
     if (arm_feature(env, ARM_FEATURE_EL3)) {
Signature · 1 line
2.34.1
Reviewed-by on v1 10/10
#21 lore raw

Re: [PATCH 10/10] target/arm: Simplify condition for tlbi_el2_cp_reginfo[]

Quoted 18 lines · Peter Maydell

We currently register the tlbi_el2_cp_reginfo[] TLBI insns if EL2 is implemented, or if EL3 and v8 is implemented. This is a copy of the logic used for el2_cp_reginfo[], but for the specific case of the TLBI insns we can simplify it. This is because we do not need the "if EL2 does not exist but EL3 does then EL2 registers should exist and be RAZ/WI" handling here: all our cpregs are for instructions, which UNDEF when EL3 exists and EL2 does not.

Simplify the condition down to just "if EL2 exists". This is not a behaviour change because:
* for AArch64 insns we marked them with ARM_CP_EL3_NO_EL2_UNDEF, which meant that define_arm_cp_regs() would ignore them if EL2 wasn't present
* for AArch32 insns, the .access = PL2_W meant that if EL2 was not present the only way to get at them was from AArch32 EL3; but we have no CPUs which have ARM_FEATURE_V8 but start in AArch32

Quoted 1 line

r~