Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75385
b: refs/heads/master
c: d7587b1
h: refs/heads/master
i:
  75383: 0e9c5a3
v: v3
  • Loading branch information
Paul Mundt committed Jan 11, 2008
1 parent 52fee9d commit ed1b52e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 844b43adba74d97f15e56b103c97bfcccaa01aa6
refs/heads/master: d7587b1445c0087cfcaa03ceae79b52eef4e9e4b
42 changes: 15 additions & 27 deletions trunk/include/asm-sh/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,26 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
/*
* __access_ok: Check if address with size is OK or not.
*
* We do three checks:
* (1) is it user space?
* (2) addr + size --> carry?
* (3) addr + size >= 0x80000000 (PAGE_OFFSET)
* Uhhuh, this needs 33-bit arithmetic. We have a carry..
*
* (1) (2) (3) | RESULT
* 0 0 0 | ok
* 0 0 1 | ok
* 0 1 0 | bad
* 0 1 1 | bad
* 1 0 0 | ok
* 1 0 1 | bad
* 1 1 0 | bad
* 1 1 1 | bad
* sum := addr + size; carry? --> flag = true;
* if (sum >= addr_limit) flag = true;
*/
static inline int __access_ok(unsigned long addr, unsigned long size)
{
unsigned long flag, tmp;

__asm__("stc r7_bank, %0\n\t"
"mov.l @(8,%0), %0\n\t"
"clrt\n\t"
"addc %2, %1\n\t"
"and %1, %0\n\t"
"rotcl %0\n\t"
"rotcl %0\n\t"
"and #3, %0"
: "=&z" (flag), "=r" (tmp)
: "r" (addr), "1" (size)
: "t");

unsigned long flag, sum;

__asm__("clrt\n\t"
"addc %3, %1\n\t"
"movt %0\n\t"
"cmp/hi %4, %1\n\t"
"rotcl %0"
:"=&r" (flag), "=r" (sum)
:"1" (addr), "r" (size),
"r" (current_thread_info()->addr_limit.seg)
:"t");
return flag == 0;

}
#endif /* CONFIG_MMU */

Expand Down

0 comments on commit ed1b52e

Please sign in to comment.