Re: [PATCH 7/9] x86/asm/entry/32: tidy up some instructions

From: Linus Torvalds
Date: Tue Mar 31 2015 - 19:09:53 EST


On Tue, Mar 31, 2015 at 3:21 PM, Brian Gerst <brgerst@xxxxxxxxx> wrote:
>>
>> @@ -708,7 +708,7 @@ END(sysenter_badsys)
>> #ifdef CONFIG_X86_ESPFIX32
>> movl %ss, %eax
>> /* see if on espfix stack */
>> - cmpw $__ESPFIX_SS, %ax
>> + cmpl $__ESPFIX_SS, %eax
>> jne 27f
>> movl $__KERNEL_DS, %eax
>> movl %eax, %ds
>
> This is incorrect. 32-bit reads from a segment register are not
> zero-extended. The upper 16 bits are implementation-defined. Most
> processors will clear them but it's not guaranteed.

Indeed. Brian is right. That cmpw needs to stay as a 16-bit compare.

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