linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/MCE: Cast rIP to respective width before printing
@ 2018-02-10 14:53 Borislav Petkov
  2018-02-11 12:11 ` [tip:x86/urgent] x86/MCE: Fix build warning introduced by "x86: do not use print_symbol()" tip-bot for Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2018-02-10 14:53 UTC (permalink / raw)
  To: X86 ML; +Cc: Tony Luck, LKML, Sergey Senozhatsky

From: Borislav Petkov <bp@suse.de>

7b6061627eb8 ("x86: do not use print_symbol()") got rid of
print_symbol() uses in favor of passing a %pS format specifier to
printk() in order to print "symbolic direct pointers with offset".

We use this to print the RIP as part of the MCE record. And %pS requires
a void *.

However, mce.ip is u64 and casting it to a void * on 32-bit rightfully
warns:

  arch/x86/kernel/cpu/mcheck/mce.c:237:21: warning: cast to pointer from integer \
	  of different size [-Wint-to-pointer-cast]
      pr_cont("{%pS}", (void *)m->ip);
                       ^

about the size mismatch.

So cast the RIP to the machine-specific unsigned long address width
first.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Fixes: 7b6061627eb8 ("x86: do not use print_symbol()")
---
 arch/x86/kernel/cpu/mcheck/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 3a8e88a611eb..75f405ac085c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -234,7 +234,7 @@ static void __print_mce(struct mce *m)
 			m->cs, m->ip);
 
 		if (m->cs == __KERNEL_CS)
-			pr_cont("{%pS}", (void *)m->ip);
+			pr_cont("{%pS}", (void *)(unsigned long)m->ip);
 		pr_cont("\n");
 	}
 
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:x86/urgent] x86/MCE: Fix build warning introduced by "x86: do not use print_symbol()"
  2018-02-10 14:53 [PATCH] x86/MCE: Cast rIP to respective width before printing Borislav Petkov
@ 2018-02-11 12:11 ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Borislav Petkov @ 2018-02-11 12:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, sergey.senozhatsky.work, peterz, torvalds, tglx, linux-kernel,
	tony.luck, mingo, hpa

Commit-ID:  c80c5ec1b2fa8d3675fc2a6807a64771ea156698
Gitweb:     https://git.kernel.org/tip/c80c5ec1b2fa8d3675fc2a6807a64771ea156698
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Sat, 10 Feb 2018 15:53:14 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 11 Feb 2018 11:37:39 +0100

x86/MCE: Fix build warning introduced by "x86: do not use print_symbol()"

The following commit:

  7b6061627eb8 ("x86: do not use print_symbol()")

... introduced a new build warning on 32-bit x86:

  arch/x86/kernel/cpu/mcheck/mce.c:237:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      pr_cont("{%pS}", (void *)m->ip);
                       ^

Fix the type mismatch between the 'void *' expected by %pS and the mce->ip
field which is u64 by casting to long.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-kernel@vger.kernel.org
Fixes: 7b6061627eb8 ("x86: do not use print_symbol()")
Link: http://lkml.kernel.org/r/20180210145314.22174-1-bp@alien8.de
[ Cleaned up the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/mcheck/mce.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 3a8e88a..75f405a 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -234,7 +234,7 @@ static void __print_mce(struct mce *m)
 			m->cs, m->ip);
 
 		if (m->cs == __KERNEL_CS)
-			pr_cont("{%pS}", (void *)m->ip);
+			pr_cont("{%pS}", (void *)(unsigned long)m->ip);
 		pr_cont("\n");
 	}
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-12  1:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-10 14:53 [PATCH] x86/MCE: Cast rIP to respective width before printing Borislav Petkov
2018-02-11 12:11 ` [tip:x86/urgent] x86/MCE: Fix build warning introduced by "x86: do not use print_symbol()" tip-bot for Borislav Petkov

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).