WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] comment fix in uaccess for x86_32

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] comment fix in uaccess for x86_32
From: Steven Rostedt <srostedt@xxxxxxxxxx>
Date: Wed, 01 Nov 2006 10:50:12 -0500
Delivery-date: Thu, 02 Nov 2006 13:50:57 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
In the xen/include/asm-x86/x68_32/uaccess.h

For range_not_ok we have:

/*
 * Test whether a block of memory is a valid user space address.
 * Returns 0 if the range is valid, nonzero otherwise.
 *
 * This is equivalent to the following test:
 * (u33)addr + (u33)size >= (u33)HYPERVISOR_VIRT_START
 */
#define __range_not_ok(addr,size) ({ \
        unsigned long flag,sum; \
        asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \
                :"=&r" (flag), "=r" (sum) \
                :"1" (addr),"g" ((int)(size)),"r" (HYPERVISOR_VIRT_START)); \
        flag; })


The code is fine, but it is *not* equivalent to >=, but it is for >.

This is not a bug in the code, since it is fine to have an address go up to the limit, since that just means it touches the byte before the limit. But I'd figure that the comment should really reflect what it is doing.

Here's a simple program to prove that the comment is wrong:

----
#include <stdio.h>

#define HYPERVISOR_VIRT_START 0xFC000000UL

#define chk(addr,size) ({\
        unsigned long flag,sum; \
        asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \
                :"=&r" (flag), "=r" (sum) \
:"1" (addr),"g" ((int)(size)),"r" (HYPERVISOR_VIRT_START)); \
        flag; })

int main (int argc, char **argv)
{
        unsigned long addr;

        addr = 0xfc000000UL - 10;
        printf("chk 9 = %d\n",chk(addr,9));
        printf("chk 10 = %d\n",chk(addr,10));
        printf("chk 11 = %d\n",chk(addr,11));
        return -1;
}
----

Which produces:

chk 9 = 0
chk 10 = 0
chk 11 = -1


So I've added a patch to update the comment.

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>


diff -r badf51e24549 xen/include/asm-x86/x86_32/uaccess.h
--- a/xen/include/asm-x86/x86_32/uaccess.h      Fri Oct 27 11:11:46 2006 -0400
+++ b/xen/include/asm-x86/x86_32/uaccess.h      Wed Nov 01 10:42:16 2006 -0500
@@ -8,7 +8,7 @@
  * Returns 0 if the range is valid, nonzero otherwise.
  *
  * This is equivalent to the following test:
- * (u33)addr + (u33)size >= (u33)HYPERVISOR_VIRT_START
+ * (u33)addr + (u33)size > (u33)HYPERVISOR_VIRT_START
  */
 #define __range_not_ok(addr,size) ({ \
        unsigned long flag,sum; \
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] comment fix in uaccess for x86_32, Steven Rostedt <=