[PATCH] add volatile to code that gets optimized out

The gcc 4.5 compiler is optimizing out some code used to bring up auxillary processors. Adding volatile to the auxillary processor jump trampoline memory references gets the bios able to boot with -smp >1 again. Signed-off-by: Bruce Rogers <brogers@novell.com> smp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/smp.c b/src/smp.c index dac95bf..ce7c81c 100644 --- a/src/smp.c +++ b/src/smp.c @@ -84,11 +84,11 @@ smp_probe(void) writel(&CountCPUs, 1); // Setup jump trampoline to counter code. - u64 old = *(u64*)BUILD_AP_BOOT_ADDR; + u64 old = *(volatile u64*)BUILD_AP_BOOT_ADDR; // ljmpw $SEG_BIOS, $(smp_ap_boot_code - BUILD_BIOS_ADDR) u64 new = (0xea | ((u64)SEG_BIOS<<24) | (((u32)smp_ap_boot_code - BUILD_BIOS_ADDR) << 8)); - *(u64*)BUILD_AP_BOOT_ADDR = new; + *(volatile u64*)BUILD_AP_BOOT_ADDR = new; // enable local APIC u32 val = readl(APIC_SVR); @@ -117,7 +117,7 @@ smp_probe(void) } // Restore memory. - *(u64*)BUILD_AP_BOOT_ADDR = old; + *(volatile u64*)BUILD_AP_BOOT_ADDR = old; MaxCountCPUs = qemu_cfg_get_max_cpus(); if (!MaxCountCPUs || MaxCountCPUs < CountCPUs)

On Tue, Mar 09, 2010 at 08:36:11PM -0700, Bruce Rogers wrote:
The gcc 4.5 compiler is optimizing out some code used to bring up auxillary processors. Adding volatile to the auxillary processor jump trampoline memory references gets the bios able to boot with -smp >1 again.
Thanks. Does the following alternate patch work? --- a/src/smp.c +++ b/src/smp.c @@ -103,6 +103,7 @@ smp_probe(void) } // broadcast SIPI + barrier(); writel(APIC_ICR_LOW, 0x000C4500); u32 sipi_vector = BUILD_AP_BOOT_ADDR >> 12; writel(APIC_ICR_LOW, 0x000C4600 | sipi_vector);

Yes, that takes care of the problem as well. Bruce
On 3/9/2010 at 10:13 PM, Kevin O'Connor <kevin@koconnor.net> wrote:
On Tue, Mar 09, 2010 at 08:36:11PM -0700, Bruce Rogers wrote:
The gcc 4.5 compiler is optimizing out some code used to bring up auxillary processors. Adding volatile to the auxillary processor jump trampoline memory references gets the bios able to boot with -smp >1 again.
Thanks. Does the following alternate patch work? --- a/src/smp.c +++ b/src/smp.c @@ -103,6 +103,7 @@ smp_probe(void) } // broadcast SIPI + barrier(); writel(APIC_ICR_LOW, 0x000C4500); u32 sipi_vector = BUILD_AP_BOOT_ADDR >> 12; writel(APIC_ICR_LOW, 0x000C4600 | sipi_vector);

On Wed, Mar 10, 2010 at 08:10:02AM -0700, Bruce Rogers wrote:
Yes, that takes care of the problem as well. Bruce
Thanks - commit 808939c1. -Kevin
participants (2)
-
Bruce Rogers
-
Kevin O'Connor