bcm63xx: make nvram checksum failures non fatal
fixes #12982. Signed-off-by: Jonas Gorski <jogo@openwrt.org> SVN-Revision: 35605v19.07.3_mercusys_ac12_duma
parent
162b8e23a5
commit
485e52e1d8
@ -1,49 +0,0 @@
|
||||
From fb1e2c8a1073297f4674ca90c7d533de5187d158 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Sat, 9 Feb 2013 12:09:53 +0100
|
||||
Subject: [PATCH] MIPS: BCM63XX: handle huawei nvram layout
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Huawei uses a custom nvram layout, extending it with additional 32
|
||||
byte field. This pushes also the checksum further, causing it to
|
||||
always fail the check.
|
||||
|
||||
Add an additional crc check for handling this modified nvram layout
|
||||
based on the different size.
|
||||
|
||||
Reported-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/nvram.c | 18 +++++++++++++++++-
|
||||
1 file changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/nvram.c
|
||||
+++ b/arch/mips/bcm63xx/nvram.c
|
||||
@@ -59,8 +59,24 @@ int __init bcm63xx_nvram_init(void *addr
|
||||
|
||||
crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
|
||||
- if (crc != expected_crc)
|
||||
+ if (crc != expected_crc) {
|
||||
+ /* huawei uses a modified nvram that is 32 bytes longer */
|
||||
+ if (nvram.version == 2 && !strncmp(nvram.name, "HW5", 3)) {
|
||||
+ check_len += 32;
|
||||
+
|
||||
+ /* restore old value */
|
||||
+ nvram.checksum_old = expected_crc;
|
||||
+ expected_crc = *(u32 *)&nvram.reserved3[28];
|
||||
+ /* zero the checksum field */
|
||||
+ memset(&nvram.reserved3[28], 0, 4);
|
||||
+
|
||||
+ crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
+
|
||||
+ if (crc == expected_crc)
|
||||
+ return 0;
|
||||
+ }
|
||||
return -EINVAL;
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
From 5e6669fe7487c58b123da1df5c2d95db43185264 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Tue, 12 Feb 2013 22:00:10 +0100
|
||||
Subject: [PATCH] MIPS: BCM63XX: make nvram checksum failure non fatal
|
||||
|
||||
Some vendors modify the nvram layout moving the checksum to a different
|
||||
place or drop it entirely, so reduce the checksum failure to a warning.
|
||||
|
||||
Reported-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 5 +----
|
||||
arch/mips/bcm63xx/nvram.c | 7 +++----
|
||||
arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h | 4 +---
|
||||
3 files changed, 5 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -745,10 +745,7 @@ void __init board_prom_init(void)
|
||||
strcpy(cfe_version, "unknown");
|
||||
printk(KERN_INFO PFX "CFE version: %s\n", cfe_version);
|
||||
|
||||
- if (bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET)) {
|
||||
- printk(KERN_ERR PFX "invalid nvram checksum\n");
|
||||
- return;
|
||||
- }
|
||||
+ bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
|
||||
|
||||
board_name = bcm63xx_nvram_get_name();
|
||||
/* find board by name */
|
||||
--- a/arch/mips/bcm63xx/nvram.c
|
||||
+++ b/arch/mips/bcm63xx/nvram.c
|
||||
@@ -38,7 +38,7 @@ struct bcm963xx_nvram {
|
||||
static struct bcm963xx_nvram nvram;
|
||||
static int mac_addr_used;
|
||||
|
||||
-int __init bcm63xx_nvram_init(void *addr)
|
||||
+void __init bcm63xx_nvram_init(void *addr)
|
||||
{
|
||||
unsigned int check_len;
|
||||
u32 crc, expected_crc;
|
||||
@@ -60,9 +60,8 @@ int __init bcm63xx_nvram_init(void *addr
|
||||
crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
|
||||
if (crc != expected_crc)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- return 0;
|
||||
+ pr_warn("nvram checksum invalid (expected %08x, actual %08x)\n",
|
||||
+ expected_crc, crc);
|
||||
}
|
||||
|
||||
u8 *bcm63xx_nvram_get_name(void)
|
||||
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
|
||||
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
|
||||
@@ -9,10 +9,8 @@
|
||||
*
|
||||
* Initialized the local nvram copy from the target address and checks
|
||||
* its checksum.
|
||||
- *
|
||||
- * Returns 0 on success.
|
||||
*/
|
||||
-int __init bcm63xx_nvram_init(void *nvram);
|
||||
+void bcm63xx_nvram_init(void *nvram);
|
||||
|
||||
/**
|
||||
* bcm63xx_nvram_get_name() - returns the board name according to nvram
|
@ -1,49 +0,0 @@
|
||||
From fb1e2c8a1073297f4674ca90c7d533de5187d158 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Sat, 9 Feb 2013 12:09:53 +0100
|
||||
Subject: [PATCH] MIPS: BCM63XX: handle huawei nvram layout
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Huawei uses a custom nvram layout, extending it with additional 32
|
||||
byte field. This pushes also the checksum further, causing it to
|
||||
always fail the check.
|
||||
|
||||
Add an additional crc check for handling this modified nvram layout
|
||||
based on the different size.
|
||||
|
||||
Reported-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/nvram.c | 18 +++++++++++++++++-
|
||||
1 file changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/nvram.c
|
||||
+++ b/arch/mips/bcm63xx/nvram.c
|
||||
@@ -59,8 +59,24 @@ int __init bcm63xx_nvram_init(void *addr
|
||||
|
||||
crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
|
||||
- if (crc != expected_crc)
|
||||
+ if (crc != expected_crc) {
|
||||
+ /* huawei uses a modified nvram that is 32 bytes longer */
|
||||
+ if (nvram.version == 2 && !strncmp(nvram.name, "HW5", 3)) {
|
||||
+ check_len += 32;
|
||||
+
|
||||
+ /* restore old value */
|
||||
+ nvram.checksum_old = expected_crc;
|
||||
+ expected_crc = *(u32 *)&nvram.reserved3[28];
|
||||
+ /* zero the checksum field */
|
||||
+ memset(&nvram.reserved3[28], 0, 4);
|
||||
+
|
||||
+ crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
+
|
||||
+ if (crc == expected_crc)
|
||||
+ return 0;
|
||||
+ }
|
||||
return -EINVAL;
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
From 5e6669fe7487c58b123da1df5c2d95db43185264 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Tue, 12 Feb 2013 22:00:10 +0100
|
||||
Subject: [PATCH] MIPS: BCM63XX: make nvram checksum failure non fatal
|
||||
|
||||
Some vendors modify the nvram layout moving the checksum to a different
|
||||
place or drop it entirely, so reduce the checksum failure to a warning.
|
||||
|
||||
Reported-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
|
||||
---
|
||||
arch/mips/bcm63xx/boards/board_bcm963xx.c | 5 +----
|
||||
arch/mips/bcm63xx/nvram.c | 7 +++----
|
||||
arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h | 4 +---
|
||||
3 files changed, 5 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
|
||||
@@ -747,10 +747,7 @@ void __init board_prom_init(void)
|
||||
strcpy(cfe_version, "unknown");
|
||||
printk(KERN_INFO PFX "CFE version: %s\n", cfe_version);
|
||||
|
||||
- if (bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET)) {
|
||||
- printk(KERN_ERR PFX "invalid nvram checksum\n");
|
||||
- return;
|
||||
- }
|
||||
+ bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
|
||||
|
||||
board_name = bcm63xx_nvram_get_name();
|
||||
/* find board by name */
|
||||
--- a/arch/mips/bcm63xx/nvram.c
|
||||
+++ b/arch/mips/bcm63xx/nvram.c
|
||||
@@ -38,7 +38,7 @@ struct bcm963xx_nvram {
|
||||
static struct bcm963xx_nvram nvram;
|
||||
static int mac_addr_used;
|
||||
|
||||
-int __init bcm63xx_nvram_init(void *addr)
|
||||
+void __init bcm63xx_nvram_init(void *addr)
|
||||
{
|
||||
unsigned int check_len;
|
||||
u32 crc, expected_crc;
|
||||
@@ -60,9 +60,8 @@ int __init bcm63xx_nvram_init(void *addr
|
||||
crc = crc32_le(~0, (u8 *)&nvram, check_len);
|
||||
|
||||
if (crc != expected_crc)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- return 0;
|
||||
+ pr_warn("nvram checksum invalid (expected %08x, actual %08x)\n",
|
||||
+ expected_crc, crc);
|
||||
}
|
||||
|
||||
u8 *bcm63xx_nvram_get_name(void)
|
||||
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
|
||||
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
|
||||
@@ -9,10 +9,8 @@
|
||||
*
|
||||
* Initialized the local nvram copy from the target address and checks
|
||||
* its checksum.
|
||||
- *
|
||||
- * Returns 0 on success.
|
||||
*/
|
||||
-int __init bcm63xx_nvram_init(void *nvram);
|
||||
+void bcm63xx_nvram_init(void *nvram);
|
||||
|
||||
/**
|
||||
* bcm63xx_nvram_get_name() - returns the board name according to nvram
|
Loading…
Reference in New Issue