Skip to contentSkip to conversation

A todo entry

parisc-linux Jurij Smakov 2 participants 2 messages Oct 8, 2001

lore
Share & tools
lore
#0 lore raw

Hi!

Quoted 1 line

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

It was probably me.

Quoted 31 lines

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;                                       \
})
Quoted 6 lines

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 is slightly over my head, but that is my understanding of what needs to be done: instead of checking with segment_eq we need a routine, which just reads from memory, using space from sr2. With proposed modifications to get_fs, get_ds and set_fs it will automagically contain a correct value (0 for kernel memory and same as sr3 for userspace).

Is it the correct interpretation? Is it still possible to do in view of John's comment?

Best regards,

Jurij.

#1 lore raw
Quoted 1 line · Jurij Smakov

It was probably me.

probably. various people hae asked in the past, but you're the most recent :-)

Quoted 5 lines

This is slightly over my head, but that is my understanding of what needs to be done: instead of checking with segment_eq we need a routine, which just reads from memory, using space from sr2. With proposed modifications to get_fs, get_ds and set_fs it will automagically contain a correct value (0 for kernel memory and same as sr3 for userspace).

Right.

Quoted 2 lines

Is it the correct interpretation? Is it still possible to do in view of John's comment?

Certainly; John was just pointing out some of the issues to be aware of.

Signature · 1 line
Revolutions do not require corporate support.