MIPS: hazards: Add hazard macros for tlb read
authorJames Hogan <james.hogan@imgtec.com>
Tue, 19 May 2015 08:50:30 +0000 (09:50 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Sun, 21 Jun 2015 19:52:28 +0000 (21:52 +0200)
Add hazard macros to <asm/hazards.h> for the following hazards around
tlbr (TLB read) instructions, which are used in TLB dumping code and
some KVM TLB management code:

- mtc0_tlbr_hazard
  Between mtc0 (Index) and tlbr. This is copied from mtc0_tlbw_hazard in
  all cases on the assumption that tlbr always has similar data user
  timings to tlbw.

- tlb_read_hazard
  Between tlbr and mfc0 (various TLB registers). This is copied from
  tlbw_use_hazard in all cases on the assumption that tlbr has similar
  data writer characteristics to tlbw, and mfc0 has similar data user
  characteristics to loads and stores.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/10078/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/hazards.h

index 4087b47ad1cbea16050e968a4daf9f0531b4aa6d..7b99efd310748dbfe12c29459ffdd5e4137a2bf8 100644 (file)
 #define __mtc0_tlbw_hazard                                             \
        ___ehb
 
+#define __mtc0_tlbr_hazard                                             \
+       ___ehb
+
 #define __tlbw_use_hazard                                              \
        ___ehb
 
+#define __tlb_read_hazard                                              \
+       ___ehb
+
 #define __tlb_probe_hazard                                             \
        ___ehb
 
@@ -80,12 +86,23 @@ do {                                                                        \
        ___ssnop;                                                       \
        ___ehb
 
+#define __mtc0_tlbr_hazard                                             \
+       ___ssnop;                                                       \
+       ___ssnop;                                                       \
+       ___ehb
+
 #define __tlbw_use_hazard                                              \
        ___ssnop;                                                       \
        ___ssnop;                                                       \
        ___ssnop;                                                       \
        ___ehb
 
+#define __tlb_read_hazard                                              \
+       ___ssnop;                                                       \
+       ___ssnop;                                                       \
+       ___ssnop;                                                       \
+       ___ehb
+
 #define __tlb_probe_hazard                                             \
        ___ssnop;                                                       \
        ___ssnop;                                                       \
@@ -147,8 +164,12 @@ do {                                                                       \
 
 #define __mtc0_tlbw_hazard
 
+#define __mtc0_tlbr_hazard
+
 #define __tlbw_use_hazard
 
+#define __tlb_read_hazard
+
 #define __tlb_probe_hazard
 
 #define __irq_enable_hazard
@@ -166,8 +187,12 @@ do {                                                                       \
  */
 #define __mtc0_tlbw_hazard
 
+#define __mtc0_tlbr_hazard
+
 #define __tlbw_use_hazard
 
+#define __tlb_read_hazard
+
 #define __tlb_probe_hazard
 
 #define __irq_enable_hazard
@@ -196,11 +221,20 @@ do {                                                                      \
        nop;                                                            \
        nop
 
+#define __mtc0_tlbr_hazard                                             \
+       nop;                                                            \
+       nop
+
 #define __tlbw_use_hazard                                              \
        nop;                                                            \
        nop;                                                            \
        nop
 
+#define __tlb_read_hazard                                              \
+       nop;                                                            \
+       nop;                                                            \
+       nop
+
 #define __tlb_probe_hazard                                             \
        nop;                                                            \
        nop;                                                            \
@@ -267,7 +301,9 @@ do {                                                                        \
 #define _ssnop ___ssnop
 #define        _ehb ___ehb
 #define mtc0_tlbw_hazard __mtc0_tlbw_hazard
+#define mtc0_tlbr_hazard __mtc0_tlbr_hazard
 #define tlbw_use_hazard __tlbw_use_hazard
+#define tlb_read_hazard __tlb_read_hazard
 #define tlb_probe_hazard __tlb_probe_hazard
 #define irq_enable_hazard __irq_enable_hazard
 #define irq_disable_hazard __irq_disable_hazard
@@ -300,6 +336,14 @@ do {                                                                       \
 } while (0)
 
 
+#define mtc0_tlbr_hazard()                                             \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       __stringify(__mtc0_tlbr_hazard)                                 \
+       );                                                              \
+} while (0)
+
+
 #define tlbw_use_hazard()                                              \
 do {                                                                   \
        __asm__ __volatile__(                                           \
@@ -308,6 +352,14 @@ do {                                                                       \
 } while (0)
 
 
+#define tlb_read_hazard()                                              \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       __stringify(__tlb_read_hazard)                                  \
+       );                                                              \
+} while (0)
+
+
 #define tlb_probe_hazard()                                             \
 do {                                                                   \
        __asm__ __volatile__(                                           \