Skip to contentSkip to conversation

kvm tools: Prepare kvmtool for another architecture

PATCH Superseded Matt Evans 2 participants 2 messages Dec 9, 2011 KVM

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Matt Evans

author
#0 lore raw

v2 cover kvm tools: Prepare kvmtool for another architecture

Hi,

This patch series rearranges and tidies various parts of kvmtool to pave the way for the addition of support for another architecture -- SPAPR PPC64. A second patch series will follow to present the PPC64 support.

Building on the separation of x86-specific code into tools/kvm/x86, this series change some of the mechanics of kvm tool, for example modifying the loop around ioctl(KVM_RUN) so that whilst it stays generic, it calls into arch-specific code to handle specific exit reasons, MMIO etc. The builtin-run initialisation path is rationalised so that PCI & IRQs are initialised before devices, and all of this happens before arch-specific code is given the chance to initialise any firmware and generate any device trees.

Most of this series is fairly trivial, in moving code, making definitions arch-local or available via a header, endian sanitisation. The PCI code changes are probably most 'interesting', in that I have made the config space accesses available to those not using the PC ioport access method, plus wrapped initialisations of config space with cpu_to_leXX accesses.

Changes since V1:
- Merged up, V1 patches now upstream are obv. not included here
- No longer uses PRIx64 etc., defining __SANE_USERSPACE_TYPES__ for LL64 on PPC
- Returns kvm__recommended_cpus (and max cpus) to generic code, but fixes them so that they cope gracefully with KVM supporting neither CAP. (A separate patch submitted for PPC KVM returns a useful number of CPUs.)
- Made hugetlbfs guest RAM mapping code generic, allow x86 to use it
- Drop unnecessary ifdef around symbol__init()
- Un-broke ioport PCI config access :o)
- Rolled in other review comments (e.g. removal of "& 0xff" in term.c, fixing pci_config_address union, create both kvm_cpu__emulate_mmio and _io)

Applies on top of Pekka's linux-kvm.git as of today.

Cheers,

Matt

Matt Evans (23):
kvm tools: Only build/init i8042 on x86
kvm tools: Add Makefile parameter for kernel include path kvm tools: Re-arrange Makefile to heed CFLAGS before checking for
optional libs
kvm tools: Get correct 64-bit types on PPC64 and link appropriately kvm tools: Add arch-specific KVM_RUN exit handling via

    kvm_cpu__handle_exit()
  kvm tools: Don't die if KVM_CAP_NR_VCPUS isn't available
  kvm tools: Fix KVM_RUN exit code check
  kvm tools: Add kvm__arch_periodic_poll()
  kvm tools: Move arch-specific cmdline init into
    kvm__arch_set_cmdline()

kvm tools: Add CONSOLE_HV term type and allow it to be selected kvm tools: Fix term_getc(), term_getc_iov() endian bugs kvm tools: Allow initrd_check() to match a cpio
kvm tools: Allow load_flat_binary() to load an initrd alongside kvm tools: Initialise PCI before devices start getting registered
with PCI
kvm tools: Perform CPU and firmware setup after devices are added kvm tools: Init IRQs after determining nrcpus
kvm tools: Add ability to map guest RAM from hugetlbfs kvm tools: Move PCI_MAX_DEVICES to pci.h
kvm tools: Endian-sanitise pci.h and PCI device setup kvm tools: Correctly set virtio-pci bar_size and remove hardwired
address
kvm tools: Add pci__config_{rd,wr}(), pci__find_dev() kvm tools: Arch-specific define for PCI MMIO allocation area kvm tools: Create arch-specific kvm_cpu__emulate_{mm}io()

 tools/kvm/Makefile                       |   99 ++++++++++++++++--------------
 tools/kvm/builtin-run.c                  |   61 +++++++++++--------
 tools/kvm/hw/pci-shmem.c                 |   23 ++++---
 tools/kvm/hw/vesa.c                      |   15 +++--
 tools/kvm/include/kvm/ioport.h           |   11 ++--
 tools/kvm/include/kvm/kvm-cpu.h          |    2 +
 tools/kvm/include/kvm/kvm.h              |    8 ++-
 tools/kvm/include/kvm/pci.h              |   46 ++++++++++----
 tools/kvm/include/kvm/term.h             |    1 +
 tools/kvm/include/kvm/util.h             |    4 +
 tools/kvm/include/linux/types.h          |    1 +
 tools/kvm/kvm-cpu.c                      |   46 ++++++++------
 tools/kvm/kvm.c                          |   28 ++++++---
 tools/kvm/pci.c                          |   76 ++++++++++++++---------
 tools/kvm/term.c                         |    7 +--
 tools/kvm/util.c                         |   45 ++++++++++++++
 tools/kvm/virtio/pci.c                   |   48 ++++++++------
 tools/kvm/x86/include/kvm/kvm-arch.h     |    5 ++
 tools/kvm/x86/include/kvm/kvm-cpu-arch.h |   17 +++++-
 tools/kvm/x86/kvm-cpu.c                  |    5 ++
 tools/kvm/x86/kvm.c                      |   52 ++++++++++++++--
 21 files changed, 396 insertions(+), 204 deletions(-)
#1 lore raw
Quoted 3 lines · Matt Evans

This patch series rearranges and tidies various parts of kvmtool to pave the way for the addition of support for another architecture -- SPAPR PPC64. A second patch series will follow to present the PPC64 support.

I applied most of the patches. I left out the ones that Sasha and myself still had comments on.

Thanks Matt for cleaning up our nasty x86ism! :-)

Pekka