* [PATCH] comment fix in uaccess for x86_32
@ 2006-11-01 15:50 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2006-11-01 15:50 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]
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@redhat.com>
[-- Attachment #2: xen-comment-uaccess-fix.patch --]
[-- Type: text/x-patch, Size: 512 bytes --]
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; \
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-11-01 15:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-01 15:50 [PATCH] comment fix in uaccess for x86_32 Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.