1. 10 1月, 2018 1 次提交
  2. 15 12月, 2017 1 次提交
  3. 17 10月, 2017 1 次提交
    • I
      ppc: spapr: use generic cpu_model parsing · 2e9c10eb
      Igor Mammedov 提交于
      use generic cpu_model parsing introduced by
       (6063d4c0 vl.c: convert cpu_model to cpu type and set of global properties before machine_init())
      
      it allows to:
        * replace sPAPRMachineClass::tcg_default_cpu with
          MachineClass::default_cpu_type
        * drop cpu_parse_cpu_model() from hw/ppc/spapr.c and reuse
          one in vl.c
        * simplify spapr_get_cpu_core_type() by removing
          not needed anymore recurrsion since alias look up
          happens earlier at vl.c and spapr_get_cpu_core_type()
          works only with resulted from that cpu type.
        * spapr no more needs to parse/depend on being phased out
          MachineState::cpu_model, all tha parsing done by generic
          code and target specific callback.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      [dwg: Correct minor compile error]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      2e9c10eb
  4. 27 9月, 2017 1 次提交
    • G
      spapr: fix the value of SDR1 in kvmppc_put_books_sregs() · 1ec26c75
      Greg Kurz 提交于
      When running with KVM PR, if a new HPT is allocated we need to inform
      KVM about the HPT address and size. This is currently done by hacking
      the value of SDR1 and pushing it to KVM in several places.
      
      Also, migration breaks the guest since it is very unlikely the HPT has
      the same address in source and destination, but we push the incoming
      value of SDR1 to KVM anyway.
      
      This patch introduces a new virtual hypervisor hook so that the spapr
      code can provide the correct value of SDR1 to be pushed to KVM each
      time kvmppc_put_books_sregs() is called.
      
      It allows to get rid of all the hacking in the spapr/kvmppc code and
      it fixes migration of nested KVM PR.
      Suggested-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      1ec26c75
  5. 08 9月, 2017 5 次提交
  6. 01 9月, 2017 1 次提交
  7. 09 8月, 2017 2 次提交
  8. 30 6月, 2017 2 次提交
    • D
      ppc: Rework CPU compatibility testing across migration · d5fc133e
      David Gibson 提交于
      Migrating between different CPU versions is a bit complicated for ppc.
      A long time ago, we ensured identical CPU versions at either end by
      checking the PVR had the same value.  However, this breaks under KVM
      HV, because we always have to use the host's PVR - it's not
      virtualized.  That would mean we couldn't migrate between hosts with
      different PVRs, even if the CPUs are close enough to compatible in
      practice (sometimes identical cores with different surrounding logic
      have different PVRs, so this happens in practice quite often).
      
      So, we removed the PVR check, but instead checked that several flags
      indicating supported instructions matched.  This turns out to be a bad
      idea, because those instruction masks are not architected information, but
      essentially a TCG implementation detail.  So changes to qemu internal CPU
      modelling can break migration - this happened between qemu-2.6 and
      qemu-2.7.  That was addressed by 146c11f1 "target-ppc: Allow eventual
      removal of old migration mistakes".
      
      Now, verification of CPU compatibility across a migration basically doesn't
      happen.  We simply ignore the PVR of the incoming migration, and hope the
      cpu on the destination is close enough to work.
      
      Now that we've cleaned up handling of processor compatibility modes
      for pseries machine type, we can do better.  For new machine types
      (pseries-2.10+) We allow migration if:
      
          * The source and destination PVRs are for the same type of CPU, as
            determined by CPU class's pvr_match function
      OR  * When the source was in a compatibility mode, and the destination CPU
            supports the same compatibility mode
      
      For older machine types we retain the existing behaviour - current CAS
      code will usually set a compat mode which would break backwards
      migration if we made them use the new behaviour. [Fixed from an
      earlier version by Greg Kurz].
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Tested-by: NAndrea Bolognani <abologna@redhat.com>
      d5fc133e
    • D
      pseries: Move CPU compatibility property to machine · 7843c0d6
      David Gibson 提交于
      Server class POWER CPUs have a "compat" property, which is used to set the
      backwards compatibility mode for the processor.  However, this only makes
      sense for machine types which don't give the guest access to hypervisor
      privilege - otherwise the compatibility level is under the guest's control.
      
      To reflect this, this removes the CPU 'compat' property and instead
      creates a 'max-cpu-compat' property on the pseries machine.  Strictly
      speaking this breaks compatibility, but AFAIK the 'compat' option was
      never (directly) used with -device or device_add.
      
      The option was used with -cpu.  So, to maintain compatibility, this
      patch adds a hack to the cpu option parsing to strip out any compat
      options supplied with -cpu and set them on the machine property
      instead of the now deprecated cpu property.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Tested-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NAndrea Bolognani <abologna@redhat.com>
      7843c0d6
  9. 06 6月, 2017 1 次提交
  10. 11 5月, 2017 3 次提交
    • T
      target/ppc: Avoid printing wrong aliases in CPU help text · e9edd931
      Thomas Huth 提交于
      When running with KVM, we update the "family" CPU alias to point
      to the right host CPU type, so that it for example possible to
      use "-cpu POWER8" on a POWER8NVL host. However, the function for
      printing the list of available CPU models is called earlier than
      the KVM setup code, so the output of "-cpu help" is wrong in that
      case. Since it would be somewhat ugly anyway to have different
      help texts depending on whether "-enable-kvm" has been specified
      or not, we should better always print the same text, so fix this
      issue by printing "alias for preferred XXX CPU" instead.
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      e9edd931
    • S
      target/ppc: Implement ISA V3.00 radix page fault handler · d5fee0bb
      Suraj Jitindar Singh 提交于
      ISA V3.00 introduced a new radix mmu model. Implement the page fault
      handler for this so we can run a tcg guest in radix mode and perform
      address translation correctly.
      
      In real mode (mmu turned off) addresses are masked to remove the top
      4 bits and then are subject to partition scoped translation, since we only
      support pseries at this stage it is only necessary to perform the masking
      and then we're done.
      
      In virtual mode (mmu turned on) address translation if performed as
      follows:
      
      1. Use the quadrant to determine the fully qualified address.
      
      The fully qualified address is defined as the combination of the effective
      address, the effective logical partition id (LPID) and the effective
      process id (PID). Based on the quadrant (EA63:62) we set the pid and lpid
      like so:
      
      quadrant 0: lpid = LPIDR, pid = PIDR
      quadrant 1: HV only (not allowed in pseries)
      quadrant 2: HV only (not allowed in pseries)
      quadrant 3: lpid = LPIDR, pid = 0
      
      If we can't get the fully qualified address we raise a segment interrupt.
      
      2. Find the guest radix tree
      
      We ask the virtual hypervisor for the partition table which was registered
      with H_REGISTER_PROC_TBL which points us to the process table in guest
      memory. We then index this table by pid to get the process table entry
      which points us to the appropriate radix tree to translate the address.
      
      If the process table isn't big enough to contain an entry for the current
      pid then we raise a storage interrupt.
      
      3. Walk the radix tree
      
      Next we walk the radix tree where each level is a table of page directory
      entries indexed by some number of bits from the effective address, where
      the number of bits is determined by the table size. We continue to walk
      the tree (while entries are valid and the table is of minimum size) until
      we reach a table of page table entries, indicated by having the leaf bit
      set. The appropriate pte is then checked for sufficient access permissions,
      the reference and change bits are updated and the real address is
      calculated from the real page number bits of the pte and the low bits of
      the effective address.
      
      If we can't find an entry or can't access the entry bacause of permissions
      then we raise a storage interrupt.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      [dwg: Add missing parentheses to macro]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d5fee0bb
    • N
      tcg: enable MTTCG by default for PPC64 on x86 · f0b0685d
      Nikunj A Dadhania 提交于
      This enables the multi-threaded system emulation by default for PPC64
      guests using the x86_64 TCG back-end.
      Signed-off-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f0b0685d
  11. 26 4月, 2017 2 次提交
    • C
      ppc/xics: introduce an 'intc' backlink under PowerPCCPU · ad5d1add
      Cédric Le Goater 提交于
      Today, the ICPState array of the sPAPR machine is indexed with
      'cpu_index' of the CPUState. This numbering of CPUs is internal to
      QEMU and the guest only knows about what is exposed in the device
      tree, that is the 'cpu_dt_id'. This is why sPAPR uses the helper
      xics_get_cpu_index_by_dt_id() to do the mapping in a couple of places.
      
      To provide a more generic XICS layer, we need to abstract the IRQ
      'server' number and remove any assumption made on its nature. It
      should not be used as a 'cpu_index' for lookups like xics_cpu_setup()
      and xics_cpu_destroy() do.
      
      To reach that goal, we choose to introduce a generic 'intc' backlink
      under PowerPCCPU, and let the machine core init routine do the
      ICPState lookup. The resulting object is passed on to xics_cpu_setup()
      which does the store under PowerPCCPU. The IRQ 'server' number in XICS
      is now generic. sPAPR uses 'cpu_dt_id' and PowerNV will use 'PIR'
      number.
      
      This also has the benefit of simplifying the sPAPR hcall routines
      which do not need to do any ICPState lookups anymore.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ad5d1add
    • S
      spapr: Add ibm,processor-radix-AP-encodings to the device tree · c64abd1f
      Sam Bobroff 提交于
      Use the new ioctl, KVM_PPC_GET_RMMU_INFO, to fetch radix MMU
      information from KVM and present the page encodings in the device tree
      under ibm,processor-radix-AP-encodings. This provides page size
      information to the guest which is necessary for it to use radix mode.
      Signed-off-by: NSam Bobroff <sam.bobroff@au1.ibm.com>
      [dwg: Compile fix for 32-bit targets, style nit fix]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      c64abd1f
  12. 14 3月, 2017 1 次提交
  13. 03 3月, 2017 4 次提交
    • S
      target/ppc: Rework hash mmu page fault code and add defines for clarity · da82c73a
      Suraj Jitindar Singh 提交于
      The hash mmu page fault handling code is responsible for generating ISIs
      and DSIs when access permissions cause an access to fail. Part of this
      involves setting the srr1 or dsisr registers to indicate what causes the
      access to fail. Add defines for the bit fields of these registers and
      rework the code to use these new defines in order to improve readability
      and code clarity.
      
      While we're here, update what is logged when an access fails to include
      information as to what caused to access to fail for debug purposes.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      [dwg: Moved constants to cpu.h since they're not MMUv3 specific]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      da82c73a
    • S
      target/ppc: Move no-execute and guarded page checking into new function · 07a68f99
      Suraj Jitindar Singh 提交于
      A pte entry has bit fields which can be used to make a page no-execute or
      guarded, if either of these bits are set then an instruction access to this
      page will fail. Currently these bits are checked with the pp_prot function
      however the ISA specifies that the access authority controlled by the
      key-pp value pair should only be checked on an instruction access after
      the no-execute and guard bits have already been verified to permit the
      access.
      
      Move the no-execute and guard bit checking into a new separate function.
      Note that we can remove the check for the no-execute bit in the slb entry
      since this check was already performed above when we obtained the slb
      entry.
      
      In the event that the no-execute or guard bits are set, an ISI should be
      generated with the SRR1_NOEXEC_GUARD (0x10000000) bit set in srr1. Add a
      define for this for clarity.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      [dwg: Move constants to cpu.h since they're not MMUv3 specific]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      07a68f99
    • S
      target/ppc: Add Instruction Authority Mask Register Check · a6152b52
      Suraj Jitindar Singh 提交于
      The instruction authority mask register (IAMR) can be used to restrict
      permissions for instruction fetch accesses on a per key basis for each
      of 32 different key values. Access permissions are derived based on the
      specific key value stored in the relevant page table entry.
      
      The IAMR was introduced in, and is present in processors since, POWER8
      (ISA v2.07). Thus introduce a function to check access permissions based
      on the pte key value and the contents of the IAMR when handling a page
      fault to ensure sufficient access permissions for an instruction fetch.
      
      A hash pte contains a key value in bits 2:3|52:54 of the second double word
      of the pte, this key value gives an index into the IAMR which contains 32
      2-bit access masks. If the least significant bit of the 2-bit access mask
      corresponding to the given key value is set (IAMR[key] & 0x1 == 0x1) then
      the instruction fetch is not permitted and an ISI is generated accordingly.
      While we're here, add defines for the srr1 bits to be set for the ISI for
      clarity.
      
      e.g.
      
      pte:
      dw0 [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
      dw1 [XX01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX010XXXXXXXXX]
             ^^                                                ^^^
      key = 01010 (0x0a)
      
      IAMR: [XXXXXXXXXXXXXXXXXXXX01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
                                 ^^
      Access mask = 0b01
      
      Test access mask: 0b01 & 0x1 == 0x1
      
      Least significant bit of the access mask is set, thus the instruction fetch
      is not permitted. We should generate an instruction storage interrupt (ISI)
      with bit 42 of SRR1 set to indicate access precluded by virtual page class
      key protection.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      [dwg: Move new constants to cpu.h, since they're not MMUv3 specific]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a6152b52
    • S
      target/ppc: Add patb_entry to sPAPRMachineState · 9861bb3e
      Suraj Jitindar Singh 提交于
      ISA v3.00 adds the idea of a partition table which is used to store the
      address translation details for all partitions on the system. The partition
      table consists of double word entries indexed by partition id where the second
      double word contains the location of the process table in guest memory. The
      process table is registered by the guest via a h-call.
      
      We need somewhere to store the address of the process table so we add an entry
      to the sPAPRMachineState struct called patb_entry to represent the second
      doubleword of a single partition table entry corresponding to the current
      guest. We need to store this value so we know if the guest is using radix or
      hash translation and the location of the corresponding process table in guest
      memory. Since we only have a single guest per qemu instance, we only need one
      entry.
      
      Since the partition table is technically a hypervisor resource we require that
      access to it is abstracted by the virtual hypervisor through the get_patbe()
      call. Currently the value of the entry is never set (and thus
      defaults to 0 indicating hash), but it will be required to both implement
      POWER9 kvm support and tcg radix support.
      
      We also add this field to be migrated as part of the sPAPRMachineState as we
      will need it on the receiving side as the guest will never tell us this
      information again and we need it to perform translation.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      9861bb3e
  14. 01 3月, 2017 8 次提交
    • M
      Add PowerPC 32-bit guest memory dump support · 356bb70e
      Mike Nawrocki 提交于
      This patch extends support for the `dump-guest-memory` command to the
      32-bit PowerPC architecture. It relies on the assumption that a 64-bit
      guest will not dump a 32-bit core file (and vice versa).
      
      [dwg: I suspect this patch won't cover all cases, in particular a
      32-bit machine type on a 64-bit qemu build.  However, it does strictly
      more than what we had before, so might as well apply as a starting
      point]
      Signed-off-by: NMike Nawrocki <michael.nawrocki@gtri.gatech.edu>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      356bb70e
    • N
      target/ppc: support for 32-bit carry and overflow · dd09c361
      Nikunj A Dadhania 提交于
      POWER ISA 3.0 adds CA32 and OV32 status in 64-bit mode. Add the flags
      and corresponding defines.
      
      Moreover, CA32 is updated when CA is updated and OV32 is updated when OV
      is updated.
      
      Arithmetic instructions:
          * Addition and Substractions:
      
              addic, addic., subfic, addc, subfc, adde, subfe, addme, subfme,
              addze, and subfze always updates CA and CA32.
      
              => CA reflects the carry out of bit 0 in 64-bit mode and out of
                 bit 32 in 32-bit mode.
              => CA32 reflects the carry out of bit 32 independent of the
                 mode.
      
              => SO and OV reflects overflow of the 64-bit result in 64-bit
                 mode and overflow of the low-order 32-bit result in 32-bit
                 mode
              => OV32 reflects overflow of the low-order 32-bit independent of
                 the mode
      
          * Multiply Low and Divide:
      
              For mulld, divd, divde, divdu and divdeu: SO, OV, and OV32 bits
              reflects overflow of the 64-bit result
      
              For mullw, divw, divwe, divwu and divweu: SO, OV, and OV32 bits
              reflects overflow of the 32-bit result
      
           * Negate with OE=1 (nego)
      
             For 64-bit mode if the register RA contains
             0x8000_0000_0000_0000, OV and OV32 are set to 1.
      
             For 32-bit mode if the register RA contains 0x8000_0000, OV and
             OV32 are set to 1.
      Signed-off-by: NNikunj A Dadhania <nikunj@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      dd09c361
    • D
      target/ppc: Manage external HPT via virtual hypervisor · e57ca75c
      David Gibson 提交于
      The pseries machine type implements the behaviour of a PAPR compliant
      hypervisor, without actually executing such a hypervisor on the virtual
      CPU.  To do this we need some hooks in the CPU code to make hypervisor
      facilities get redirected to the machine instead of emulated internally.
      
      For hypercalls this is managed through the cpu->vhyp field, which points
      to a QOM interface with a method implementing the hypercall.
      
      For the hashed page table (HPT) - also a hypervisor resource - we use an
      older hack.  CPUPPCState has an 'external_htab' field which when non-NULL
      indicates that the HPT is stored in qemu memory, rather than within the
      guest's address space.
      
      For consistency - and to make some future extensions easier - this merges
      the external HPT mechanism into the vhyp mechanism.  Methods are added
      to vhyp for the basic operations the core hash MMU code needs: map_hptes()
      and unmap_hptes() for reading the HPT, store_hpte() for updating it and
      hpt_mask() to retrieve its size.
      
      To match this, the pseries machine now sets these vhyp fields in its
      existing vhyp class, rather than reaching into the cpu object to set the
      external_htab field.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      e57ca75c
    • D
      target/ppc: Eliminate htab_base and htab_mask variables · 36778660
      David Gibson 提交于
      CPUPPCState includes fields htab_base and htab_mask which store the base
      address (GPA) and size (as a mask) of the guest's hashed page table (HPT).
      These are set when the SDR1 register is updated.
      
      Keeping these in sync with the SDR1 is actually a little bit fiddly, and
      probably not useful for performance, since keeping them expands the size of
      CPUPPCState.  It also makes some upcoming changes harder to implement.
      
      This patch removes these fields, in favour of calculating them directly
      from the SDR1 contents when necessary.
      
      This does make a change to the behaviour of attempting to write a bad value
      (invalid HPT size) to the SDR1 with an mtspr instruction.  Previously, the
      bad value would be stored in SDR1 and could be retrieved with a later
      mfspr, but the HPT size as used by the softmmu would be, clamped to the
      allowed values.  Now, writing a bad value is treated as a no-op.  An error
      message is printed in both new and old versions.
      
      I'm not sure which behaviour, if either, matches real hardware.  I don't
      think it matters that much, since it's pretty clear that if an OS writes
      a bad value to SDR1, it's not going to boot.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      36778660
    • D
      target/ppc: Cleanup HPTE accessors for 64-bit hash MMU · 7222b94a
      David Gibson 提交于
      Accesses to the hashed page table (HPT) are complicated by the fact that
      the HPT could be in one of three places:
         1) Within guest memory - when we're emulating a full guest CPU at the
            hardware level (e.g. powernv, mac99, g3beige)
         2) Within qemu, but outside guest memory - when we're emulating user and
            supervisor instructions within TCG, but instead of emulating
            the CPU's hypervisor mode, we just emulate a hypervisor's behaviour
            (pseries in TCG or KVM-PR)
         3) Within the host kernel - a pseries machine using KVM-HV
            acceleration.  Mostly accesses to the HPT are handled by KVM,
            but there are a few cases where qemu needs to access it via a
            special fd for the purpose.
      
      In order to batch accesses to the fd in case (3), we use a somewhat awkward
      ppc_hash64_start_access() / ppc_hash64_stop_access() pair, which for case
      (3) reads / releases several HPTEs from the kernel as a batch (usually a
      whole PTEG).  For cases (1) & (2) it just returns an address value.  The
      actual HPTE load helpers then need to interpret the returned token
      differently in the 3 cases.
      
      This patch keeps the same basic structure, but simplfiies the details.
      First start_access() / stop_access() are renamed to map_hptes() and
      unmap_hptes() to make their operation more obvious.  Second, map_hptes()
      now always returns a qemu pointer, which can always be used in the same way
      by the load_hpte() helpers.  In case (1) it comes from address_space_map()
      in case (2) directly from qemu's HPT buffer and in case (3) from a
      temporary buffer read from the KVM fd.
      
      While we're at it, make things a bit more consistent in terms of types and
      variable names: avoid variables named 'index' (it shadows index(3) which
      can lead to confusing results), use 'hwaddr ptex' for HPTE indices and
      uint64_t for each of the HPTE words, use ptex throughout the call stack
      instead of pte_offset in some places (we still need that at the bottom
      layer, but nowhere else).
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      7222b94a
    • D
      target/ppc: Merge cpu_ppc_set_vhyp() with cpu_ppc_set_papr() · b7b0b1f1
      David Gibson 提交于
      cpu_ppc_set_papr() sets up various aspects of CPU state for use with PAPR
      paravirtualized guests.  However, it doesn't set the virtual hypervisor,
      so callers must also call cpu_ppc_set_vhyp() so that PAPR hypercalls are
      handled properly.  This is a bit silly, so fold setting the virtual
      hypervisor into cpu_ppc_set_papr().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      b7b0b1f1
    • D
      target/ppc: Fix KVM-HV HPTE accessors · 1ad9f0a4
      David Gibson 提交于
      When a 'pseries' guest is running with KVM-HV, the guest's hashed page
      table (HPT) is stored within the host kernel, so it is not directly
      accessible to qemu.  Most of the time, qemu doesn't need to access it:
      we're using the hardware MMU, and KVM itself implements the guest
      hypercalls for manipulating the HPT.
      
      However, qemu does need access to the in-KVM HPT to implement
      get_phys_page_debug() for the benefit of the gdbstub, and maybe for
      other debug operations.
      
      To allow this, 7c43bca0 "target-ppc: Fix page table lookup with kvm
      enabled" added kvmppc_hash64_read_pteg() to target/ppc/kvm.c to read
      in a batch of HPTEs from the KVM table.  Unfortunately, there are a
      couple of problems with this:
      
      First, the name of the function implies it always reads a whole PTEG
      from the HPT, but in fact in some cases it's used to grab individual
      HPTEs (which ends up pulling 8 HPTEs, not aligned to a PTEG from the
      kernel).
      
      Second, and more importantly, the code to read the HPTEs from KVM is
      simply wrong, in general.  The data from the fd that KVM provides is
      designed mostly for compact migration rather than this sort of one-off
      access, and so needs some decoding for this purpose.  The current code
      will work in some cases, but if there are invalid HPTEs then it will
      not get sane results.
      
      This patch rewrite the HPTE reading function to have a simpler
      interface (just read n HPTEs into a caller provided buffer), and to
      correctly decode the stream from the kernel.
      
      For consistency we also clean up the similar function for altering
      HPTEs within KVM (introduced in c1385933 "target-ppc: Update
      ppc_hash64_store_hpte to support updating in-kernel htab").
      
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      1ad9f0a4
    • N
  15. 22 2月, 2017 2 次提交
  16. 31 1月, 2017 5 次提交
    • S
      target/ppc: Add pcr_supported to POWER9 cpu class definition · 216c944e
      Suraj Jitindar Singh 提交于
      pcr_supported is used to define the supported PCR values for a given
      processor. A POWER9 processor can support 3.00, 2.07, 2.06 and 2.05
      compatibility modes, thus we set this accordingly.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      216c944e
    • D
      ppc: Add ppc_set_compat_all() · f6f242c7
      David Gibson 提交于
      Once a compatiblity mode is negotiated with the guest,
      h_client_architecture_support() uses run_on_cpu() to update each CPU to
      the new mode.  We're going to want this logic somewhere else shortly,
      so make a helper function to do this global update.
      
      We put it in target-ppc/compat.c - it makes as much sense at the CPU level
      as it does at the machine level.  We also move the cpu_synchronize_state()
      into ppc_set_compat(), since it doesn't really make any sense to call that
      without synchronizing state.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f6f242c7
    • D
      ppc: Validate compatibility modes when setting · 9d2179d6
      David Gibson 提交于
      Current ppc_set_compat() will attempt to set any compatiblity mode
      specified, regardless of whether it's available on the CPU.  The caller is
      expected to make sure it is setting a possible mode, which is awkwward
      because most of the information to make that decision is at the CPU level.
      
      This begins to clean this up by introducing a ppc_check_compat() function
      which will determine if a given compatiblity mode is supported on a CPU
      (and also whether it lies within specified minimum and maximum compat
      levels, which will be useful later).  It also contains an assertion that
      the CPU has a "virtual hypervisor"[1], that is, that the guest isn't
      permitted to execute hypervisor privilege code.  Without that, the guest
      would own the PCR and so could override any mode set here.  Only machine
      types which use a virtual hypervisor (i.e. 'pseries') should use
      ppc_check_compat().
      
      ppc_set_compat() is modified to validate the compatibility mode it is given
      and fail if it's not available on this CPU.
      
      [1] Or user-only mode, which also obviously doesn't allow access to the
      hypervisor privileged PCR.  We don't use that now, but could in future.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      9d2179d6
    • D
      ppc: Rewrite ppc_get_compat_smt_threads() · 12dbeb16
      David Gibson 提交于
      To continue consolidation of compatibility mode information, this rewrites
      the ppc_get_compat_smt_threads() function using the table of compatiblity
      modes in target-ppc/compat.c.
      
      It's not a direct replacement, the new ppc_compat_max_threads() function
      has simpler semantics - it just returns the number of threads the cpu
      model has, taking into account any compatiblity mode it is in.
      
      This no longer takes into account kvmppc_smt_threads() as the previous
      version did.  That check wasn't useful because we check in
      ppc_cpu_realizefn() that CPUs aren't instantiated with more threads
      than kvm allows (or if we didn't things will already be broken and
      this won't make it any worse).
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      12dbeb16
    • D
      ppc: Rewrite ppc_set_compat() · 9d6f1065
      David Gibson 提交于
      This rewrites the ppc_set_compat() function so that instead of open coding
      the various compatibility modes, it reads the relevant data from a table.
      This is a first step in consolidating the information on compatibility
      modes scattered across the code into a single place.
      
      It also makes one change to the logic.  The old code masked the bits
      to be set in the PCR (Processor Compatibility Register) by which bits
      are valid on the host CPU.  This made no sense, since it was done
      regardless of whether our guest CPU was the same as the host CPU or
      not.  Furthermore, the actual PCR bits are only relevant for TCG[1] -
      KVM instead uses the compatibility mode we tell it in
      kvmppc_set_compat().  When using TCG host cpu information usually
      isn't even present.
      
      While we're at it, we put the new implementation in a new file to make the
      enormous translate_init.c a little smaller.
      
      [1] Actually it doesn't even do anything in TCG, but it will if / when we
          get to implementing compatibility mode logic at that level.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      9d6f1065