All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: John David Anglin <dave@hiauly1.hia.nrc.ca>
Cc: Joel Soete <joel.soete@freebel.net>, parisc-linux@parisc-linux.org
Subject: Re: [parisc-linux] Need help to improve uaccess.h patch
Date: Sat, 5 Oct 2002 17:07:28 -0700	[thread overview]
Message-ID: <20021006000728.GA15230@tausq.org> (raw)
In-Reply-To: <200210052210.g95MACBv010773@hiauly1.hia.nrc.ca>

> > That is my main doubt :(
> > In this uaccess.h, I read (but i am not quit sure to have understand all 
> >   fine aspect) that we have to 'jump' after the erronious code (for me 
> > 3b-[12]b + 1 ? am i wrong? ). And understand +3 in get_user_asm because 
> > we would have to jump after the cast "(x) = (__typeof__(*(ptr))) 
> > __gu_val;". Is it wrong?
> 
> I may be wrong but I think the code is trying to build a PLABEL.  In
> which case, the value should be 2 or 3.  The least significant bit is
> not used.  See the runtime architecture manual for more info on PLABELs.

nah, the comment says:

/*
 * The exception table contains two values: the first is an address
 * for an instruction that is allowed to fault, and the second is
 * the number of bytes to skip if a fault occurs. We also support in
 * two bit flags: 0x2 tells the exception handler to clear register
 * r9 and 0x1 tells the exception handler to put -EFAULT in r8.
 * This allows us to handle the simple cases for put_user and
 * get_user without having to have .fixup sections.
 */

struct exception_table_entry {
        unsigned long addr;  /* address of insn that is allowed to fault.   */
        long skip;           /* pcoq skip | r9 clear flag | r8 -EFAULT flag */
};

so let's take __get_user() ...

#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: LDD_KERNEL(ptr); break;             \
            default: BUG(); break;                      \
            }                                           \
        }                                               \
        (x) = (__typeof__(*(ptr))) __gu_val;            \
        __gu_err;                                       \
})

iow, at the end of __get_user, x == r9, and the return value is r8

so, if the extable says:
                "\t.section __ex_table,\"a\"\n"         \
                 "\t.word\t1b\n"                        \
                 "\t.word\t(2b-1b)+3\n"                 \
                 "\t.previous"                          \

this means that:
if the insn at label 1 faults, handle the fault (see
arch/parisc/mm/fault.c) and then continue at 
label1+((label2-label1)&~3) == label2; also, since the lowest 2 bits are
set (+3), set r9 = 0 and r8 = -EFAULT --> get_user will set x = 0 and
return -EFAULT

randolph
--  
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

  reply	other threads:[~2002-10-06  0:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-04 15:24 [parisc-linux] Need help to improve uaccess.h patch Joel.soete
2002-10-04 16:08 ` Randolph Chung
2002-10-05 20:22   ` Joel Soete
2002-10-05 22:10     ` John David Anglin
2002-10-06  0:07       ` Randolph Chung [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-10-07 16:12 jsoe0708

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021006000728.GA15230@tausq.org \
    --to=randolph@tausq.org \
    --cc=dave@hiauly1.hia.nrc.ca \
    --cc=joel.soete@freebel.net \
    --cc=parisc-linux@parisc-linux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.