aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-03-09 11:58:21 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-10 04:56:12 -0500
commitd4894f3ea7375dd9492b5d3d2ecb0b6e4bdb604e (patch)
treea538179ac50d080a4240f7f9da77655d4b40160c
parent01c3a3920f9f78866420b2004602944fca45083a (diff)
tg3: Add code to verify RODATA checksum of VPD
This patch adds code to verify the checksum stored in the "RV" info keyword of the RODATA VPD section. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tg3.c35
-rw-r--r--include/linux/pci.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8f7160812e06..ffb09795101e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -10499,6 +10499,41 @@ static int tg3_test_nvram(struct tg3 *tp)
10499 if (csum != le32_to_cpu(buf[0xfc/4])) 10499 if (csum != le32_to_cpu(buf[0xfc/4]))
10500 goto out; 10500 goto out;
10501 10501
10502 for (i = 0; i < TG3_NVM_VPD_LEN; i += 4) {
10503 /* The data is in little-endian format in NVRAM.
10504 * Use the big-endian read routines to preserve
10505 * the byte order as it exists in NVRAM.
10506 */
10507 if (tg3_nvram_read_be32(tp, TG3_NVM_VPD_OFF + i, &buf[i/4]))
10508 goto out;
10509 }
10510
10511 i = pci_vpd_find_tag((u8 *)buf, 0, TG3_NVM_VPD_LEN,
10512 PCI_VPD_LRDT_RO_DATA);
10513 if (i > 0) {
10514 j = pci_vpd_lrdt_size(&((u8 *)buf)[i]);
10515 if (j < 0)
10516 goto out;
10517
10518 if (i + PCI_VPD_LRDT_TAG_SIZE + j > TG3_NVM_VPD_LEN)
10519 goto out;
10520
10521 i += PCI_VPD_LRDT_TAG_SIZE;
10522 j = pci_vpd_find_info_keyword((u8 *)buf, i, j,
10523 PCI_VPD_RO_KEYWORD_CHKSUM);
10524 if (j > 0) {
10525 u8 csum8 = 0;
10526
10527 j += PCI_VPD_INFO_FLD_HDR_SIZE;
10528
10529 for (i = 0; i <= j; i++)
10530 csum8 += ((u8 *)buf)[i];
10531
10532 if (csum8)
10533 goto out;
10534 }
10535 }
10536
10502 err = 0; 10537 err = 0;
10503 10538
10504out: 10539out:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 559d02897075..ff5bccb87136 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1479,6 +1479,7 @@ void pci_request_acs(void);
1479#define PCI_VPD_RO_KEYWORD_PARTNO "PN" 1479#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
1480#define PCI_VPD_RO_KEYWORD_MFR_ID "MN" 1480#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
1481#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0" 1481#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0"
1482#define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
1482 1483
1483/** 1484/**
1484 * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length 1485 * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length