OSDN Git Service

MIPS: memset.S: Add comments to fault fixup handlers
authorMatt Redfearn <matt.redfearn@mips.com>
Wed, 23 May 2018 13:39:59 +0000 (14:39 +0100)
committerPaul Burton <paul.burton@mips.com>
Wed, 25 Jul 2018 00:02:43 +0000 (17:02 -0700)
It is not immediately obvious what the expected inputs to these fault
handlers is and how they calculate the number of unset bytes. Having
stared deeply at this in order to fix some corner cases, add some
comments to assist those who follow.

Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/19339/
Cc: James Hogan <jhogan@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: <linux-mips@linux-mips.org>
Cc: <linux-kernel@vger.kernel.org>
arch/mips/lib/memset.S

index fac26ce..3a6f34e 100644 (file)
 
 #ifdef CONFIG_CPU_MIPSR6
 .Lbyte_fixup\@:
+       /*
+        * unset_bytes = (#bytes - (#unaligned bytes)) - (-#unaligned bytes remaining + 1) + 1
+        *      a2     =             a2                -              t0                   + 1
+        */
        PTR_SUBU        a2, t0
        jr              ra
         PTR_ADDIU      a2, 1
 #endif /* CONFIG_CPU_MIPSR6 */
 
 .Lfirst_fixup\@:
+       /* unset_bytes already in a2 */
        jr      ra
         nop
 
 .Lfwd_fixup\@:
+       /*
+        * unset_bytes = partial_start_addr +  #bytes   -     fault_addr
+        *      a2     =         t1         + (a2 & 3f) - $28->task->BUADDR
+        */
        PTR_L           t0, TI_TASK($28)
        andi            a2, 0x3f
        LONG_L          t0, THREAD_BUADDR(t0)
         LONG_SUBU      a2, t0
 
 .Lpartial_fixup\@:
+       /*
+        * unset_bytes = partial_end_addr +      #bytes     -     fault_addr
+        *      a2     =       a0         + (a2 & STORMASK) - $28->task->BUADDR
+        */
        PTR_L           t0, TI_TASK($28)
        andi            a2, STORMASK
        LONG_L          t0, THREAD_BUADDR(t0)
         LONG_SUBU      a2, t0
 
 .Llast_fixup\@:
+       /* unset_bytes already in a2 */
        jr              ra
         nop
 
 .Lsmall_fixup\@:
+       /*
+        * unset_bytes = end_addr - current_addr + 1
+        *      a2     =    t1    -      a0      + 1
+        */
        PTR_SUBU        a2, t1, a0
        jr              ra
         PTR_ADDIU      a2, 1