x86 bugfixes for LTO
Subsystems (4)
cover x86 bugfixes for LTO
Here are three bugfixes for x86 that I needed to get LTO-enabled kernels to build reliably. I'm not sure abouto that first one though.
None of these are urgent, as they don't show up in mainline kernels and they don't indicate serious problems.
Arnd Bergmann (3):
x86: dumpstack: avoid uninitialized variable
x86: fix swsusp_arch_resume prototype
x86: error_inject: make just_return_func globally visible
arch/x86/kernel/dumpstack.c | 2 +- arch/x86/lib/error-inject.c | 1 + arch/x86/power/hibernate_32.c | 2 +- arch/x86/power/hibernate_64.c | 2 +- include/linux/suspend.h | 2 ++ kernel/power/power.h | 3 --- 6 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.0
PATCH 1/3 x86: dumpstack: avoid uninitlized variable
In some configurations, 'partial' does not get initialized, as shown by this gcc-8 warning:
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]
show_regs_if_on_stack(&stack_info, regs, partial);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This initializes it to false, to get the previous behavior in this case.
a9cdbe72c4e8 ("x86/dumpstack: Fix partial register dumps")
--- arch/x86/kernel/dumpstack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/dumpstack.c +1 -1
@@ -109,7 +109,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,struct stack_info stack_info = {0 };unsigned long visit_mask =0 ;int graph_idx =0 ; -bool partial; +bool partial = false;printk ("%sCall Trace:\n" , log_lvl);
Signature · 1 line
2.9.0
PATCH 2/3 x86: fix swsusp_arch_resume prototype
The declaration for swsusp_arch_resume marks it as 'asmlinkage', but the definition in x86-32 does not, and it fails to include the header with the declaration. This leads to a warning when building with link-time-optimizations:
kernel/power/power.h:108:23: error: type of 'swsusp_arch_resume' does not match original declaration [-Werror=lto-type-mismatch]
extern asmlinkage int swsusp_arch_resume(void);
^arch/x86/power/hibernate_32.c:148:0: note: 'swsusp_arch_resume' was previously declared here
int swsusp_arch_resume(void)
This moves the declaration into a globally visible header file and fixes up both x86 definitions to match it.
--- arch/x86/power/hibernate_32.c | 2 +- arch/x86/power/hibernate_64.c | 2 +- include/linux/suspend.h | 2 ++ kernel/power/power.h | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-)
arch/x86/power/hibernate_32.c +1 -1
@@ -145,7 +145,7 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir)#endif } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
arch/x86/power/hibernate_64.c +1 -1
@@ -174,7 +174,7 @@ static int relocate_restore_code(void)return 0 ; } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
include/linux/suspend.h +2 -0
@@ -384,6 +384,8 @@ extern int swsusp_page_is_forbidden(struct page *);extern void swsusp_set_page_free (struct page *);extern void swsusp_unset_page_free (struct page *);extern unsigned long get_safe_page (gfp_t gfp_mask); +extern asmlinkage int swsusp_arch_suspend(void); +extern asmlinkage int swsusp_arch_resume(void);extern void hibernation_set_ops (const struct platform_hibernation_ops *ops);extern int hibernate (void );
kernel/power/power.h +0 -3
@@ -104,9 +104,6 @@ extern int in_suspend;extern dev_t swsusp_resume_device;extern sector_t swsusp_resume_block; -extern asmlinkage int swsusp_arch_suspend(void); -extern asmlinkage int swsusp_arch_resume(void); -extern int create_basic_memory_bitmaps (void );extern void free_basic_memory_bitmaps (void );extern int hibernate_preallocate_memory (void );
Signature · 1 line
2.9.0
tip-bot for Arnd Bergmann
merge bot[tip:x86/urgent] x86/power: Fix swsusp_arch_resume prototype
x86/power: Fix swsusp_arch_resume prototype
Commit-ID: 328008a72d38b5bde6491e463405c34a81a65d3e Gitweb: https://git.kernel.org/tip/328008a72d38b5bde6491e463405c34a81a65d3e Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:18 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 2 Feb 2018 23:33:50 +0100
x86/power: Fix swsusp_arch_resume prototype
The declaration for swsusp_arch_resume marks it as 'asmlinkage', but the definition in x86-32 does not, and it fails to include the header with the declaration. This leads to a warning when building with link-time-optimizations:
kernel/power/power.h:108:23: error: type of 'swsusp_arch_resume' does not match original declaration [-Werror=lto-type-mismatch]
extern asmlinkage int swsusp_arch_resume(void);
^arch/x86/power/hibernate_32.c:148:0: note: 'swsusp_arch_resume' was previously declared here
int swsusp_arch_resume(void)
This moves the declaration into a globally visible header file and fixes up both x86 definitions to match it.
--- arch/x86/power/hibernate_32.c | 2 +- arch/x86/power/hibernate_64.c | 2 +- include/linux/suspend.h | 2 ++ kernel/power/power.h | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-)
arch/x86/power/hibernate_32.c +1 -1
@@ -145,7 +145,7 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir)#endif } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
arch/x86/power/hibernate_64.c +1 -1
@@ -174,7 +174,7 @@ out:return 0 ; } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;
include/linux/suspend.h +2 -0
@@ -384,6 +384,8 @@ extern int swsusp_page_is_forbidden(struct page *);extern void swsusp_set_page_free (struct page *);extern void swsusp_unset_page_free (struct page *);extern unsigned long get_safe_page (gfp_t gfp_mask); +extern asmlinkage int swsusp_arch_suspend(void); +extern asmlinkage int swsusp_arch_resume(void);extern void hibernation_set_ops (const struct platform_hibernation_ops *ops);extern int hibernate (void );
kernel/power/power.h +0 -3
@@ -104,9 +104,6 @@ extern int in_suspend;extern dev_t swsusp_resume_device;extern sector_t swsusp_resume_block; -extern asmlinkage int swsusp_arch_suspend(void); -extern asmlinkage int swsusp_arch_resume(void); -extern int create_basic_memory_bitmaps (void );extern void free_basic_memory_bitmaps (void );extern int hibernate_preallocate_memory (void );
Rafael J. Wysocki
AppliedRe: [PATCH 2/3] x86: fix swsusp_arch_resume prototype
In reply to Arnd BergmannQuoted 67 lines · CET Arnd Bergmann
The declaration for
swsusp_arch_resumemarks it as 'asmlinkage', but the definition in x86-32 does not, and it fails to include the header with the declaration. This leads to a warning when building with link-time-optimizations:
kernel/power/power.h:108:23: error: type of 'swsusp_arch_resume' does not match original declaration [-Werror=lto-type-mismatch]extern asmlinkage int swsusp_arch_resume(void); ^
arch/x86/power/hibernate_32.c:148:0: note: 'swsusp_arch_resume' was previously declared here
intswsusp_arch_resume(void)This moves the declaration into a globally visible header file and fixes up both x86 definitions to match it.
Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/power/hibernate_32.c | 2 +- arch/x86/power/hibernate_64.c | 2 +- include/linux/suspend.h | 2 ++ kernel/power/power.h | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-)arch/x86/power/hibernate_32.c +1
-1@@ -145,7 +145,7 @@ static inline void resume_init_first_level_page_table(pgd_t *pg_dir)#endif } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;arch/x86/power/hibernate_64.c +1
-1@@ -174,7 +174,7 @@ static int relocate_restore_code(void)return 0 ; } -int swsusp_arch_resume (void ) +asmlinkage int swsusp_arch_resume(void) {int error;include/linux/suspend.h +2
-0@@ -384,6 +384,8 @@ extern int swsusp_page_is_forbidden(struct page *);extern void swsusp_set_page_free (struct page *);extern void swsusp_unset_page_free (struct page *);extern unsigned long get_safe_page (gfp_t gfp_mask); +extern asmlinkage int swsusp_arch_suspend(void); +extern asmlinkage int swsusp_arch_resume(void);extern void hibernation_set_ops (const struct platform_hibernation_ops *ops);extern int hibernate (void );kernel/power/power.h +0
-0
kernel/power/power.h extern int in_suspend; · line 109
Quoted 9 lines
kernel/power/power.h +0
-3@@ -104,9 +104,6 @@ extern int in_suspend;extern dev_t swsusp_resume_device;extern sector_t swsusp_resume_block; -extern asmlinkage int swsusp_arch_suspend(void); -extern asmlinkage int swsusp_arch_resume(void); -extern int create_basic_memory_bitmaps (void );extern void free_basic_memory_bitmaps (void );extern int hibernate_preallocate_memory (void );
Applied, thanks!
PATCH 3/3 x86: error_inject: make just_return_func globally visible
In reply to Arnd BergmannWith link time optimizations enabled, I get a link failure:
./ccLbOEHX.ltrans19.ltrans.o: In function `override_function_with_return':
<artificial>:(.text+0x7f3): undefined reference to `just_return_func'
Marking the symbol .globl makes it work as expected.
--- arch/x86/lib/error-inject.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/lib/error-inject.c +1 -0
@@ -7,6 +7,7 @@ asmlinkage void just_return_func(void); asm(".type just_return_func, @function\n" +".globl just_return_func\n" "just_return_func:\n" " ret\n" ".size just_return_func, .-just_return_func\n"
Signature · 1 line
2.9.0
Re: [PATCH 3/3] x86: error_inject: make just_return_func globally visible
Quoted 6 lines · On Fri, 2 Feb 2018 15:56:19 +0100 Arnd Bergmann <[email protected]> wrote:
With link time optimizations enabled, I get a link failure:
./ccLbOEHX.ltrans19.ltrans.o: In function `override_function_with_return':
<artificial>:(.text+0x7f3): undefined reference to `just_return_func'Marking the symbol .globl makes it work as expected.
Good catch!
Thank you!
Quoted 22 lines
Fixes 540adea3809f ("error-injection: Separate error-injection from kprobe")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/lib/error-inject.c | 1 + 1 file changed, 1 insertion(+)arch/x86/lib/error-inject.c +1
-0@@ -7,6 +7,7 @@ asmlinkage void just_return_func(void); asm(".type just_return_func, @function\n" +".globl just_return_func\n" "just_return_func:\n" " ret\n" ".size just_return_func, .-just_return_func\n"Signature · 1 line
2.9.0
Signature · 1 line
Masami Hiramatsu <[email protected]>
tip-bot for Arnd Bergmann
merge bot[tip:x86/urgent] x86/error_inject: Make just_return_func() globally visible
In reply to Arnd Bergmannx86/error_inject: Make just_return_func() globally visible
Commit-ID: 01684e72f16727e6ae0aeb1392f478e11ec5b8f7 Gitweb: https://git.kernel.org/tip/01684e72f16727e6ae0aeb1392f478e11ec5b8f7 Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:19 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 13 Feb 2018 14:33:35 +0100
x86/error_inject: Make just_return_func() globally visible
With link time optimizations enabled, I get a link failure:
./ccLbOEHX.ltrans19.ltrans.o: In function `override_function_with_return':
<artificial>:(.text+0x7f3): undefined reference to `just_return_func'
Marking the symbol .globl makes it work as expected.
--- arch/x86/lib/error-inject.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/lib/error-inject.c +1 -0
@@ -7,6 +7,7 @@ asmlinkage void just_return_func(void); asm(".type just_return_func, @function\n" +".globl just_return_func\n" "just_return_func:\n" " ret\n" ".size just_return_func, .-just_return_func\n"
tip-bot for Arnd Bergmann
merge bot[tip:x86/urgent] x86/dumpstack: Avoid uninitlized variable
In reply to Arnd Bergmannx86/dumpstack: Avoid uninitlized variable
Commit-ID: ebfc15019cfa72496c674ffcb0b8ef10790dcddc Gitweb: https://git.kernel.org/tip/ebfc15019cfa72496c674ffcb0b8ef10790dcddc Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:17 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 2 Feb 2018 23:33:50 +0100
x86/dumpstack: Avoid uninitlized variable
In some configurations, 'partial' does not get initialized, as shown by this gcc-8 warning:
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]
show_regs_if_on_stack(&stack_info, regs, partial);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This initializes it to false, to get the previous behavior in this case.
--- arch/x86/kernel/dumpstack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/dumpstack.c +1 -1
@@ -109,7 +109,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,struct stack_info stack_info = {0 };unsigned long visit_mask =0 ;int graph_idx =0 ; -bool partial; +bool partial = false;printk ("%sCall Trace:\n" , log_lvl);
Re: [tip:x86/urgent] x86/dumpstack: Avoid uninitlized variable
Quoted 12 lines · tip-bot for Arnd Bergmann
Commit-ID: ebfc15019cfa72496c674ffcb0b8ef10790dcddc Gitweb: https://git.kernel.org/tip/ebfc15019cfa72496c674ffcb0b8ef10790dcddc Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:17 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 2 Feb 2018 23:33:50 +0100x86/dumpstack: Avoid uninitlized variable
In some configurations, 'partial' does not get initialized, as shown by this gcc-8 warning:
Quoted 8 lines
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]show_regs_if_on_stack(&stack_info, regs, partial); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This initializes it to false, to get the previous behavior in this case.
Fixes a9cdbe72c4e8 ("x86/dumpstack: Fix partial register dumps")
I just noticed my annotation got lost when I sent the patch. I originally meant to ask Josh to double-check whether it should be 'false' or 'true' here, or if we maybe need a larger change.
Josh, could you take a look? Unfortunately I did not really understand your original commit, so I don't know what the safe choice is here in those cases in which 'partial' is uninitialized.
Arnd
Re: [tip:x86/urgent] x86/dumpstack: Avoid uninitlized variable
Quoted 24 lines · Arnd Bergmann
Quoted 12 lines · tip-bot for Arnd Bergmann
Commit-ID: ebfc15019cfa72496c674ffcb0b8ef10790dcddc Gitweb: https://git.kernel.org/tip/ebfc15019cfa72496c674ffcb0b8ef10790dcddc Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:17 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 2 Feb 2018 23:33:50 +0100x86/dumpstack: Avoid uninitlized variable
In some configurations, 'partial' does not get initialized, as shown by this gcc-8 warning:
Quoted 8 lines
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]show_regs_if_on_stack(&stack_info, regs, partial); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This initializes it to false, to get the previous behavior in this case.
Fixes a9cdbe72c4e8 ("x86/dumpstack: Fix partial register dumps")
Quoted 7 lines
I just noticed my annotation got lost when I sent the patch. I originally meant to ask Josh to double-check whether it should be 'false' or 'true' here, or if we maybe need a larger change.
Josh, could you take a look? Unfortunately I did not really understand your original commit, so I don't know what the safe choice is here in those cases in which 'partial' is uninitialized.
I think it doesn't matter, it seems to be a false positive warning.
The 'partial' variable is only used when 'regs' is non-NULL, and 'regs' is only set in unwind_get_entry_regs() after 'partial' gets initialized.
Signature · 1 line
Josh
Re: [tip:x86/urgent] x86/dumpstack: Avoid uninitlized variable
Quoted 29 lines · Josh Poimboeuf
Quoted 28 lines · Arnd Bergmann
Quoted 12 lines · tip-bot for Arnd Bergmann
Commit-ID: ebfc15019cfa72496c674ffcb0b8ef10790dcddc Gitweb: https://git.kernel.org/tip/ebfc15019cfa72496c674ffcb0b8ef10790dcddc Author: Arnd Bergmann <[email protected]> AuthorDate: Fri, 2 Feb 2018 15:56:17 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 2 Feb 2018 23:33:50 +0100x86/dumpstack: Avoid uninitlized variable
In some configurations, 'partial' does not get initialized, as shown by this gcc-8 warning:
Quoted 8 lines
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]show_regs_if_on_stack(&stack_info, regs, partial); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This initializes it to false, to get the previous behavior in this case.
Fixes a9cdbe72c4e8 ("x86/dumpstack: Fix partial register dumps")I just noticed my annotation got lost when I sent the patch. I originally meant to ask Josh to double-check whether it should be 'false' or 'true' here, or if we maybe need a larger change.
Quoted 8 lines
Quoted 3 lines
Josh, could you take a look? Unfortunately I did not really understand your original commit, so I don't know what the safe choice is here in those cases in which 'partial' is uninitialized.
I think it doesn't matter, it seems to be a false positive warning.
The 'partial' variable is only used when 'regs' is non-NULL, and 'regs' is only set in
unwind_get_entry_regs()after 'partial' gets initialized.
Right, got it now. So my patch is correct either way, just the description could have been better.
Arnd
Quoting Arnd Bergmann (2018-02-02 14:54:28)
Quoted 3 lines
Here are three bugfixes for x86 that I needed to get LTO-enabled kernels to build reliably. I'm not sure abouto that first one though.
Is there a howto on how to build LTO kernels? I tried Andi's lto-415-2 branch, but linking fails with lots of arcane PIE-vs-PIC errors. We are wanting to investigate how we can use LTO to reduce our (i915.ko) module size (by e.g. supporting a subset of chipsets).
-Chris
Quoted 9 lines · Chris Wilson
Quoting Arnd Bergmann (2018-02-02 14:54:28)
Quoted 3 lines
Here are three bugfixes for x86 that I needed to get LTO-enabled kernels to build reliably. I'm not sure abouto that first one though.
Is there a howto on how to build LTO kernels? I tried Andi's lto-415-2 branch, but linking fails with lots of arcane PIE-vs-PIC errors. We are wanting to investigate how we can use LTO to reduce our (i915.ko) module size (by e.g. supporting a subset of chipsets).
What are the errors? Kernel shouldn't use PIE or PIC
-Andi