Hi, On 25. 01. 19, 16:41, Sean Christopherson wrote: > As evidenced by the myriad patches leading up to this moment, using > an inline asm blob for vCPU-run is nothing short of horrific. It's also > been called "unholy", "an abomination" and likely a whole host of other > names that would violate the Code of Conduct if recorded here and now. > > The code is relocated nearly verbatim, e.g. quotes, newlines, tabs and > __stringify need to be dropped, but other than those cosmetic changes > the only functional changees are to add the "call" and replace the final > "jmp" with a "ret". > > Note that STACK_FRAME_NON_STANDARD is also dropped from __vmx_vcpu_run(). > > Suggested-by: Andi Kleen <ak@xxxxxxxxxxxxxxx> > Suggested-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > --- > arch/x86/kvm/vmx/vmenter.S | 147 +++++++++++++++++++++++++++++++++++++ > arch/x86/kvm/vmx/vmx.c | 138 +--------------------------------- > 2 files changed, 148 insertions(+), 137 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmenter.S b/arch/x86/kvm/vmx/vmenter.S > index bcef2c7e9bc4..db223cfe9812 100644 > --- a/arch/x86/kvm/vmx/vmenter.S > +++ b/arch/x86/kvm/vmx/vmenter.S ... > @@ -55,3 +82,123 @@ ENDPROC(vmx_vmenter) > ENTRY(vmx_vmexit) > ret > ENDPROC(vmx_vmexit) > + > +/** > + * ____vmx_vcpu_run - Run a vCPU via a transition to VMX guest mode > + * @vmx: struct vcpu_vmx * > + * @regs: unsigned long * (to guest registers) > + * %RBX: VMCS launched status (non-zero indicates already launched) > + * > + * Returns: > + * %RBX is 0 on VM-Exit, 1 on VM-Fail > + */ > +ENTRY(____vmx_vcpu_run) > + push %_ASM_BP > + mov %_ASM_SP, %_ASM_BP Was there any particular reason not to use FRAME_BEGIN (and FRAME_END below)? It would compile to a nop on !CONFIG_FRAME_POINTER configs. I understand this patch is only a move of the code from .c to .S. So I would send a cleanup patch, but I just wonder if there is anything blocking it? > + > + /* > + * Save @regs, _ASM_ARG2 may be modified by vmx_update_host_rsp() and > + * @regs is needed after VM-Exit to save the guest's register values. > + */ > + push %_ASM_ARG2 ... > +1: > +#ifdef CONFIG_X86_64 > + xor %r8d, %r8d > + xor %r9d, %r9d > + xor %r10d, %r10d > + xor %r11d, %r11d > + xor %r12d, %r12d > + xor %r13d, %r13d > + xor %r14d, %r14d > + xor %r15d, %r15d > +#endif > + xor %eax, %eax > + xor %ecx, %ecx > + xor %edx, %edx > + xor %esi, %esi > + xor %edi, %edi > + xor %ebp, %ebp > + > + /* "POP" @regs. */ > + add $WORD_SIZE, %_ASM_SP > + pop %_ASM_BP > + ret > + > + /* VM-Fail. Out-of-line to avoid a taken Jcc after VM-Exit. */ > +2: mov $1, %ebx > + jmp 1b > +ENDPROC(____vmx_vcpu_run) thanks, -- js suse labs