Re: [PATCH 2/4] x86: get rid of KERNEL_STACK_OFFSET

From: Andy Lutomirski
Date: Wed Feb 25 2015 - 11:15:13 EST


On Wed, Feb 25, 2015 at 1:45 AM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
> * Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>
>> - BUG_ON(((current_stack_pointer() ^ this_cpu_read_stable(kernel_stack))
>> + BUG_ON(((current_stack_pointer() ^
>> + (this_cpu_read_stable(kernel_stack) - 1))
>> & ~(THREAD_SIZE - 1)) != 0);
>>
>> preempt_count_sub(HARDIRQ_OFFSET);
>>
>> I added that in and applied this patch.
>
> So this is not just slightly buggy, it's fundamentally
> wrong as well as it removes the possibility of an RSP value
> optimization from the 64-bit path, see my previous mail.

This is just trying to check that the function is executing on the
per-thread stack. It was correct (and fairly heavily tested by Tony)
wither KERNEL_STACK_OFFSET being nonzero, but we're checking the wrong
page if KERNEL_STACK_OFFSET becomes zero.

I don't think I understand your objection to this bit.

>
> The right solution would be to make SAVE_ARGS recognize
> when KERNEL_STACK_OFFSET == args-offset and omit the RSP
> fixup in that case, or to simply use a __SAVE_ARGS for the
> 64-bit path, knowing that RSP has the right value already.
>
> Please also add comments that explain the relationship
> between percpu::kernel_stack, KERNEL_STACK_OFFSET and the
> 64-bit system call entry code.
>
> Also, guys, please slow down a bit and be more careful.
> Andy, could you please send me all currently pending entry
> bits pending in your tree, because all the in-flight
> changes make it hard for me to review patches? Please
> (re-)send all patches as well as part of the submission.

Will do later today.

Note that someone just found a bug as a result of this being in -next.

--Andy
--
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/