Skip to content

Commit 6312455

Browse files
mpredfearnpaulburton
authored andcommitted
MIPS: memset.S: Add comments to fault fixup handlers
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>
1 parent b1c03f1 commit 6312455

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎arch/mips/lib/memset.S‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,25 @@
232232

233233
#ifdef CONFIG_CPU_MIPSR6
234234
.Lbyte_fixup\@:
235+
/*
236+
* unset_bytes = (#bytes - (#unaligned bytes)) - (-#unaligned bytes remaining + 1) + 1
237+
* a2 = a2 - t0 + 1
238+
*/
235239
PTR_SUBU a2, t0
236240
jr ra
237241
PTR_ADDIU a2, 1
238242
#endif /* CONFIG_CPU_MIPSR6 */
239243

240244
.Lfirst_fixup\@:
245+
/* unset_bytes already in a2 */
241246
jr ra
242247
nop
243248

244249
.Lfwd_fixup\@:
250+
/*
251+
* unset_bytes = partial_start_addr + #bytes - fault_addr
252+
* a2 = t1 + (a2 & 3f) - $28->task->BUADDR
253+
*/
245254
PTR_L t0, TI_TASK($28)
246255
andi a2, 0x3f
247256
LONG_L t0, THREAD_BUADDR(t0)
@@ -250,6 +259,10 @@
250259
LONG_SUBU a2, t0
251260

252261
.Lpartial_fixup\@:
262+
/*
263+
* unset_bytes = partial_end_addr + #bytes - fault_addr
264+
* a2 = a0 + (a2 & STORMASK) - $28->task->BUADDR
265+
*/
253266
PTR_L t0, TI_TASK($28)
254267
andi a2, STORMASK
255268
LONG_L t0, THREAD_BUADDR(t0)
@@ -258,10 +271,15 @@
258271
LONG_SUBU a2, t0
259272

260273
.Llast_fixup\@:
274+
/* unset_bytes already in a2 */
261275
jr ra
262276
nop
263277

264278
.Lsmall_fixup\@:
279+
/*
280+
* unset_bytes = end_addr - current_addr + 1
281+
* a2 = t1 - a0 + 1
282+
*/
265283
PTR_SUBU a2, t1, a0
266284
jr ra
267285
PTR_ADDIU a2, 1

0 commit comments

Comments
 (0)