1. 30 5月, 2014 1 次提交
    • A
      KVM: PPC: Make shared struct aka magic page guest endian · 5deb8e7a
      Alexander Graf 提交于
      The shared (magic) page is a data structure that contains often used
      supervisor privileged SPRs accessible via memory to the user to reduce
      the number of exits we have to take to read/write them.
      
      When we actually share this structure with the guest we have to maintain
      it in guest endianness, because some of the patch tricks only work with
      native endian load/store operations.
      
      Since we only share the structure with either host or guest in little
      endian on book3s_64 pr mode, we don't have to worry about booke or book3s hv.
      
      For booke, the shared struct stays big endian. For book3s_64 hv we maintain
      the struct in host native endian, since it never gets shared with the guest.
      
      For book3s_64 pr we introduce a variable that tells us which endianness the
      shared struct is in and route every access to it through helper inline
      functions that evaluate this variable.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      5deb8e7a
  2. 17 10月, 2013 3 次提交
    • A
      kvm: powerpc: book3s: Support building HV and PR KVM as module · 2ba9f0d8
      Aneesh Kumar K.V 提交于
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [agraf: squash in compile fix]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      2ba9f0d8
    • A
      kvm: powerpc: Add kvmppc_ops callback · 3a167bea
      Aneesh Kumar K.V 提交于
      This patch add a new callback kvmppc_ops. This will help us in enabling
      both HV and PR KVM together in the same kernel. The actual change to
      enable them together is done in the later patch in the series.
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [agraf: squash in booke changes]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      3a167bea
    • P
      KVM: PPC: Book3S PR: Keep volatile reg values in vcpu rather than shadow_vcpu · a2d56020
      Paul Mackerras 提交于
      Currently PR-style KVM keeps the volatile guest register values
      (R0 - R13, CR, LR, CTR, XER, PC) in a shadow_vcpu struct rather than
      the main kvm_vcpu struct.  For 64-bit, the shadow_vcpu exists in two
      places, a kmalloc'd struct and in the PACA, and it gets copied back
      and forth in kvmppc_core_vcpu_load/put(), because the real-mode code
      can't rely on being able to access the kmalloc'd struct.
      
      This changes the code to copy the volatile values into the shadow_vcpu
      as one of the last things done before entering the guest.  Similarly
      the values are copied back out of the shadow_vcpu to the kvm_vcpu
      immediately after exiting the guest.  We arrange for interrupts to be
      still disabled at this point so that we can't get preempted on 64-bit
      and end up copying values from the wrong PACA.
      
      This means that the accessor functions in kvm_book3s.h for these
      registers are greatly simplified, and are same between PR and HV KVM.
      In places where accesses to shadow_vcpu fields are now replaced by
      accesses to the kvm_vcpu, we can also remove the svcpu_get/put pairs.
      Finally, on 64-bit, we don't need the kmalloc'd struct at all any more.
      
      With this, the time to read the PVR one million times in a loop went
      from 567.7ms to 575.5ms (averages of 6 values), an increase of about
      1.4% for this worse-case test for guest entries and exits.  The
      standard deviation of the measurements is about 11ms, so the
      difference is only marginally significant statistically.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      a2d56020
  3. 08 7月, 2013 1 次提交
  4. 27 4月, 2013 2 次提交
  5. 10 1月, 2013 2 次提交
  6. 06 12月, 2012 1 次提交
  7. 06 5月, 2012 2 次提交
    • A
      KVM: PPC: Emulator: clean up SPR reads and writes · 54771e62
      Alexander Graf 提交于
      When reading and writing SPRs, every SPR emulation piece had to read
      or write the respective GPR the value was read from or stored in itself.
      
      This approach is pretty prone to failure. What if we accidentally
      implement mfspr emulation where we just do "break" and nothing else?
      Suddenly we would get a random value in the return register - which is
      always a bad idea.
      
      So let's consolidate the generic code paths and only give the core
      specific SPR handling code readily made variables to read/write from/to.
      
      Functionally, this patch doesn't change anything, but it increases the
      readability of the code and makes is less prone to bugs.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      54771e62
    • A
      KVM: PPC: Emulator: clean up instruction parsing · c46dc9a8
      Alexander Graf 提交于
      Instructions on PPC are pretty similarly encoded. So instead of
      every instruction emulation code decoding the instruction fields
      itself, we can move that code to more generic places and rely on
      the compiler to optimize the unused bits away.
      
      This has 2 advantages. It makes the code smaller and it makes the
      code less error prone, as the instruction fields are always
      available, so accidental misusage is reduced.
      
      Functionally, this patch doesn't change anything.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      c46dc9a8
  8. 02 4月, 2012 1 次提交
  9. 05 3月, 2012 1 次提交
  10. 26 9月, 2011 2 次提交
  11. 24 10月, 2010 5 次提交
    • A
      KVM: PPC: Move BAT handling code into spr handler · c1c88e2f
      Alexander Graf 提交于
      The current approach duplicates the spr->bat finding logic and makes it harder
      to reuse the actually used variables. So let's move everything down to the spr
      handler.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      c1c88e2f
    • A
      KVM: PPC: Convert SRR0 and SRR1 to shared page · de7906c3
      Alexander Graf 提交于
      The SRR0 and SRR1 registers contain cached values of the PC and MSR
      respectively. They get written to by the hypervisor when an interrupt
      occurs or directly by the kernel. They are also used to tell the rfi(d)
      instruction where to jump to.
      
      Because it only gets touched on defined events that, it's very simple to
      share with the guest. Hypervisor and guest both have full r/w access.
      
      This patch converts all users of the current field to the shared page.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      de7906c3
    • A
      KVM: PPC: Convert DAR to shared page. · 5e030186
      Alexander Graf 提交于
      The DAR register contains the address a data page fault occured at. This
      register behaves pretty much like a simple data storage register that gets
      written to on data faults. There is no hypervisor interaction required on
      read or write.
      
      This patch converts all users of the current field to the shared page.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      5e030186
    • A
      KVM: PPC: Convert DSISR to shared page · d562de48
      Alexander Graf 提交于
      The DSISR register contains information about a data page fault. It is fully
      read/write from inside the guest context and we don't need to worry about
      interacting based on writes of this register.
      
      This patch converts all users of the current field to the shared page.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      d562de48
    • A
      KVM: PPC: Convert MSR to shared page · 666e7252
      Alexander Graf 提交于
      One of the most obvious registers to share with the guest directly is the
      MSR. The MSR contains the "interrupts enabled" flag which the guest has to
      toggle in critical sections.
      
      So in order to bring the overhead of interrupt en- and disabling down, let's
      put msr into the shared page. Keep in mind that even though you can fully read
      its contents, writing to it doesn't always update all state. There are a few
      safe fields that don't require hypervisor interaction. See the documentation
      for a list of MSR bits that are safe to be set from inside the guest.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      666e7252
  12. 17 5月, 2010 9 次提交
  13. 25 4月, 2010 5 次提交
    • A
      KVM: PPC: Implement Paired Single emulation · 831317b6
      Alexander Graf 提交于
      The one big thing about the Gekko is paired singles.
      
      Paired singles are an extension to the instruction set, that adds 32 single
      precision floating point registers (qprs), some SPRs to modify the behavior
      of paired singled operations and instructions to deal with qprs to the
      instruction set.
      
      Unfortunately, it also changes semantics of existing operations that affect
      single values in FPRs. In most cases they get mirrored to the coresponding
      QPR.
      
      Thanks to that we need to emulate all FPU operations and all the new paired
      single operations too.
      
      In order to achieve that, we use the just introduced FPU call helpers to
      call the real FPU whenever the guest wants to modify an FPR. Additionally
      we also fix up the QPR values along the way.
      
      That way we can execute paired single FPU operations without implementing a
      soft fpu.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      831317b6
    • A
      KVM: PPC: Fix error in BAT assignment · dba2e123
      Alexander Graf 提交于
      BATs didn't work. Well, they did, but only up to BAT3. As soon as we
      came to BAT4 the offset calculation was screwed up and we ended up
      overwriting BAT0-3.
      
      Fortunately, Linux hasn't been using BAT4+. It's still a good
      idea to write correct code though.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      dba2e123
    • A
      KVM: PPC: Make software load/store return eaddr · 5467a97d
      Alexander Graf 提交于
      The Book3S KVM implementation contains some helper functions to load and store
      data from and to virtual addresses.
      
      Unfortunately, this helper used to keep the physical address it so nicely
      found out for us to itself. So let's change that and make it return the
      physical address it resolved.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      5467a97d
    • A
      KVM: PPC: Implement mtsr instruction emulation · 71db4089
      Alexander Graf 提交于
      The Book3S_32 specifications allows for two instructions to modify segment
      registers: mtsrin and mtsr.
      
      Most normal operating systems use mtsrin, because it allows to define which
      segment it wants to change using a register. But since I was trying to run
      an embedded guest, it turned out to be using mtsr with hardcoded values.
      
      So let's also emulate mtsr. It's a valid instruction after all.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      71db4089
    • A
      KVM: PPC: Add Gekko SPRs · d6d549b2
      Alexander Graf 提交于
      The Gekko has some SPR values that differ from other PPC core values and
      also some additional ones.
      
      Let's add support for them in our mfspr/mtspr emulator.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      d6d549b2
  14. 01 3月, 2010 1 次提交
    • A
      KVM: PPC: Use accessor functions for GPR access · 8e5b26b5
      Alexander Graf 提交于
      All code in PPC KVM currently accesses gprs in the vcpu struct directly.
      
      While there's nothing wrong with that wrt the current way gprs are stored
      and loaded, it doesn't suffice for the PACA acceleration that will follow
      in this patchset.
      
      So let's just create little wrapper inline functions that we call whenever
      a GPR needs to be read from or written to. The compiled code shouldn't really
      change at all for now.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      8e5b26b5
  15. 08 12月, 2009 1 次提交
  16. 05 11月, 2009 1 次提交