1. 26 Nov, 2016 2 commits
    • Paolo Bonzini's avatar
      KVM: x86: fix missed SRCU usage in kvm_lapic_set_vapic_addr · b689e86c
      Paolo Bonzini authored
      commit 7301d6ab upstream.
      
      Reported by syzkaller:
      
          [ INFO: suspicious RCU usage. ]
          4.9.0-rc4+ #47 Not tainted
          -------------------------------
          ./include/linux/kvm_host.h:536 suspicious rcu_dereference_check() usage!
      
          stack backtrace:
          CPU: 1 PID: 6679 Comm: syz-executor Not tainted 4.9.0-rc4+ #47
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
           ffff880039e2f6d0 ffffffff81c2e46b ffff88003e3a5b40 0000000000000000
           0000000000000001 ffffffff83215600 ffff880039e2f700 ffffffff81334ea9
           ffffc9000730b000 0000000000000004 ffff88003c4f8420 ffff88003d3f8000
          Call Trace:
           [<     inline     >] __dump_stack lib/dump_stack.c:15
           [<ffffffff81c2e46b>] dump_stack+0xb3/0x118 lib/dump_stack.c:51
           [<ffffffff81334ea9>] lockdep_rcu_suspicious+0x139/0x180 kernel/locking/lockdep.c:4445
           [<     inline     >] __kvm_memslots include/linux/kvm_host.h:534
           [<     inline     >] kvm_memslots include/linux/kvm_host.h:541
           [<ffffffff8105d6ae>] kvm_gfn_to_hva_cache_init+0xa1e/0xce0 virt/kvm/kvm_main.c:1941
           [<ffffffff8112685d>] kvm_lapic_set_vapic_addr+0xed/0x140 arch/x86/kvm/lapic.c:2217
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Fixes: fda4e2e8
      Cc: Andrew Honig <ahonig@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b689e86c
    • Yazen Ghannam's avatar
      x86/cpu/AMD: Fix cpu_llc_id for AMD Fam17h systems · aea9d760
      Yazen Ghannam authored
      commit b0b6e868 upstream.
      
      cpu_llc_id (Last Level Cache ID) derivation on AMD Fam17h has an
      underflow bug when extracting the socket_id value. It starts from 0
      so subtracting 1 from it will result in an invalid value. This breaks
      scheduling topology later on since the cpu_llc_id will be incorrect.
      
      For example, the the cpu_llc_id of the *other* CPU in the loops in
      set_cpu_sibling_map() underflows and we're generating the funniest
      thread_siblings masks and then when I run 8 threads of nbench, they get
      spread around the LLC domains in a very strange pattern which doesn't
      give you the normal scheduling spread one would expect for performance.
      
      Other things like EDAC use cpu_llc_id so they will be b0rked too.
      
      So, the APIC ID is preset in APICx020 for bits 3 and above: they contain
      the core complex, node and socket IDs.
      
      The LLC is at the core complex level so we can find a unique cpu_llc_id
      by right shifting the APICID by 3 because then the least significant bit
      will be the Core Complex ID.
      Tested-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarYazen Ghannam <Yazen.Ghannam@amd.com>
      [ Cleaned up and extended the commit message. ]
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Aravind Gopalakrishnan <aravindksg.lkml@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: 3849e91f ("x86/AMD: Fix last level cache topology for AMD Fam17h systems")
      Link: http://lkml.kernel.org/r/20161108083506.rvqb5h4chrcptj7d@pd.tnicSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aea9d760
  2. 21 Nov, 2016 38 commits