* [PATCH V2] MIPS: Fix longstanding errors in div64.h
@ 2021-04-07 6:29 Huacai Chen
2021-04-07 6:53 ` H. Nikolaus Schaller
0 siblings, 1 reply; 3+ messages in thread
From: Huacai Chen @ 2021-04-07 6:29 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, Jiaxun Yang, Huacai Chen, stable
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 */
+#include <asm-generic/div64.h>
+
#endif /* __ASM_DIV64_H */
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] MIPS: Fix longstanding errors in div64.h
2021-04-07 6:29 [PATCH V2] MIPS: Fix longstanding errors in div64.h Huacai Chen
@ 2021-04-07 6:53 ` H. Nikolaus Schaller
2021-04-07 9:00 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: H. Nikolaus Schaller @ 2021-04-07 6:53 UTC (permalink / raw)
To: Huacai Chen
Cc: Thomas Bogendoerfer, linux-mips, Jiaxun Yang, Huacai Chen, stable
> 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
BR and thanks,
Nikolaus Schaller
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] MIPS: Fix longstanding errors in div64.h
2021-04-07 6:53 ` H. Nikolaus Schaller
@ 2021-04-07 9:00 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2021-04-07 9:00 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Thomas Bogendoerfer, linux-mips, Jiaxun Yang, Huacai Chen, stable
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-07 9:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 6:29 [PATCH V2] MIPS: Fix longstanding errors in div64.h Huacai Chen
2021-04-07 6:53 ` H. Nikolaus Schaller
2021-04-07 9:00 ` Huacai Chen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.