[parisc-linux] A todo entry

Matthew Wilcox willy@debian.org
Fri, 5 Oct 2001 06:38:22 +0100


Someone was asking for a job to do.  Here's one.

In include/asm-parisc/uaccess.h, we have a couple of functions which
look like this:

#define __get_user(x,ptr)                               \
({                                                      \
        register long __gu_err __asm__ ("r8") = 0;      \
        register long __gu_val __asm__ ("r9") = 0;      \
                                                        \
        if (segment_eq(get_fs(),KERNEL_DS)) {           \
            switch (sizeof(*(ptr))) {                   \
            case 1: __get_kernel_asm("ldb",ptr); break; \
            case 2: __get_kernel_asm("ldh",ptr); break; \
            case 4: __get_kernel_asm("ldw",ptr); break; \
            case 8: __get_kernel_asm("ldd",ptr); break; \
            default: BUG(); break;                      \
            }                                           \
        }                                               \
        else {                                          \
            switch (sizeof(*(ptr))) {                   \
            case 1: __get_user_asm("ldb",ptr); break;   \
            case 2: __get_user_asm("ldh",ptr); break;   \
            case 4: __get_user_asm("ldw",ptr); break;   \
            case 8: __get_user_asm("ldd",ptr); break;   \
            default: BUG(); break;                      \
            }                                           \
        }                                               \
                                                        \
        (x) = (__typeof__(*(ptr))) __gu_val;            \
        __gu_err;                                       \
})

This is rather suboptimal.  The way it should be done is to always
access userspace through %sr2 (currently listed as unused).  Set sr2
to the same value as sr3 normally.  Set it to 0 when someone does a
set_fs(KERNEL_DS), and to sr3 when USER_DS.  get_fs() should return the
value of sr2.  None of these functions are called frequently, so there's
no need to cache the values outside the space registers.

This probably isn't a big job, but there's probably some subtlety I've
overlooked.

-- 
Revolutions do not require corporate support.