Re: [Fastboot] [CFT] kexec syscall for 2.5.43 (linux booting linux)

erich
2002-10-22T16:21:53Z

ebiederm@xmission.com (Eric W. Biederman) wrote:

> In the process of setting up hooks, I have run across a very interesting
> data point. If I load %ds, %es, %ss in my hook the problem goes away.
> But I must load all 3.
>
> Given that the code sequence that is executed if my hook is not run is:
>
> cld
> cli
> movl $(__KERNEL_DS),%eax
> movl %eax,%ds
> movl %eax,%es
> movl %eax,%fs
> movl %eax,%gs
>
> lss stack_start,%esp
>
> I am rather confused. I am not changing the gdt or anything like that so it
> appears I may have found a way to tickle a processor errata.

I kind of doubt you found an errata... the mode switch combinations in most
of the modern x86-variants has been tested pretty exhaustively because
people use so many variations on it.

Let's see:

%ds and %es are implicit operands for the source and destination of a
MOVS operation, so if you or the Linux kernel performs a MOVS copy
before that point, that is likely the problem there.

The requirement of %ss is a bit more puzzling, but are you 100% sure
you don't reference the stack anywhere? Else it may blow up.

For example, the start sequence calls "cli", but do you have interrupts
disabled before that point? Maybe you have a stray interrupt catching
you there...

I had to deal with these problems, and had exactly something like the
last case, in my early work on the GRUB bootloader.

--
Erich Stefan Boleyn <erich@uruk.org> http://www.uruk.org/
"Reality is truly stranger than fiction; Probably why fiction is so popular"