Skip to content

emulator cleanup

Gleb Natapov kvm 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest30 patches 8 repliesIn review
  2. v230 patches 22 repliesSuperseded
  3. v1 RFC24 patches 28 repliesSuperseded

Changes in v3 from the cover letter

- use correct operand length for pio instruction with REX prefix
- check for string instruction before decrementing ecx
- change guest re-entry condition for string instruction

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30KVM: x86 emulator: Fix DstAcc decoding.arch/x86/kvm/emulate.c+5 -20 replies
2/30KVM: x86 emulator: fix RCX access during rep emulationarch/x86/kvm/emulate.c+2 -20 replies
3/30KVM: x86 emulator: check return value against correct definearch/x86/kvm/emulate.c+1 -10 replies
4/30KVM: Remove pointer to rflags from realmode_set_cr parameters.arch/x86/include/asm/kvm_host.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+3 -70 replies
5/30KVM: Provide callback to get/set control registers in emulator ops.arch/x86/include/asm/kvm_emulate.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/emulate.c +1 more+63 -630 replies
6/30KVM: remove realmode_lmsw function.arch/x86/include/asm/kvm_host.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+2 -110 replies
7/30KVM: Provide x86_emulate_ctxt callback to get current cplarch/x86/include/asm/kvm_emulate.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+15 -70 replies
8/30KVM: Provide current eip as part of emulator context.arch/x86/include/asm/kvm_emulate.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+9 -70 replies
9/30KVM: x86 emulator: fix mov r/m, sreg emulation.arch/x86/kvm/emulate.c+3 -40 replies
10/30KVM: x86 emulator: fix 0f 01 /5 emulationarch/x86/kvm/emulate.c+3 -00 replies
11/30KVM: x86 emulator: 0f (20|21|22|23) ignore mod bits.arch/x86/kvm/emulate.c+0 -80 replies
12/30KVM: x86 emulator: inject #UD on access to non-existing CRarch/x86/kvm/emulate.c+7 -00 replies
13/30KVM: x86 emulator: fix mov dr to inject #UD when needed.arch/x86/kvm/emulate.c+12 -60 replies
14/30KVM: x86 emulator: fix return values of syscall/sysenter/sysexit emulationsarch/x86/kvm/emulate.c+11 -60 replies
15/30KVM: x86 emulator: do not call writeback if msr access fails.arch/x86/kvm/emulate.c+2 -20 replies
16/30KVM: x86 emulator: If LOCK prefix is used dest arg should be memory.arch/x86/kvm/emulate.c+1 -15 replies
17/30KVM: x86 emulator: cleanup grp3 return valuearch/x86/kvm/emulate.c+4 -80 replies
18/30KVM: x86 emulator: Provide more callbacks for x86 emulator.arch/x86/include/asm/kvm_emulate.h arch/x86/kvm/x86.c+131 -150 replies
19/30KVM: x86 emulator: Emulate task switch in emulator.carch/x86/include/asm/kvm_emulate.h arch/x86/kvm/emulate.c+568 -00 replies
20/30KVM: x86 emulator: Use load_segment_descriptor() instead of kvm_load_segment_descriptor()arch/x86/kvm/emulate.c+5 -50 replies
21/30KVM: Use task switch from emulator.carch/x86/kvm/x86.c+17 -5400 replies
22/30KVM: x86 emulator: populate OP_MEM operand during decoding.arch/x86/kvm/emulate.c+29 -370 replies
23/30KVM: x86 emulator: add decoding of X,Y parameters from Intel SDMarch/x86/kvm/emulate.c+44 -810 replies
24/30KVM: x86 emulator: during rep emulation decrement ECX only if emulation succeededarch/x86/kvm/emulate.c+8 -70 replies
25/30KVM: x86 emulator: fix in/out emulation.arch/x86/include/asm/kvm_emulate.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/emulate.c +3 more+177 -1330 replies
26/30KVM: x86 emulator: Move string pio emulation into emulator.carch/x86/include/asm/kvm_host.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+31 -2290 replies
27/30KVM: x86 emulator: remove saved_eiparch/x86/kvm/emulate.c+1 -80 replies
28/30KVM: x86 emulator: restart string instruction without going back to a guest.arch/x86/include/asm/kvm_emulate.h arch/x86/kvm/emulate.c arch/x86/kvm/x86.c+42 -120 replies
29/30KVM: x86 emulator: introduce pio in string read ahead.arch/x86/include/asm/kvm_emulate.h arch/x86/kvm/emulate.c+45 -50 replies
30/30KVM: small kvm_arch_vcpu_ioctl_run() cleanup.arch/x86/kvm/x86.c+6 -260 replies

Reviews trailers per patch

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

PatchAvi KivityAndre Przywara
SeriesR-b R-b
1/30
2/30
3/30
4/30
5/30
6/30
7/30
8/30
9/30
10/30
11/30
12/30
13/30
14/30
15/30
16/30
17/30
18/30
19/30
20/30
21/30
22/30
23/30
24/30
25/30
26/30
27/30
28/30
29/30
30/30

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 00/30] emulator cleanup

This is the first series of patches that tries to cleanup emulator code. This is mix of bug fixes and moving code that does emulation from x86.c to emulator.c while making it KVM independent. The status of the patches:
works for me. realtime.flat test now also pass where it failed before.

ChangeLog:

v1->v2:
- A couple of new bug fixed
- cpl is now x86_emulator_ops callback
- during string instruction re-enter guest on each page boundary
- retain fast path for pio out (do not go through emulator)
v2->v3:
- use correct operand length for pio instruction with REX prefix
- check for string instruction before decrementing ecx
- change guest re-entry condition for string instruction

Gleb Natapov (30):
KVM: x86 emulator: Fix DstAcc decoding.
KVM: x86 emulator: fix RCX access during rep emulation
KVM: x86 emulator: check return value against correct define
KVM: Remove pointer to rflags from realmode_set_cr parameters.
KVM: Provide callback to get/set control registers in emulator ops.
KVM: remove realmode_lmsw function.
KVM: Provide x86_emulate_ctxt callback to get current cpl
KVM: Provide current eip as part of emulator context.
KVM: x86 emulator: fix mov r/m, sreg emulation.
KVM: x86 emulator: fix 0f 01 /5 emulation
KVM: x86 emulator: 0f (20|21|22|23) ignore mod bits.
KVM: x86 emulator: inject #UD on access to non-existing CR
KVM: x86 emulator: fix mov dr to inject #UD when needed.
KVM: x86 emulator: fix return values of syscall/sysenter/sysexit
emulations
KVM: x86 emulator: do not call writeback if msr access fails.
KVM: x86 emulator: If LOCK prefix is used dest arg should be memory.
KVM: x86 emulator: cleanup grp3 return value
KVM: x86 emulator: Provide more callbacks for x86 emulator.
KVM: x86 emulator: Emulate task switch in emulator.c
KVM: x86 emulator: Use load_segment_descriptor() instead of
kvm_load_segment_descriptor()
KVM: Use task switch from emulator.c
KVM: x86 emulator: populate OP_MEM operand during decoding.
KVM: x86 emulator: add decoding of X,Y parameters from Intel SDM
KVM: x86 emulator: during rep emulation decrement ECX only if
emulation succeeded
KVM: x86 emulator: fix in/out emulation.
KVM: x86 emulator: Move string pio emulation into emulator.c
KVM: x86 emulator: remove saved_eip
KVM: x86 emulator: restart string instruction without going back to a
guest.
KVM: x86 emulator: introduce pio in string read ahead.
KVM: small kvm_arch_vcpu_ioctl_run() cleanup.

 arch/x86/include/asm/kvm_emulate.h |   41 ++-
 arch/x86/include/asm/kvm_host.h    |   16 +-
 arch/x86/kvm/emulate.c             | 1062 ++++++++++++++++++++++++++---------
 arch/x86/kvm/svm.c                 |   20 +-
 arch/x86/kvm/vmx.c                 |   18 +-
 arch/x86/kvm/x86.c                 | 1121 +++++++++---------------------------
 6 files changed, 1146 insertions(+), 1132 deletions(-)