Re: [PATCH v2 3/5] MIPS: Only change $28 to thread_info if coming from user mode

From: Maciej W. Rozycki
Date: Thu Dec 15 2016 - 07:08:55 EST


On Tue, 13 Dec 2016, Matt Redfearn wrote:

> diff --git a/arch/mips/include/asm/stackframe.h b/arch/mips/include/asm/stackframe.h
> index eebf39549606..e13164daf9c2 100644
> --- a/arch/mips/include/asm/stackframe.h
> +++ b/arch/mips/include/asm/stackframe.h
> @@ -216,12 +216,20 @@
> LONG_S $25, PT_R25(sp)
> LONG_S $28, PT_R28(sp)
> LONG_S $31, PT_R31(sp)
> +
> + /* Set thread_info if we're coming from user mode */
> + mfc0 k0, CP0_STATUS
> + sll k0, 3 /* extract cu0 bit */
> + bltz k0, 9f
> + nop
> +

Have you actually verified the machine code generated as expected with
such a change? This supposedly delay-slot NOP can be dropped as this is
`.set reorder' code, so GAS will have scheduled a NOP itself already,
having found there is an SLL->BLTZ data dependency and consequently the
two instructions cannot be swapped. So now there'll be an extraneous NOP
there, wasting code space and execution time.

Maciej