Dump the registers on undefined instruction userspace faults
[firefly-linux-kernel-4.4.55.git] / arch / arm / include / asm / assembler.h
index 5c228516057552b6eca4f6f5a54f2a3f9733fd09..b974184f9941883339c0480df1290a6a6f66a4ae 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/ptrace.h>
 #include <asm/domain.h>
 #include <asm/opcodes-virt.h>
+#include <asm/asm-offsets.h>
 
 #define IOMEM(x)       (x)
 
@@ -30,8 +31,8 @@
  * Endian independent macros for shifting bytes within registers.
  */
 #ifndef __ARMEB__
-#define pull            lsr
-#define push            lsl
+#define lspull          lsr
+#define lspush          lsl
 #define get_byte_0      lsl #0
 #define get_byte_1     lsr #8
 #define get_byte_2     lsr #16
@@ -41,8 +42,8 @@
 #define put_byte_2     lsl #16
 #define put_byte_3     lsl #24
 #else
-#define pull            lsl
-#define push            lsr
+#define lspull          lsl
+#define lspush          lsr
 #define get_byte_0     lsr #24
 #define get_byte_1     lsr #16
 #define get_byte_2     lsr #8
        restore_irqs_notrace \oldcpsr
        .endm
 
+/*
+ * Get current thread_info.
+ */
+       .macro  get_thread_info, rd
+ ARM(  mov     \rd, sp, lsr #13        )
+ THUMB(        mov     \rd, sp                 )
+ THUMB(        lsr     \rd, \rd, #13           )
+       mov     \rd, \rd, lsl #13
+       .endm
+
+/*
+ * Increment/decrement the preempt count.
+ */
+#ifdef CONFIG_PREEMPT_COUNT
+       .macro  inc_preempt_count, ti, tmp
+       ldr     \tmp, [\ti, #TI_PREEMPT]        @ get preempt count
+       add     \tmp, \tmp, #1                  @ increment it
+       str     \tmp, [\ti, #TI_PREEMPT]
+       .endm
+
+       .macro  dec_preempt_count, ti, tmp
+       ldr     \tmp, [\ti, #TI_PREEMPT]        @ get preempt count
+       sub     \tmp, \tmp, #1                  @ decrement it
+       str     \tmp, [\ti, #TI_PREEMPT]
+       .endm
+
+       .macro  dec_preempt_count_ti, ti, tmp
+       get_thread_info \ti
+       dec_preempt_count \ti, \tmp
+       .endm
+#else
+       .macro  inc_preempt_count, ti, tmp
+       .endm
+
+       .macro  dec_preempt_count, ti, tmp
+       .endm
+
+       .macro  dec_preempt_count_ti, ti, tmp
+       .endm
+#endif
+
 #define USER(x...)                             \
 9999:  x;                                      \
        .pushsection __ex_table,"a";            \