]> Pileus Git - ~andy/linux/commitdiff
ARC: [SMP] Fix build failures for large NR_CPUS
authorVineet Gupta <vgupta@synopsys.com>
Fri, 1 Nov 2013 05:16:40 +0000 (10:46 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Wed, 6 Nov 2013 05:11:46 +0000 (10:41 +0530)
ST.as only takes S9 (255) for offset. This was going out of range when
accessing a task_struct field with 4k NR_CPUS (due to 128b of coumaks
itself in there).

Workaround by using an intermediate register to do the address scaling.

There is some duplication of fix for ctx_sw.c and ctx_sw_asm.S however
given that C version will go away soon I'm not bothering to factor out
the common code.

Reported-by: Noam Camus <noamc@ezchip.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/kernel/ctx_sw.c
arch/arc/kernel/ctx_sw_asm.S

index 34410eb1a308e7d801abbc6ece893db54975f9c7..c14a5bea0c76792ead17b42e1f548e38960cc194 100644 (file)
@@ -17,6 +17,8 @@
 #include <asm/asm-offsets.h>
 #include <linux/sched.h>
 
+#define KSP_WORD_OFF   ((TASK_THREAD + THREAD_KSP) / 4)
+
 struct task_struct *__sched
 __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 {
@@ -45,7 +47,16 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 #endif
 
                /* set ksp of outgoing task in tsk->thread.ksp */
+#if KSP_WORD_OFF <= 255
                "st.as   sp, [%3, %1]    \n\t"
+#else
+               /*
+                * Workaround for NR_CPUS=4k
+                * %1 is bigger than 255 (S9 offset for st.as)
+                */
+               "add2    r24, %3, %1     \n\t"
+               "st      sp, [r24]       \n\t"
+#endif
 
                "sync   \n\t"
 
@@ -97,7 +108,7 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
                /* FP/BLINK restore generated by gcc (standard func epilogue */
 
                : "=r"(tmp)
-               : "n"((TASK_THREAD + THREAD_KSP) / 4), "r"(next), "r"(prev)
+               : "n"(KSP_WORD_OFF), "r"(next), "r"(prev)
                : "blink"
        );
 
index d8972345e4c22ab9bd036827c76974065229cb39..65690e7fcc8cce6b3d1f76e33750f49b788d0b19 100644 (file)
@@ -14,6 +14,8 @@
 #include <asm/asm-offsets.h>
 #include <asm/linkage.h>
 
+#define KSP_WORD_OFF   ((TASK_THREAD + THREAD_KSP) / 4)
+
 ;################### Low Level Context Switch ##########################
 
        .section .sched.text,"ax",@progbits
@@ -28,8 +30,13 @@ __switch_to:
        SAVE_CALLEE_SAVED_KERNEL
 
        /* Save the now KSP in task->thread.ksp */
-       st.as  sp, [r0, (TASK_THREAD + THREAD_KSP)/4]
-
+#if KSP_WORD_OFF  <= 255
+       st.as  sp, [r0, KSP_WORD_OFF]
+#else
+       /* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
+       add2    r24, r0, KSP_WORD_OFF
+       st      sp, [r24]
+#endif
        /*
        * Return last task in r0 (return reg)
        * On ARC, Return reg = First Arg reg = r0.