Skip to content

Streamline arithmetic instruction emulation

Avi Kivity kvm 3 versions – Applied

Status from this message: Applied, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 2 repliesApplied
  2. v27 patches 1 replySuperseded
  3. v17 patches 16 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/7KVM: x86 emulator: framework for streamlining arithmetic opcodesarch/x86/kvm/emulate.c+41 -00 replies
2/7KVM: x86 emulator: Support for declaring single operand fastopsarch/x86/kvm/emulate.c+25 -00 replies
3/7KVM: x86 emulator: introduce NoWrite flagarch/x86/kvm/emulate.c+4 -00 replies
4/7KVM: x86 emulator: mark CMP, CMPS, SCAS, TEST as NoWritearch/x86/kvm/emulate.c+8 -120 replies
5/7KVM: x86 emulator: convert NOT, NEG to fastoparch/x86/kvm/emulate.c+4 -130 replies
6/7KVM: x86 emulator: add macros for defining 2-operand fastop emulationarch/x86/kvm/emulate.c+12 -00 replies
7/7KVM: x86 emulator: convert basic ALU ops to fastoparch/x86/kvm/emulate.c+34 -780 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchGleb Natapov
SeriesA-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/7] Streamline arithmetic instruction emulation

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.

v3: fix reversed operand order in 2-operand macro

v2: rebased

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(-)
Signature · 1 line
1.8.0.1