fix kexec asm
PATCH 1/1 fix kexec asm
From: Michael Matz <[email protected]>
While testing kexec and kdump we hit problems where the new kernel would freeze or instantly reboot. The easiest way to trigger it was to kexec a kernel compiled for CONFIG_M586 on an athlon cpu. Compiling for CONFIG_MK7 instead would work fine.
The patch below fixes a few problems with the kexec inline asm.
---
arch/i386/kernel/machine_kexec.c +7 -7
@@ -116,13 +116,13 @@ static void load_segments(void) __asm__ __volatile__ ( "\tljmp $"STR(__KERNEL_CS)",$1f\n""\t1:\n" - "\tmovl $"STR(__KERNEL_DS)",%eax\n" -"\tmovl %eax,%ds\n" -"\tmovl %eax,%es\n" -"\tmovl %eax,%fs\n" -"\tmovl %eax,%gs\n" -"\tmovl %eax,%ss\n" - ); + "\tmovl $"STR(__KERNEL_DS)",%%eax\n" +"\tmovl %%eax,%%ds\n" +"\tmovl %%eax,%%es\n" +"\tmovl %%eax,%%fs\n" +"\tmovl %%eax,%%gs\n" +"\tmovl %%eax,%%ss\n" + ::: "eax", "memory");#undef STR#undef __STR }
arch/x86_64/kernel/machine_kexec.c +1 -1
@@ -140,7 +140,7 @@ static void load_segments(void) "\tmovl %0,%%ss\n" "\tmovl %0,%%fs\n" "\tmovl %0,%%gs\n" - : : "a" (__KERNEL_DS) + : : "a" (__KERNEL_DS) : "memory" ); }
include/asm-powerpc/kexec.h +2 -1
@@ -93,7 +93,8 @@ static inline void crash_setup_regs(stru "mfxer %0\n" "std %0, 296(%2)\n" : "=&r" (tmp1), "=&r" (tmp2) - : "b" (newregs)); + : "b" (newregs) + : "memory"); } }#else
Quoted 8 lines · Chris Mason
From: Michael Matz <[email protected]>
While testing kexec and kdump we hit problems where the new kernel would freeze or instantly reboot. The easiest way to trigger it was to kexec a kernel compiled for
CONFIG_M586on an athlon cpu. Compiling forCONFIG_MK7instead would work fine.The patch below fixes a few problems with the kexec inline asm.
Thanks. Specifying the stomp of %eax in load_segments is definitely good. The memory stomp looks excessive and if this was a fast path I would worry about it. As it is better safe than sorry.
Eric
Quoted 9 lines · Eric W. Biederman
Quoted 7 lines · Chris Mason
From: Michael Matz <[email protected]>
While testing kexec and kdump we hit problems where the new kernel would freeze or instantly reboot. The easiest way to trigger it was to kexec a kernel compiled for
CONFIG_M586on an athlon cpu. Compiling forCONFIG_MK7instead would work fine.
Quoted 5 lines
Quoted 1 line
The patch below fixes a few problems with the kexec inline asm.
Thanks. Specifying the stomp of %eax in
load_segmentsis definitely good. The memory stomp looks excessive and if this was a fast path I would worry about it. As it is better safe than sorry.
Why excessive? It reloads %ss, AFAICS; at that point, all the stack potentially changes from gcc's POV.
Pavel
Signature · 1 line
Web maintainer for suspend.sf.net (www.sf.net/projects/suspend) wanted...