From: Allan Xavier <allan.x.xavier@oracle.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Allan Xavier <allan.x.xavier@oracle.com>
Subject: [PATCH] objtool: Fix GCC 8 cold function processing without -freorder-functions
Date: Tue, 26 Jun 2018 17:20:45 +0100 [thread overview]
Message-ID: <20180626162045.25516-1-allan.x.xavier@oracle.com> (raw)
As of commit 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions")
objtool can get stuck in an infinite loop when processing cold functions
compiled without -freorder-functions. Using v4.17.2 and "gcc version
8.1.1 20180502 (Red Hat 8.1.1-1) (GCC)" from Fedora, this can be
reproduced trivially with make EXTRA_CFLAGS='-fno-reorder-functions'.
When -freorder-functions is used (enabled by default for -O2 in GCC 8)
cold functions are emitted in the .text.unlikely section.
0000000000000230 g F .text 000000000000002c nmi_panic
00000000000002df l F .text.unlikely 000000000000000c nmi_panic.cold.7
Without -freorder-functions, cold functions are emitted in the .text
section within the range of their parent function.
0000000000000500 g F .text 0000000000000034 nmi_panic
0000000000000528 l F .text 000000000000000c nmi_panic.cold.7
When objtool processes the second case it associates all of the
instructions in the parent function range 0x500-0x534 with nmi_panic
since that symbol is processed first. No instructions are associated
with nmi_panic.cold.7.
Later on, objtool iterates through the instructions in nmi_panic using
next_insn_same_func. Once it reaches the end of nmi_panic at 0x534 it
jumps to 0x528 as that's the start of nmi_panic.cold.7. However, since
the instructions starting at 0x528 are still associated with nmi_panic
objtool will get stuck in a loop, continually jumping back to 0x528
after reaching 0x534.
This doesn't happen with -freorder-functions in the first example as the
symbols don't overlap. So when 0x25c in .text is reached objtool will
jump to 0x2df in .text.unlikely where the instructions are correctly
associated with nmi_panic.cold.7.
Fix this issue by modifying decode_instructions to check whether an
instruction is associated with the parent function of the cold function
currently being processed. If so, reference the cold function rather
than the parent.
Signed-off-by: Allan Xavier <allan.x.xavier@oracle.com>
---
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3a31b238f8856..2a5eea534ab3e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -314,7 +314,7 @@ static int decode_instructions(struct objtool_file *file)
}
func_for_each_insn(file, func, insn)
- if (!insn->func)
+ if (!insn->func || insn->func == func->pfunc)
insn->func = func;
}
}
--
2.14.1
next reply other threads:[~2018-06-26 16:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 16:20 Allan Xavier [this message]
2018-06-26 16:43 ` Peter Zijlstra
2018-06-26 18:31 ` Allan Xavier
2018-06-26 18:44 ` Josh Poimboeuf
2018-06-26 19:43 ` Peter Zijlstra
2018-06-26 21:07 ` Josh Poimboeuf
2018-06-27 9:35 ` Allan Xavier
2018-06-27 15:15 ` Josh Poimboeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180626162045.25516-1-allan.x.xavier@oracle.com \
--to=allan.x.xavier@oracle.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®