Skip to contentSkip to conversation

Fix lguest bzImage loading with CONFIG_RELOCATABLE=y

PATCH In review Rusty Russell 2 participants 3 messages Jul 27, 2007 – Jul 29, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix lguest bzImage loading with CONFIG_RELOCATABLE=y

Jason Yeh sent his crashing .config: bzImages made with CONFIG_RELOCATABLE=y put the relocs where the BSS is expected, and we crash with unusual results such as:

	lguest: unhandled trap 14 at 0xc0122ae1 (0xa9)

Relying on BSS being zero was merely laziness on my part.

drivers/lguest/lguest.c +5 -0
diff -r cf2bfb364110 drivers/lguest/lguest.c
@@ -1039,6 +1039,11 @@ __init void lguest_init(void *boot)
 	 * the normal data segment to get through booting. */
 	asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory");
 
+	/* Clear the part of the kernel data which is expected to be zero.
+	 * Normally it will be anyway, but if we're loading from a bzImage with
+	 * CONFIG_RELOCATALE=y, the relocations will be sitting here. */
+	memset(__bss_start, 0, __bss_stop - __bss_start);
+
 	/* The Host uses the top of the Guest's virtual address space for the
 	 * Host<->Guest Switcher, and it tells us how much it needs in
 	 * lguest_data.reserve_mem, set up on the LGUEST_INIT hypercall. */
#1 lore raw
Quoted 3 lines · Rusty Russell

Jason Yeh sent his crashing .config: bzImages made with CONFIG_RELOCATABLE=y put the relocs where the BSS is expected, and we crash with unusual results such as:

The normal kernel startup should already clear BSS. Why does this not work here? Can it be fixed?

-Andi

#2 lore raw
Quoted 8 lines · Andi Kleen
Quoted 3 lines · Rusty Russell

Jason Yeh sent his crashing .config: bzImages made with CONFIG_RELOCATABLE=y put the relocs where the BSS is expected, and we crash with unusual results such as:

The normal kernel startup should already clear BSS. Why does this not work here? Can it be fixed?

Unfortunately, lguest doesn't go through the normal startup path (which does this in asm).

Thanks,
Rusty.