]> err.no Git - linux-2.6/commitdiff
KVM: Fix overflow bug in overflow detection code
authorEric Sesterhenn / Snakebyte <snakebyte@gmx.de>
Mon, 9 Apr 2007 14:15:05 +0000 (16:15 +0200)
committerAvi Kivity <avi@qumranet.com>
Thu, 3 May 2007 07:52:29 +0000 (10:52 +0300)
The expression

   sp - 6 < sp

where sp is a u16 is undefined in C since 'sp - 6' is promoted to int,
and signed overflow is undefined in C.  gcc 4.2 actually warns about it.
Replace with a simpler test.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/vmx.c

index 61a611691e50171e93317ebc4303cca0c89d877f..8c0115b548026dbf9574b53e4f8d87bf73d8e3e6 100644 (file)
@@ -1182,7 +1182,7 @@ static void inject_rmode_irq(struct kvm_vcpu *vcpu, int irq)
        u16 sp =  vmcs_readl(GUEST_RSP);
        u32 ss_limit = vmcs_read32(GUEST_SS_LIMIT);
 
-       if (sp > ss_limit || sp - 6 > sp) {
+       if (sp > ss_limit || sp < 6 ) {
                vcpu_printf(vcpu, "%s: #SS, rsp 0x%lx ss 0x%lx limit 0x%x\n",
                            __FUNCTION__,
                            vmcs_readl(GUEST_RSP),