1. 30 8月, 2013 1 次提交
  2. 06 8月, 2013 1 次提交
  3. 23 7月, 2013 1 次提交
  4. 17 7月, 2013 1 次提交
    • H
      x86, bitops: Change bitops to be native operand size · 9b710506
      H. Peter Anvin 提交于
      Change the bitops operation to be naturally "long", i.e. 63 bits on
      the 64-bit kernel.  Additional bugs are likely to crop up in the
      future.
      
      We already have bugs which machines with > 16 TiB of memory in a
      single node, as can happen if memory is interleaved.  The x86 bitop
      operations take a signed index, so using an unsigned type is not an
      option.
      
      Jim Kukunas measured the effect of this patch on kernel size: it adds
      2779 bytes to the allyesconfig kernel.  Some of that probably could be
      elided by replacing the inline functions with macros which select the
      32-bit type if the index is a 32-bit value, something like:
      
      In that case we could also use "Jr" constraints for the 64-bit
      version.
      
      However, this would more than double the amount of code for a
      relatively small gain.
      
      Note that we can't use ilog2() for _BITOPS_LONG_SHIFT, as that causes
      a recursive header inclusion problem.
      
      The change to constant_test_bit() should both generate better code and
      give correct result for negative bit indicies.  As previously written
      the compiler had to generate extra code to create the proper wrong
      result for negative values.
      Signed-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      Cc: Jim Kukunas <james.t.kukunas@intel.com>
      Link: http://lkml.kernel.org/n/tip-z61ofiwe90xeyb461o72h8ya@git.kernel.org
      9b710506
  5. 29 6月, 2013 1 次提交
    • W
      x86: Use asm-goto to implement mutex fast path on x86-64 · 00e55a79
      Wedson Almeida Filho 提交于
      The new implementation allows the compiler to better optimize the code; the
      original implementation is still used when the kernel is compiled with older
      versions of gcc that don't support asm-goto.
      
      Compiling with gcc 4.7.3, the original mutex_lock() is 60 bytes with the fast
      path taking 16 instructions; the new mutex_lock() is 42 bytes, with the fast
      path taking 12 instructions.
      
      The original mutex_unlock() is 24 bytes with the fast path taking 7
      instructions; the new mutex_unlock() is 25 bytes (because the compiler used
      a 2-byte ret) with the fast path taking 4 instructions.
      
      The two versions of the functions are included below for reference.
      
      Old:
      ffffffff817742a0 <mutex_lock>:
      ffffffff817742a0:       55                      push   %rbp
      ffffffff817742a1:       48 89 e5                mov    %rsp,%rbp
      ffffffff817742a4:       48 83 ec 10             sub    $0x10,%rsp
      ffffffff817742a8:       48 89 5d f0             mov    %rbx,-0x10(%rbp)
      ffffffff817742ac:       48 89 fb                mov    %rdi,%rbx
      ffffffff817742af:       4c 89 65 f8             mov    %r12,-0x8(%rbp)
      ffffffff817742b3:       e8 28 15 00 00          callq  ffffffff817757e0 <_cond_resched>
      ffffffff817742b8:       48 89 df                mov    %rbx,%rdi
      ffffffff817742bb:       f0 ff 0f                lock decl (%rdi)
      ffffffff817742be:       79 05                   jns    ffffffff817742c5 <mutex_lock+0x25>
      ffffffff817742c0:       e8 cb 04 00 00          callq  ffffffff81774790 <__mutex_lock_slowpath>
      ffffffff817742c5:       65 48 8b 04 25 c0 b7    mov    %gs:0xb7c0,%rax
      ffffffff817742cc:       00 00
      ffffffff817742ce:       4c 8b 65 f8             mov    -0x8(%rbp),%r12
      ffffffff817742d2:       48 89 43 18             mov    %rax,0x18(%rbx)
      ffffffff817742d6:       48 8b 5d f0             mov    -0x10(%rbp),%rbx
      ffffffff817742da:       c9                      leaveq
      ffffffff817742db:       c3                      retq
      
      ffffffff81774250 <mutex_unlock>:
      ffffffff81774250:       55                      push   %rbp
      ffffffff81774251:       48 c7 47 18 00 00 00    movq   $0x0,0x18(%rdi)
      ffffffff81774258:       00
      ffffffff81774259:       48 89 e5                mov    %rsp,%rbp
      ffffffff8177425c:       f0 ff 07                lock incl (%rdi)
      ffffffff8177425f:       7f 05                   jg     ffffffff81774266 <mutex_unlock+0x16>
      ffffffff81774261:       e8 ea 04 00 00          callq  ffffffff81774750 <__mutex_unlock_slowpath>
      ffffffff81774266:       5d                      pop    %rbp
      ffffffff81774267:       c3                      retq
      
      New:
      ffffffff81774920 <mutex_lock>:
      ffffffff81774920:       55                      push   %rbp
      ffffffff81774921:       48 89 e5                mov    %rsp,%rbp
      ffffffff81774924:       53                      push   %rbx
      ffffffff81774925:       48 89 fb                mov    %rdi,%rbx
      ffffffff81774928:       e8 a3 0e 00 00          callq  ffffffff817757d0 <_cond_resched>
      ffffffff8177492d:       f0 ff 0b                lock decl (%rbx)
      ffffffff81774930:       79 08                   jns    ffffffff8177493a <mutex_lock+0x1a>
      ffffffff81774932:       48 89 df                mov    %rbx,%rdi
      ffffffff81774935:       e8 16 fe ff ff          callq  ffffffff81774750 <__mutex_lock_slowpath>
      ffffffff8177493a:       65 48 8b 04 25 c0 b7    mov    %gs:0xb7c0,%rax
      ffffffff81774941:       00 00
      ffffffff81774943:       48 89 43 18             mov    %rax,0x18(%rbx)
      ffffffff81774947:       5b                      pop    %rbx
      ffffffff81774948:       5d                      pop    %rbp
      ffffffff81774949:       c3                      retq
      
      ffffffff81774730 <mutex_unlock>:
      ffffffff81774730:       48 c7 47 18 00 00 00    movq   $0x0,0x18(%rdi)
      ffffffff81774737:       00
      ffffffff81774738:       f0 ff 07                lock incl (%rdi)
      ffffffff8177473b:       7f 0a                   jg     ffffffff81774747 <mutex_unlock+0x17>
      ffffffff8177473d:       55                      push   %rbp
      ffffffff8177473e:       48 89 e5                mov    %rsp,%rbp
      ffffffff81774741:       e8 aa ff ff ff          callq  ffffffff817746f0 <__mutex_unlock_slowpath>
      ffffffff81774746:       5d                      pop    %rbp
      ffffffff81774747:       f3 c3                   repz retq
      Signed-off-by: NWedson Almeida Filho <wedsonaf@gmail.com>
      Link: http://lkml.kernel.org/r/1372420245-60021-1-git-send-email-wedsonaf@gmail.comSigned-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      00e55a79
  6. 26 6月, 2013 4 次提交
  7. 19 6月, 2013 1 次提交
  8. 31 5月, 2013 1 次提交
  9. 28 5月, 2013 1 次提交
  10. 21 5月, 2013 2 次提交
  11. 15 5月, 2013 1 次提交
    • J
      time: Revert ALWAYS_USE_PERSISTENT_CLOCK compile time optimizaitons · b4f711ee
      John Stultz 提交于
      Kay Sievers noted that the ALWAYS_USE_PERSISTENT_CLOCK config,
      which enables some minor compile time optimization to avoid
      uncessary code in mostly the suspend/resume path could cause
      problems for userland.
      
      In particular, the dependency for RTC_HCTOSYS on
      !ALWAYS_USE_PERSISTENT_CLOCK, which avoids setting the time
      twice and simplifies suspend/resume, has the side effect
      of causing the /sys/class/rtc/rtcN/hctosys flag to always be
      zero, and this flag is commonly used by udev to setup the
      /dev/rtc symlink to /dev/rtcN, which can cause pain for
      older applications.
      
      While the udev rules could use some work to be less fragile,
      breaking userland should strongly be avoided. Additionally
      the compile time optimizations are fairly minor, and the code
      being optimized is likely to be reworked in the future, so
      lets revert this change.
      Reported-by: NKay Sievers <kay@vrfy.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: stable <stable@vger.kernel.org> #3.9
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
      Link: http://lkml.kernel.org/r/1366828376-18124-1-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      b4f711ee
  12. 10 5月, 2013 4 次提交
  13. 09 5月, 2013 5 次提交
    • P
      KVM: emulator: emulate SALC · 326f578f
      Paolo Bonzini 提交于
      This is an almost-undocumented instruction available in 32-bit mode.
      I say "almost" undocumented because AMD documents it in their opcode
      maps just to say that it is unavailable in 64-bit mode (sections
      "A.2.1 One-Byte Opcodes" and "B.3 Invalid and Reassigned Instructions
      in 64-Bit Mode").
      
      It is roughly equivalent to "sbb %al, %al" except it does not
      set the flags.  Use fastop to emulate it, but do not use the opcode
      directly because it would fail if the host is 64-bit!
      Reported-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Cc: stable@vger.kernel.org # 3.9
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      326f578f
    • P
      KVM: emulator: emulate XLAT · 7fa57952
      Paolo Bonzini 提交于
      This is used by SGABIOS, KVM breaks with emulate_invalid_guest_state=1.
      It is just a MOV in disguise, with a funny source address.
      Reported-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Cc: stable@vger.kernel.org # 3.9
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      7fa57952
    • P
      KVM: emulator: emulate AAM · a035d5c6
      Paolo Bonzini 提交于
      This is used by SGABIOS, KVM breaks with emulate_invalid_guest_state=1.
      
      AAM needs the source operand to be unsigned; do the same in AAD as well
      for consistency, even though it does not affect the result.
      Reported-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Cc: stable@vger.kernel.org # 3.9
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      a035d5c6
    • K
      x86/microcode: Add local mutex to fix physical CPU hot-add deadlock · 074d72ff
      Konrad Rzeszutek Wilk 提交于
      This can easily be triggered if a new CPU is added (via
      ACPI hotplug mechanism) and from user-space you do:
      
         echo 1 > /sys/devices/system/cpu/cpu3/online
      
      (or wait for UDEV to do it) on a newly appeared physical CPU.
      
      The deadlock is that the "store_online" in drivers/base/cpu.c
      takes the cpu_hotplug_driver_lock() lock, then calls "cpu_up".
      "cpu_up" eventually ends up calling "save_mc_for_early"
      which also takes the cpu_hotplug_driver_lock() lock.
      
      And here is that lockdep thinks of it:
      
       smpboot: Stack at about ffff880075c39f44
       smpboot: CPU3: has booted.
       microcode: CPU3 sig=0x206a7, pf=0x2, revision=0x25
      
       =============================================
       [ INFO: possible recursive locking detected ]
       3.9.0upstream-10129-g167af0e #1 Not tainted
       ---------------------------------------------
       sh/2487 is trying to acquire lock:
        (x86_cpu_hotplug_driver_mutex){+.+.+.}, at: [<ffffffff81075512>] cpu_hotplug_driver_lock+0x12/0x20
      
       but task is already holding lock:
        (x86_cpu_hotplug_driver_mutex){+.+.+.}, at: [<ffffffff81075512>] cpu_hotplug_driver_lock+0x12/0x20
      
       other info that might help us debug this:
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(x86_cpu_hotplug_driver_mutex);
         lock(x86_cpu_hotplug_driver_mutex);
      
        *** DEADLOCK ***
      
        May be due to missing lock nesting notation
      
       6 locks held by sh/2487:
        #0:  (sb_writers#5){.+.+.+}, at: [<ffffffff811ca48d>] vfs_write+0x17d/0x190
        #1:  (&buffer->mutex){+.+.+.}, at: [<ffffffff812464ef>] sysfs_write_file+0x3f/0x160
        #2:  (s_active#20){.+.+.+}, at: [<ffffffff81246578>] sysfs_write_file+0xc8/0x160
        #3:  (x86_cpu_hotplug_driver_mutex){+.+.+.}, at: [<ffffffff81075512>] cpu_hotplug_driver_lock+0x12/0x20
        #4:  (cpu_add_remove_lock){+.+.+.}, at: [<ffffffff810961c2>] cpu_maps_update_begin+0x12/0x20
        #5:  (cpu_hotplug.lock){+.+.+.}, at: [<ffffffff810962a7>] cpu_hotplug_begin+0x27/0x60
      Suggested-and-Acked-by: NBorislav Petkov <bp@alien8.de>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: fenghua.yu@intel.com
      Cc: xen-devel@lists.xensource.com
      Cc: stable@vger.kernel.org # for v3.9
      Link: http://lkml.kernel.org/r/1368029583-23337-1-git-send-email-konrad.wilk@oracle.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      074d72ff
    • G
      KVM: VMX: fix halt emulation while emulating invalid guest sate · 8d76c49e
      Gleb Natapov 提交于
      The invalid guest state emulation loop does not check halt_request
      which causes 100% cpu loop while guest is in halt and in invalid
      state, but more serious issue is that this leaves halt_request set, so
      random instruction emulated by vm86 #GP exit can be interpreted
      as halt which causes guest hang. Fix both problems by handling
      halt_request in emulation loop.
      Reported-by: NTomas Papan <tomas.papan@gmail.com>
      Tested-by: NTomas Papan <tomas.papan@gmail.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      CC: stable@vger.kernel.org
      Signed-off-by: NGleb Natapov <gleb@redhat.com>
      8d76c49e
  14. 08 5月, 2013 4 次提交
  15. 07 5月, 2013 3 次提交
  16. 06 5月, 2013 1 次提交
    • K
      xen/vcpu/pvhvm: Fix vcpu hotplugging hanging. · 7f1fc268
      Konrad Rzeszutek Wilk 提交于
      If a user did:
      
      	echo 0 > /sys/devices/system/cpu/cpu1/online
      	echo 1 > /sys/devices/system/cpu/cpu1/online
      
      we would (this a build with DEBUG enabled) get to:
      smpboot: ++++++++++++++++++++=_---CPU UP  1
      .. snip..
      smpboot: Stack at about ffff880074c0ff44
      smpboot: CPU1: has booted.
      
      and hang. The RCU mechanism would kick in an try to IPI the CPU1
      but the IPIs (and all other interrupts) would never arrive at the
      CPU1. At first glance at least. A bit digging in the hypervisor
      trace shows that (using xenanalyze):
      
      [vla] d4v1 vec 243 injecting
         0.043163027 --|x d4v1 intr_window vec 243 src 5(vector) intr f3
      ]  0.043163639 --|x d4v1 vmentry cycles 1468
      ]  0.043164913 --|x d4v1 vmexit exit_reason PENDING_INTERRUPT eip ffffffff81673254
         0.043164913 --|x d4v1 inj_virq vec 243  real
        [vla] d4v1 vec 243 injecting
         0.043164913 --|x d4v1 intr_window vec 243 src 5(vector) intr f3
      ]  0.043165526 --|x d4v1 vmentry cycles 1472
      ]  0.043166800 --|x d4v1 vmexit exit_reason PENDING_INTERRUPT eip ffffffff81673254
         0.043166800 --|x d4v1 inj_virq vec 243  real
        [vla] d4v1 vec 243 injecting
      
      there is a pending event (subsequent debugging shows it is the IPI
      from the VCPU0 when smpboot.c on VCPU1 has done
      "set_cpu_online(smp_processor_id(), true)") and the guest VCPU1 is
      interrupted with the callback IPI (0xf3 aka 243) which ends up calling
      __xen_evtchn_do_upcall.
      
      The __xen_evtchn_do_upcall seems to do *something* but not acknowledge
      the pending events. And the moment the guest does a 'cli' (that is the
      ffffffff81673254 in the log above) the hypervisor is invoked again to
      inject the IPI (0xf3) to tell the guest it has pending interrupts.
      This repeats itself forever.
      
      The culprit was the per_cpu(xen_vcpu, cpu) pointer. At the bootup
      we set each per_cpu(xen_vcpu, cpu) to point to the
      shared_info->vcpu_info[vcpu] but later on use the VCPUOP_register_vcpu_info
      to register per-CPU  structures (xen_vcpu_setup).
      This is used to allow events for more than 32 VCPUs and for performance
      optimizations reasons.
      
      When the user performs the VCPU hotplug we end up calling the
      the xen_vcpu_setup once more. We make the hypercall which returns
      -EINVAL as it does not allow multiple registration calls (and
      already has re-assigned where the events are being set). We pick
      the fallback case and set per_cpu(xen_vcpu, cpu) to point to the
      shared_info->vcpu_info[vcpu] (which is a good fallback during bootup).
      However the hypervisor is still setting events in the register
      per-cpu structure (per_cpu(xen_vcpu_info, cpu)).
      
      As such when the events are set by the hypervisor (such as timer one),
      and when we iterate in __xen_evtchn_do_upcall we end up reading stale
      events from the shared_info->vcpu_info[vcpu] instead of the
      per_cpu(xen_vcpu_info, cpu) structures. Hence we never acknowledge the
      events that the hypervisor has set and the hypervisor keeps on reminding
      us to ack the events which we never do.
      
      The fix is simple. Don't on the second time when xen_vcpu_setup is
      called over-write the per_cpu(xen_vcpu, cpu) if it points to
      per_cpu(xen_vcpu_info).
      Acked-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>
      CC: stable@vger.kernel.org
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      7f1fc268
  17. 05 5月, 2013 1 次提交
  18. 04 5月, 2013 2 次提交
  19. 03 5月, 2013 4 次提交
  20. 01 5月, 2013 1 次提交
    • S
      Kconfig: consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS · 446f24d1
      Stephen Boyd 提交于
      The help text for this config is duplicated across the x86, parisc, and
      s390 Kconfig.debug files.  Arnd Bergman noted that the help text was
      slightly misleading and should be fixed to state that enabling this
      option isn't a problem when using pre 4.4 gcc.
      
      To simplify the rewording, consolidate the text into lib/Kconfig.debug
      and modify it there to be more explicit about when you should say N to
      this config.
      
      Also, make the text a bit more generic by stating that this option
      enables compile time checks so we can cover architectures which emit
      warnings vs.  ones which emit errors.  The details of how an
      architecture decided to implement the checks isn't as important as the
      concept of compile time checking of copy_from_user() calls.
      
      While we're doing this, remove all the copy_from_user_overflow() code
      that's duplicated many times and place it into lib/ so that any
      architecture supporting this option can get the function for free.
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NIngo Molnar <mingo@kernel.org>
      Acked-by: NH. Peter Anvin <hpa@zytor.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Acked-by: NHelge Deller <deller@gmx.de>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Chris Metcalf <cmetcalf@tilera.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      446f24d1