Re: [PATCH 4.4 54/58] powerpc: Convert cmp to cmpd in idle enter sequence

From: Vaidyanathan Srinivasan
Date: Mon Jan 09 2017 - 04:56:07 EST


* Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> [2017-01-06 22:44:39]:

> 4.4-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx>
>
> commit 80f23935cadb1c654e81951f5a8b7ceae0acc1b4 upstream.
>
> PowerPC's "cmp" instruction has four operands. Normally people write
> "cmpw" or "cmpd" for the second cmp operand 0 or 1. But, frequently
> people forget, and write "cmp" with just three operands.
>
> With older binutils this is silently accepted as if this was "cmpw",
> while often "cmpd" is wanted. With newer binutils GAS will complain
> about this for 64-bit code. For 32-bit code it still silently assumes
> "cmpw" is what is meant.
>
> In this instance the code comes directly from ISA v2.07, including the
> cmp, but cmpd is correct. Backport to stable so that new toolchains can
> build old kernels.
>
> Fixes: 948cf67c4726 ("powerpc: Add NAP mode support on Power7 in HV mode")
> Reviewed-by: Vaidyanathan Srinivasan <svaidy@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Signed-off-by: Joel Stanley <joel@xxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

Acked-by: Vaidyanathan Srinivasan <svaidy@xxxxxxxxxxxxxxxxxx>

The change from cmp to cmpd is correct. This code will execute
in 64-bit mode only and fix applies to stable as described above.

>
>
> ---
> arch/powerpc/kernel/idle_power7.S | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/arch/powerpc/kernel/idle_power7.S
> +++ b/arch/powerpc/kernel/idle_power7.S
> @@ -44,7 +44,7 @@
> std r0,0(r1); \
> ptesync; \
> ld r0,0(r1); \
> -1: cmp cr0,r0,r0; \
> +1: cmpd cr0,r0,r0; \
> bne 1b; \
> IDLE_INST; \
> b .
>
>