• Uros Bizjak's avatar
    KVM/x86: Use assembly instruction mnemonics instead of .byte streams · 4b1e5478
    Uros Bizjak authored
    Recently the minimum required version of binutils was changed to 2.20,
    which supports all VMX instruction mnemonics. The patch removes
    all .byte #defines and uses real instruction mnemonics instead.
    
    The compiler is now able to pass memory operand to the instruction,
    so there is no need for memory clobber anymore. Also, the compiler
    adds CC register clobber automatically to all extended asm clauses,
    so the patch also removes explicit CC clobber.
    
    The immediate benefit of the patch is removal of many unnecesary
    register moves, resulting in 1434 saved bytes in vmx.o:
    
       text    data     bss     dec     hex filename
     151257   18246    8500  178003   2b753 vmx.o
     152691   18246    8500  179437   2bced vmx-old.o
    
    Some examples of improvement include removal of unneeded moves
    of %rsp to %rax in front of invept and invvpid instructions:
    
        a57e:	b9 01 00 00 00       	mov    $0x1,%ecx
        a583:	48 89 04 24          	mov    %rax,(%rsp)
        a587:	48 89 e0             	mov    %rsp,%rax
        a58a:	48 c7 44 24 08 00 00 	movq   $0x0,0x8(%rsp)
        a591:	00 00
        a593:	66 0f 38 80 08       	invept (%rax),%rcx
    
    to:
    
        a45c:	48 89 04 24          	mov    %rax,(%rsp)
        a460:	b8 01 00 00 00       	mov    $0x1,%eax
        a465:	48 c7 44 24 08 00 00 	movq   $0x0,0x8(%rsp)
        a46c:	00 00
        a46e:	66 0f 38 80 04 24    	invept (%rsp),%rax
    
    and the ability to use more optimal registers and memory operands
    in the instruction:
    
        8faa:	48 8b 44 24 28       	mov    0x28(%rsp),%rax
        8faf:	4c 89 c2             	mov    %r8,%rdx
        8fb2:	0f 79 d0             	vmwrite %rax,%rdx
    
    to:
    
        8e7c:	44 0f 79 44 24 28    	vmwrite 0x28(%rsp),%r8
    Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    4b1e5478
virtext.h 2.6 KB