powerpc: Fix 0 vs. r0 confusion in X/D-form instructions
authorJ. Neuschäfer <j.ne@posteo.net>
Thu, 12 Dec 2024 17:05:46 +0000 (18:05 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 30 Dec 2024 21:55:07 +0000 (15:55 -0600)
commitfd1c2938c0ef23db322b974a5d2b8020aa6a8750
tree2ce93b0cd5cf39687688e54d2432651b3d3a0d39
parente5aef1bbf11412eebd4c242b46adff5301353c30
powerpc: Fix 0 vs. r0 confusion in X/D-form instructions

Instructions such as dcbi are in the X-form; they have RA and RB fields
and the effective address (EA) is computed as (RA|0)+(RB). In words,
this means that if RA is zero, the left-hand side of the addition is
zero, otherwise the corresponding GPR is used. r0 can never be used on
the left-hand side of a X-form instruction.

For D-form instructions such as addis, the Power ISA illustrates this in
the instruction pseudo-code:

if RA = 0 then RT <-        EXTS(SI || 0x0000)
else           RT <- (RA) + EXIS(SI || 0x0000)

In all of these cases, RA=0 indicates the value zero, not register r0.

I verified with gazerbeam_defconfig (MPC83xx) and qemu-ppce500_defconfig
(MPC85xx) that this patch results in the same machine code.

Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
arch/powerpc/cpu/mpc83xx/start.S
arch/powerpc/cpu/mpc85xx/start.S
arch/powerpc/lib/ppccache.S