[PATCH] pci-sysfs: backport fix for 2.6.11.12

From: Michael S. Tsirkin (mst_at_mellanox.co.il)
Date: 05/31/05

  • Next message: Dominik Hackl: "[PATCH 2.6.12-rc5] UML + UDF duplicated symbol"
    Date:	Tue, 31 May 2005 19:36:19 +0300
    To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>, linux-kernel@vger.kernel.org, linux-pci@atrey.karlin.mff.cuni.cz
    
    

    Greg, before 2.6.12, pci_write_config in pci-sysfs.c was broken, causing
    incorrect data being written to the configuration register,
    which in the case of my userspace driver results in system failure.

    This has been fixed in 2.6.12-rc5:

    http://www.kernel.org/diff/diffview.cgi?file=%2Fpub%2Flinux%2Fkernel%2Fv2.6%2Ftesting%2Fpatch-2.6.12-rc5.bz2;z=2656

    Would you please consider merging the fix for 2.6.11.12 as well?

    Alternatively (since there were multiple other changes in pci-sysfs.c), here's
    a small patch to fix just this issue.

    Thanks,
    MST

    cast from (signed) char to unsigned int in pci_write_config
    causes the result to be sign extended, clobbering high bits in the result.
    Thus:

    # setpci -s 07:00.0 14.L=E4
    # setpci -s 07:00.0 14.L
    ffffffe4

    Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>

    --- linux-2.6.11-openib/drivers/pci/pci-sysfs.c.bad 2005-05-30 13:45:02.000000000 +0300
    +++ linux-2.6.11-openib/drivers/pci/pci-sysfs.c 2005-05-30 13:51:39.000000000 +0300
    @@ -161,10 +161,10 @@ pci_write_config(struct kobject *kobj, c
             }
     
             while (size > 3) {
    - unsigned int val = buf[off - init_off];
    - val |= (unsigned int) buf[off - init_off + 1] << 8;
    - val |= (unsigned int) buf[off - init_off + 2] << 16;
    - val |= (unsigned int) buf[off - init_off + 3] << 24;
    + unsigned int val = (u8)buf[off - init_off];
    + val |= (unsigned int)(u8)buf[off - init_off + 1] << 8;
    + val |= (unsigned int)(u8)buf[off - init_off + 2] << 16;
    + val |= (unsigned int)(u8)buf[off - init_off + 3] << 24;
                     pci_write_config_dword(dev, off, val);
                     off += 4;
                     size -= 4;

    -- 
    MST - Michael S. Tsirkin
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Dominik Hackl: "[PATCH 2.6.12-rc5] UML + UDF duplicated symbol"

    Relevant Pages

    • [PATCH] pci-sysfs: backport fix for 2.6.11.12
      ... incorrect data being written to the configuration register, ... which in the case of my userspace driver results in system failure. ... Would you please consider merging the fix for 2.6.11.12 as well? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Power Management Update
      ... I encountered this problem by having an IDE CD-ROM, ... He mentioned producing a cleaner patch, but this should at least fix the ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] fs/fcntl.c : dont test unsigned value for less than zero
      ... I think the real problem here is that 'arg' ... architecture's ptrace code could easily make use of the latter, ... But be careful not to "fix up" ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Testing RC kernels [KORG]
      ... Can someone with access to the html for kernel.org please fix that? ... We've had several messages now complaining about this. ... Copyright 2005 by Maurice Eugene Heskett, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.4.22-rc2 ext2 filesystem corruption
      ... > # Without this fix it mistakenly assumes that the empty drive slot ... the 64K cylinders problem) I know I saw transfer speeds greater than ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)