linux-stable/lib/mpi
Nathan Chancellor ed3cbbfeba lib/mpi: Fix 64-bit MIPS build with Clang
[ Upstream commit 18f1ca4685 ]

When building 64r6_defconfig with CONFIG_MIPS32_O32 disabled and
CONFIG_CRYPTO_RSA enabled:

lib/mpi/generic_mpih-mul1.c:37:24: error: invalid use of a cast in a
inline asm context requiring an l-value: remove the cast
or build with -fheinous-gnu-extensions
                umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/mpi/longlong.h:664:22: note: expanded from macro 'umul_ppmm'
                 : "=d" ((UDItype)(w0))
                         ~~~~~~~~~~^~~
lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a
inline asm context requiring an l-value: remove the cast
or build with -fheinous-gnu-extensions
                umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/mpi/longlong.h:668:22: note: expanded from macro 'umul_ppmm'
                 : "=d" ((UDItype)(w1))
                         ~~~~~~~~~~^~~
2 errors generated.

This special case for umul_ppmm for MIPS64r6 was added in
commit bbc25bee37 ("lib/mpi: Fix umul_ppmm() for MIPS64r6"), due to
GCC being inefficient and emitting a __multi3 intrinsic.

There is no such issue with clang; with this patch applied, I can build
this configuration without any problems and there are no link errors
like mentioned in the commit above (which I can still reproduce with
GCC 9.3.0 when that commit is reverted). Only use this definition when
GCC is being used.

This really should have been caught by commit b0c091ae04 ("lib/mpi:
Eliminate unused umul_ppmm definitions for MIPS") when I was messing
around in this area but I was not testing 64-bit MIPS at the time.

Link: https://github.com/ClangBuiltLinux/linux/issues/885
Reported-by: Dmitry Golovin <dima@golovin.in>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-20 10:24:15 +02:00
..
Makefile MPILIB: Reinstate mpi_cmp[_ui]() and export for RSA signature verification 2012-10-08 13:50:15 +10:30
generic_mpih-add1.c
generic_mpih-lshift.c
generic_mpih-mul1.c
generic_mpih-mul2.c
generic_mpih-mul3.c
generic_mpih-rshift.c
generic_mpih-sub1.c
longlong.h lib/mpi: Fix 64-bit MIPS build with Clang 2020-06-20 10:24:15 +02:00
mpi-bit.c MPILIB: Provide count_leading/trailing_zeros() based on arch functions 2012-10-08 13:50:11 +10:30
mpi-cmp.c MPILIB: Fix comparison of negative MPIs 2015-01-14 16:10:12 +00:00
mpi-inline.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-internal.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-pow.c lib/mpi: Fix karactx leak in mpi_powm 2019-07-10 09:55:46 +02:00
mpicoder.c lib/mpi: kunmap after finishing accessing buffer 2017-09-07 08:35:40 +02:00
mpih-cmp.c
mpih-div.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpih-mul.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpiutil.c MPILIB: add mpi_read_buf() and mpi_get_size() helpers 2015-06-16 14:35:06 +08:00