mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: X86 ML <x86@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: [PATCH] x86/MCE: Cast rIP to respective width before printing
Date: Sat, 10 Feb 2018 15:53:14 +0100	[thread overview]
Message-ID: <20180210145314.22174-1-bp@alien8.de> (raw)

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

             reply	other threads:[~2018-02-10 14:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-10 14:53 Borislav Petkov [this message]
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

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=20180210145314.22174-1-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=tony.luck@intel.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

Powered by JetHome