alistair23-linux/arch
James Hogan c22c804310 MIPS: Fix input modify in __write_64bit_c0_split()
The inline asm in __write_64bit_c0_split() modifies the 64-bit input
operand by shifting the high register left by 32, and constructing the
full 64-bit value in the low register (even on a 32-bit kernel), so if
that value is used again it could cause breakage as GCC would assume the
registers haven't changed when they have.

To quote the GCC extended asm documentation:
> Warning: Do not modify the contents of input-only operands (except for
> inputs tied to outputs). The compiler assumes that on exit from the
> asm statement these operands contain the same values as they had
> before executing the statement.

Avoid modifying the input by using a temporary variable as an output
which is modified instead of the input and not otherwise used. The asm
is always __volatile__ so GCC shouldn't optimise it out. The low
register of the temporary output is written before the high register of
the input is read, so we have two constraint alternatives, one where
both use the same registers (for when the input value isn't subsequently
used), and one with an early clobber on the output in case the low
output uses the same register as the high input. This allows the
resulting assembly to remain mostly unchanged.

A diff of a MIPS32r6 kernel reveals only three differences, two in
relation to write_c0_r10k_diag() in cpu_probe() (register allocation
rearranged slightly but otherwise identical), and one in relation to
write_c0_cvmmemctl2() in kvm_vz_local_flush_guesttlb_all(), but the
octeon CPU is only supported on 64-bit kernels where
__write_64bit_c0_split() isn't used so that shouldn't matter in
practice. So there currently doesn't appear to be anything broken by
this bug.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17315/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2017-09-21 16:26:42 +02:00
..
alpha Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2017-09-11 18:34:47 -07:00
arc mm: treewide: remove GFP_TEMPORARY allocation flag 2017-09-13 18:53:16 -07:00
arm The diff is dominated by the Allwinner A10/A20 SoCs getting converted to 2017-09-13 11:04:14 -07:00
arm64 arm64: stacktrace: avoid listing stacktrace functions in stacktrace 2017-09-13 18:53:16 -07:00
blackfin Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2017-09-11 18:34:47 -07:00
c6x c6x: Convert to using %pOF instead of full_name 2017-08-24 09:35:40 -04:00
cris MTD changes for 4.14: 2017-09-09 14:48:21 -07:00
frv Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2017-09-11 18:34:47 -07:00
h8300 arch: define CPU_BIG_ENDIAN for all fixed big endian archs 2017-09-08 18:26:48 -07:00
hexagon Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-09-04 11:52:29 -07:00
ia64 Merge branch 'work.ipc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-09-14 17:37:26 -07:00
m32r m32r: defconfig: cleanup from old Kconfig options 2017-09-08 18:26:51 -07:00
m68k Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu 2017-09-10 21:07:39 -07:00
metag dma-mapping updates for 4.14: 2017-09-12 13:30:06 -07:00
microblaze Merge branch 'akpm' (patches from Andrew) 2017-09-09 10:30:07 -07:00
mips MIPS: Fix input modify in __write_64bit_c0_split() 2017-09-21 16:26:42 +02:00
mn10300 mn10300: defconfig: cleanup from old Kconfig options 2017-09-08 18:26:51 -07:00
nios2 nios2 update for v4.14-rc1 2017-09-15 12:47:21 -07:00
openrisc OpenRISC patches for 4.14 2017-09-13 11:52:18 -07:00
parisc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2017-09-11 18:34:47 -07:00
powerpc * PPC bugfixes 2017-09-15 15:43:55 -07:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2017-09-12 06:01:59 -07:00
score
sh dma-mapping updates for 4.14: 2017-09-12 13:30:06 -07:00
sparc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2017-09-11 18:34:47 -07:00
tile dma-mapping updates for 4.14: 2017-09-12 13:30:06 -07:00
um Merge branch 'for-linus-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml 2017-09-16 12:03:25 -07:00
unicore32 unicore32/PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks 2017-08-03 16:29:34 -05:00
x86 Merge branch 'for-linus-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml 2017-09-16 12:03:25 -07:00
xtensa Merge branch 'akpm' (patches from Andrew) 2017-09-06 20:49:49 -07:00
.gitignore
Kconfig - For the randstruct plugin, enable automatic randomization of structures 2017-09-07 20:30:19 -07:00