From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 0/7] Streamline arithmetic instruction emulation Date: Sat, 22 Dec 2012 14:26:50 +0200 Message-ID: <1356179217-5526-1-git-send-email-avi.kivity@gmail.com> Cc: kvm@vger.kernel.org To: Marcelo Tosatti , Gleb Natapov Return-path: Received: from mail-wg0-f51.google.com ([74.125.82.51]:56471 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059Ab2LVMci (ORCPT ); Sat, 22 Dec 2012 07:32:38 -0500 Received: by mail-wg0-f51.google.com with SMTP id gg4so2476291wgb.18 for ; Sat, 22 Dec 2012 04:32:37 -0800 (PST) Sender: kvm-owner@vger.kernel.org List-ID: The current arithmetic instruction emulation is fairly clumsy: after decode, each instruction gets a switch (size), and for every size we fetch the operands, prepare flags, emulate the instruction, then store back the flags and operands. This patchset simplifies things by moving everything into common code except the instruction itself. All the pre- and post- processing is coded just once. The per-instrution code looks like: add %bl, %al ret add %bx, %ax ret add %ebx, %eax ret add %rbx, %rax ret The savings in size, for the ten instructions converted in this patchset, are fairly large: text data bss dec hex filename 63724 0 0 63724 f8ec arch/x86/kvm/emulate.o.before 61268 0 0 61268 ef54 arch/x86/kvm/emulate.o.after - around 2500 bytes. Avi Kivity (7): KVM: x86 emulator: framework for streamlining arithmetic opcodes KVM: x86 emulator: Support for declaring single operand fastops KVM: x86 emulator: introduce NoWrite flag KVM: x86 emulator: mark CMP, CMPS, SCAS, TEST as NoWrite KVM: x86 emulator: convert NOT, NEG to fastop KVM: x86 emulator: add macros for defining 2-operand fastop emulation KVM: x86 emulator: convert basic ALU ops to fastop arch/x86/kvm/emulate.c | 215 +++++++++++++++++++++++++++---------------------- 1 file changed, 120 insertions(+), 95 deletions(-) -- 1.7.11.7