Re: [RFC PATCH] x86: Make sure verify_cpu has a good stack

From: Mika PenttilÃ
Date: Wed Mar 02 2016 - 11:38:29 EST



On 02.03.2016 18:15, Borislav Petkov wrote:
> On Wed, Mar 02, 2016 at 05:55:14PM +0200, Mika Penttilà wrote:
>>> + /* Setup a stack for verify_cpu */
>>> + movq stack_start - __START_KERNEL_map, %rsp
>>> + subq $__START_KERNEL_map, %rsp
>>> +
>> You subtract __START_KERNEL_map twice ?
> Yes. That's not very obvious and it took me a while. I probably should
> add a comment.
>
> Want to stare at it a little bit more and try to figure it out or should
> I explain?
>
> :-)
>

I actually looked at it a while too...

The
movq stack_start - __START_KERNEL_map, %rsp

turns into (objdump disassembly)

mov 0x0,%rsp

with relocation
0000000000000004 R_X86_64_32S stack_start+0x0000000080000000

Now stack_start is at ffffffff81ef3380, so the relocation gives 1ef3380 which would be correct, so why the
second subq ?

You may explain :)

--Mika