Re: [PATCH 03/22] x86/kvm: Fix frame pointer usage in vmx_vmenter()

From: Josh Poimboeuf
Date: Mon Jul 15 2019 - 09:35:38 EST


On Mon, Jul 15, 2019 at 03:03:23PM +0200, Paolo Bonzini wrote:
> On 15/07/19 14:37, Josh Poimboeuf wrote:
> > On Mon, Jul 15, 2019 at 11:04:03AM +0200, Paolo Bonzini wrote:
> >> On 15/07/19 02:36, Josh Poimboeuf wrote:
> >>> With CONFIG_FRAME_POINTER, vmx_vmenter() needs to do frame pointer setup
> >>> before calling kvm_spurious_fault().
> >>>
> >>> Fixes the following warning:
> >>>
> >>> arch/x86/kvm/vmx/vmenter.o: warning: objtool: vmx_vmenter()+0x14: call without frame pointer save/setup
> >>>
> >>> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> >>
> >> This is not enough, because the RSP value must match what is computed at
> >> this place:
> >>
> >> /* Adjust RSP to account for the CALL to vmx_vmenter(). */
> >> lea -WORD_SIZE(%_ASM_SP), %_ASM_ARG2
> >> call vmx_update_host_rsp
> >
> > Ah, that is surprising :-)
> >
> > And then there's this, which overwrites the frame pointer anyway:
> >
> > mov VCPU_RBP(%_ASM_AX), %_ASM_BP
> >
> > Would it make sense to remove the call to vmx_vmenter() altogether, and
> > just either embed it in __vmx_vcpu_run(), or jmp back and forth to it
> > from __vmx_vcpu_run()?
>
> Unfortunately there's another use of it in nested_vmx_check_vmentry_hw.

Ah, I missed that too (failed by cscope). Is this ok?

diff --git a/arch/x86/kvm/vmx/vmenter.S b/arch/x86/kvm/vmx/vmenter.S
index d4cb1945b2e3..4010d519eb8c 100644
--- a/arch/x86/kvm/vmx/vmenter.S
+++ b/arch/x86/kvm/vmx/vmenter.S
@@ -54,9 +54,9 @@ ENTRY(vmx_vmenter)
ret

3: cmpb $0, kvm_rebooting
- jne 4f
- call kvm_spurious_fault
-4: ret
+ je 4f
+ ret
+4: ud2

.pushsection .fixup, "ax"
5: jmp 3b