lkml.org 
[lkml]   [2009]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] x86: Make sure get_user_desc() doesn't sign extend.
Date
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.

(sending direct to Linus this time, since I got no response
to the previous 3 submissions)

Signed-off-by: Chris Lalancette <clalance@redhat.com>
---
arch/x86/include/asm/desc.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index e8de2f6..617bd56 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -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)
--
1.6.0.6


\
 
 \ /
  Last update: 2009-11-05 11:51    [W:0.021 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site