Re: kexec: Clearing registers just before jumping into purgatory

From: Daniel Kiper
Date: Mon Oct 14 2013 - 14:25:39 EST


On Fri, Oct 11, 2013 at 03:15:38PM -0700, ebiederm@xxxxxxxxxxxx wrote:
> Daniel Kiper <daniel.kiper@xxxxxxxxxx> writes:
>
> > On Fri, Oct 11, 2013 at 03:08:43AM -0700, ebiederm@xxxxxxxxxxxx wrote:
> >> Daniel Kiper <daniel.kiper@xxxxxxxxxx> writes:

[...]

> > What is your opinion in that case?
>
> I can see documenting the registers other than the stack pointer
> as undefined. (A stack pointer is needed to implement PIC code).
>
> For the implementation I recommend setting these registers to known
> values. The issue is that your implementation will not change much and
> if you don't set the registers to known values someone may develop a
> dependency on what you happen to have those registers set to.
>
> It is easier to force a fixed value into a register that isn't hard to
> maintain into your registers than to discover when you make a change
> that there is some odd client that depends on some value that just
> happened to be in your register, and that your necessary change is now
> made 10x harder by a client you can't afford to break that depends on a
> bug in the previous implementation.
>
> So yes I strongly recommend setting the registers to a 0 in this case.

Thank you for this explanation. I think that it is worth to add relevant
comment to arch/x86/kernel/relocate_kernel_*.S and purgatory entry.
I will try to prepare something when we work out nice thing for Xen.

Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/