1. 08 9月, 2016 3 次提交
    • S
      KVM: PPC: Book3S HV: Implement halt polling · 0cda69dd
      Suraj Jitindar Singh 提交于
      This patch introduces new halt polling functionality into the kvm_hv kernel
      module. When a vcore is idle it will poll for some period of time before
      scheduling itself out.
      
      When all of the runnable vcpus on a vcore have ceded (and thus the vcore is
      idle) we schedule ourselves out to allow something else to run. In the
      event that we need to wake up very quickly (for example an interrupt
      arrives), we are required to wait until we get scheduled again.
      
      Implement halt polling so that when a vcore is idle, and before scheduling
      ourselves, we poll for vcpus in the runnable_threads list which have
      pending exceptions or which leave the ceded state. If we poll successfully
      then we can get back into the guest very quickly without ever scheduling
      ourselves, otherwise we schedule ourselves out as before.
      
      There exists generic halt_polling code in virt/kvm_main.c, however on
      powerpc the polling conditions are different to the generic case. It would
      be nice if we could just implement an arch specific kvm_check_block()
      function, but there is still other arch specific things which need to be
      done for kvm_hv (for example manipulating vcore states) which means that a
      separate implementation is the best option.
      
      Testing of this patch with a TCP round robin test between two guests with
      virtio network interfaces has found a decrease in round trip time of ~15us
      on average. A performance gain is only seen when going out of and
      back into the guest often and quickly, otherwise there is no net benefit
      from the polling. The polling interval is adjusted such that when we are
      often scheduled out for long periods of time it is reduced, and when we
      often poll successfully it is increased. The rate at which the polling
      interval increases or decreases, and the maximum polling interval, can
      be set through module parameters.
      
      Based on the implementation in the generic kvm module by Wanpeng Li and
      Paolo Bonzini, and on direction from Paul Mackerras.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      0cda69dd
    • S
      KVM: PPC: Book3S HV: Change vcore element runnable_threads from linked-list to array · 7b5f8272
      Suraj Jitindar Singh 提交于
      The struct kvmppc_vcore is a structure used to store various information
      about a virtual core for a kvm guest. The runnable_threads element of the
      struct provides a list of all of the currently runnable vcpus on the core
      (those in the KVMPPC_VCPU_RUNNABLE state). The previous implementation of
      this list was a linked_list. The next patch requires that the list be able
      to be iterated over without holding the vcore lock.
      
      Reimplement the runnable_threads list in the kvmppc_vcore struct as an
      array. Implement function to iterate over valid entries in the array and
      update access sites accordingly.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      7b5f8272
    • S
      KVM: PPC: Book3S HV: Move struct kvmppc_vcore from kvm_host.h to kvm_book3s.h · e64fb7e2
      Suraj Jitindar Singh 提交于
      The next commit will introduce a member to the kvmppc_vcore struct which
      references MAX_SMT_THREADS which is defined in kvm_book3s_asm.h, however
      this file isn't included in kvm_host.h directly. Thus compiling for
      certain platforms such as pmac32_defconfig and ppc64e_defconfig with KVM
      fails due to MAX_SMT_THREADS not being defined.
      
      Move the struct kvmppc_vcore definition to kvm_book3s.h which explicitly
      includes kvm_book3s_asm.h.
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      e64fb7e2
  2. 25 8月, 2016 1 次提交
    • P
      KVM: PPC: Always select KVM_VFIO, plus Makefile cleanup · 4b3d173d
      Paul Mackerras 提交于
      As discussed recently on the kvm mailing list, David Gibson's
      intention in commit 178a7875 ("vfio: Enable VFIO device for
      powerpc", 2016-02-01) was to have the KVM VFIO device built in
      on all powerpc platforms.  This patch adds the "select KVM_VFIO"
      statement that makes this happen.
      
      Currently, arch/powerpc/kvm/Makefile doesn't include vfio.o for
      the 64-bit kvm module, because the list of objects doesn't use
      the $(common-objs-y) list.  The reason it doesn't is because we
      don't necessarily want coalesced_mmio.o or emulate.o (for example
      if HV KVM is the only target), and common-objs-y includes both.
      
      Since this is confusing, this patch adjusts the definitions so that
      we now use $(common-objs-y) in the list for the 64-bit kvm.ko
      module, emulate.o is removed from common-objs-y and added in the
      places that need it, and the inclusion of coalesced_mmio.o now
      depends on CONFIG_KVM_MMIO.
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      4b3d173d
  3. 19 8月, 2016 2 次提交
    • P
      KVM: PPC: Implement kvm_arch_intc_initialized() for PPC · 34a75b0f
      Paul Mackerras 提交于
      It doesn't make sense to create irqfds for a VM that doesn't have
      in-kernel interrupt controller emulation.  There is an existing
      interface for architecture code to tell the irqfd code whether or
      not any interrupt controller has been initialized, called
      kvm_arch_intc_initialized(), so let's implement that for powerpc.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      34a75b0f
    • P
      KVM: PPC: Book3S: Don't crash if irqfd used with no in-kernel XICS emulation · e48ba1cb
      Paul Mackerras 提交于
      It turns out that if userspace creates a pseries-type VM without
      in-kernel XICS (interrupt controller) emulation, and then connects
      an eventfd to the VM as an irqfd, and the eventfd gets signalled,
      that the code will try to deliver an interrupt via the non-existent
      XICS object and crash the host kernel with a NULL pointer dereference.
      
      To fix this, we check for the presence of the XICS object before
      trying to deliver the interrupt, and return with an error if not.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      e48ba1cb
  4. 12 8月, 2016 2 次提交
  5. 10 8月, 2016 7 次提交
    • N
      powerpc/vdso: Fix build rules to rebuild vdsos correctly · b9a4a0d0
      Nicholas Piggin 提交于
      When using if_changed, we need to add FORCE as a dependency (see
      Documentation/kbuild/makefiles.txt) otherwise we don't get command line
      change checking amongst other things. This has resulted in vdsos not
      being rebuilt when switching between big and little endian.
      
      The vdso64/32ld commands have to be changed around to avoid pulling
      FORCE into the linker command line (code copied from x86).
      Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      b9a4a0d0
    • M
      powerpc/Makefile: Use cflags-y/aflags-y for setting endian options · 164af597
      Michael Ellerman 提交于
      When we introduced the little endian support, we added the endian flags
      to CC directly using override. I don't know the history of why we did
      that, I suspect no one does.
      
      Although this mostly works, it has one bug, which is that CROSS32CC
      doesn't get -mbig-endian. That means when the compiler is little endian
      by default and the user is building big endian, vdso32 is incorrectly
      compiled as little endian and the kernel fails to build.
      
      Instead we can add the endian flags to cflags-y/aflags-y, and then
      append those to KBUILD_CFLAGS/KBUILD_AFLAGS.
      
      This has the advantage of being 1) less ugly, 2) the documented way of
      adding flags in the arch Makefile and 3) it fixes building vdso32 with a
      LE toolchain.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      164af597
    • B
      powerpc/32: Fix crash during static key init · 97f6e0cc
      Benjamin Herrenschmidt 提交于
      We cannot do those initializations from apply_feature_fixups() as
      this function runs in a very restricted environment on 32-bit where
      the kernel isn't running at its linked address and the PTRRELOC()
      macro must be used for any global accesss.
      
      Instead, split them into a separtate steup_feature_keys() function
      which is called in a more suitable spot on ppc32.
      
      Fixes: 309b315b ("powerpc: Call jump_label_init() in apply_feature_fixups()")
      Reported-and-tested-by: NChristian Kujau <lists@nerdbynature.de>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      97f6e0cc
    • B
      powerpc: Update obsolete comment in setup_32.c about early_init() · f9cc1d1f
      Benjamin Herrenschmidt 提交于
      We don't identify the machine type anymore...
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      f9cc1d1f
    • B
      powerpc: Print the kernel load address at the end of prom_init() · 7d70c63c
      Benjamin Herrenschmidt 提交于
      This makes it easier to debug crashes that happen very early before
      the kernel takes over Open Firmware by allowing us to relate the OF
      reported crashing addresses to offsets within the kernel.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      7d70c63c
    • C
      powerpc/ptrace: Fix coredump since ptrace TM changes · c7a318ba
      Cyril Bur 提交于
      Commit 8d460f61 ("powerpc/process: Add the function
      flush_tmregs_to_thread") added flush_tmregs_to_thread() and included
      the assumption that it would only be called for a task which is not
      current.
      
      Although this is correct for ptrace, when generating a core dump, some
      of the routines which call flush_tmregs_to_thread() are called. This
      leads to a WARNing such as:
      
        Not expecting ptrace on self: TM regs may be incorrect
        ------------[ cut here ]------------
        WARNING: CPU: 123 PID: 7727 at arch/powerpc/kernel/process.c:1088 flush_tmregs_to_thread+0x78/0x80
        CPU: 123 PID: 7727 Comm: libvirtd Not tainted 4.8.0-rc1-gcc6x-g61e8a0d5 #1
        task: c000000fe631b600 task.stack: c000000fe63b0000
        NIP: c00000000001a1a8 LR: c00000000001a1a4 CTR: c000000000717780
        REGS: c000000fe63b3420 TRAP: 0700   Not tainted  (4.8.0-rc1-gcc6x-g61e8a0d5)
        MSR: 900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>  CR: 28004222  XER: 20000000
        ...
        NIP [c00000000001a1a8] flush_tmregs_to_thread+0x78/0x80
        LR [c00000000001a1a4] flush_tmregs_to_thread+0x74/0x80
        Call Trace:
         flush_tmregs_to_thread+0x74/0x80 (unreliable)
         vsr_get+0x64/0x1a0
         elf_core_dump+0x604/0x1430
         do_coredump+0x5fc/0x1200
         get_signal+0x398/0x740
         do_signal+0x54/0x2b0
         do_notify_resume+0x98/0xb0
         ret_from_except_lite+0x70/0x74
      
      So fix flush_tmregs_to_thread() to detect the case where it is called on
      current, and a transaction is active, and in that case flush the TM regs
      to the thread_struct.
      
      This patch also moves flush_tmregs_to_thread() into ptrace.c as it is
      only called from that file.
      
      Fixes: 8d460f61 ("powerpc/process: Add the function flush_tmregs_to_thread")
      Signed-off-by: NCyril Bur <cyrilbur@gmail.com>
      [mpe: Flesh out change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      c7a318ba
    • C
      powerpc/32: Fix csum_partial_copy_generic() · 1bc8b816
      Christophe Leroy 提交于
      Commit 7aef4136 ("powerpc32: rewrite csum_partial_copy_generic()
      based on copy_tofrom_user()") introduced a bug when destination
      address is odd and initial csum is not null
      
      In that (rare) case the initial csum value has to be rotated one byte
      as well as the resulting value is
      
      This patch also fixes related comments
      
      Fixes: 7aef4136 ("powerpc32: rewrite csum_partial_copy_generic() based on copy_tofrom_user()")
      Signed-off-by: NChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1bc8b816
  6. 09 8月, 2016 13 次提交
  7. 08 8月, 2016 1 次提交
  8. 05 8月, 2016 1 次提交
  9. 04 8月, 2016 4 次提交
  10. 03 8月, 2016 6 次提交