1. 03 Dec, 2012 35 commits
  2. 26 Nov, 2012 5 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.0.53 · 2fc3fd44
      Greg Kroah-Hartman authored
      2fc3fd44
    • Ram Pai's avatar
      Resource: fix wrong resource window calculation · b87c48d7
      Ram Pai authored
      commit 47ea91b4 upstream.
      
      __find_resource() incorrectly returns a resource window which overlaps
      an existing allocated window.  This happens when the parent's
      resource-window spans 0x00000000 to 0xffffffff and is entirely allocated
      to all its children resource-windows.
      
      __find_resource() looks for gaps in resource allocation among the
      children resource windows.  When it encounters the last child window it
      blindly tries the range next to one allocated to the last child.  Since
      the last child's window ends at 0xffffffff the calculation overflows,
      leading the algorithm to believe that any window in the range 0x0000000
      to 0xfffffff is available for allocation.  This leads to a conflicting
      window allocation.
      
      Michal Ludvig reported this issue seen on his platform.  The following
      patch fixes the problem and has been verified by Michal.  I believe this
      bug has been there for ages.  It got exposed by git commit 2bbc6942
      ("PCI : ability to relocate assigned pci-resources")
      Signed-off-by: default avatarRam Pai <linuxram@us.ibm.com>
      Tested-by: default avatarMichal Ludvig <mludvig@logix.net.nz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b87c48d7
    • Yinghai Lu's avatar
      PCI : Calculate right add_size · 8515be67
      Yinghai Lu authored
      commit a4ac9fea upstream.
      
      During debug of one SRIOV enabled hotplug device, we found found that
      add_size is not passed properly.
      
      The device has devices under two level bridges:
      
       +-[0000:80]-+-00.0-[81-8f]--
       |           +-01.0-[90-9f]--
       |           +-02.0-[a0-af]----00.0-[a1-a3]--+-02.0-[a2]--+-00.0  Oracle Corporation Device
       |           |                               \-03.0-[a3]--+-00.0  Oracle Corporation Device
      
      Which means later the parent bridge will not try to add a big enough range:
      
      [  557.455077] pci 0000:a0:00.0: BAR 14: assigned [mem 0xf9000000-0xf93fffff]
      [  557.461974] pci 0000:a0:00.0: BAR 15: assigned [mem 0xf6000000-0xf61fffff pref]
      [  557.469340] pci 0000:a1:02.0: BAR 14: assigned [mem 0xf9000000-0xf91fffff]
      [  557.476231] pci 0000:a1:02.0: BAR 15: assigned [mem 0xf6000000-0xf60fffff pref]
      [  557.483582] pci 0000:a1:03.0: BAR 14: assigned [mem 0xf9200000-0xf93fffff]
      [  557.490468] pci 0000:a1:03.0: BAR 15: assigned [mem 0xf6100000-0xf61fffff pref]
      [  557.497833] pci 0000:a1:03.0: BAR 14: can't assign mem (size 0x200000)
      [  557.504378] pci 0000:a1:03.0: failed to add optional resources res=[mem 0xf9200000-0xf93fffff]
      [  557.513026] pci 0000:a1:02.0: BAR 14: can't assign mem (size 0x200000)
      [  557.519578] pci 0000:a1:02.0: failed to add optional resources res=[mem 0xf9000000-0xf91fffff]
      
      It turns out we did not calculate size1 properly.
      
      static resource_size_t calculate_memsize(resource_size_t size,
                      resource_size_t min_size,
                      resource_size_t size1,
                      resource_size_t old_size,
                      resource_size_t align)
      {
              if (size < min_size)
                      size = min_size;
              if (old_size == 1 )
                      old_size = 0;
              if (size < old_size)
                      size = old_size;
              size = ALIGN(size + size1, align);
              return size;
      }
      
      We should not pass add_size with min_size in calculate_memsize since
      that will make add_size not contribute final add_size.
      
      So just pass add_size with size1 to calculate_memsize().
      
      With this change, we should have chance to remove extra addon in
      pci_reassign_resource.
      Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
      Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Andrew Worsley <amworsley@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8515be67
    • Ram Pai's avatar
      PCI : ability to relocate assigned pci-resources · 36720ae8
      Ram Pai authored
      commit 2bbc6942 upstream.
      
      Currently pci-bridges are allocated enough resources to satisfy their immediate
      requirements.  Any additional resource-requests fail if additional free space,
      contiguous to the one already allocated, is not available. This behavior is not
      reasonable since sufficient contiguous resources, that can satisfy the request,
      are available at a different location.
      
      This patch provides the ability to expand and relocate a allocated resource.
      
      	v2: Changelog: Fixed size calculation in pci_reassign_resource()
      	v3: Changelog : Split this patch. The resource.c changes are already
      			upstream. All the pci driver changes are in here.
      Signed-off-by: default avatarRam Pai <linuxram@us.ibm.com>
      Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Andrew Worsley <amworsley@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36720ae8
    • Dave Jones's avatar
      selinux: fix sel_netnode_insert() suspicious rcu dereference · 95eb6d3d
      Dave Jones authored
      commit 88a693b5 upstream.
      
      ===============================
      [ INFO: suspicious RCU usage. ]
      3.5.0-rc1+ #63 Not tainted
      -------------------------------
      security/selinux/netnode.c:178 suspicious rcu_dereference_check() usage!
      
      other info that might help us debug this:
      
      rcu_scheduler_active = 1, debug_locks = 0
      1 lock held by trinity-child1/8750:
       #0:  (sel_netnode_lock){+.....}, at: [<ffffffff812d8f8a>] sel_netnode_sid+0x16a/0x3e0
      
      stack backtrace:
      Pid: 8750, comm: trinity-child1 Not tainted 3.5.0-rc1+ #63
      Call Trace:
       [<ffffffff810cec2d>] lockdep_rcu_suspicious+0xfd/0x130
       [<ffffffff812d91d1>] sel_netnode_sid+0x3b1/0x3e0
       [<ffffffff812d8e20>] ? sel_netnode_find+0x1a0/0x1a0
       [<ffffffff812d24a6>] selinux_socket_bind+0xf6/0x2c0
       [<ffffffff810cd1dd>] ? trace_hardirqs_off+0xd/0x10
       [<ffffffff810cdb55>] ? lock_release_holdtime.part.9+0x15/0x1a0
       [<ffffffff81093841>] ? lock_hrtimer_base+0x31/0x60
       [<ffffffff812c9536>] security_socket_bind+0x16/0x20
       [<ffffffff815550ca>] sys_bind+0x7a/0x100
       [<ffffffff816c03d5>] ? sysret_check+0x22/0x5d
       [<ffffffff810d392d>] ? trace_hardirqs_on_caller+0x10d/0x1a0
       [<ffffffff8133b09e>] ? trace_hardirqs_on_thunk+0x3a/0x3f
       [<ffffffff816c03a9>] system_call_fastpath+0x16/0x1b
      
      This patch below does what Paul McKenney suggested in the previous thread.
      Signed-off-by: default avatarDave Jones <davej@redhat.com>
      Reviewed-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Cc: Eric Paris <eparis@parisplace.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95eb6d3d