Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

The problem with custom board. (Exception access user space)

Hello everyone,

I have trying to run Linux on my custom board.

But, Exception occurs when you access the user space.

start_kernel () is passed.

kernel_init () will call the initialization function of each module,

Therein futex_init () exception occurs.


futex_init() 
   cmpxchg_futex_value_locked()
     futex_atomic_cmpxchg_inatomic() 
            get_user() 
                 __get_user_common()
                    __get_user_asm2()  ※Unhandled exception!!
My custom_fpga.h prepare and replace.

linux.initramfs.gz downloaded to the board.

[steps]

nios2-configure my_fpga.sof

nios2-download -g linux.initramfs.gz

nios2-terminal.exe

Please advice to solve the problem?

Thanks a lot All.

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Do you use the MMU-based or the no-MMU distribution ?

    AFAIK, Futex is not (yet) implemented in the MMU based distribution, as the planned "atomic region" stuff is not yet in place.

    Maybe the no-MMU distribution implements Futex (i.e. the "atomic" userland stuff) by interrupt disabling, but I am not sure about this.

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi mschnell.

    Thanks for your reply.

    I am using MMU-based distribution.

    In the case of NEEK, futex_init() is no problem.

    MMU-based distribution is the same.

    futex_init () where removed with Menuconfig, the process went ahead.

    But, An exception occurred at a user-space access(__clear_user() called).

    custom_fpga.h has been replaced, what others have to change the source?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    As (AFAIK) Futex is not yet correctly implemented with the MMU based distribution, anything can happen if you use it.

    Background: NIOS does not have any atomic instructions in hardware, so in an MMU-system that does not allow to disable interrupt in userspace, the OS needs to help the userspace with these instructions, that are absolutely necessary for implementing Futex. This is (planned to be) done using the "atomic region" trick.

    Maybe Hippo can jump in with a statement when this might be available.

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi mschnell.

    I found the background.

    futex() has stopped using it.

    But, futex() stop using it, with the exception occurs

    in the user space access to other function.

    Could you tell me the point of debugging...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    As said, Futex supposedly is not implemented, so debugging does not make any sense.

    If you want to help implementing "atomic region" to allow for implementing Futex, please talk to Thomas Chou (AKA Hippo) about this, as he suggested this solution, did some investigations and found that a similar solution is implemented in the Blackfin uClinux distribution.

    Futex does need atomic instructions to work. If you found an implementation that does not, it supposedly is not workable.

    I don't see any other pure software way to allow for atomic instructions than doing the "atomic region" trick (please see the backlog of the uClinux-Nios mailing list for more infos on this). We do hope for Altera to implement some kind of atomic user space instructions some day, but I did not yet see any info if they will do so.

    Why are you using Futiex in your code, anyway ? The normal way of using FUTEX is calling pthread_muutex_??() in libc. This will do Futex if the distribution supports it and use an OS based mutex, if Futex is not available.

    When trying to use a Futex system call in your user land program you need to do the management of the Futex variable in your own code before. This needs to be done with atomic user land instructions I don't suppose you can do this with the current distribution (See the Article "Futxes are tricky" that you easily should find in the Internet.)

    -Michael

    (BTW, this issue is the main reason why I stopped doing active development on NIOS.)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi mschnell,

    I really appreciate your advice and explanation.That is very helpful.

    The reason why we tried to use Futiex is just it is installed in the Menu Config by default.

    Do you mind if I change the topics?

    I proceeded the debug after I remove the Futex.

    And then, An exception occurred at a user-space access(__clear_user() called).

    I've already replaced custom_fpga.h.

    Do you think there are anything of what I have to do ?

    I appreciate if you reply me.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Sorry. No idea on this.

    You might want to start a new thread with an appropriate topic to draw more attention.

    -Michael