linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* objtool warning: "duplicate frame pointer save"
@ 2016-05-25 17:14 Linus Torvalds
  2016-05-25 17:56 ` Josh Poimboeuf
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2016-05-25 17:14 UTC (permalink / raw)
  To: Josh Poimboeuf, Ingo Molnar; +Cc: Linux Kernel Mailing List, DRI

Josh,
 my current git version (with gcc 5.3.1) makes objtool warn about
"duplicate frame pointer save" in drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
for both vmw_send_msg() and vmw_host_get_guestinfo().

The reason is that VMW_PORT_HB_OUT() uses a magic instruction sequence
(a "rep outsb") to communicate with the hypervisor (it's a virtual GPU
driver for vmware), and %rbp is part of the communication. So the
inline asm does a save-and-restore of the frame pointer around the
instruction sequence.

I actually find the objtool warning to be quite reasonable, so it's
not exactly a false positive, since in this case it actually does
point out that the frame pointer won't be reliable over that
instruction sequence.

But in this particular case it just ends up being the wrong thing -
the code is what it is, and %rbp just can't have the frame information
due to annoying magic calling conventions.

Is there some way to override objtool for this situation? I hate
seeing warnings that I need to ignore, it has just too often caused me
to mistakenly ignore warnings I *should* have reacted to.

I guess a STACK_FRAME_NON_STANDARD will shut objtool up (or just
disabling it entirely for the whole file), but I was wondering about
something more targeted that could be marked in the inline asm itself
(rather than have to mark the functions that use it)

               Linus

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

* Re: objtool warning: "duplicate frame pointer save"
  2016-05-25 17:14 objtool warning: "duplicate frame pointer save" Linus Torvalds
@ 2016-05-25 17:56 ` Josh Poimboeuf
  2016-05-25 23:51   ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Poimboeuf @ 2016-05-25 17:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Ingo Molnar, Linux Kernel Mailing List, DRI

On Wed, May 25, 2016 at 10:14:24AM -0700, Linus Torvalds wrote:
> Josh,
>  my current git version (with gcc 5.3.1) makes objtool warn about
> "duplicate frame pointer save" in drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> for both vmw_send_msg() and vmw_host_get_guestinfo().
> 
> The reason is that VMW_PORT_HB_OUT() uses a magic instruction sequence
> (a "rep outsb") to communicate with the hypervisor (it's a virtual GPU
> driver for vmware), and %rbp is part of the communication. So the
> inline asm does a save-and-restore of the frame pointer around the
> instruction sequence.
> 
> I actually find the objtool warning to be quite reasonable, so it's
> not exactly a false positive, since in this case it actually does
> point out that the frame pointer won't be reliable over that
> instruction sequence.
> 
> But in this particular case it just ends up being the wrong thing -
> the code is what it is, and %rbp just can't have the frame information
> due to annoying magic calling conventions.
> 
> Is there some way to override objtool for this situation? I hate
> seeing warnings that I need to ignore, it has just too often caused me
> to mistakenly ignore warnings I *should* have reacted to.
> 
> I guess a STACK_FRAME_NON_STANDARD will shut objtool up (or just
> disabling it entirely for the whole file), but I was wondering about
> something more targeted that could be marked in the inline asm itself
> (rather than have to mark the functions that use it)

I used to have a STACKTOOL_IGNORE_INSN macro that would tell the tool to
skip warnings for specific instructions in inline asm:

Here's an example of it how it was used:

  https://lkml.kernel.org/r/c0c1a92df921961cae5cce208247bb8d8a975d6d.1450442274.git.jpoimboe@redhat.com

And here's the implementation of the macro:

  https://lkml.kernel.org/r/cd7778181d2a5251c3dc21811fdbcaa2c16c98c3.1450442274.git.jpoimboe@redhat.com

As it turns out, we didn't need the macro, so I removed it.  But I can
easily add something like that again to get rid of the warnings.

There were objections to having "OBJTOOL" in the names of macros, so I
guess I'll call it STACK_INSN_NON_STANDARD, unless anybody has a better
idea.

-- 
Josh

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

* Re: objtool warning: "duplicate frame pointer save"
  2016-05-25 17:56 ` Josh Poimboeuf
@ 2016-05-25 23:51   ` Linus Torvalds
  2016-05-26 18:43     ` [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning Josh Poimboeuf
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2016-05-25 23:51 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: Ingo Molnar, Linux Kernel Mailing List, DRI

On Wed, May 25, 2016 at 10:56 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> I used to have a STACKTOOL_IGNORE_INSN macro that would tell the tool to
> skip warnings for specific instructions in inline asm:
>
> Here's an example of it how it was used:

Ok, looking at that, I'm starting to suspect that it is simpler to
just use STACK_FRAME_NON_STANDARD and mark the two functions that use
this particular inline asm with the odd %rbp problem.

It's a rather special case, after all.

                 Linus

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

* [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning
  2016-05-25 23:51   ` Linus Torvalds
@ 2016-05-26 18:43     ` Josh Poimboeuf
  2016-05-26 18:58       ` Linus Torvalds
  2016-06-08 14:27       ` [tip:core/urgent] objtool, drm/vmwgfx: Fix " tip-bot for Josh Poimboeuf
  0 siblings, 2 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-05-26 18:43 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Ingo Molnar, Linux Kernel Mailing List, DRI

On Wed, May 25, 2016 at 04:51:21PM -0700, Linus Torvalds wrote:
> On Wed, May 25, 2016 at 10:56 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> >
> > I used to have a STACKTOOL_IGNORE_INSN macro that would tell the tool to
> > skip warnings for specific instructions in inline asm:
> >
> > Here's an example of it how it was used:
> 
> Ok, looking at that, I'm starting to suspect that it is simpler to
> just use STACK_FRAME_NON_STANDARD and mark the two functions that use
> this particular inline asm with the odd %rbp problem.
> 
> It's a rather special case, after all.

That's fine with me, it is indeed a rare case.  We can always add the
per-instruction macro later if needed.  Here's a patch.

---

From: Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning

objtool reports the following warnings:

  drivers/gpu/drm/vmwgfx/vmwgfx_msg.o: warning: objtool: vmw_send_msg()+0x107: duplicate frame pointer save
  drivers/gpu/drm/vmwgfx/vmwgfx_msg.o: warning: objtool: vmw_host_get_guestinfo()+0x252: duplicate frame pointer save

To quote Linus:

 "The reason is that VMW_PORT_HB_OUT() uses a magic instruction sequence
  (a "rep outsb") to communicate with the hypervisor (it's a virtual GPU
  driver for vmware), and %rbp is part of the communication. So the
  inline asm does a save-and-restore of the frame pointer around the
  instruction sequence.

  I actually find the objtool warning to be quite reasonable, so it's
  not exactly a false positive, since in this case it actually does
  point out that the frame pointer won't be reliable over that
  instruction sequence.

  But in this particular case it just ends up being the wrong thing -
  the code is what it is, and %rbp just can't have the frame information
  due to annoying magic calling conventions."

Silence the warnings by telling objtool to ignore the two functions
which use the VMW_PORT_HB_{IN,OUT} macros.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index 6de283c..f0374f9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/frame.h>
 #include <asm/hypervisor.h>
 #include "drmP.h"
 #include "vmwgfx_msg.h"
@@ -194,7 +195,7 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg)
 
 	return -EINVAL;
 }
-
+STACK_FRAME_NON_STANDARD(vmw_send_msg);
 
 
 /**
@@ -304,6 +305,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
 
 	return 0;
 }
+STACK_FRAME_NON_STANDARD(vmw_recv_msg);
 
 
 /**
-- 
2.4.11

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

* Re: [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning
  2016-05-26 18:43     ` [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning Josh Poimboeuf
@ 2016-05-26 18:58       ` Linus Torvalds
  2016-06-08 14:27       ` [tip:core/urgent] objtool, drm/vmwgfx: Fix " tip-bot for Josh Poimboeuf
  1 sibling, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2016-05-26 18:58 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: Ingo Molnar, Linux Kernel Mailing List, DRI

On Thu, May 26, 2016 at 11:43 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> That's fine with me, it is indeed a rare case.  We can always add the
> per-instruction macro later if needed.  Here's a patch.

Ingo, I can take this directly, unless you have other things pending
that you want to send anyway and would  just add this to that existing
pile.

Just let me know.

                 Linus

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

* [tip:core/urgent] objtool, drm/vmwgfx: Fix "duplicate frame pointer save" warning
  2016-05-26 18:43     ` [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning Josh Poimboeuf
  2016-05-26 18:58       ` Linus Torvalds
@ 2016-06-08 14:27       ` tip-bot for Josh Poimboeuf
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2016-06-08 14:27 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, linux-kernel, tglx, mingo, dri-devel, jpoimboe, hpa

Commit-ID:  0b0d81e3b7334897da9b2e3ffee860c2046f7bc0
Gitweb:     http://git.kernel.org/tip/0b0d81e3b7334897da9b2e3ffee860c2046f7bc0
Author:     Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Thu, 26 May 2016 13:43:43 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 8 Jun 2016 15:36:18 +0200

objtool, drm/vmwgfx: Fix "duplicate frame pointer save" warning

objtool reports the following warnings:

  drivers/gpu/drm/vmwgfx/vmwgfx_msg.o: warning: objtool: vmw_send_msg()+0x107: duplicate frame pointer save
  drivers/gpu/drm/vmwgfx/vmwgfx_msg.o: warning: objtool: vmw_host_get_guestinfo()+0x252: duplicate frame pointer save

To quote Linus:

 "The reason is that VMW_PORT_HB_OUT() uses a magic instruction sequence
  (a "rep outsb") to communicate with the hypervisor (it's a virtual GPU
  driver for vmware), and %rbp is part of the communication. So the
  inline asm does a save-and-restore of the frame pointer around the
  instruction sequence.

  I actually find the objtool warning to be quite reasonable, so it's
  not exactly a false positive, since in this case it actually does
  point out that the frame pointer won't be reliable over that
  instruction sequence.

  But in this particular case it just ends up being the wrong thing -
  the code is what it is, and %rbp just can't have the frame information
  due to annoying magic calling conventions."

Silence the warnings by telling objtool to ignore the two functions
which use the VMW_PORT_HB_{IN,OUT} macros.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: DRI <dri-devel@lists.freedesktop.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160526184343.fdtjjjg67smmeekt@treble
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index 6de283c..f0374f9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/frame.h>
 #include <asm/hypervisor.h>
 #include "drmP.h"
 #include "vmwgfx_msg.h"
@@ -194,7 +195,7 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg)
 
 	return -EINVAL;
 }
-
+STACK_FRAME_NON_STANDARD(vmw_send_msg);
 
 
 /**
@@ -304,6 +305,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
 
 	return 0;
 }
+STACK_FRAME_NON_STANDARD(vmw_recv_msg);
 
 
 /**

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

end of thread, other threads:[~2016-06-08 14:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25 17:14 objtool warning: "duplicate frame pointer save" Linus Torvalds
2016-05-25 17:56 ` Josh Poimboeuf
2016-05-25 23:51   ` Linus Torvalds
2016-05-26 18:43     ` [PATCH] drm/vmwgfx: fix "duplicate frame pointer save" warning Josh Poimboeuf
2016-05-26 18:58       ` Linus Torvalds
2016-06-08 14:27       ` [tip:core/urgent] objtool, drm/vmwgfx: Fix " tip-bot for Josh Poimboeuf

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