1. 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
  2. 16 6月, 2014 4 次提交
  3. 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
  4. 26 10月, 2013 1 次提交
  5. 29 7月, 2013 1 次提交
  6. 27 4月, 2013 2 次提交
  7. 16 4月, 2013 1 次提交
  8. 19 1月, 2013 1 次提交
  9. 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
  10. 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
  11. 19 12月, 2012 2 次提交
  12. 04 10月, 2012 1 次提交
  13. 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
  14. 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
  15. 15 3月, 2012 1 次提交
  16. 31 10月, 2011 6 次提交
    • 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
    • D
      pseries: Support SMT systems for KVM Book3S-HV · e97c3636
      David Gibson 提交于
      Alex Graf has already made qemu support KVM for the pseries machine
      when using the Book3S-PR KVM variant (which runs the guest in
      usermode, emulating supervisor operations).  This code allows gets us
      very close to also working with KVM Book3S-HV (using the hypervisor
      capabilities of recent POWER CPUs).
      
      This patch moves us another step towards Book3S-HV support by
      correctly handling SMT (multithreaded) POWER CPUs.  There are two
      parts to this:
      
       * Querying KVM to check SMT capability, and if present, adjusting the
         cpu numbers that qemu assigns to cause KVM to assign guest threads
         to cores in the right way (this isn't automatic, because the POWER
         HV support has a limitation that different threads on a single core
         cannot be in different guests at the same time).
      
       * Correctly informing the guest OS of the SMT thread to core mappings
         via the device tree.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      e97c3636
  17. 06 10月, 2011 5 次提交
  18. 08 4月, 2011 1 次提交
  19. 02 4月, 2011 1 次提交
  20. 05 9月, 2010 1 次提交
    • A
      KVM: PPC: Add level based interrupt logic · fc87e185
      Alexander Graf 提交于
      KVM on PowerPC used to have completely broken interrupt logic. Usually,
      interrupts work by having a PIC that pulls a line up/down, so the CPU knows
      that an interrupt is active. This line stays active until some action is
      done to the PIC to release the line.
      
      On KVM for PPC, we just checked if there was an interrupt pending and pulled
      a line in the kernel module. We never released it though, hoping that kernel
      space would just declare an interrupt as released when injected - which is
      wrong.
      
      To fix this, we need to completely redesign the interrupt injection logic.
      Whenever an interrupt line gets triggered, we need to notify kernel space
      that the line is up. Whenever it gets released, we do the same. This way
      we can assure that the interrupt state is always known to kernel space.
      
      This fixes random stalls in KVM guests on PowerPC that were waiting for
      an interrupt while everyone else thought they received it already.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      fc87e185
  21. 27 8月, 2010 1 次提交
    • A
      PPC: Add PV hypercall transport through fw_cfg · 45024f09
      Alexander Graf 提交于
      On KVM for PPC we need to tell the guest which instructions to use when
      doing a hypercall. The clean way to do this is to go through an ioctl
      from userspace and passing it on to the guest using the device tree.
      
      So let's do the qemu part here: read out the hypercall and pass it on
      to the guest's fw_cfg so openBIOS can read it out and expose it again.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      45024f09
  22. 14 2月, 2010 1 次提交
    • A
      PPC: tell the guest about the time base frequency · dc333cd6
      Alexander Graf 提交于
      Our guest systems need to know by how much the timebase increases every second,
      so there usually is a "timebase-frequency" property in the cpu leaf of the
      device tree.
      
      This property is missing in OpenBIOS.
      
      With qemu, Linux's fallback timebase speed and qemu's internal timebase speed
      match up. With KVM, that is no longer true. The guest is running at the same
      timebase speed as the host.
      
      This leads to massive timing problems. On my test machine, a "sleep 2" takes
      about 14 seconds with KVM enabled.
      
      This patch exports the timebase frequency to OpenBIOS, so it can then put them
      into the device tree.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      dc333cd6
  23. 25 1月, 2009 1 次提交