Hi, Nikolaus,
On Wed, Apr 7, 2021 at 2:57 PM H. Nikolaus Schaller hns@goldelico.com wrote:
Am 07.04.2021 um 08:29 schrieb Huacai Chen chenhuacai@kernel.org:
There are three errors in div64.h caused by commit c21004cd5b4cb7d479514 ("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0."):
1, Only 32bit kernel need __div64_32(), but the above commit makes it depend on 64bit kernel by mistake.
2, asm-generic/div64.h should be included after __div64_32() definition.
3, __n should be initialized as *n before use (and "*__n >> 32" should be "__n >> 32") in __div64_32() definition.
Fixes: c21004cd5b4cb7d479514 ("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0.") Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen chenhuacai@loongson.cn
arch/mips/include/asm/div64.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/mips/include/asm/div64.h b/arch/mips/include/asm/div64.h index dc5ea5736440..3be2318f8e0e 100644 --- a/arch/mips/include/asm/div64.h +++ b/arch/mips/include/asm/div64.h @@ -9,9 +9,7 @@ #ifndef __ASM_DIV64_H #define __ASM_DIV64_H
-#include <asm-generic/div64.h>
-#if BITS_PER_LONG == 64 +#if BITS_PER_LONG == 32
#include <linux/types.h>
@@ -24,9 +22,9 @@ unsigned long __cf, __tmp, __tmp2, __i; \ unsigned long __quot32, __mod32; \ unsigned long __high, __low; \
unsigned long long __n; \
unsigned long long __n = *n; \ \
__high = *__n >> 32; \
__high = __n >> 32; \ __low = __n; \ __asm__( \ " .set push \n" \
@@ -65,4 +63,6 @@
#endif /* BITS_PER_LONG == 64 */
IMHO these #if/else/endif comments should also be fixed.
+#include <asm-generic/div64.h>
#endif /* __ASM_DIV64_H */
2.27.0
compiles fine now. But I still get a linker issue:
fs/ubifs/budget.o: In function `div_u64_rem': fs/ubifs/budget.c:(.text+0x1fc): undefined reference to `__div64_32' fs/ubifs/lpt.o: In function `div_u64_rem': fs/ubifs/lpt.c:(.text+0x8fc): undefined reference to `__div64_32' make[2]: *** [vmlinux] Error 1 make[1]: *** [__build_one_by_one] Error 2 make: *** [__sub-make] Error 2
Oh, there is the 4th bug in this file.... linux/types.h should be included at the first place, otherwise BITS_PER_LONG is not defined...
Huacai
BR and thanks, Nikolaus Schaller