Re: [PATCH v2] x86/asm/entry/64: Use shorter MOVs from segmers registers

From: H. Peter Anvin
Date: Thu May 14 2015 - 17:51:15 EST


On 05/14/2015 11:07 AM, Denys Vlasenko wrote:
> "movw %ds,%cx" insn needs a 0x66 prefix, while "movw %ds,%ecx" does not.
> The difference is that latter form (on 64-bit CPUs) overwrites
> entire %ecx, not only its lower half.
>
> But subsequent code doesn't depend on the value of upper
> half of %ecx, we can safely use the shorter insn.
>
> The new code is also faster than old one - now we don't depend on old value
> of %ecx, but this code fragment is not performance-critical.

This is still misleading. On P6 or later CPUs, not just 64 bits, this
zeroes the upper half, whereas on older CPUs it is undefined. Which is
still fine, but if we are going to make such a minor change we should
get it correct.

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