public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linux-pci@atrey.karlin.mff.cuni.cz
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Possible issue with dangling PCI BARs
Date: Thu, 13 Dec 2007 14:00:04 +1100	[thread overview]
Message-ID: <1197514804.15741.60.camel@pasglop> (raw)

While reworking the powerpc PCI resource management, to make it more
x86-like and use more of the generic code in setup-bus.c and
setup-res.c, I noticed something a bit fishy in the way we deal with
resources that we failed to assign.

That's especially problematic for us as we have to deal with all sort of
more or less crappy firmwares, so we need our PCI code to be as robust
as possible vs. whatever might have been there before the kernel kicks
in.

Now, let's say that we have a device for which a BAR contain a value out
of whack or conflicting with something else. We "see" that in
pcibios_allocate_resources() and set res->start to 0 (and offset
res->end accordingly).

At this stage, we thus have a resource that is marked as unassigned.
However, we haven't actually modified the BAR content. So the device is
still potentially decoding the conflicting addresses (which may have
been allocated to some other device).

Now, normally, pci_assign_unassigned_resources() will take care of that
and assign some new address to this device. However, that may fail
(bridge window too small for example). Which mean we leave a device with
a dangling BAR. In fact, a driver may even successfully call
pci_enable_device_bars() on it, provided that the device has several
resources and that the one that is/are requested by the driver (via the
bitmask argument) are not the one(s) that failed to allocate.

So not only we can have a dangling BAR, but nothing prevent us to
actually go turn IO or MEM decoding on in case it wasn't already the
case on that device.

Ben.



             reply	other threads:[~2007-12-13  3:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-13  3:00 Benjamin Herrenschmidt [this message]
2007-12-13  3:04 ` Possible issue with dangling PCI BARs Benjamin Herrenschmidt
2007-12-13  3:40   ` Benjamin Herrenschmidt
2007-12-14 11:52 ` Jon Masters
2007-12-14 22:11   ` Benjamin Herrenschmidt
2007-12-15  2:18     ` Jon Masters
     [not found] <fa.YfTvVN5C3e6zwXPW5biWgeZ9XXc@ifi.uio.no>
     [not found] ` <fa.EhUqlM3V3y3HCcQkLBLSEKTJxBs@ifi.uio.no>
     [not found]   ` <fa.4FjaYKIciOijtgO+0DDrMkrLjv0@ifi.uio.no>
2007-12-13  4:22     ` Robert Hancock
2007-12-13  5:26       ` Benjamin Herrenschmidt
2007-12-13  9:14         ` Ivan Kokshaysky
2007-12-13  9:29           ` Benjamin Herrenschmidt
2007-12-13  9:04       ` Ivan Kokshaysky
2007-12-13 10:24         ` Alan Cox
2007-12-13 11:17           ` Benjamin Herrenschmidt
2007-12-13 11:20             ` Benjamin Herrenschmidt
2007-12-13 20:04               ` Jesse Barnes
2007-12-13 20:51                 ` Benjamin Herrenschmidt
2007-12-13 21:12                   ` Ivan Kokshaysky
2007-12-13 23:09                     ` Benjamin Herrenschmidt
2007-12-13 21:02               ` Ivan Kokshaysky
2007-12-13 13:27             ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1197514804.15741.60.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox