1. 16 3月, 2016 1 次提交
    • D
      target-ppc: Add helpers for updating a CPU's SDR1 and external HPT · e5c0d3ce
      David Gibson 提交于
      When a Power cpu with 64-bit hash MMU has it's hash page table (HPT)
      pointer updated by a write to the SDR1 register we need to update some
      derived variables.  Likewise, when the cpu is configured for an external
      HPT (one not in the guest memory space) some derived variables need to be
      updated.
      
      Currently the logic for this is (partially) duplicated in ppc_store_sdr1()
      and in spapr_cpu_reset().  In future we're going to need it in some other
      places, so make some common helpers for this update.
      
      In addition the new ppc_hash64_set_external_hpt() helper also updates
      SDR1 in KVM - it's not updated by the normal runtime KVM <-> qemu CPU
      synchronization.  In a sense this belongs logically in the
      ppc_hash64_set_sdr1() helper, but that is called from
      kvm_arch_get_registers() so can't itself call cpu_synchronize_state()
      without infinite recursion.  In practice this doesn't matter because
      the only other caller is TCG specific.
      
      Currently there aren't situations where updating SDR1 at runtime in KVM
      matters, but there are going to be in future.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      e5c0d3ce
  2. 25 2月, 2016 1 次提交
    • T
      hw/ppc/spapr: Implement the h_page_init hypercall · 3240dd9a
      Thomas Huth 提交于
      This hypercall either initializes a page with zeros, or copies
      another page.
      According to LoPAPR, the i-cache of the page should also be
      flushed if using H_ICACHE_INVALIDATE or H_ICACHE_SYNCHRONIZE,
      and the d-cache should be synchronized to the RAM if the
      H_ICACHE_SYNCHRONIZE flag is used. For this, two new functions
      are introduced, kvmppc_dcbst_range() and kvmppc_icbi()_range, which
      use the corresponding assembler instructions to flush the caches
      if running with KVM on Power. If the code runs with TCG instead,
      the code only uses tb_flush(), assuming that this will be
      enough for synchronization.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      3240dd9a
  3. 17 2月, 2016 1 次提交
  4. 30 1月, 2016 1 次提交
  5. 11 11月, 2015 1 次提交
  6. 23 10月, 2015 1 次提交
    • D
      spapr_iommu: Rename vfio_accel parameter · 6a81dd17
      David Gibson 提交于
      The vfio_accel parameter used when creating a new TCE table (guest IOMMU
      context) has a confusing name.  What it really means is whether we need the
      TCE table created to be able to support VFIO devices.
      
      VFIO is relevant, because when available we use in-kernel acceleration of
      the TCE table, but that may not work with VFIO devices because updates to
      the table are handled in kernel, bypass qemu and so don't hit qemu's
      infrastructure for keeping the VFIO host IOMMU state in sync with the guest
      IOMMU state.
      
      Rename the parameter to "need_vfio" throughout.  This is a cosmetic change,
      with no impact on the logic.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      6a81dd17
  7. 23 9月, 2015 2 次提交
    • T
      ppc/spapr: Implement H_RANDOM hypercall in QEMU · 4d9392be
      Thomas Huth 提交于
      The PAPR interface defines a hypercall to pass high-quality
      hardware generated random numbers to guests. Recent kernels can
      already provide this hypercall to the guest if the right hardware
      random number generator is available. But in case the user wants
      to use another source like EGD, or QEMU is running with an older
      kernel, we should also have this call in QEMU, so that guests that
      do not support virtio-rng yet can get good random numbers, too.
      
      This patch now adds a new pseudo-device to QEMU that either
      directly provides this hypercall to the guest or is able to
      enable the in-kernel hypercall if available. The in-kernel
      hypercall can be enabled with the use-kvm property, e.g.:
      
       qemu-system-ppc64 -device spapr-rng,use-kvm=true
      
      For handling the hypercall in QEMU instead, a "RngBackend" is
      required since the hypercall should provide "good" random data
      instead of pseudo-random (like from a "simple" library function
      like rand() or g_random_int()). Since there are multiple RngBackends
      available, the user must select an appropriate back-end via the
      "rng" property of the device, e.g.:
      
       qemu-system-ppc64 -object rng-random,filename=/dev/hwrng,id=gid0 \
                         -device spapr-rng,rng=gid0 ...
      
      See http://wiki.qemu-project.org/Features-Done/VirtIORNG for
      other example of specifying RngBackends.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      4d9392be
    • A
      spapr: Enable in-kernel H_SET_MODE handling · ef9971dd
      Alexey Kardashevskiy 提交于
      For setting debug watchpoints, sPAPR guests use H_SET_MODE hypercall.
      The existing QEMU H_SET_MODE handler does not support this but
      the KVM handler in HV KVM does. However it is not enabled.
      
      This enables the in-kernel H_SET_MODE handler which handles:
      - Completed Instruction Address Breakpoint Register
      - Watch point 0 registers.
      
      The rest is still handled in QEMU.
      Reported-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ef9971dd
  8. 21 9月, 2015 1 次提交
  9. 04 6月, 2015 1 次提交
    • D
      pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, STORE} implementations · 026bfd89
      David Gibson 提交于
      qemu currently implements the hypercalls H_LOGICAL_CI_LOAD and
      H_LOGICAL_CI_STORE as PAPR extensions.  These are used by the SLOF firmware
      for IO, because performing cache inhibited MMIO accesses with the MMU off
      (real mode) is very awkward on POWER.
      
      This approach breaks when SLOF needs to access IO devices implemented
      within KVM instead of in qemu.  The simplest example would be virtio-blk
      using an iothread, because the iothread / dataplane mechanism relies on
      an in-kernel implementation of the virtio queue notification MMIO.
      
      To fix this, an in-kernel implementation of these hypercalls has been made,
      (kernel commit 99342cf "kvmppc: Implement H_LOGICAL_CI_{LOAD,STORE} in KVM"
      however, the hypercalls still need to be enabled from qemu.  This performs
      the necessary calls to do so.
      
      It would be nice to provide some warning if we encounter a problematic
      device with a kernel which doesn't support the new calls.  Unfortunately,
      I can't see a way to detect this case which won't either warn in far too
      many cases that will probably work, or which is horribly invasive.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      026bfd89
  10. 08 9月, 2014 1 次提交
  11. 15 7月, 2014 1 次提交
    • A
      spapr: Move RMA memory region registration code · 658fa66b
      Alexey Kardashevskiy 提交于
      PPC970 does not support VRMA (virtual RMA) so real memory required
      for SLOF to execute must be allocated by the KVM_ALLOCATE_RMA ioctl.
      Later this memory is used as a part of the guest RAM area.
      The RMA allocating code also registers a memory region for this piece
      of RAM.
      
      We are going to simplify memory regions layout: RMA memory region
      will be a subregion in the RAM memory region, both starting from zero.
      This way we will not have to take care of start address alignment for
      the piece of RAM next to the RMA.
      
      This moves memory region business closer to the RAM memory region
      creation/allocation code.
      
      As this is a mechanical patch, no change in behaviour is expected.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      [agraf: fix compilation on non-kvm systems]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      658fa66b
  12. 27 6月, 2014 1 次提交
    • A
      spapr_iommu: Make in-kernel TCE table optional · 9bb62a07
      Alexey Kardashevskiy 提交于
      POWER KVM supports an KVM_CAP_SPAPR_TCE capability which allows allocating
      TCE tables in the host kernel memory and handle H_PUT_TCE requests
      targeted to specific LIOBN (logical bus number) right in the host without
      switching to QEMU. At the moment this is used for emulated devices only
      and the handler only puts TCE to the table. If the in-kernel H_PUT_TCE
      handler finds a LIOBN and corresponding table, it will put a TCE to
      the table and complete hypercall execution. The user space will not be
      notified.
      
      Upcoming VFIO support is going to use the same sPAPRTCETable device class
      so KVM_CAP_SPAPR_TCE is going to be used as well. That means that TCE
      tables for VFIO are going to be allocated in the host as well.
      However VFIO operates with real IOMMU tables and simple copying of
      a TCE to the real hardware TCE table will not work as guest physical
      to host physical address translation is requited.
      
      So until the host kernel gets VFIO support for H_PUT_TCE, we better not
      to register VFIO's TCE in the host.
      
      This adds a place holder for KVM_CAP_SPAPR_TCE_VFIO capability. It is not
      in upstream yet and being discussed so now it is always false which means
      that in-kernel VFIO acceleration is not supported.
      
      This adds a bool @vfio_accel flag to the sPAPRTCETable device telling
      that sPAPRTCETable should not try allocating TCE table in the host kernel
      for VFIO. The flag is false now as at the moment there is no VFIO.
      
      This adds an vfio_accel parameter to spapr_tce_new_table(), the semantic
      is the same. Since there is only emulated PCI and VIO now, the flag is set
      to false. Upcoming VFIO support will set it to true.
      
      This is a preparation patch so no change in behaviour is expected
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      9bb62a07
  13. 16 6月, 2014 4 次提交
  14. 05 3月, 2014 3 次提交
    • A
      target-ppc: add PowerPCCPU::cpu_dt_id · 0ce470cd
      Alexey Kardashevskiy 提交于
      Normally CPUState::cpu_index is used to pick the right CPU for various
      operations. However default consecutive numbering does not always work
      for POWERPC.
      
      These indexes are reflected in /proc/device-tree/cpus/PowerPC,POWER7@XX
      and used to call KVM VCPU's ioctls. In order to achieve this,
      kvmppc_fixup_cpu() was introduced. Roughly speaking, it multiplies
      cpu_index by the number of threads per core.
      
      This approach has disadvantages such as:
      1. NUMA configuration stays broken after the fixup;
      2. CPU-targeted commands from the QEMU Monitor do not work properly as
      CPU indexes have been fixed and there is no clear way for the user to
      know what the new CPU indexes are.
      
      This introduces a @cpu_dt_id field in the CPUPPCState struct which
      is initialized from @cpu_index by default and can be fixed later
      to meet the device tree requirements.
      
      This adds an API to handle @cpu_dt_id.
      
      This removes kvmppc_fixup_cpu() as it is not more needed, @cpu_dt_id
      is calculated in ppc_cpu_realize().
      
      This will be used later in machine code.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Acked-by: NMike Day <ncmike@ncultra.org>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      0ce470cd
    • A
      target-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab · c1385933
      Aneesh Kumar K.V 提交于
      This support updating htab managed by the hypervisor. Currently we don't have
      any user for this feature. This actually bring the store_hpte interface
      in-line with the load_hpte one. We may want to use this when we want to
      emulate henter hcall in qemu for HV kvm.
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [ folded fix for the "warn_unused_result" build break in
        kvmppc_hash64_write_pte(), Greg Kurz <gkurz@linux.vnet.ibm.com> ]
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      c1385933
    • A
      target-ppc: Fix page table lookup with kvm enabled · 7c43bca0
      Aneesh Kumar K.V 提交于
      With kvm enabled, we store the hash page table information in the hypervisor.
      Use ioctl to read the htab contents. Without this we get the below error when
      trying to read the guest address
      
       (gdb) x/10 do_fork
       0xc000000000098660 <do_fork>:   Cannot access memory at address 0xc000000000098660
       (gdb)
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [ fixes for 32 bit build (casts!), ldq_phys() API change,
        Greg Kurz <gkurz@linux.vnet.ibm.com ]
      Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      7c43bca0
  15. 26 10月, 2013 1 次提交
  16. 29 7月, 2013 1 次提交
  17. 27 4月, 2013 2 次提交
  18. 16 4月, 2013 1 次提交
  19. 19 1月, 2013 1 次提交
  20. 15 1月, 2013 1 次提交
    • A
      cpu: Move cpu_index field to CPUState · 55e5c285
      Andreas Färber 提交于
      Note that target-alpha accesses this field from TCG, now using a
      negative offset. Therefore the field is placed last in CPUState.
      
      Pass PowerPCCPU to [kvm]ppc_fixup_cpu() to facilitate this change.
      
      Move common parts of mips cpu_state_reset() to mips_cpu_reset().
      
      Acked-by: Richard Henderson <rth@twiddle.net> (for alpha)
      [AF: Rebased onto ppc CPU subclasses and openpic changes]
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      55e5c285
  21. 08 1月, 2013 2 次提交
    • A
      target-ppc: Slim conversion of model definitions to QOM subclasses · 2985b86b
      Andreas Färber 提交于
      Since the model list is highly macrofied, keep ppc_def_t for now and
      save a pointer to it in PowerPCCPUClass. This results in a flat list of
      subclasses including aliases, to be refined later.
      
      Move cpu_ppc_init() to translate_init.c and drop helper.c.
      Long-term the idea is to turn translate_init.c into a standalone cpu.c.
      
      Inline cpu_ppc_usable() into type registration.
      
      Split cpu_ppc_register() in two by code movement into the initfn and
      by turning the remaining part into a realizefn.
      Move qemu_init_vcpu() call into the new realizefn and adapt
      create_ppc_opcodes() to return an Error.
      
      Change ppc_find_by_pvr() -> ppc_cpu_class_by_pvr().
      Change ppc_find_by_name() -> ppc_cpu_class_by_name().
      
      Turn -cpu host into its own subclass. This requires to move the
      kvm_enabled() check in ppc_cpu_class_by_name() to avoid the class being
      found via the normal name lookup in the !kvm_enabled() case.
      Turn kvmppc_host_cpu_def() into the class_init and add an initfn that
      asserts KVM is in fact enabled.
      
      Implement -cpu ? and the QMP equivalent in terms of subclasses.
      This newly exposes -cpu host to the user, ordered last for -cpu ?.
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      2985b86b
    • S
      PPC: KVM: set has-idle in guest device tree · 1a61a9ae
      Stuart Yoder 提交于
      On e500mc, the platform doesn't provide a way for the CPU to go idle.
      
      To still not uselessly burn CPU time, expose an idle hypercall to the guest
      if kvm supports it.
      Signed-off-by: NStuart Yoder <stuart.yoder@freescale.com>
      [agraf: adjust for current code base, add patch description, fix non-kvm case]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      1a61a9ae
  22. 19 12月, 2012 2 次提交
  23. 04 10月, 2012 1 次提交
  24. 24 6月, 2012 1 次提交
    • B
      ppc64: Rudimentary Support for extra page sizes on server CPUs · 4656e1f0
      Benjamin Herrenschmidt 提交于
      More recent Power server chips (i.e. based on the 64 bit hash MMU)
      support more than just the traditional 4k and 16M page sizes.  This
      can get quite complicated, because which page sizes are supported,
      which combinations are supported within an MMU segment and how these
      page sizes are encoded both in the SLB entry and the hash PTE can vary
      depending on the CPU model (they are not specified by the
      architecture).  In addition the firmware or hypervisor may not permit
      use of certain page sizes, for various reasons.  Whether various page
      sizes are supported on KVM, for example, depends on whether the PR or
      HV variant of KVM is in use, and on the page size of the memory
      backing the guest's RAM.
      
      This patch adds information to the CPUState and cpu defs to describe
      the supported page sizes and encodings.  Since TCG does not yet
      support any extended page sizes, we just set this to NULL in the
      static CPU definitions, expanding this to the default 4k and 16M page
      sizes when we initialize the cpu state.  When using KVM, however, we
      instead determine available page sizes using the new
      KVM_PPC_GET_SMMU_INFO call.  For old kernels without that call, we use
      some defaults, with some guesswork which should do the right thing for
      existing HV and PR implementations.  The fallback might not be correct
      for future versions, but that's ok, because they'll have
      KVM_PPC_GET_SMMU_INFO.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      4656e1f0
  25. 15 4月, 2012 1 次提交
    • D
      target-ppc: Add hooks for handling tcg and kvm limitations · 12b1143b
      David Gibson 提交于
      On target-ppc, our table of CPU types and features encodes the features as
      found on the hardware, regardless of whether these features are actually
      usable under TCG or KVM.  We already have cases where the information from
      the cpu table must be fixed up to account for limitations in the emulation
      method we're using.  e.g. TCG does not support the DFP and VSX instructions
      and KVM needs different numbering of the CPUs in order to tell it the
      correct thread to core mappings.
      
      This patch cleans up these hacks to handle emulation limitations by
      consolidating them into a pair of functions specifically for the purpose.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      [AF: Style and typo fixes, rename new functions and drop ppc_def_t arg]
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      12b1143b
  26. 15 3月, 2012 1 次提交
  27. 31 10月, 2011 5 次提交
    • D
      ppc: Fix up usermode only builds · 98efaf75
      David Gibson 提交于
      The recent usage of MemoryRegion in kvm_ppc.h breaks builds with
      CONFIG_USER_ONLY=y.  This patch fixes it.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      98efaf75
    • D
      ppc: First cut implementation of -cpu host · a1e98583
      David Gibson 提交于
      For convenience with kvm, x86 allows the user to specify -cpu host on the
      qemu command line, which means make the guest cpu the same as the host
      cpu.  This patch implements the same option for ppc targets.
      
      For now, this just read the host PVR (Processor Version Register) and
      selects one of our existing CPU specs based on it.  This means that the
      option will not work if the host cpu is not supported by TCG, even if that
      wouldn't matter for use under kvm.
      
      In future, we can extend this in future to override parts of the cpu spec
      based on information obtained from the host (via /proc/cpuinfo, the host
      device tree, or explicit KVM calls).  That will let us handle cases where
      the real kvm-virtualized CPU doesn't behave exactly like the TCG-emulated
      CPU.  With appropriate annotation of the CPU specs we'll also then be able
      to use host cpus under kvm even when there isn't a matching full TCG model.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      a1e98583
    • D
      pseries: Add device tree properties for VMX/VSX and DFP under kvm · 6659394f
      David Gibson 提交于
      Sufficiently recent PAPR specifications define properties "ibm,vmx"
      and "ibm,dfp" on the CPU node which advertise whether the VMX vector
      extensions (or the later VSX version) and/or the Decimal Floating
      Point operations from IBM's recent POWER CPUs are available.
      
      Currently we do not put these in the guest device tree and the guest
      kernel will consequently assume they are not available.  This is good,
      because they are not supported under TCG.  VMX is similar enough to
      Altivec that it might be trivial to support, but VSX and DFP would
      both require significant work to support in TCG.
      
      However, when running under kvm on a host which supports these
      instructions, there's no reason not to let the guest use them.  This
      patch, therefore, checks for the relevant support on the host CPU
      and, if present, advertises them to the guest as well.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      6659394f
    • D
      pseries: Use Book3S-HV TCE acceleration capabilities · 0f5cb298
      David Gibson 提交于
      The pseries machine of qemu implements the TCE mechanism used as a
      virtual IOMMU for the PAPR defined virtual IO devices.  Because the
      PAPR spec only defines a small DMA address space, the guest VIO
      drivers need to update TCE mappings very frequently - the virtual
      network device is particularly bad.  This means many slow exits to
      qemu to emulate the H_PUT_TCE hypercall.
      
      Sufficiently recent kernels allow this to be mitigated by implementing
      H_PUT_TCE in the host kernel.  To make use of this, however, qemu
      needs to initialize the necessary TCE tables, and map them into itself
      so that the VIO device implementations can retrieve the mappings when
      they access guest memory (which is treated as a virtual DMA
      operation).
      
      This patch adds the necessary calls to use the KVM TCE acceleration.
      If the kernel does not support acceleration, or there is some other
      error creating the accelerated TCE table, then it will still fall back
      to full userspace TCE implementation.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      0f5cb298
    • D
      pseries: Allow KVM Book3S-HV on PPC970 CPUS · 354ac20a
      David Gibson 提交于
      At present, using the hypervisor aware Book3S-HV KVM will only work
      with qemu on POWER7 CPUs.  PPC970 CPUs also have hypervisor
      capability, but they lack the VRMA feature which makes assigning guest
      memory easier.
      
      In order to allow KVM Book3S-HV on PPC970, we need to specially
      allocate the first chunk of guest memory (the "Real Mode Area" or
      RMA), so that it is physically contiguous.
      
      Sufficiently recent host kernels allow such contiguous RMAs to be
      allocated, with a kvm capability advertising whether the feature is
      available and/or necessary on this hardware.  This patch enables qemu
      to use this support, thus allowing kvm acceleration of pseries qemu
      machines on PPC970 hardware.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      
      ---
      
      agraf: fix to use memory api
      354ac20a