[PATCH] kexec x86_64: Make purgatory relocatable anywhere in the 64bit address space.

Simon Horman horms at verge.net.au
Tue Nov 20 19:16:26 EST 2012


On Mon, Nov 19, 2012 at 08:56:22AM -0800, Eric W. Biederman wrote:
> 
> Remove kexec/arch/i386/compat_x6_64.S
> purgatory/arch/i386/linux-entry16.S and purgatory/arch/i386/entry16.S
> Those were early attempts at entry32-16.S that should have been
> deleted long ago.
> 
> Strip the purgatory code of debug symbols.  There is no need to carry
> debug symbols we will never use around in /sbin/kexec.
> 
> On x86_64 use -mcmodel=large so that the code is built without
> any 32bit assumptions.  -mcmodel=medium and -mcmodel=small
> result int code that has 32bit relocations against variables
> that can live anywhere in the address space
> 
> Modify the assembly in entry64.S and setup-x86_64.S to use %rip
> relative addressing of variables so no relocates are emitted.
> 
> Modify entry64-32.S so that it does not have any relocations that can
> not be processed when purgatory is loaded above 4G.  entry64-32.S
> jumps to a 32bit entry point and can not itself be used above 4G so
> these changes merely prevent it from being a problem in the other case.
> 
> eip is modifed to be a 64bit value of which only the low 32bits are
> exported outside of entry64-32.S
> 
> The long mode exit code is modified to run with a %cs value whose
> base address is the address of the symbol entry32.  From there
> all of the 32bit code in entry64-32.S can read variables by reading
> them through %cs.  Until the final jump to the the target address
> which is made a far jump reloading %cs and the intstruction pointer.
> 
> Modify entry32-16.S and entry32-16-debug.S to be position independent
> 32bit code.  At their start make a short call to push the current value
> of %eip on the stack and pop it off.  Allowing the calculation of the
> address of entry16 which the code has always kept in %ebx.
> 
> Update the pointer to the gdt in the gdt so that lgdt will work.
> 
> Modify the instructions in entry32-16.S and entry32-16-debug.S so
> that the 32bit code uses offsets from %ebx which points at entry16.
> 
> Tested-by: Yinghai Lu <yinghai at kernel.org>
> Signed-off-by: "Eric W. Biederman" <ebiederm at xmission.com>

Thanks, applied.



More information about the kexec mailing list