• Paolo Bonzini's avatar
    KVM: x86: avoid useless set of KVM_REQ_EVENT after emulation · 6addfc42
    Paolo Bonzini authored
    Despite the provisions to emulate up to 130 consecutive instructions, in
    practice KVM will emulate just one before exiting handle_invalid_guest_state,
    because x86_emulate_instruction always sets KVM_REQ_EVENT.
    
    However, we only need to do this if an interrupt could be injected,
    which happens a) if an interrupt shadow bit (STI or MOV SS) has gone
    away; b) if the interrupt flag has just been set (other instructions
    than STI can set it without enabling an interrupt shadow).
    
    This cuts another 700-900 cycles from the cost of emulating an
    instruction (measured on a Sandy Bridge Xeon: 1650-2600 cycles
    before the patch on kvm-unit-tests, 925-1700 afterwards).
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    6addfc42
x86.c 191 KB