linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: x86@kernel.org
Cc: Andy Lutomirski <luto@kernel.org>,
	kbuild-all@01.org, linux-kernel@vger.kernel.org,
	tipbuild@zytor.com, Ingo Molnar <mingo@kernel.org>,
	Borislav Petkov <bp@suse.de>,
	kbuild test robot <fengguang.wu@intel.com>
Subject: [PATCH] objtool: Prevent GCC from merging annotate_unreachable(), take 2
Date: Fri, 3 Nov 2017 17:19:41 -0500	[thread overview]
Message-ID: <20171103221941.cajpwszir7ujxyc4@treble> (raw)
In-Reply-To: <20171103155027.yhypc4tydthaifss@treble>


This fixes the following warning with GCC 4.6:

  mm/migrate.o: warning: objtool: migrate_misplaced_transhuge_page()+0x71: unreachable instruction

The problem is that the compiler merged identical annotate_unreachable()
inline asm blocks, resulting in a missing 'unreachable' annotation.

This problem happened before, and was partially fixed with:

  3d1e236022cc ("objtool: Prevent GCC from merging annotate_unreachable()")

That commit tried to ensure that each instance of the
annotate_unreachable() inline asm statement has a unique label.  It used
the __LINE__ macro to generate the label number.  However, even the line
number isn't necessarily unique when used in an inline function with
multiple callers (in this case, __alloc_pages_node()'s use of
VM_BUG_ON).

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: 3d1e236022cc ("objtool: Prevent GCC from merging annotate_unreachable()")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 include/linux/compiler.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index e95a2631e545..e9fe95b138cf 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -190,13 +190,13 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 	asm("%c0:\n\t"							\
 	    ".pushsection .discard.reachable\n\t"			\
 	    ".long %c0b - .\n\t"					\
-	    ".popsection\n\t" : : "i" (__LINE__));			\
+	    ".popsection\n\t" : : "i" (__COUNTER__));			\
 })
 #define annotate_unreachable() ({					\
 	asm("%c0:\n\t"							\
 	    ".pushsection .discard.unreachable\n\t"			\
 	    ".long %c0b - .\n\t"					\
-	    ".popsection\n\t" : : "i" (__LINE__));			\
+	    ".popsection\n\t" : : "i" (__COUNTER__));			\
 })
 #define ASM_UNREACHABLE							\
 	"999:\n\t"							\
-- 
2.13.6

  reply	other threads:[~2017-11-03 22:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03  3:36 [tip:x86/asm 24/32] mm/migrate.o: warning: objtool: migrate_misplaced_transhuge_page()+0x71: unreachable instruction kbuild test robot
2017-11-03 15:50 ` Josh Poimboeuf
2017-11-03 22:19   ` Josh Poimboeuf [this message]
2017-11-04 22:31     ` [tip:core/urgent] objtool: Prevent GCC from merging annotate_unreachable(), take 2 tip-bot for 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=20171103221941.cajpwszir7ujxyc4@treble \
    --to=jpoimboe@redhat.com \
    --cc=bp@suse.de \
    --cc=fengguang.wu@intel.com \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=tipbuild@zytor.com \
    --cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).