[PATCH] unaligned.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,linux-mips,
 This patch does:
  1.As Mr. Atsushi Nemoto has pointed out,the newest unaligned.c leave out several jb in
the sw/sh emulation code.It will lead to oops if someone use unaligned addresses as syscall 
arguments to be stored to.Because the fixup code won't return to emulate_load_store_insn then.

  2.when search_exception_table does find a fixup in emulate_load_store_insn,I think we should
   skip compute_return_epc(regs) in do_ade then.Or it will jump to wrong fixup position later.
   ltp failed the getsockname syscall test in this way:
           getsockname(fd,&sock,(int *)1)         1 is used at the position of &sinlen.
       then,kernel will finally call get_user to fetch the user provided len and
       cause a AdeL exception: 
             get_user(len,ulen)
              (a fixup installed for the lw)
                 ---->exception
                       ---> do_ade
                         ------>emulate_load_store_insn
                                 emulate fail
                                           --->exception
                                           <---fixup
                                 search_exception_table find the handler
                                 installed by get_user and change 
                                  regs->cp0_epc to the fixup position
                          <-------return
                          compute_return_epc(regs) ADD another 4 to epc!
                 <----------------
               execution continues from fixup + 4,this omit the code to load -EFAULT to return
               value of get_user,may lead to further failures
   so i propose watch epc during emulate_load_store_insn,if it changes,then skip compute_return
   _epc
             
  3.(optional,implemented)it may be better for search_exception_table & fixup_exception
   to use PC instead of regs->cp0_epc as arguments. PC points to the actual load/store 
   instruction anyway, although this is for kernel code so it is almost impossible for 
   user space accessing code to put load/store in a branch delay.
  
  4.(optional,unimplemented) Will it be more efficient to put use emulation code of lw/lh/sw/sh
    before other impossible conditions?

  Am i missing something?

  BTW: 
   Could somebody be so kind to explain the use of save_static_function?I know they build
  a pseudo function with a return, so call sys_sigsuspend will fall through to _sys_sigsuspend
  but what's the use? Nobody calls _sys_sigsuspend.


Regards
            Zhang Fuxin
            fxzhang@ict.ac.cn

unaligned.c.patch


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux