1. 05 3月, 2013 1 次提交
  2. 28 2月, 2013 1 次提交
    • S
      hlist: drop the node parameter from iterators · b67bfe0d
      Sasha Levin 提交于
      I'm not sure why, but the hlist for each entry iterators were conceived
      
              list_for_each_entry(pos, head, member)
      
      The hlist ones were greedy and wanted an extra parameter:
      
              hlist_for_each_entry(tpos, pos, head, member)
      
      Why did they need an extra pos parameter? I'm not quite sure. Not only
      they don't really need it, it also prevents the iterator from looking
      exactly like the list iterator, which is unfortunate.
      
      Besides the semantic patch, there was some manual work required:
      
       - Fix up the actual hlist iterators in linux/list.h
       - Fix up the declaration of other iterators based on the hlist ones.
       - A very small amount of places were using the 'node' parameter, this
       was modified to use 'obj->member' instead.
       - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
       properly, so those had to be fixed up manually.
      
      The semantic patch which is mostly the work of Peter Senna Tschudin is here:
      
      @@
      iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
      
      type T;
      expression a,c,d,e;
      identifier b;
      statement S;
      @@
      
      -T b;
          <+... when != b
      (
      hlist_for_each_entry(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue(a,
      - b,
      c) S
      |
      hlist_for_each_entry_from(a,
      - b,
      c) S
      |
      hlist_for_each_entry_rcu(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_rcu_bh(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue_rcu_bh(a,
      - b,
      c) S
      |
      for_each_busy_worker(a, c,
      - b,
      d) S
      |
      ax25_uid_for_each(a,
      - b,
      c) S
      |
      ax25_for_each(a,
      - b,
      c) S
      |
      inet_bind_bucket_for_each(a,
      - b,
      c) S
      |
      sctp_for_each_hentry(a,
      - b,
      c) S
      |
      sk_for_each(a,
      - b,
      c) S
      |
      sk_for_each_rcu(a,
      - b,
      c) S
      |
      sk_for_each_from
      -(a, b)
      +(a)
      S
      + sk_for_each_from(a) S
      |
      sk_for_each_safe(a,
      - b,
      c, d) S
      |
      sk_for_each_bound(a,
      - b,
      c) S
      |
      hlist_for_each_entry_safe(a,
      - b,
      c, d, e) S
      |
      hlist_for_each_entry_continue_rcu(a,
      - b,
      c) S
      |
      nr_neigh_for_each(a,
      - b,
      c) S
      |
      nr_neigh_for_each_safe(a,
      - b,
      c, d) S
      |
      nr_node_for_each(a,
      - b,
      c) S
      |
      nr_node_for_each_safe(a,
      - b,
      c, d) S
      |
      - for_each_gfn_sp(a, c, d, b) S
      + for_each_gfn_sp(a, c, d) S
      |
      - for_each_gfn_indirect_valid_sp(a, c, d, b) S
      + for_each_gfn_indirect_valid_sp(a, c, d) S
      |
      for_each_host(a,
      - b,
      c) S
      |
      for_each_host_safe(a,
      - b,
      c, d) S
      |
      for_each_mesh_entry(a,
      - b,
      c, d) S
      )
          ...+>
      
      [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
      [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
      [akpm@linux-foundation.org: checkpatch fixes]
      [akpm@linux-foundation.org: fix warnings]
      [akpm@linux-foudnation.org: redo intrusive kvm changes]
      Tested-by: NPeter Senna Tschudin <peter.senna@gmail.com>
      Acked-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Gleb Natapov <gleb@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b67bfe0d
  3. 15 2月, 2013 2 次提交
    • P
      powerpc/kvm/book3s_pr: Fix compilation on 32-bit machines · deb26c27
      Paul Mackerras 提交于
      Commit a413f474 ("powerpc: Disable relocation on exceptions whenever
      PR KVM is active") added calls to pSeries_disable_reloc_on_exc() and
      pSeries_enable_reloc_on_exc() to book3s_pr.c, and added declarations
      of those functions to <asm/hvcall.h>, but didn't add an include of
      <asm/hvcall.h> to book3s_pr.c.  64-bit kernels seem to get hvcall.h
      included via some other path, but 32-bit kernels fail to compile with:
      
      arch/powerpc/kvm/book3s_pr.c: In function ‘kvmppc_core_init_vm’:
      arch/powerpc/kvm/book3s_pr.c:1300:4: error: implicit declaration of function ‘pSeries_disable_reloc_on_exc’ [-Werror=implicit-function-declaration]
      arch/powerpc/kvm/book3s_pr.c: In function ‘kvmppc_core_destroy_vm’:
      arch/powerpc/kvm/book3s_pr.c:1316:4: error: implicit declaration of function ‘pSeries_enable_reloc_on_exc’ [-Werror=implicit-function-declaration]
      cc1: all warnings being treated as errors
      make[2]: *** [arch/powerpc/kvm/book3s_pr.o] Error 1
      make[1]: *** [arch/powerpc/kvm] Error 2
      make: *** [sub-make] Error 2
      
      This fixes it by adding an include of hvcall.h.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      deb26c27
    • P
      powerpc/kvm/book3s_hv: Preserve guest CFAR register value · 0acb9111
      Paul Mackerras 提交于
      The CFAR (Come-From Address Register) is a useful debugging aid that
      exists on POWER7 processors.  Currently HV KVM doesn't save or restore
      the CFAR register for guest vcpus, making the CFAR of limited use in
      guests.
      
      This adds the necessary code to capture the CFAR value saved in the
      early exception entry code (it has to be saved before any branch is
      executed), save it in the vcpu.arch struct, and restore it on entry
      to the guest.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      0acb9111
  4. 13 2月, 2013 3 次提交
  5. 25 1月, 2013 8 次提交
  6. 22 1月, 2013 1 次提交
  7. 18 1月, 2013 1 次提交
  8. 10 1月, 2013 8 次提交
    • A
      KVM: PPC: BookE: Add EPR ONE_REG sync · 324b3e63
      Alexander Graf 提交于
      We need to be able to read and write the contents of the EPR register
      from user space.
      
      This patch implements that logic through the ONE_REG API and declares
      its (never implemented) SREGS counterpart as deprecated.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      324b3e63
    • A
      KVM: PPC: BookE: Implement EPR exit · 1c810636
      Alexander Graf 提交于
      The External Proxy Facility in FSL BookE chips allows the interrupt
      controller to automatically acknowledge an interrupt as soon as a
      core gets its pending external interrupt delivered.
      
      Today, user space implements the interrupt controller, so we need to
      check on it during such a cycle.
      
      This patch implements logic for user space to enable EPR exiting,
      disable EPR exiting and EPR exiting itself, so that user space can
      acknowledge an interrupt when an external interrupt has successfully
      been delivered into the guest vcpu.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      1c810636
    • A
      KVM: PPC: BookE: Emulate mfspr on EPR · 37ecb257
      Alexander Graf 提交于
      The EPR register is potentially valid for PR KVM as well, so we need
      to emulate accesses to it. It's only defined for reading, so only
      handle the mfspr case.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      37ecb257
    • A
      KVM: PPC: BookE: Allow irq deliveries to inject requests · b8c649a9
      Alexander Graf 提交于
      When injecting an interrupt into guest context, we usually don't need
      to check for requests anymore. At least not until today.
      
      With the introduction of EPR, we will have to create a request when the
      guest has successfully accepted an external interrupt though.
      
      So we need to prepare the interrupt delivery to abort guest entry
      gracefully. Otherwise we'd delay the EPR request.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      b8c649a9
    • M
      KVM: PPC: Fix mfspr/mtspr MMUCFG emulation · f2be6550
      Mihai Caraman 提交于
      On mfspr/mtspr emulation path Book3E's MMUCFG SPR with value 1015 clashes
      with G4's MSSSR0 SPR. Move MSSSR0 emulation from generic part to Books3S.
      MSSSR0 also clashes with Book3S's DABRX SPR. DABRX was not explicitly
      handled so Book3S execution flow will behave as before.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      f2be6550
    • A
      KVM: PPC: Book3S: PR: Enable alternative instruction for SC 1 · 50c7bb80
      Alexander Graf 提交于
      When running on top of pHyp, the hypercall instruction "sc 1" goes
      straight into pHyp without trapping in supervisor mode.
      
      So if we want to support PAPR guest in this configuration we need to
      add a second way of accessing PAPR hypercalls, preferably with the
      exact same semantics except for the instruction.
      
      So let's overlay an officially reserved instruction and emulate PAPR
      hypercalls whenever we hit that one.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      50c7bb80
    • A
      KVM: PPC: Only WARN on invalid emulation · 5a33169e
      Alexander Graf 提交于
      When we hit an emulation result that we didn't expect, that is an error,
      but it's nothing that warrants a BUG(), because it can be guest triggered.
      
      So instead, let's only WARN() the user that this happened.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      5a33169e
    • I
      powerpc: Disable relocation on exceptions whenever PR KVM is active · a413f474
      Ian Munsie 提交于
      For PR KVM we allow userspace to map 0xc000000000000000. Because
      transitioning from userspace to the guest kernel may use the relocated
      exception vectors we have to disable relocation on exceptions whenever
      PR KVM is active as we cannot trust that address.
      
      This issue does not apply to HV KVM, since changing from a guest to the
      hypervisor will never use the relocated exception vectors.
      
      Currently the hypervisor interface only allows us to toggle relocation
      on exceptions on a partition wide scope, so we need to globally disable
      relocation on exceptions when the first PR KVM instance is started and
      only re-enable them when all PR KVM instances have been destroyed.
      
      It's a bit heavy handed, but until the hypervisor gives us a lightweight
      way to toggle relocation on exceptions on a single thread it's only real
      option.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      a413f474
  9. 06 1月, 2013 1 次提交
  10. 14 12月, 2012 2 次提交
  11. 06 12月, 2012 12 次提交
    • M
      KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface · 352df1de
      Mihai Caraman 提交于
      Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR to
      the list of ONE_REG PPC supported registers.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      [agraf: remove HV dependency, use get/put_user]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      352df1de
    • M
      KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation · 38f98824
      Mihai Caraman 提交于
      Add EPCR support in booke mtspr/mfspr emulation. EPCR register is defined only
      for 64-bit and HV categories, we will expose it at this point only to 64-bit
      virtual processors running on 64-bit HV hosts.
      Define a reusable setter function for vcpu's EPCR.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      [agraf: move HV dependency in the code]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      38f98824
    • M
      KVM: PPC: bookehv: Add guest computation mode for irq delivery · 95e90b43
      Mihai Caraman 提交于
      When delivering guest IRQs, update MSR computation mode according to guest
      interrupt computation mode found in EPCR.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      [agraf: remove HV dependency in the code]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      95e90b43
    • M
      KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit · e9666ea1
      Mihai Caraman 提交于
      Extend MAS2 EPN mask to retain most significant bits on 64-bit hosts.
      Use this mask in tlb effective address accessor.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      e9666ea1
    • M
      KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation · 9e2fa646
      Mihai Caraman 提交于
      Mask high 32 bits of MAS2's effective page number in tlbwe emulation for guests
      running in 32-bit mode.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      9e2fa646
    • M
      KVM: PPC: e500: Add emulation helper for getting instruction ea · 7cdd7a95
      Mihai Caraman 提交于
      Add emulation helper for getting instruction ea and refactor tlb instruction
      emulation to use it.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      [agraf: keep rt variable around]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      7cdd7a95
    • M
      KVM: PPC: bookehv64: Add support for interrupt handling · e51f8f32
      Mihai Caraman 提交于
      Add interrupt handling support for 64-bit bookehv hosts. Unify 32 and 64 bit
      implementations using a common stack layout and a common execution flow starting
      from kvm_handler_common macro. Update documentation for 64-bit input register
      values. This patch only address the bolted TLB miss exception handlers version.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      e51f8f32
    • M
      KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler · ff594746
      Mihai Caraman 提交于
      GET_VCPU define will not be implemented for 64-bit for performance reasons
      so get rid of it also on 32-bit.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      ff594746
    • M
      KVM: PPC: booke: Fix get_tb() compile error on 64-bit · b50df19c
      Mihai Caraman 提交于
      Include header file for get_tb() declaration.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      b50df19c
    • M
      KVM: PPC: e500: Silence bogus GCC warning in tlb code · 910040b8
      Mihai Caraman 提交于
      64-bit GCC 4.5.1 warns about an uninitialized variable which was guarded
      by a flag. Initialize the variable to make it happy.
      Signed-off-by: NMihai Caraman <mihai.caraman@freescale.com>
      [agraf: reword comment]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      910040b8
    • P
      KVM: PPC: Book3S HV: Handle guest-caused machine checks on POWER7 without panicking · b4072df4
      Paul Mackerras 提交于
      Currently, if a machine check interrupt happens while we are in the
      guest, we exit the guest and call the host's machine check handler,
      which tends to cause the host to panic.  Some machine checks can be
      triggered by the guest; for example, if the guest creates two entries
      in the SLB that map the same effective address, and then accesses that
      effective address, the CPU will take a machine check interrupt.
      
      To handle this better, when a machine check happens inside the guest,
      we call a new function, kvmppc_realmode_machine_check(), while still in
      real mode before exiting the guest.  On POWER7, it handles the cases
      that the guest can trigger, either by flushing and reloading the SLB,
      or by flushing the TLB, and then it delivers the machine check interrupt
      directly to the guest without going back to the host.  On POWER7, the
      OPAL firmware patches the machine check interrupt vector so that it
      gets control first, and it leaves behind its analysis of the situation
      in a structure pointed to by the opal_mc_evt field of the paca.  The
      kvmppc_realmode_machine_check() function looks at this, and if OPAL
      reports that there was no error, or that it has handled the error, we
      also go straight back to the guest with a machine check.  We have to
      deliver a machine check to the guest since the machine check interrupt
      might have trashed valid values in SRR0/1.
      
      If the machine check is one we can't handle in real mode, and one that
      OPAL hasn't already handled, or on PPC970, we exit the guest and call
      the host's machine check handler.  We do this by jumping to the
      machine_check_fwnmi label, rather than absolute address 0x200, because
      we don't want to re-execute OPAL's handler on POWER7.  On PPC970, the
      two are equivalent because address 0x200 just contains a branch.
      
      Then, if the host machine check handler decides that the system can
      continue executing, kvmppc_handle_exit() delivers a machine check
      interrupt to the guest -- once again to let the guest know that SRR0/1
      have been modified.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      [agraf: fix checkpatch warnings]
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      b4072df4
    • P
      KVM: PPC: Book3S HV: Improve handling of local vs. global TLB invalidations · 1b400ba0
      Paul Mackerras 提交于
      When we change or remove a HPT (hashed page table) entry, we can do
      either a global TLB invalidation (tlbie) that works across the whole
      machine, or a local invalidation (tlbiel) that only affects this core.
      Currently we do local invalidations if the VM has only one vcpu or if
      the guest requests it with the H_LOCAL flag, though the guest Linux
      kernel currently doesn't ever use H_LOCAL.  Then, to cope with the
      possibility that vcpus moving around to different physical cores might
      expose stale TLB entries, there is some code in kvmppc_hv_entry to
      flush the whole TLB of entries for this VM if either this vcpu is now
      running on a different physical core from where it last ran, or if this
      physical core last ran a different vcpu.
      
      There are a number of problems on POWER7 with this as it stands:
      
      - The TLB invalidation is done per thread, whereas it only needs to be
        done per core, since the TLB is shared between the threads.
      - With the possibility of the host paging out guest pages, the use of
        H_LOCAL by an SMP guest is dangerous since the guest could possibly
        retain and use a stale TLB entry pointing to a page that had been
        removed from the guest.
      - The TLB invalidations that we do when a vcpu moves from one physical
        core to another are unnecessary in the case of an SMP guest that isn't
        using H_LOCAL.
      - The optimization of using local invalidations rather than global should
        apply to guests with one virtual core, not just one vcpu.
      
      (None of this applies on PPC970, since there we always have to
      invalidate the whole TLB when entering and leaving the guest, and we
      can't support paging out guest memory.)
      
      To fix these problems and simplify the code, we now maintain a simple
      cpumask of which cpus need to flush the TLB on entry to the guest.
      (This is indexed by cpu, though we only ever use the bits for thread
      0 of each core.)  Whenever we do a local TLB invalidation, we set the
      bits for every cpu except the bit for thread 0 of the core that we're
      currently running on.  Whenever we enter a guest, we test and clear the
      bit for our core, and flush the TLB if it was set.
      
      On initial startup of the VM, and when resetting the HPT, we set all the
      bits in the need_tlb_flush cpumask, since any core could potentially have
      stale TLB entries from the previous VM to use the same LPID, or the
      previous contents of the HPT.
      
      Then, we maintain a count of the number of online virtual cores, and use
      that when deciding whether to use a local invalidation rather than the
      number of online vcpus.  The code to make that decision is extracted out
      into a new function, global_invalidates().  For multi-core guests on
      POWER7 (i.e. when we are using mmu notifiers), we now never do local
      invalidations regardless of the H_LOCAL flag.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      1b400ba0