Skip to content

RFC ISA 3.00 KVM guest support

Sam Bobroff qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest12 patches 15 repliesIn review
  2. v1 RFC9 patches 20 repliesSuperseded

Changes in v2 from the cover letter

Patch 1/12: scripts/update-linux-headers.sh: refactor extra files

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12spapr: Small cleanup of PPC MMU enumshw/ppc/spapr.c target/ppc/cpu-qom.h target/ppc/kvm.c +3 more+50 -671 reply
2/12scripts/update-linux-headers.sh: refactor extra filesscripts/update-linux-headers.sh+11 -141 reply
3/12scripts/update-linux-headers.sh: add new files for ARMscripts/update-linux-headers.sh+1 -00 replies
4/12Move virtio_mmio.h to fix update-linux-headers.shhw/virtio/virtio-mmio.c include/kernel-headers/linux/virtio_mmio.h+1 -13 replies
5/12Update headers using update-linux-headers.shinclude/standard-headers/linux/input-event-codes.h include/standard-headers/linux/pci_regs.h include/standard-headers/linux/virtio_ids.h +9 more+97 -4190 replies
6/12spapr: Add ibm, processor-radix-AP-encodings to the device treehw/ppc/spapr.c include/sysemu/kvm.h target/ppc/cpu-qom.h +2 more+45 -02 replies
7/12target-ppc: support KVM_CAP_PPC_MMU_RADIX, KVM_CAP_PPC_MMU_HASH_V3target/ppc/kvm.c target/ppc/kvm_ppc.h+26 -01 reply
8/12spapr: Only setup HTP if necessary.hw/ppc/spapr.c hw/ppc/spapr_hcall.c include/hw/ppc/spapr.h+26 -95 replies
9/12spapr: Add h_register_process_table() hypercallhw/ppc/spapr_hcall.c include/hw/ppc/spapr.h target/ppc/kvm.c +1 more+62 -00 replies
10/12spapr: move spapr_populate_pa_features()hw/ppc/spapr.c+43 -431 reply
11/12spapr: Enable ISA 3.0 MMU mode selection via CAShw/ppc/spapr.c hw/ppc/spapr_hcall.c include/hw/ppc/spapr_ovec.h+87 -80 replies
12/12spapr: Workaround for broken radix guestshw/ppc/spapr.c hw/ppc/spapr_hcall.c include/hw/ppc/spapr.h +1 more+20 -41 reply

Reviews trailers per patch

2 of 12 patches have a Reviewed-by or Acked-by.

PatchDavid Gibson
1/12Reviewd-by
2/12R-b
3/12
4/12
5/12
6/12
7/12R-b
8/12
9/12
10/12
11/12
12/12

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

Read the v2 thread

Cover letter [Qemu-devel] [RFC PATCH v2 00/12] ISA 3.00 KVM guest support

Update notes:

Since the last version, there has been a change to specification of the values used during client architecture support, regarding the bits in option vector 5, so some bits and other processing have changed a bit.

This version has not been as well tested as the last. Testing is ongoing.

General intro:

Because KVM will soon provide the necessary infrastructure for KVM guests to run on POWER9 CPUs, we can now start exploiting this new functionality from QEMU. See:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2017-January/153433.html

This work is not yet complete but it is functional and is presented for early review. It overlaps in some places with current work supporting the same guests under full emulation.

This set aims to support only the following scenarios:
* A POWER9 host running in radix mode, running a guest in radix mode.
* A POWER9 host running in hash mode, running a guest in hash mode.
* A POWER9 host running in hash mode, running a guest in legacy(+) mode. (+) Where legacy means that the guest does not support ISA 3.00.

Hash or radix mode for the host is controlled via the "disable_radix" kernel command line parameter: the host will use radix unless disable_radix is given. For the guest it should be automatically selected to match the host.

Bad legacy guests: There are some recent kernels (e.g. 4.9) that will, when run as a KVM guest and if the ibm,pa-features entry in the device tree has the Radix MMU bit set, attempt to initialize the MMU as if they were a host (which will cause them to crash). To avoid exposing this problem, the Radix MMU bit is removed from ibm,pa-features when a legacy guest is detected.

Final Notes:
* Migration/snapshots are not yet investigated.
* This set is based on the ppc-for-2.9 branch of David Gibson's tree at https://github.com/dgibson/qemu.git
* It also relies on some work already posted here:
https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg02527.html
Specifically patches 1..4 which set up the new CPU and MMU models.

Changes v1 -> v2:
Patch 1/12: scripts/update-linux-headers.sh: refactor extra files

I've factored the script to make it easier to add new files.

Patch 2/12: scripts/update-linux-headers.sh: add new files for ARM

* Added the two new arm headers.

Patch 3/12: Move virtio_mmio.h to fix update-linux-headers.sh
* FWIW, here's one way of fixing it.

Patch 4/12: Update headers using update-linux-headers.sh

* Added information about where the headers came from.

Patch 5/12: spapr: Add ibm,processor-radix-AP-encodings to the device tree

* ppc_radix_page_info now kept in native format, conversion to BE done when adding to the device tree.
* radix_page_info moved into the CPU class, cleaning up some code.

Patch 6/12: target-ppc: support KVM_CAP_PPC_MMU_RADIX, KVM_CAP_PPC_MMU_HASH_V3

* cap_mmu_hash renamed to cap_mmu_hash_v3.

Patch 7/12: spapr: Only setup HTP if necessary.

* This patch has been mostly rewritten to move the late HPT allocation to CAS. This allows a guest to start in radix mode (when it's in real mode) and then change to hash, even if it is a legacy guest and will not call h_register_process_table().
* Added an exported function to spapr.c to perform HPT allocation and adjust the vrma if necessary. This makes it possible to allocate the HPT from h_client_architecture_support() in spapr_hcall.c.

Patch 8/12: spapr: Add h_register_process_table() hypercall

* I haven't addressed review comments for this patch because it overlaps with Suraj's implementation of the same function and we'll work together to integrate them.

Patch 10/12: spapr: Enable ISA 3.0 MMU mode selection via CAS

* Unused bits removed.
* Logic and bit definitions changed due to architectural change.
* Cleanly terminate QEMU if the guest requests an unavailable mode (as required by the new architecture).
* Legacy guest workaround moved to it's own patch.
* I'm sorry for the bitfield constants in spapr_dt_ov5_platform_support() but there don't seem to be convienent macros for converting an option vector specifier (OV_BIT(x,y)) into a byte-mask. I'm open to suggestions.

Sam Bobroff (12):
spapr: Small cleanup of PPC MMU enums scripts/update-linux-headers.sh: refactor extra files scripts/update-linux-headers.sh: add new files for ARM Move virtio_mmio.h to fix update-linux-headers.sh Update headers using update-linux-headers.sh
spapr: Add ibm,processor-radix-AP-encodings to the device tree
target-ppc: support KVM_CAP_PPC_MMU_RADIX, KVM_CAP_PPC_MMU_HASH_V3
spapr: Only setup HTP if necessary.
spapr: Add h_register_process_table() hypercall
spapr: move spapr_populate_pa_features()
spapr: Enable ISA 3.0 MMU mode selection via CAS
spapr: Workaround for broken radix guests

 hw/ppc/spapr.c                                     | 190 +++++++---
 hw/ppc/spapr_hcall.c                               |  84 ++++-
 hw/virtio/virtio-mmio.c                            |   2 +-
 include/hw/ppc/spapr.h                             |   3 +
 include/hw/ppc/spapr_ovec.h                        |   8 +
 .../linux/virtio_mmio.h                            |   0
 include/standard-headers/linux/input-event-codes.h |   2 +-
 include/standard-headers/linux/pci_regs.h          |   8 +
 include/standard-headers/linux/virtio_ids.h        |   1 +
 include/sysemu/kvm.h                               |   1 +
 linux-headers/asm-arm/kvm.h                        |   2 +
 linux-headers/asm-arm/unistd-eabi.h                |   5 +
 linux-headers/asm-arm/unistd-oabi.h                |  17 +
 linux-headers/asm-arm/unistd.h                     | 419 +--------------------
 linux-headers/asm-powerpc/kvm.h                    |  27 ++
 linux-headers/asm-powerpc/unistd.h                 |   1 +
 linux-headers/asm-x86/kvm_para.h                   |   4 +-
 linux-headers/linux/kvm.h                          |  20 +-
 linux-headers/linux/vfio.h                         |  10 +
 scripts/update-linux-headers.sh                    |  26 +-
 target/ppc/cpu-qom.h                               |  13 +-
 target/ppc/cpu.h                                   |   4 +
 target/ppc/kvm.c                                   |  61 ++-
 target/ppc/kvm_ppc.h                               |  13 +
 target/ppc/mmu-hash64.c                            |  10 +-
 target/ppc/mmu_helper.c                            |  67 ++--
 target/ppc/translate.c                             |  12 +-
 27 files changed, 457 insertions(+), 553 deletions(-)
 rename include/{standard-headers => kernel-headers}/linux/virtio_mmio.h (100%)
 create mode 100644 linux-headers/asm-arm/unistd-eabi.h
 create mode 100644 linux-headers/asm-arm/unistd-oabi.h
Signature · 1 line
2.11.0