All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm
@ 2016-03-09 18:59 Josh Poimboeuf
  2016-04-14 20:00 ` Josh Poimboeuf
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Poimboeuf @ 2016-03-09 18:59 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: x86, Gleb Natapov, Paolo Bonzini, linux-kernel

The kbuild test robot reported this objtool warning [1]:

  arch/x86/kvm/emulate.o: warning: objtool: fastop()+0x69: call without frame pointer save/setup

The issue seems to be caused by CONFIG_PROFILE_ALL_BRANCHES.  With that
option, for some reason gcc decides not to create a stack frame in
fastop() before doing the inline asm call, which can result in a bad
stack trace.

Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by
listing the stack pointer as an output operand for the inline asm
statement.

This change has no effect for !CONFIG_PROFILE_ALL_BRANCHES.

[1] https://lists.01.org/pipermail/kbuild-all/2016-March/018249.html

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kvm/emulate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 0f62943..a2f24af 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -5110,13 +5110,17 @@ static void fetch_possible_mmx_operand(struct x86_emulate_ctxt *ctxt,
 
 static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
 {
+	register void *__sp asm(_ASM_SP);
 	ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF;
+
 	if (!(ctxt->d & ByteOp))
 		fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE;
+
 	asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n"
 	    : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags),
-	      [fastop]"+S"(fop)
+	      [fastop]"+S"(fop), "+r"(__sp)
 	    : "c"(ctxt->src2.val));
+
 	ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);
 	if (!fop) /* exception is returned in fop variable */
 		return emulate_de(ctxt);
-- 
2.4.3

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

* Re: [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm
  2016-03-09 18:59 [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm Josh Poimboeuf
@ 2016-04-14 20:00 ` Josh Poimboeuf
  2016-04-15  9:40   ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Poimboeuf @ 2016-04-14 20:00 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: x86, Gleb Natapov, Paolo Bonzini, linux-kernel

Hi Ingo,

Ping?

On Wed, Mar 09, 2016 at 12:59:50PM -0600, Josh Poimboeuf wrote:
> The kbuild test robot reported this objtool warning [1]:
> 
>   arch/x86/kvm/emulate.o: warning: objtool: fastop()+0x69: call without frame pointer save/setup
> 
> The issue seems to be caused by CONFIG_PROFILE_ALL_BRANCHES.  With that
> option, for some reason gcc decides not to create a stack frame in
> fastop() before doing the inline asm call, which can result in a bad
> stack trace.
> 
> Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by
> listing the stack pointer as an output operand for the inline asm
> statement.
> 
> This change has no effect for !CONFIG_PROFILE_ALL_BRANCHES.
> 
> [1] https://lists.01.org/pipermail/kbuild-all/2016-March/018249.html
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  arch/x86/kvm/emulate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 0f62943..a2f24af 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -5110,13 +5110,17 @@ static void fetch_possible_mmx_operand(struct x86_emulate_ctxt *ctxt,
>  
>  static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
>  {
> +	register void *__sp asm(_ASM_SP);
>  	ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF;
> +
>  	if (!(ctxt->d & ByteOp))
>  		fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE;
> +
>  	asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n"
>  	    : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags),
> -	      [fastop]"+S"(fop)
> +	      [fastop]"+S"(fop), "+r"(__sp)
>  	    : "c"(ctxt->src2.val));
> +
>  	ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);
>  	if (!fop) /* exception is returned in fop variable */
>  		return emulate_de(ctxt);
> -- 
> 2.4.3
> 

-- 
Josh

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

* Re: [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm
  2016-04-14 20:00 ` Josh Poimboeuf
@ 2016-04-15  9:40   ` Ingo Molnar
  2016-04-25 16:11     ` Josh Poimboeuf
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2016-04-15  9:40 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: x86, Gleb Natapov, Paolo Bonzini, linux-kernel


* Josh Poimboeuf <jpoimboe@redhat.com> wrote:

> Hi Ingo,
> 
> Ping?

I think this should go via the KVM tree.

Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

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

* Re: [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm
  2016-04-15  9:40   ` Ingo Molnar
@ 2016-04-25 16:11     ` Josh Poimboeuf
  2016-05-09 16:58       ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Poimboeuf @ 2016-04-25 16:11 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: x86, Gleb Natapov, Paolo Bonzini, linux-kernel, Ingo Molnar

Hi Paolo,

Would you be willing to merge this patch?

On Fri, Apr 15, 2016 at 11:40:40AM +0200, Ingo Molnar wrote:
> 
> * Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> 
> > Hi Ingo,
> > 
> > Ping?
> 
> I think this should go via the KVM tree.
> 
> Acked-by: Ingo Molnar <mingo@kernel.org>
> 
> Thanks,
> 
> 	Ingo

-- 
Josh

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

* Re: [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm
  2016-04-25 16:11     ` Josh Poimboeuf
@ 2016-05-09 16:58       ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2016-05-09 16:58 UTC (permalink / raw)
  To: Josh Poimboeuf; +Cc: x86, Gleb Natapov, linux-kernel, Ingo Molnar



On 25/04/2016 18:11, Josh Poimboeuf wrote:
> Hi Paolo,
> 
> Would you be willing to merge this patch?

Yes, will be in 4.7.

Paolo

> On Fri, Apr 15, 2016 at 11:40:40AM +0200, Ingo Molnar wrote:
>>
>> * Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>>
>>> Hi Ingo,
>>>
>>> Ping?
>>
>> I think this should go via the KVM tree.
>>
>> Acked-by: Ingo Molnar <mingo@kernel.org>
>>
>> Thanks,
>>
>> 	Ingo
> 

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

end of thread, other threads:[~2016-05-09 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09 18:59 [PATCH] x86/kvm: Add stack frame dependency to fastop() inline asm Josh Poimboeuf
2016-04-14 20:00 ` Josh Poimboeuf
2016-04-15  9:40   ` Ingo Molnar
2016-04-25 16:11     ` Josh Poimboeuf
2016-05-09 16:58       ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.