* [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
@ 2018-03-08 6:11 Mikulas Patocka
2018-03-08 7:39 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2018-03-08 6:11 UTC (permalink / raw)
To: Peter Zijlstra
Cc: David Woodhouse, Thomas Gleixner, Josh Poimboeuf,
Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel
The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add
retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.
This patch fixes the following error and a large number of "can't find
rela for retpoline_safe" errors that occur when using x32 or i386 gcc.
You shouldn't use the type 'unsigned long' in objtool at all - because its
size depends on the compiler and not on the kernel you are compiling.
In file included from check.c:26:0:
check.c: In function 'read_retpoline_hints':
warn.h:57:3: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Werror=format=]
"%s: warning: objtool: " format "\n", \
^
check.c:1135:3: note: in expansion of macro 'WARN'
WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
^~~~
check.c:1135:44: note: format string is defined here
WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
~~^
%d
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: b5bc2231b8ad ("objtool: Add retpoline validation")
---
tools/objtool/check.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: linux-2.6/tools/objtool/check.c
===================================================================
--- linux-2.6.orig/tools/objtool/check.c 2018-03-08 06:53:03.535471000 +0100
+++ linux-2.6/tools/objtool/check.c 2018-03-08 06:56:32.975471000 +0100
@@ -1131,13 +1131,13 @@ static int read_retpoline_hints(struct o
return -1;
}
- if (sec->len % sizeof(unsigned long)) {
- WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
+ if (sec->len % sizeof(uint64_t)) {
+ WARN("retpoline_safe size mismatch: %d %d", sec->len, (int)sizeof(uint64_t));
return -1;
}
- for (i = 0; i < sec->len / sizeof(unsigned long); i++) {
- rela = find_rela_by_dest(sec, i * sizeof(unsigned long));
+ for (i = 0; i < sec->len / sizeof(uint64_t); i++) {
+ rela = find_rela_by_dest(sec, i * sizeof(uint64_t));
if (!rela) {
WARN("can't find rela for retpoline_safe[%d]", i);
return -1;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
2018-03-08 6:11 [PATCH] fix compilation of 64-bit kernel with 32-bit compiler Mikulas Patocka
@ 2018-03-08 7:39 ` Peter Zijlstra
2018-03-08 9:09 ` Mikulas Patocka
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2018-03-08 7:39 UTC (permalink / raw)
To: Mikulas Patocka
Cc: David Woodhouse, Thomas Gleixner, Josh Poimboeuf,
Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel
On Thu, Mar 08, 2018 at 01:11:26AM -0500, Mikulas Patocka wrote:
> The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add
> retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.
>
> This patch fixes the following error and a large number of "can't find
> rela for retpoline_safe" errors that occur when using x32 or i386 gcc.
>
> You shouldn't use the type 'unsigned long' in objtool at all - because its
> size depends on the compiler and not on the kernel you are compiling.
Your patch is wrong because the data field is actually a long. A correct
patch is already in merged in tip.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
2018-03-08 7:39 ` Peter Zijlstra
@ 2018-03-08 9:09 ` Mikulas Patocka
2018-03-08 9:39 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Mikulas Patocka @ 2018-03-08 9:09 UTC (permalink / raw)
To: Peter Zijlstra
Cc: David Woodhouse, Thomas Gleixner, Josh Poimboeuf,
Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel
On Thu, 8 Mar 2018, Peter Zijlstra wrote:
> On Thu, Mar 08, 2018 at 01:11:26AM -0500, Mikulas Patocka wrote:
> > The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add
> > retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.
> >
> > This patch fixes the following error and a large number of "can't find
> > rela for retpoline_safe" errors that occur when using x32 or i386 gcc.
> >
> > You shouldn't use the type 'unsigned long' in objtool at all - because its
> > size depends on the compiler and not on the kernel you are compiling.
>
> Your patch is wrong because the data field is actually a long. A correct
> patch is already in merged in tip.
I'm wondering, why is objtool using 'unsigned long' at all? Why not
uint32_t and uint64_t? The size of 'unsigned long' is dependent on the
compiler, so it will lead to different behavior.
Mikulas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
2018-03-08 9:09 ` Mikulas Patocka
@ 2018-03-08 9:39 ` Peter Zijlstra
2018-03-08 15:17 ` Josh Poimboeuf
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2018-03-08 9:39 UTC (permalink / raw)
To: Mikulas Patocka
Cc: David Woodhouse, Thomas Gleixner, Josh Poimboeuf,
Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel
On Thu, Mar 08, 2018 at 04:09:30AM -0500, Mikulas Patocka wrote:
>
>
> On Thu, 8 Mar 2018, Peter Zijlstra wrote:
>
> > On Thu, Mar 08, 2018 at 01:11:26AM -0500, Mikulas Patocka wrote:
> > > The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add
> > > retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.
> > >
> > > This patch fixes the following error and a large number of "can't find
> > > rela for retpoline_safe" errors that occur when using x32 or i386 gcc.
> > >
> > > You shouldn't use the type 'unsigned long' in objtool at all - because its
> > > size depends on the compiler and not on the kernel you are compiling.
> >
> > Your patch is wrong because the data field is actually a long. A correct
> > patch is already in merged in tip.
>
> I'm wondering, why is objtool using 'unsigned long' at all? Why not
> uint32_t and uint64_t? The size of 'unsigned long' is dependent on the
> compiler, so it will lead to different behavior.
Because pointers... As Josh said, I should've used the right ELF methods
which use the object's ABI.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fix compilation of 64-bit kernel with 32-bit compiler
2018-03-08 9:39 ` Peter Zijlstra
@ 2018-03-08 15:17 ` Josh Poimboeuf
0 siblings, 0 replies; 5+ messages in thread
From: Josh Poimboeuf @ 2018-03-08 15:17 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Mikulas Patocka, David Woodhouse, Thomas Gleixner,
Andy Lutomirski, Arjan van de Ven, Borislav Petkov, Dan Williams,
Dave Hansen, Greg Kroah-Hartman, Ingo Molnar, linux-kernel
On Thu, Mar 08, 2018 at 10:39:44AM +0100, Peter Zijlstra wrote:
> On Thu, Mar 08, 2018 at 04:09:30AM -0500, Mikulas Patocka wrote:
> >
> >
> > On Thu, 8 Mar 2018, Peter Zijlstra wrote:
> >
> > > On Thu, Mar 08, 2018 at 01:11:26AM -0500, Mikulas Patocka wrote:
> > > > The patch b5bc2231b8ad4387c9641f235ca0ad8cd300b6df ("objtool: Add
> > > > retpoline validation") broke compiling 64-bit kernel with 32-bit compiler.
> > > >
> > > > This patch fixes the following error and a large number of "can't find
> > > > rela for retpoline_safe" errors that occur when using x32 or i386 gcc.
> > > >
> > > > You shouldn't use the type 'unsigned long' in objtool at all - because its
> > > > size depends on the compiler and not on the kernel you are compiling.
> > >
> > > Your patch is wrong because the data field is actually a long. A correct
> > > patch is already in merged in tip.
> >
> > I'm wondering, why is objtool using 'unsigned long' at all? Why not
> > uint32_t and uint64_t? The size of 'unsigned long' is dependent on the
> > compiler, so it will lead to different behavior.
>
> Because pointers... As Josh said, I should've used the right ELF methods
> which use the object's ABI.
But there are still a few other places where objtool uses longs
unnecessarily. Those should probably be converted. Patches welcome...
--
Josh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-08 15:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 6:11 [PATCH] fix compilation of 64-bit kernel with 32-bit compiler Mikulas Patocka
2018-03-08 7:39 ` Peter Zijlstra
2018-03-08 9:09 ` Mikulas Patocka
2018-03-08 9:39 ` Peter Zijlstra
2018-03-08 15:17 ` Josh Poimboeuf
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.