Skip to content

uq/master: TPR access optimization for Windows guests

Jan Kiszka kvm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6target-i386: Add infrastructure for reporting TPR MMIO accessescpu-all.h hw/apic.h hw/apic_common.c +3 more+58 -30 replies
2/6kvmvapic: Add option ROM.gitignore Makefile pc-bios/optionrom/Makefile +1 more+344 -20 replies
3/6kvmvapic: Introduce TPR access optimization for Windows guestsMakefile.target hw/apic.c hw/apic_common.c +3 more+976 -1412 replies
4/6kvmvapic: Simplify mp/up_set_tprpc-bios/optionrom/kvmvapic.S+1 -50 replies
5/6optionsrom: Reserve space for checksumpc-bios/optionrom/optionrom.h+2 -10 replies
6/6kvmvapic: Use optionrom helperspc-bios/optionrom/kvmvapic.S+8 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] uq/master: TPR access optimization for Windows guests

And yet another qemu-kvm piece: Windows 32-bit guests make heavy use of the MMIO-based TPR register. On older Intel CPUs and current AMDs, this causes significant KVM vmexit rates as the register needs to be trapped by the hypervisor.

This series introduces a workaround for this hardware limitation: A paravirtual APIC extension, based on guest extension using an options ROM and a special VAPIC device that patches TPR accesses of Windows to call into the option ROM instead. See patch 3 for details.

The speedup is noteworthy: I measured 15 vs. 45 s XP bootup time (disk cached) with the VAPIC enabled vs. disabled on an Intel CPU with flexpriority=0.

Therefore, the VAPI is enabled by default, even in TCG mode. Here, no speedup can be achieved as the emulation overhead of the TPR register is marginal compared to instruction emulation. On the other hand, enabling the optimization causes not measurable slowdown of Windows guests.

The patches depend on the follow upstream or uq/master patches:
- kvm: Implement kvm_irqchip_in_kernel
http://thread.gmane.org/gmane.comp.emulators.qemu/134399
- KVM: Fix breakages of QOM conversion
http://permalink.gmane.org/gmane.comp.emulators.qemu/134844

It is based on upstream commit cb437e48ab (before the VGA breakage). The series plus dependencies is also available at

git://git.kiszka.org/qemu-kvm.git queues/kvm-tpr

Please review carefully.

Jan Kiszka (6):
target-i386: Add infrastructure for reporting TPR MMIO accesses
kvmvapic: Add option ROM
kvmvapic: Introduce TPR access optimization for Windows guests
kvmvapic: Simplify mp/up_set_tpr
optionsrom: Reserve space for checksum
kvmvapic: Use optionrom helpers

 .gitignore                    |    1 +
 Makefile                      |    2 +-
 Makefile.target               |    3 +-
 cpu-all.h                     |    3 +-
 hw/apic.c                     |  126 +++++++-
 hw/apic.h                     |    2 +
 hw/apic_common.c              |   68 ++++-
 hw/apic_internal.h            |   27 ++
 hw/kvm/apic.c                 |   32 ++
 hw/kvmvapic.c                 |  738 +++++++++++++++++++++++++++++++++++++++++
 pc-bios/optionrom/Makefile    |    2 +-
 pc-bios/optionrom/kvmvapic.S  |  335 +++++++++++++++++++
 pc-bios/optionrom/optionrom.h |    3 +-
 target-i386/cpu.h             |    9 +
 target-i386/helper.c          |   19 +
 target-i386/kvm.c             |   24 ++-
 16 files changed, 1374 insertions(+), 20 deletions(-)
 create mode 100644 hw/kvmvapic.c
 create mode 100644 pc-bios/optionrom/kvmvapic.S
Signature · 1 line
1.7.3.4