public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Olof Johansson <olof@lixom.net>
To: linux-kernel@vger.kernel.org
Cc: linux-pci@atrey.karlin.mff.cuni.cz, greg@kroah.com,
	akpm@osdl.org, linuxppc64-dev@ozlabs.org
Subject: [PATCH] Fix PCI BAR size interpretation on 64-bit arches
Date: Fri, 10 Jun 2005 16:22:52 -0500	[thread overview]
Message-ID: <20050610212252.GA28655@austin.ibm.com> (raw)

Hi,

On 64-bit machines, PCI_BASE_ADDRESS_MEM_MASK and other mask constants
passed to pci_size() are 64-bit (for example ~0x0fUL). However, pci_size
does comparisons between the u32 arguments and the mask, which will fail
even though any result from pci_size is still just 32-bit.

Changing the mask argument to u32 seems the obvious thing to do, since
all arithmetic in the function is 32-bit and having a larger mask makes
no sense.

This triggered on a PPC64 system here where an adapter (VGA, as it
happened) had a memory region base of 0xfe000000 and a sz of the same,
matching the if (max == maxbase ...) test at the bottom of pci_size
but failing the mask comparison. Quite a corner case which I guess
explains why we haven't seen it until now.


Signed-off-by: Olof Johansson <olof@lixom.net>

Index: 2.6/drivers/pci/probe.c
===================================================================
--- 2.6.orig/drivers/pci/probe.c	2005-06-10 15:09:37.000000000 -0500
+++ 2.6/drivers/pci/probe.c	2005-06-10 15:43:36.000000000 -0500
@@ -125,7 +125,7 @@ static inline unsigned int pci_calc_reso
 /*
  * Find the extent of a PCI decode..
  */
-static u32 pci_size(u32 base, u32 maxbase, unsigned long mask)
+static u32 pci_size(u32 base, u32 maxbase, u32 mask)
 {
 	u32 size = mask & maxbase;	/* Find the significant bits */
 	if (!size)

                 reply	other threads:[~2005-06-10 22:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20050610212252.GA28655@austin.ibm.com \
    --to=olof@lixom.net \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=linuxppc64-dev@ozlabs.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