sparc64: Prepare to move to more saner user copy exception handling.
authorDavid S. Miller <davem@davemloft.net>
Mon, 15 Aug 2016 21:47:54 +0000 (14:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Nov 2016 09:06:41 +0000 (10:06 +0100)
[ Upstream commit 83a17d2661674d8c198adc0e183418f72aabab79 ]

The fixup helper function mechanism for handling user copy fault
handling is not %100 accurrate, and can never be made so.

We are going to transition the code to return the running return
return length, which is always kept track in one or more registers
of each of these routines.

In order to convert them one by one, we have to allow the existing
behavior to continue functioning.

Therefore make all the copy code that wants the fixup helper to be
used return negative one.

After all of the user copy routines have been converted, this logic
and the fixup helpers themselves can be removed completely.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 files changed:
arch/sparc/include/asm/uaccess_64.h
arch/sparc/kernel/head_64.S
arch/sparc/lib/GENcopy_from_user.S
arch/sparc/lib/GENcopy_to_user.S
arch/sparc/lib/NG2copy_from_user.S
arch/sparc/lib/NG2copy_to_user.S
arch/sparc/lib/NG4copy_from_user.S
arch/sparc/lib/NG4copy_to_user.S
arch/sparc/lib/NGcopy_from_user.S
arch/sparc/lib/NGcopy_to_user.S
arch/sparc/lib/U1copy_from_user.S
arch/sparc/lib/U1copy_to_user.S
arch/sparc/lib/U3copy_from_user.S
arch/sparc/lib/U3copy_to_user.S
arch/sparc/lib/copy_in_user.S

index a17b8c4b189f64616ecd15bc78794eb2fb1f58d1..00a9fb89588736deddd75a97c4ffe8c6773dae21 100644 (file)
@@ -211,8 +211,11 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_from_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_from_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_from_user_fixup(to, from, size);
+               return ret;
+       }
 
        return ret;
 }
@@ -228,8 +231,11 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
 {
        unsigned long ret = ___copy_to_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_to_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_to_user_fixup(to, from, size);
+               return ret;
+       }
        return ret;
 }
 #define __copy_to_user copy_to_user
@@ -244,8 +250,11 @@ copy_in_user(void __user *to, void __user *from, unsigned long size)
 {
        unsigned long ret = ___copy_in_user(to, from, size);
 
-       if (unlikely(ret))
-               ret = copy_in_user_fixup(to, from, size);
+       if (unlikely(ret)) {
+               if ((long)ret < 0)
+                       ret = copy_in_user_fixup(to, from, size);
+               return ret;
+       }
        return ret;
 }
 #define __copy_in_user copy_in_user
index 7d45fd31573a4b7e7bbdd9f2eedc3454800c1ee3..73ea59667bbfe6d9c5874a88ae814355ebfa74e6 100644 (file)
@@ -922,41 +922,40 @@ prom_tba: .xword  0
 tlb_type:      .word   0       /* Must NOT end up in BSS */
        .section        ".fixup",#alloc,#execinstr
 
-       .globl  __retl_efault, __ret_one, __retl_one
 ENTRY(__retl_efault)
        retl
         mov    -EFAULT, %o0
 ENDPROC(__retl_efault)
 
-ENTRY(__retl_one)
+ENTRY(__retl_mone)
        retl
-        mov    1, %o0
-ENDPROC(__retl_one)
+        mov    -1, %o0
+ENDPROC(__retl_mone)
 
-ENTRY(__retl_one_fp)
+ENTRY(__retl_mone_fp)
        VISExitHalf
        retl
         mov    1, %o0
-ENDPROC(__retl_one_fp)
+ENDPROC(__retl_mone_fp)
 
-ENTRY(__ret_one_asi)
+ENTRY(__ret_mone_asi)
        wr      %g0, ASI_AIUS, %asi
        ret
         restore %g0, 1, %o0
-ENDPROC(__ret_one_asi)
+ENDPROC(__ret_mone_asi)
 
-ENTRY(__retl_one_asi)
+ENTRY(__retl_mone_asi)
        wr      %g0, ASI_AIUS, %asi
        retl
         mov    1, %o0
-ENDPROC(__retl_one_asi)
+ENDPROC(__retl_mone_asi)
 
-ENTRY(__retl_one_asi_fp)
+ENTRY(__retl_mone_asi_fp)
        wr      %g0, ASI_AIUS, %asi
        VISExitHalf
        retl
         mov    1, %o0
-ENDPROC(__retl_one_asi_fp)
+ENDPROC(__retl_mone_asi_fp)
 
 ENTRY(__retl_o1)
        retl
index b7d0bd6b14063bc1e62cfed3c0e32f0b43799396..5bce682022465696cae99770a7166c96aea44782 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
index 780550e1afc74fd6efe38ef16f73a07ea021a8f2..f663ce3ee8d997443903cfaf58c6d16385782b72 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
index d5242b8c4f9495fe4241ee39de01255364e877af..4d47fa5519d4f4e1977456b1cfa1f9997c0a7abe 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi;\
+       .word 98b, __retl_mone_asi;\
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi_fp;\
+       .word 98b, __retl_mone_asi_fp;\
        .text;                  \
        .align 4;
 
index 4e962d993b10cdff7677f8d51e61ad877901facc..2078d752709a7bd502f2ec75340dfdf40e855c45 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi;\
+       .word 98b, __retl_mone_asi;\
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi_fp;\
+       .word 98b, __retl_mone_asi_fp;\
        .text;                  \
        .align 4;
 
index 2e8ee7ad07a9ce06129cd63c4129ccade674ab77..f9746e7cf25ee2d207ed0260dd582ddf4822de4c 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi;\
+       .word 98b, __retl_mone_asi;\
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi_fp;\
+       .word 98b, __retl_mone_asi_fp;\
        .text;                  \
        .align 4;
 
index be0bf4590df8971ddf29a81153f05de7c0ef30da..5fa44349addee381de12915ab0458ec02bb9479f 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi;\
+       .word 98b, __retl_mone_asi;\
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_asi_fp;\
+       .word 98b, __retl_mone_asi_fp;\
        .text;                  \
        .align 4;
 
index 5d1e4d1ac21edf09a664663dc005e1fcae805b6a..e61694c444af8554db3e5d51c05e208abd1d9261 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __ret_one_asi;\
+       .word 98b, __ret_mone_asi;\
        .text;                  \
        .align 4;
 
index ff630dcb273c9649de6fc9e145fce42e72667787..2d6b33d3998f0ada1548b8ef8a279f3a7a402a8c 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __ret_one_asi;\
+       .word 98b, __ret_mone_asi;\
        .text;                  \
        .align 4;
 
index ecc5692fa2b49a3acfc6a6592c6c247835417b4c..1ad59fbac7a7512c6af214d3d12746d4a7ca5878 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_fp;\
+       .word 98b, __retl_mone_fp;\
        .text;                  \
        .align 4;
 
index 9eea392e44d471679ba85c22867a9767b34912a5..adcc3a510185084e097c9d318214f0d590dc23f0 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_fp;\
+       .word 98b, __retl_mone_fp;\
        .text;                  \
        .align 4;
 
index 88ad73d86fe44b64c2313483e7490cc8ae0ee438..1046e2b083fece97deb4d4ba5567eebc11f6d9c8 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_fp;\
+       .word 98b, __retl_mone_fp;\
        .text;                  \
        .align 4;
 
index 845139d7553720ce5fe98d6e30bcb11215f71e2f..032b0c5419b0c5dbe69eb178094286f0a6a3694f 100644 (file)
@@ -7,7 +7,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;
 
@@ -15,7 +15,7 @@
 98:    x;                      \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one_fp;\
+       .word 98b, __retl_mone_fp;\
        .text;                  \
        .align 4;
 
index 302c0e60dc2ceb48a3212840ac7891f337419d14..8ec287d15da31d0ed1d69a83f4f39bd83fd6dc42 100644 (file)
@@ -12,7 +12,7 @@
 98:    x,y;                    \
        .section __ex_table,"a";\
        .align 4;               \
-       .word 98b, __retl_one;  \
+       .word 98b, __retl_mone; \
        .text;                  \
        .align 4;