lkml.org 
[lkml]   [2011]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH 05/12] unicore32 additional architecture files: low-level lib: uaccess
    Date
    On Wednesday 16 February 2011, Guan Xuetao wrote:
    > +
    > +#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS))
    > +#define __user_ok(addr, size) (((size) <= TASK_SIZE) \
    > + && ((addr) <= TASK_SIZE - (size)))
    > +#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size)))

    A nice trick to simplify this is to introduce a per-process variable for comparing
    the pointer, set_fs() then sets this variable to either TASK_SIZE or
    UINT_MAX.

    This saves one conditional branch for each call to __access_ok.

    Arnd


    \
     
     \ /
      Last update: 2011-02-17 18:47    [W:2.976 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site