Commit 2c75910f authored by Chris Lalancette's avatar Chris Lalancette Committed by Linus Torvalds
Browse files

x86: Make sure get_user_desc() doesn't sign extend.

The current implementation of get_user_desc() sign extends the return
value because of integer promotion rules.  For the most part, this
doesn't matter, because the top bit of base2 is usually 0.  If, however,
that bit is 1, then the entire value will be 0xffff...  which is
probably not what the caller intended.

This patch casts the entire thing to unsigned before returning, which
generates almost the same assembly as the current code but replaces the
final "cltq" (sign extend) with a "mov %eax %eax" (zero-extend).  This
fixes booting certain guests under KVM.
Signed-off-by: default avatarChris Lalancette <>
Signed-off-by: default avatarLinus Torvalds <>
parent 9a6fc8d0
......@@ -288,7 +288,7 @@ static inline void load_LDT(mm_context_t *pc)
static inline unsigned long get_desc_base(const struct desc_struct *desc)
return desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24);
return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
static inline void set_desc_base(struct desc_struct *desc, unsigned long base)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment