1. 16 11月, 2010 1 次提交
  2. 12 11月, 2010 1 次提交
    • M
      PCI: fix size checks for mmap() on /proc/bus/pci files · 3b519e4e
      Martin Wilck 提交于
      The checks for valid mmaps of PCI resources made through /proc/bus/pci files
      that were introduced in 9eff02e2 have several
      problems:
      
      1. mmap() calls on /proc/bus/pci files are made with real file offsets > 0,
      whereas under /sys/bus/pci/devices, the start of the resource corresponds
      to offset 0. This may lead to false negatives in pci_mmap_fits(), which
      implicitly assumes the /sys/bus/pci/devices layout.
      
      2. The loop in proc_bus_pci_mmap doesn't skip empty resouces. This leads
      to false positives, because pci_mmap_fits() doesn't treat empty resources
      correctly (the calculated size is 1 << (8*sizeof(resource_size_t)-PAGE_SHIFT)
      in this case!).
      
      3. If a user maps resources with BAR > 0, pci_mmap_fits will emit bogus
      WARNINGS for the first resources that don't fit until the correct one is found.
      
      On many controllers the first 2-4 BARs are used, and the others are empty.
      In this case, an mmap attempt will first fail on the non-empty BARs
      (including the "right" BAR because of 1.) and emit bogus WARNINGS because
      of 3., and finally succeed on the first empty BAR because of 2.
      This is certainly not the intended behaviour.
      
      This patch addresses all 3 issues.
      Updated with an enum type for the additional parameter for pci_mmap_fits().
      
      Cc: stable@kernel.org
      Signed-off-by: NMartin Wilck <martin.wilck@ts.fujitsu.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      3b519e4e
  3. 31 7月, 2010 3 次提交
  4. 12 6月, 2010 1 次提交
  5. 22 5月, 2010 2 次提交
    • C
      pci: check caps from sysfs file open to read device dependent config space · de139a33
      Chris Wright 提交于
      The PCI config space bin_attr read handler has a hardcoded CAP_SYS_ADMIN
      check to verify privileges before allowing a user to read device
      dependent config space.  This is meant to protect from an unprivileged
      user potentially locking up the box.
      
      When assigning a PCI device directly to a guest with libvirt and KVM,
      the sysfs config space file is chown'd to the unprivileged user that
      the KVM guest will run as.  The guest needs to have full access to the
      device's config space since it's responsible for driving the device.
      However, despite being the owner of the sysfs file, the CAP_SYS_ADMIN
      check will not allow read access beyond the config header.
      
      With this patch we check privileges against the capabilities used when
      openining the sysfs file.  The allows a privileged process to open the
      file and hand it to an unprivileged process, and the unprivileged process
      can still read all of the config space.
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Acked-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      de139a33
    • C
      sysfs: add struct file* to bin_attr callbacks · 2c3c8bea
      Chris Wright 提交于
      This allows bin_attr->read,write,mmap callbacks to check file specific data
      (such as inode owner) as part of any privilege validation.
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2c3c8bea
  6. 12 5月, 2010 2 次提交
  7. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  8. 19 3月, 2010 1 次提交
  9. 08 3月, 2010 2 次提交
  10. 05 1月, 2010 1 次提交
  11. 05 12月, 2009 1 次提交
  12. 07 11月, 2009 1 次提交
    • A
      PCI: derive nearby CPUs from device's instead of bus' NUMA information · e0cd5160
      Andreas Herrmann 提交于
      In case of AMD CPU northbridge functions this NUMA information might
      differ.  Here is an example from a 4-socket system.
      
      Currently Linux shows
      
        root@hagen:/sys/devices/pci0000:00/0000:00:1a.4# cat numa_node
        0
        root@hagen:/sys/devices/pci0000:00/0000:00:1a.4# cat local_cpu*
        0-3
        00000000,0000000f
      
      which is not correct for northbridge functions as the local CPUs
      are those of the same socket.
      
      With this patch and a quirk for AMD CPU NB functions Linux can
      do better and correctly show
      
        root@hagen:/sys/devices/pci0000:00/0000:00:1a.4# cat numa_node
        2
        root@hagen:/sys/devices/pci0000:00/0000:00:1a.4# cat local_cpu*
        8-11
        00000000,00000f00
      Signed-off-by: NAndreas Herrmann <andreas.herrmann3@amd.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      e0cd5160
  13. 10 9月, 2009 1 次提交
  14. 23 4月, 2009 1 次提交
  15. 07 4月, 2009 2 次提交
    • A
      PCI: allow PCI core hotplug to remove PCI root bus · c2ac7cdc
      Alex Chiang 提交于
      There is no reason to prevent removal of root bus devices. A subsequent
      rescan will find them just fine.
      Reviewed-by: NKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
      Signed-off-by: NAlex Chiang <achiang@hp.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      c2ac7cdc
    • Y
      PCI: Setup disabled bridges even if buses are added · 296ccb08
      Yuji Shimada 提交于
      This patch sets up disabled bridges even if buses have already been
      added.
      
      pci_assign_unassigned_resources is called after buses are added.
      pci_assign_unassigned_resources calls pci_bus_assign_resources.
      pci_bus_assign_resources calls pci_setup_bridge to configure BARs of
      bridges.
      
      Currently pci_setup_bridge returns immediately if the bus have already
      been added. So pci_assign_unassigned_resources can't configure BARs of
      bridges that were added in a disabled state; this patch fixes the issue.
      
      On logical hot-add, we need to prevent the kernel from re-initializing
      bridges that have already been initialized. To achieve this,
      pci_setup_bridge returns immediately if the bridge have already been
      enabled.
      
      We don't need to check whether the specified bus is a root bus or not.
      pci_setup_bridge is not called on a root bus, because a root bus does
      not have a bridge.
      
      The patch adds a new helper function, pci_is_enabled. I made the
      function name similar to pci_is_managed. The codes which use
      enable_cnt directly are changed to use pci_is_enabled.
      Acked-by: NAlex Chiang <achiang@hp.com>
      Signed-off-by: NYuji Shimada <shimada-yxb@necst.nec.co.jp>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      296ccb08
  16. 21 3月, 2009 4 次提交
  17. 20 3月, 2009 1 次提交
    • I
      PCI/alpha: pci sysfs resources · 10a0ef39
      Ivan Kokshaysky 提交于
      This closes http://bugzilla.kernel.org/show_bug.cgi?id=10893
      which is a showstopper for X development on alpha.
      
      The generic HAVE_PCI_MMAP code (drivers/pci-sysfs.c) is not
      very useful since we have to deal with three different types
      of MMIO address spaces: sparse and dense mappings for old
      ev4/ev5 machines and "normal" 1:1 MMIO space (bwx) for ev56 and
      later.
      Also "write combine" mappings are meaningless on alpha - roughly
      speaking, alpha does write combining, IO reordering and other
      optimizations by default, unless user splits IO accesses
      with memory barriers.
      
      I think the cleanest way to deal with resource files on alpha
      is to convert the default no-op pci_create_resource_files() and
      pci_remove_resource_files() for !HAVE_PCI_MMAP case into __weak
      functions and override them with alpha specific ones.
      
      Another alpha hook is needed for "legacy_" resource files
      to handle sparse addressing (pci_adjust_legacy_attr).
      
      With the "standard" resourceN files on ev56/ev6 libpciaccess
      works "out of the box". Handling of resourceN_sparse/resourceN_dense
      files on older machines obviously requires some userland work.
      
      Sparse/dense stuff has been tested on sx164 (pca56/pyxis, normally
      uses bwx IO) with the kernel hacked into "cia compatible" mode.
      Signed-off-by: NIvan Kokshaysky <ink@jurassic.park.msu.ru>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      10a0ef39
  18. 05 2月, 2009 1 次提交
  19. 08 1月, 2009 5 次提交
  20. 04 1月, 2009 1 次提交
  21. 13 12月, 2008 1 次提交
    • R
      cpumask: change cpumask_scnprintf, cpumask_parse_user, cpulist_parse, and... · 29c0177e
      Rusty Russell 提交于
      cpumask: change cpumask_scnprintf, cpumask_parse_user, cpulist_parse, and cpulist_scnprintf to take pointers.
      
      Impact: change calling convention of existing cpumask APIs
      
      Most cpumask functions started with cpus_: these have been replaced by
      cpumask_ ones which take struct cpumask pointers as expected.
      
      These four functions don't have good replacement names; fortunately
      they're rarely used, so we just change them over.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NMike Travis <travis@sgi.com>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Cc: paulus@samba.org
      Cc: mingo@redhat.com
      Cc: tony.luck@intel.com
      Cc: ralf@linux-mips.org
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: cl@linux-foundation.org
      Cc: srostedt@redhat.com
      29c0177e
  22. 04 11月, 2008 1 次提交
  23. 21 10月, 2008 3 次提交
  24. 03 10月, 2008 1 次提交
    • L
      Check mapped ranges on sysfs resource files · b5ff7df3
      Linus Torvalds 提交于
      This is loosely based on a patch by Jesse Barnes to check the user-space
      PCI mappings though the sysfs interfaces.  Quoting Jesse's original
      explanation:
      
        It's fairly common for applications to map PCI resources through sysfs.
        However, with the current implementation, it's possible for an application
        to map far more than the range corresponding to the resourceN file it
        opened.  This patch plugs that hole by checking the range at mmap time,
        similar to what is done on platforms like sparc64 in their lower level
        PCI remapping routines.
      
        It was initially put together to help debug the e1000e NVRAM corruption
        problem, since we initially thought an X driver might be walking past the
        end of one of its mappings and clobbering the NVRAM.  It now looks like
        that's not the case, but doing the check is still important for obvious
        reasons.
      
      and this version of the patch differs in that it uses a helper function
      to clarify the code, and does all the checks in pages (instead of bytes)
      in order to avoid overflows when doing "<< PAGE_SHIFT" etc.
      Acked-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b5ff7df3
  25. 03 7月, 2008 1 次提交
    • B
      PCI: Limit VPD read/write lengths for Broadcom 5706, 5708, 5709 rev. · 99cb233d
      Benjamin Li 提交于
      For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the
      VPD end tag will hang the device.  This problem was initially
      observed when a vpd entry was created in sysfs
      ('/sys/bus/pci/devices/<id>/vpd').   A read to this sysfs entry
      will dump 32k of data.  Reading a full 32k will cause an access
      beyond the VPD end tag causing the device to hang.  Once the device
      is hung, the bnx2 driver will not be able to reset the device.
      We believe that it is legal to read beyond the end tag and
      therefore the solution is to limit the read/write length.
      
      A majority of this patch is from Matthew Wilcox who gave code for
      reworking the PCI vpd size information.  A PCI quirk added for the
      Broadcom NIC's to limit the read/write's.
      Signed-off-by: NBenjamin Li <benli@broadcom.com>
      Signed-off-by: NMatthew Wilcox <willy@linux.intel.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      99cb233d