AMD sb800 sb900: Fix corruption of a global ramstage variable

A late for loop may reference over the current array allocation
and corrupt an unrelated global variable. As a quick fix bumb the
size of the array allocation uniformly to 6.

Change-Id: Ib067fdf077e091d13e32cc3a8e4a0b713d19bcc2
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/3914
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
Reviewed-by: Bruce Griffith <Bruce.Griffith@se-eng.com>
This commit is contained in:
Kyösti Mälkki 2013-09-09 09:23:19 +03:00
parent c984f4f303
commit 9c7d73ca3f
36 changed files with 51 additions and 72 deletions

View File

@ -36,7 +36,7 @@
*/ */
int bus_isa; int bus_isa;
u8 bus_rs780[11]; u8 bus_rs780[11];
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,7 @@ void get_bus_conf(void)
sbdn_rs780 = sysconf.sbdn; sbdn_rs780 = sysconf.sbdn;
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) { for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) {
bus_rs780[i] = 0; bus_rs780[i] = 0;
} }

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_rs780[8]; extern u8 bus_rs780[8];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -28,7 +28,7 @@
extern int bus_isa; extern int bus_isa;
extern u8 bus_rs780[11]; extern u8 bus_rs780[11];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;
extern u32 bus_type[256]; extern u32 bus_type[256];
extern u32 sbdn_rs780; extern u32 sbdn_rs780;

View File

@ -33,7 +33,7 @@
*/ */
int bus_isa; int bus_isa;
u8 bus_rs780[11]; u8 bus_rs780[11];
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -84,9 +84,8 @@ void get_bus_conf(void)
sbdn_rs780 = sysconf.sbdn; sbdn_rs780 = sysconf.sbdn;
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) { for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) {
bus_rs780[i] = 0; bus_rs780[i] = 0;
} }

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_rs780[8]; extern u8 bus_rs780[8];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -28,7 +28,7 @@
extern int bus_isa; extern int bus_isa;
extern u8 bus_rs780[11]; extern u8 bus_rs780[11];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;
extern u32 bus_type[256]; extern u32 bus_type[256];
extern u32 sbdn_rs780; extern u32 sbdn_rs780;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,7 @@ void get_bus_conf(void)
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -99,9 +99,7 @@ void get_bus_conf(void)
#endif #endif
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,7 @@ void get_bus_conf(void)
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -31,7 +31,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb900[3]; u8 bus_sb900[6];
/* /*
* Here you only need to set value in pci1234 for HT-IO that could be installed or not * Here you only need to set value in pci1234 for HT-IO that could be installed or not
@ -94,9 +94,7 @@ void get_bus_conf(void)
sbdn_sb900 = 0; sbdn_sb900 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb900, 0, sizeof(bus_sb900));
bus_sb900[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -46,7 +46,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb900[2]; extern u8 bus_sb900[6];
extern unsigned long sbdn_sb900; extern unsigned long sbdn_sb900;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -31,7 +31,7 @@
//-#define IO_APIC_ID CONFIG_MAX_PHYSICAL_CPUS + 1 //-#define IO_APIC_ID CONFIG_MAX_PHYSICAL_CPUS + 1
#define IO_APIC_ID CONFIG_MAX_CPUS #define IO_APIC_ID CONFIG_MAX_CPUS
extern u8 bus_sb900[2]; extern u8 bus_sb900[6];
extern u32 bus_type[256]; extern u32 bus_type[256];

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,7 @@ void get_bus_conf(void)
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,7 @@ void get_bus_conf(void)
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -36,7 +36,7 @@
*/ */
int bus_isa; int bus_isa;
u8 bus_rs780[11]; u8 bus_rs780[11];
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,8 @@ void get_bus_conf(void)
sbdn_rs780 = sysconf.sbdn; sbdn_rs780 = sysconf.sbdn;
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) { for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) {
bus_rs780[i] = 0; bus_rs780[i] = 0;
} }

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_rs780[8]; extern u8 bus_rs780[8];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -28,7 +28,7 @@
extern int bus_isa; extern int bus_isa;
extern u8 bus_rs780[11]; extern u8 bus_rs780[11];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;
extern u32 bus_type[256]; extern u32 bus_type[256];
extern u32 sbdn_rs780; extern u32 sbdn_rs780;

View File

@ -36,7 +36,7 @@
*/ */
int bus_isa; int bus_isa;
u8 bus_rs780[11]; u8 bus_rs780[11];
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -87,9 +87,8 @@ void get_bus_conf(void)
sbdn_rs780 = sysconf.sbdn; sbdn_rs780 = sysconf.sbdn;
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) { for (i = 0; i < ARRAY_SIZE(bus_rs780); i++) {
bus_rs780[i] = 0; bus_rs780[i] = 0;
} }

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_rs780[8]; extern u8 bus_rs780[8];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -28,7 +28,7 @@
extern int bus_isa; extern int bus_isa;
extern u8 bus_rs780[11]; extern u8 bus_rs780[11];
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;
extern u32 bus_type[256]; extern u32 bus_type[256];
extern u32 sbdn_rs780; extern u32 sbdn_rs780;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -99,9 +99,7 @@ void get_bus_conf(void)
#endif #endif
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;

View File

@ -34,7 +34,7 @@
* and acpi_tables busnum is default. * and acpi_tables busnum is default.
*/ */
u8 bus_isa; u8 bus_isa;
u8 bus_sb800[3]; u8 bus_sb800[6];
u32 apicid_sb800; u32 apicid_sb800;
/* /*
@ -99,9 +99,7 @@ void get_bus_conf(void)
#endif #endif
sbdn_sb800 = 0; sbdn_sb800 = 0;
for (i = 0; i < 3; i++) { memset(bus_sb800, 0, sizeof(bus_sb800));
bus_sb800[i] = 0;
}
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
bus_type[i] = 0; /* default ISA bus. */ bus_type[i] = 0; /* default ISA bus. */

View File

@ -45,7 +45,7 @@ static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
pirq_info->rfu = rfu; pirq_info->rfu = rfu;
} }
extern u8 bus_isa; extern u8 bus_isa;
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern unsigned long sbdn_sb800; extern unsigned long sbdn_sb800;
unsigned long write_pirq_routing_table(unsigned long addr) unsigned long write_pirq_routing_table(unsigned long addr)

View File

@ -27,7 +27,7 @@
#include <cpu/amd/amdfam14.h> #include <cpu/amd/amdfam14.h>
#include <SBPLATFORM.h> #include <SBPLATFORM.h>
extern u8 bus_sb800[2]; extern u8 bus_sb800[6];
extern u32 apicid_sb800; extern u32 apicid_sb800;