All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: Federico <federicotg@gmail.com>
Cc: Maling list - DRI developers <dri-devel@lists.freedesktop.org>
Subject: Re: Softlockup on boot with Cape Verde XT on many kernels
Date: Thu, 15 Jan 2015 15:21:29 +0900	[thread overview]
Message-ID: <54B75C69.4070907@daenzer.net> (raw)
In-Reply-To: <CAFUqUc6uKzY8MUKiENgE69vq-vBWRxYNZJn5EPyFd__YMtRn6A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

On 15.01.2015 12:53, Federico wrote:
> How about this? It seems at least related.
> 
> https://github.com/alterapraxisptyltd/openatom/issues/1
> 
> Quote:
> [linux] Infinite loop in pci_get_rom_size()
> 
> This is one of those issues that you find when putting supposedly stable
> code through unusual situations. I did expect any function in linux that
> is not part of radeon.ko to not be rock solid. Turns out that's not
> really the case.
> 
> If we have a PCIR structure with a zero size length, the loop iterating
> through those structure does not advance. It simply does "image +=
> readw(pds + 16) * 512;", but if that field is zero we're back analyzing
> the same structure on the next loop. The way to get out of this loop is
> to set bit 7 of the type field. That's what 'last_image' does. If that
> bit is not set, with the above, that's an infinite loop.
> 
> Luckily, it doesn't crash the kernel, but it hangs any driver that calls
> the function under said circumstances. No more modprobe -r or unbinding.
> Reboot is needed. No idea why a firmware blob here is treated as trusted
> input.

That could indeed explain it, does the attached patch help?


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pci_get_rom_size.diff --]
[-- Type: text/x-patch; name="pci_get_rom_size.diff", Size: 870 bytes --]

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index f955edb..2fb5013 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -75,6 +75,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 	image = rom;
 	do {
 		void __iomem *pds;
+		u16 length;
 		/* Standard PCI ROMs start out with these bytes 55 AA */
 		if (readb(image) != 0x55) {
 			dev_err(&pdev->dev, "Invalid ROM contents\n");
@@ -93,8 +94,10 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 		if (readb(pds + 3) != 'R')
 			break;
 		last_image = readb(pds + 21) & 0x80;
-		/* this length is reliable */
-		image += readw(pds + 16) * 512;
+		length = readw(pds + 16);
+		if (!length)
+			break;
+		image += length * 512;
 	} while (!last_image);
 
 	/* never return a size larger than the PCI resource window */

[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-01-15  6:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-11  1:58 Softlockup on boot with Cape Verde XT on many kernels Federico
2015-01-11 17:19 ` Alex Deucher
     [not found]   ` <CAFUqUc7qXoNQJwyXJtcx=6gmG0hwnHeor-NyfoPPchX9EYTDzA@mail.gmail.com>
2015-01-11 19:44     ` Fwd: " Federico
2015-01-11 20:27       ` Federico
2015-01-12 21:48         ` Alex Deucher
2015-01-12 23:34           ` Federico
2015-01-13  7:06 ` Michel Dänzer
2015-01-13 18:20   ` Federico
2015-01-14  2:19     ` Michel Dänzer
2015-01-14  3:41       ` Federico
2015-01-14  3:54         ` Michel Dänzer
2015-01-14 13:29           ` Federico
2015-01-15  0:10             ` Federico
2015-01-15  2:10               ` Federico
2015-01-15  2:46                 ` Michel Dänzer
2015-01-15  2:59                   ` Federico
2015-01-15  3:14                     ` Federico
2015-01-15  3:53                       ` Federico
2015-01-15  6:21                         ` Michel Dänzer [this message]
2015-01-15 20:33                           ` Federico
2015-01-16 13:02                             ` Federico
2015-01-19  8:53                               ` [PATCH v2] pci: Fix infinite loop with ROM image of size 0 Michel Dänzer
2015-01-19  8:53                                 ` Michel Dänzer
2015-01-19 18:48                                 ` Alex Deucher
2015-01-23 23:51                                 ` Bjorn Helgaas
2015-01-23 23:51                                   ` Bjorn Helgaas

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=54B75C69.4070907@daenzer.net \
    --to=michel@daenzer.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=federicotg@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.