Re: [PATCH] x86: entry_32.S: change ESPFIX test to not touch PT_OLDSS(%esp)

From: H. Peter Anvin
Date: Mon Mar 09 2015 - 13:43:28 EST


On 03/09/2015 09:08 AM, Linus Torvalds wrote:
>
> Sure, the btl is easier to explain in the source code, but instead of this:
>
>> + btl $X86_EFLAGS_VM_BIT,PT_EFLAGS(%esp)
>
> you'd have to add a comment, like
>
> testb $2, PT_EFLAGS+2(%esp) # X86_EFLAGS_VM_BIT
>
> or something.
>

Maybe:

testb $(X86_EFLAGS_VM-16), PT_EFLAGS+2(%esp)

> Or just at least *partially* do what we used to do, and make it all be
>
> movb PT_EFLAGS+2(%esp),%al
> andb $2,%al
> orb PT_CS(%esp),%al
> testb $3,%al
> je restore_nocheck
> testb $SEGMENT_TI_MASK,PT_OLDSS(%esp)
> jne ldt_ss
>
> which still avoids looking at SS unless needed, and is smaller and
> faster than the btl, afaik.

The question is if avoiding looking at a field on the stack matters at all.

-hpa


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