From: Steven Rostedt <srostedt@redhat.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] comment fix in uaccess for x86_32
Date: Wed, 01 Nov 2006 10:50:12 -0500 [thread overview]
Message-ID: <4548C234.1090906@redhat.com> (raw)
[-- 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
reply other threads:[~2006-11-01 15:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4548C234.1090906@redhat.com \
--to=srostedt@redhat.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.