Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149321
b: refs/heads/master
c: cb9dc92
h: refs/heads/master
i:
  149319: dfcfc43
v: v3
  • Loading branch information
Nicolas Pitre committed May 30, 2009
1 parent 7a92235 commit 4df5ba2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 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: 39ec58f3fea47c242724109cc1da999f74810bbc
refs/heads/master: cb9dc92c0a1b76165c8c334402e27191084b2047
36 changes: 27 additions & 9 deletions trunk/arch/arm/lib/uaccess_with_memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp)
return 1;
}

unsigned long
__copy_to_user(void __user *to, const void *from, unsigned long n)
static unsigned long noinline
__copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
{
int atomic;

if (n < 1024)
return __copy_to_user_std(to, from, n);

if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
memcpy((void *)to, from, n);
return 0;
Expand Down Expand Up @@ -99,11 +96,24 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)
return n;
}

unsigned long __clear_user(void __user *addr, unsigned long n)
unsigned long
__copy_to_user(void __user *to, const void *from, unsigned long n)
{
/*
* This test is stubbed out of the main function above to keep
* the overhead for small copies low by avoiding a large
* register dump on the stack just to reload them right away.
* With frame pointer disabled, tail call optimization kicks in
* as well making this test almost invisible.
*/
if (n < 1024)
return __copy_to_user_std(to, from, n);
return __copy_to_user_memcpy(to, from, n);
}

static unsigned long noinline
__clear_user_memset(void __user *addr, unsigned long n)
{
if (n < 256)
return __clear_user_std(addr, n);

if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
memset((void *)addr, 0, n);
return 0;
Expand Down Expand Up @@ -137,3 +147,11 @@ unsigned long __clear_user(void __user *addr, unsigned long n)
out:
return n;
}

unsigned long __clear_user(void __user *addr, unsigned long n)
{
/* See rational for this in __copy_to_user() above. */
if (n < 256)
return __clear_user_std(addr, n);
return __clear_user_memset(addr, n);
}

0 comments on commit 4df5ba2

Please sign in to comment.