Re: [tip:x86/alternatives 14/14] arch/x86/kvm/kvm.o: warning: objtool: .altinstr_replacement+0xc5: call without frame pointer save/setup

From: Sean Christopherson
Date: Fri Jun 14 2024 - 11:41:01 EST


On Fri, Jun 14, 2024, Borislav Petkov wrote:
> On Fri, Jun 14, 2024 at 04:15:14PM +0800, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/alternatives
> > head: f776e41fdcc4141876ef6f297318ab04c2382eb7
> > commit: f776e41fdcc4141876ef6f297318ab04c2382eb7 [14/14] x86/alternative: Replace the old macros
> > config: x86_64-buildonly-randconfig-r001-20211209 (https://download.01.org/0day-ci/archive/20240614/202406141648.jO9qNGLa-lkp@xxxxxxxxx/config)
> > compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240614/202406141648.jO9qNGLa-lkp@xxxxxxxxx/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202406141648.jO9qNGLa-lkp@xxxxxxxxx/
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> arch/x86/kvm/kvm.o: warning: objtool: .altinstr_replacement+0xc5: call without frame pointer save/setup
>
> That thing comes from:
>
> SYM_FUNC_START(vmx_do_interrupt_irqoff)
> VMX_DO_EVENT_IRQOFF CALL_NOSPEC _ASM_ARG1
> SYM_FUNC_END(vmx_do_interrupt_irqoff)
>
> at the end of arch/x86/kvm/vmx/vmenter.S.
>
> I know Sean had a patchset to cleanup that gunk. Sean?

That series was just for the actual VM-Enter/VM-Exit path. vmx_do_interrupt_irqoff()
is unrelated, it's just another asm chunk of code that happnes to live in vmenter.S
(which is obviously is a bit of a misnomer these days).

> >From reading objtool docs, those functions (vmx_do_nmi_irqoff() too AFAICT)
> should have FRAME_BEGIN/FRAME_END but if I do that, objtool bitches
> differently:

That function does create a stack frame, just without using FRAME_BEGIN/END so
it's not dependent on using frame pointers. Ironically, the intent is to try and
placate objtool.

IIUC, this warning just stared showing up with the alternatives changes? Does
CALL_NOSPEC generate different code now?

.macro VMX_DO_EVENT_IRQOFF call_insn call_target
/*
* Unconditionally create a stack frame, getting the correct RSP on the
* stack (for x86-64) would take two instructions anyways, and RBP can
* be used to restore RSP to make objtool happy (see below).
*/
push %_ASM_BP
mov %_ASM_SP, %_ASM_BP

#ifdef CONFIG_X86_64
/*
* Align RSP to a 16-byte boundary (to emulate CPU behavior) before
* creating the synthetic interrupt stack frame for the IRQ/NMI.
*/
and $-16, %rsp
push $__KERNEL_DS
push %rbp
#endif
pushf
push $__KERNEL_CS
\call_insn \call_target

/*
* "Restore" RSP from RBP, even though IRET has already unwound RSP to
* the correct value. objtool doesn't know the callee will IRET and,
* without the explicit restore, thinks the stack is getting walloped.
* Using an unwind hint is problematic due to x86-64's dynamic alignment.
*/
mov %_ASM_BP, %_ASM_SP
pop %_ASM_BP
RET
.endm

>
> arch/x86/kvm/kvm-intel.o: warning: objtool: vmx_do_interrupt_irqoff+0xc: undefined stack state
>
> Suggestions?