From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 3 Oct 2008 12:30:33 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-151598186-1223037033=:12208" Message-ID: <118594.12208.qm@domain.hid> Subject: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org --0-151598186-1223037033=:12208 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0AI need to trap and manage exceptions (floating point for example).=0AI = want to execute at user domain (x86-ring 3) something like that=0A=0Areal_t= ime_task function:=0A{=0A (for example fpu_handle= r)=0A=0A (this code need custom management of= exceptions)=0A=0A =0A}=0A=0Afpu_handler funct= ion=0A{=0A ...=0A}=0A=0AI need to customize some exception (fpu is the mos= t important) inside real time.=0AHow can I do that?=0AIs it possible in th= e rt user domain? And what about that in the rt-kernel domain?=0A=0AThank y= ou=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e la= tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-151598186-1223037033=:12208 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

I need to trap and manage  exceptions (floati= ng point for example).
I want to execute at user domain (x86-ring 3) som= ething like that

real_time_task function:
{
  <set exc= eption handlers> (for example fpu_handler)

  <real time c= ode (asm x86)>  (this code need  custom management of exceptio= ns)

  <release exception handlers>
}

fpu_handle= r function
{
  ...
}

I need to customize some exceptio= n (fpu is the most important) inside real time.
How can I do that?
Is= it possible in  the rt user domain? And what about that in the rt-ker= nel domain?

Thank you


=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, co= nsigli... e anche la tua opinione! --0-151598186-1223037033=:12208-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48E6332C.80304@domain.hid> Date: Fri, 03 Oct 2008 16:58:52 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <118594.12208.qm@domain.hid> In-Reply-To: <118594.12208.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: xenomai@xenomai.org Gabriele Moabiti wrote: > I need to customize some exception (fpu is the most important) inside real time. > How can I do that? > Is it possible in the rt user domain? And what about that in the rt-kernel domain? You should probably tell us what you want to do instead of how you want to do it. Because what you ask requires xenomai kernel modifications and will have really poor performances, so is a solution which you should avoid. So, what does your real-time x86 assembler code do exactly ? -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48EC86BE.3010308@domain.hid> Date: Wed, 08 Oct 2008 12:09:02 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <296620.67855.qm@domain.hid> In-Reply-To: <296620.67855.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: Please do not drop the list from the CC. > The asm x86 code is a "legacy" code developed in x86 plain binary asm > (written with tasm and can't be re-written of course) I do not understant the "of course". If this is assembly, then run a disassembler and you will get the source. > with fixed addresses for data and code (I'll call SIS in the follow). > When one of the follow exception occurred > > * 0x00 Divide by zero > * 0x01 Debug exception > * 0x03 Int3 > * 0x04 Overflow > * 0x05 Array bounds check > * 0x06 Illegal Opcode > * 0x07 FPU not available > * 0x08 Double fault > * 0x09 Coprocessor segment overrun > * 0x0a Invalid task state > * 0x0b Segment not present > * 0x0c Stack exception > * 0x0d General Protection Fault > * 0x0e Page fault > * 0x0f Reserved > * 0x10 Coprocessor error > > SIS expects some custom actions (set internal flags, save errors and so on). > > I have mapped SIS in a kernel module and mapped to user space with xenomai. > Now I though to execute SIS in ring 3 (as rt task) and trap the exceptions at ring 0 (always inside real time constraints). > > The result should be > > > > > > > > In the "C code" part I'll use rtnet. I think you are traping yourself with impossible constraints. Anyway, the only way is register a custom exception handler using rthal functions. In your trap handler, you may wake up a user-space server thread which role is to handle exceptions (in user-space). This means that: - upon exception, you have a switch to the user-space server thread context, this will be slow; - you have to rewrite the exception handling code, you can not rely on the exception handling code that was written in the assembly blob. I do not think it is a good idea to simply override the exception vectors, the kernel uses them, and you certainly want the kernel to continue working. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 8 Oct 2008 10:34:46 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-2060974364-1223462086=:90718" Message-ID: <563071.90718.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-2060974364-1223462086=:90718 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A=0A>I think you are traping yourself with impossible constraints.=0A>=0A= >Anyway, the only way is register a custom exception handler using rthal=0A= >functions. In your trap handler, you may wake up a user-space server=0A>th= read which role is to handle exceptions (in user-space). This means that:= =0A>- upon exception, you have a switch to the user-space server thread=0A>= context, this will be slow;=0A=0ADo I change rthal inside xenomai? How can = I do?=0AIs there a benchmark or some number to understand better this slown= ess (in us)?=0A=0A>- you have to rewrite the exception handling code, you c= an not rely=0A>on the exception handling code that was written in the assem= bly blob.=0A>=0A>I do not think it is a good idea to simply override the ex= ception=0A>vectors, the kernel uses them, and you certainly want the kernel= to=0A>continue working.=0A =0AYes I think so=0A=0ANow SIS is about 500 kb = of pure asm and works with a big cli on start and a sti=0Aon finish @ring 0= and reprogram the exception vectors but I want to integrate into xenomai. = =0A=0AProposal:=0A=0A- At start SIS save the addresses of the exception vec= tors=0A- When an exception is raised then the processor switch to the custo= m exception vectors but=0A if the SIS is not currently active then jump to= the old exception vectors=0A=0AIs it possible?=0A=0ASorry for the large nu= mber of questions=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, n= ovit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-2060974364-1223462086=:90718 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


>I think you are traping yourself with impossible constraints.>
>Anyway, the only way is register a custom exception handler u= sing rthal
>functions. In your trap handler, you may wake up a user-s= pace server
>thread which role is to handle exceptions (in user-space= ). This means that:
>- upon exception, you have a switch to the user-= space server thread
>context, this will be slow;

Do I change r= thal inside xenomai? How can I do?
Is there a benchmark or some number t= o understand better this slowness (in us)?

>- you have to rewrite = the exception handling code, you can not rely
>on the exception handl= ing code that was written in the assembly blob.
>
>I do not thi= nk it is a good idea to simply override the exception
>vectors, the k= ernel uses them, and you certainly want the kernel to
>continue worki= ng.
 
Yes I think so

Now SIS is about 500 kb of pure asm and works w= ith a big cli on start and a sti
on finish @ring 0 and reprogram the exc= eption vectors but I want to integrate into xenomai.

Proposal:
<= br>- At start SIS save the addresses of the exception vectors
- When an = exception is raised then the processor switch to the custom exception vecto= rs but
  if the SIS is not currently active then jump to the old ex= ception vectors

Is it possible?

Sorry for the large number of questions



=0A=0A=0A=0A Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, = consigli... e scrivi la tua opinione! --0-2060974364-1223462086=:90718-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48EC908D.9060902@domain.hid> Date: Wed, 08 Oct 2008 12:50:53 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <563071.90718.qm@domain.hid> In-Reply-To: <563071.90718.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > >> I think you are traping yourself with impossible constraints. >> >> Anyway, the only way is register a custom exception handler using rthal >> functions. In your trap handler, you may wake up a user-space server >> thread which role is to handle exceptions (in user-space). This means that: >> - upon exception, you have a switch to the user-space server thread >> context, this will be slow; > > Do I change rthal inside xenomai? How can I do? > Is there a benchmark or some number to understand better this slowness (in us)? Every context switch (including kernel/user switches) costs time. There is a switchbench test which measures the user to user context switch time. Look at rthal_trap_catch. In your exception handler, you have to take care about whether the fault was directed to your particular application and let the fault be handled normally otherwise. > >> - you have to rewrite the exception handling code, you can not rely >> on the exception handling code that was written in the assembly blob. >> >> I do not think it is a good idea to simply override the exception >> vectors, the kernel uses them, and you certainly want the kernel to >> continue working. > > Yes I think so > > Now SIS is about 500 kb of pure asm and works with a big cli on start and a sti > on finish @ring 0 and reprogram the exception vectors but I want to integrate into xenomai. > > Proposal: > > - At start SIS save the addresses of the exception vectors > - When an exception is raised then the processor switch to the custom exception vectors but > if the SIS is not currently active then jump to the old exception vectors You say yes, then propose to do what I told you was a bad idea. So, I repeat: this is a bad idea. I think it is better not to touch the hardware vector and use the trap interception mechanism proposed by Xenomai rthal. And split exception handling in a kernel-space handler which signals a user-space server thread. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 8 Oct 2008 11:32:44 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1559547962-1223465564=:10282" Message-ID: <581220.10282.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1559547962-1223465564=:10282 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >You say yes, then propose to do what I told you was a bad idea. So, I=0A>r= epeat: this is a bad idea. =0A=0AOk, now it's clear. This a port of a real = time application first developed in DOS=0Athen ported to Windows XP so dirt= y hacking was the rule.=0ASorry for the misunderstanding.=0A=0A> I think it= is better not to touch the=0A>hardware vector and use the trap interceptio= n mechanism proposed by=0A>Xenomai rthal. And split exception handling in a= kernel-space handler=0A>which signals a user-space server thread.=0A=0AI t= hink I can do the exception handling in a kernel-space handler without pass= to an user space server thread=0Adue to the memory of the process where th= e SIS live (both data and code) is kernel memory mapped in the user space a= nd SIS.=0A=0AI had read Adeos is the low level of the real time part and Xe= nomai is one of the possible=0Adomain. Do I Have to use the rthal_trap_catc= h function to alter Xenomai? Is there some examples=0Ato better understand = how to do? =0ANOTE: I have to used rtnet too. Can this customization altera= te the behaviour of rtnet?=0A=0AThank you=0A=0A=0A Scopri il blog di Y= ahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.y= mailblogit.com/blog --0-1559547962-1223465564=:10282 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
&= gt;You say yes, then propose to do what I told you was a bad idea. So, I>repeat: this is a bad idea.

Ok, now it's clear. This a port of= a real time application first developed in DOS
then ported to Windows X= P so dirty hacking was the rule.
Sorry for the misunderstanding.

= > I think it is better not to touch the
>hardware vector and use t= he trap interception mechanism proposed by
>Xenomai rthal. And split = exception handling in a kernel-space handler
>which signals a user-sp= ace server thread.

I think I can do the exception handling in a kern= el-space handler without pass to an user space server thread
=0Adue to t= he memory of the process where the SIS live (both data and code) is kernel = memory mapped in the user space and SIS.
=0A
I had read Adeos is the = low level of the real time part and Xenomai is one of the possible
domai= n. Do I Have to use the rthal_trap_catch function to alter Xenomai? Is ther= e some examples
to better understand how to do?
NOTE: I have to used= rtnet too. Can this customization alterate the behaviour of rtnet?

= Thank you


=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, consigli... e s= crivi la tua opinione! --0-1559547962-1223465564=:10282-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48ECA7AD.1020909@domain.hid> Date: Wed, 08 Oct 2008 14:29:33 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <581220.10282.qm@domain.hid> In-Reply-To: <581220.10282.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > I had read Adeos is the low level of the real time part and Xenomai is one of the possible > domain. Do I Have to use the rthal_trap_catch function to alter Xenomai? Is there some examples > to better understand how to do? Xenomai uses rthal_trap_catch, so, you can use Xenomai code as an example. > NOTE: I have to used rtnet too. Can this customization alterate the behaviour of rtnet? well, if your real-time task has a huge cli/sti critical section, it will affect the latencies of pretty much everything on the system, including rtnet. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 10 Oct 2008 13:50:36 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1742083866-1223646636=:70429" Message-ID: <39918.70429.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1742083866-1223646636=:70429 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A=0A> Xenomai uses rthal_trap_catch, so, you can use Xenomai code as an e= xample.=0A=0ANamed=0AKD: kernel driver (ring 0).=0AUD: user space task (rin= g 3).=0A=0A- KD reserve 16 MB of memory (note: virtual and physical contig= uous)=0A=0A- I use rthal_trap_catch to customize exceptions (redirected to = "custom_except" function)=0A The "custom_except" function print the number= of exception and recall the xenomai standard one.=0A=0A- KD has an rtdm in= terface to map the 16 MB memory on user space with rtdm_iomap_to_user.=0A= =0A- UD starts and It maps with the rtdm (rtdm_iomap_to_user)=0A=0A- UD cop= y a binary asm x86 test fpu (some instructions to generate exceptions for t= ests) in the 16 MB memory mapped=0A=0A- UD start the real time task=0A=0ANo= w here is a the problem.=0AIf I invoke an exception (int 3, floating point = exception and so on) outside the 16 MB mapped memory "custom_except" is cal= led ok.=0AIf the same code is invoked into the 16 MB mapped memory the prog= ram crash (and this is ok) reporting the description of the exception in th= e terminal (also this is ok) but "custom_except" is not called!=0A=0AIs the= re something wrong using the mapped memory in this mode?=0A=0ANOTE:=0AI am = using xenomai 2.4.0rc1 with kernel 2.6.23=0A=0A=0A Scopri il blog di Y= ahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.y= mailblogit.com/blog --0-1742083866-1223646636=:70429 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

> Xenomai uses rthal_trap_catch, so, you can use Xenomai code as an e= xample.

Named
KD: kernel driver (ring 0).
UD: user space task = (ring 3).

- KD reserve 16 MB  of memory (note: virtual and phys= ical contiguous)

- I use rthal_trap_catch to customize exceptions (r= edirected to "custom_except" function)
  The "custom_except" functi= on print the number of exception and recall the xenomai standard one.
- KD has an rtdm interface to map the 16 MB memory on user space with rtd= m_iomap_to_user.

- UD starts and It maps with the rtdm (rtdm_iomap_t= o_user)

- UD copy a binary asm x86 test fpu (some instructions to generate exceptions for tests) in the 16 MB memory mapped

- UD star= t the real time task

Now here is a the problem.
If I invoke an ex= ception (int 3, floating point exception and so on) outside the 16 MB mappe= d memory "custom_except" is called ok.
If the same code is invoked into = the 16 MB mapped memory the program crash (and this is ok) reporting the de= scription of the exception in the terminal (also this is ok) but "custom_ex= cept" is not called!

Is there something wrong using the mapped memor= y in this mode?

NOTE:
I am using xenomai 2.4.0rc1 with kernel 2.6= .23


=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, consigli... e scrivi= la tua opinione! --0-1742083866-1223646636=:70429-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48EF600C.3060306@domain.hid> Date: Fri, 10 Oct 2008 16:00:44 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <39918.70429.qm@domain.hid> In-Reply-To: <39918.70429.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > >> Xenomai uses rthal_trap_catch, so, you can use Xenomai code as an >> example. > > Named KD: kernel driver (ring 0). UD: user space task (ring 3). > > - KD reserve 16 MB of memory (note: virtual and physical contiguous) > > > - I use rthal_trap_catch to customize exceptions (redirected to > "custom_except" function) The "custom_except" function print the > number of exception and recall the xenomai standard one. Where does custom_except leaves, in kernel-space or user-space ? > > - KD has an rtdm interface to map the 16 MB memory on user space with > rtdm_iomap_to_user. > > - UD starts and It maps with the rtdm (rtdm_iomap_to_user) This is completely useless. You can use an anonymous mapping in user-space, you will not need the help from an rtdm driver. And your mapping needs to be executable (you need to pass PROT_EXEC to mmap). > > - UD copy a binary asm x86 test fpu (some instructions to generate > exceptions for tests) in the 16 MB memory mapped If you do that, your binary needs to be relocatable, that is its code must not depend on the address at which it is loaded. Are you sure your binary blob has this property ? > > - UD start the real time task > > Now here is a the problem. If I invoke an exception (int 3, floating > point exception and so on) outside the 16 MB mapped memory > "custom_except" is called ok. If the same code is invoked into the 16 > MB mapped memory the program crash (and this is ok) reporting the > description of the exception in the terminal (also this is ok) but > "custom_except" is not called! Who reports the exception, then ? Are you sure the exception reported is the one you expect ? IOW, are you sure the problem is not that your memory mapping is not executable ? > > Is there something wrong using the mapped memory in this mode? > > NOTE: I am using xenomai 2.4.0rc1 with kernel 2.6.23 Is this a joke ? Why choosing a release candidate of a release which happened since then ? Why not using the latest stable release ? -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 10 Oct 2008 15:24:29 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1471674837-1223652269=:28662" Message-ID: <819144.28662.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1471674837-1223652269=:28662 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A> Where does custom_except leaves, in kernel-space or user-space ?=0A=0A= I have called rthal_trap_catch in the init function of the KD.=0AI have tri= ed also in a rt task inside KD.=0A=0A>> - KD has an rtdm interface to map t= he 16 MB memory on user space with=0A>> rtdm_iomap_to_user.=0A>> - UD start= s and It maps with the rtdm (rtdm_iomap_to_user)=0A>=0A>This is completely = useless. You can use an anonymous mapping in=0A>user-space, you will not ne= ed the help from an rtdm driver. And your=0A>mapping needs to be executable= (you need to pass PROT_EXEC to mmap).=0A>> =0A>> - UD copy a binary asm x8= 6 test fpu (some instructions to generate=0A>> exceptions for tests) in the= 16 MB memory mapped=0A>=0A>If you do that, your binary needs to be relocat= able, that is its code=0A>must not depend on the address at which it is loa= ded. Are you sure your=0A>binary blob has this property ?=0A=0AIt's a long = story... I know anonymous mapping is better but I have need physical contig= uos memory=0A(not for the test of course). The binary blob has fixed addres= ses between 1 to 16 MB so I have mapped the first 15 MB of the UD (starting= to 1 MB). I Know it is very strange...=0A=0A>> =0A>> - UD start the real t= ime task=0A>> =0A>> Now here is a the problem. If I invoke an exception (in= t 3, floating=0A>> point exception and so on) outside the 16 MB mapped memo= ry=0A>> "custom_except" is called ok. If the same code is invoked into the = 16=0A>> MB mapped memory the program crash (and this is ok) reporting the= =0A>> description of the exception in the terminal (also this is ok) but=0A= >> "custom_except" is not called!=0A>=0A>Who reports the exception, then ? = =0A=0AI start UD from the terminal and the terminal always report the right= error.=0A=0A>Are you sure the exception reported is=0A>the one you expect = ? =0A=0AYes, I tried floating point, debug (int 3), page fault..=0A=0A>IOW,= are you sure the problem is not that your=0A>memory mapping is not executa= ble ?=0A=0AThe PROT_EXEC flag is set.=0AIf I try to execute some instructio= ns It works.=0A=0A>> Is there something wrong using the mapped memory in th= is mode?=0A>> NOTE: I am using xenomai 2.4.0rc1 with kernel 2.6.23=0A>>Is t= his a joke ? Why choosing a release candidate of a release which=0A>>happen= ed since then ? Why not using the latest stable release ?=0A=0Ayou are righ= t. It will be better to use the latest one (not rc). I had an already patch= ed kernel=0A(with an other working xenomai application)=0A=0A Gabriele= =0A=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e s= crivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-1471674837-1223652269=:28662 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<= br>> Where does custom_except leaves, in kernel-space or user-space ?
I have called rthal_trap_catch in the init function of the KD.
I ha= ve tried also in a rt task inside KD.

>> - KD has an rtdm inte= rface to map the 16 MB memory on user space with
>> rtdm_iomap_to_= user.
>> - UD starts and It maps with the rtdm (rtdm_iomap_to_user= )
>
>This is completely useless. You can use an anonymous mappi= ng in
>user-space, you will not need the help from an rtdm driver. An= d your
>mapping needs to be executable (you need to pass PROT_EXEC to= mmap).
>>
>> - UD copy a binary asm x86 test fpu (some instructions to generate
>> exceptions for tests) in the 16 MB me= mory mapped
>
>If you do that, your binary needs to be relocata= ble, that is its code
>must not depend on the address at which it is = loaded. Are you sure your
>binary blob has this property ?

It'= s a long story... I know anonymous mapping is better but I have need physic= al contiguos memory
(not for the test of course). The binary blob has fi= xed addresses between 1 to 16 MB so I have mapped the first 15 MB of the UD= (starting to 1 MB). I Know it is very strange...

>>
>&= gt; - UD start the real time task
>>
>> Now here is a th= e problem. If I invoke an exception (int 3, floating
>> point exce= ption and so on) outside the 16 MB mapped memory
>> "custom_except= " is called ok. If the same code is invoked into the 16
>> MB mapp= ed memory the program crash (and this is ok) reporting the
>> description of the exception in the terminal (also this is= ok) but
>> "custom_except" is not called!
>
>Who repo= rts the exception, then ?

I start UD from the terminal and the term= inal always report the right error.

>Are you sure the exception r= eported is
>the one you expect ?

Yes, I tried floating point,= debug (int 3), page fault..

>IOW, are you sure the problem is no= t that your
>memory mapping is not executable ?

The PROT_EXEC = flag is set.
If I try to execute some instructions It works.

>= > Is there something wrong using the mapped memory in this mode?
>= > NOTE: I am using xenomai 2.4.0rc1 with kernel 2.6.23
>>Is thi= s a joke ? Why choosing a release candidate of a release which
>>h= appened since then ? Why not using the latest stable release ?

you a= re right. It will be better to use the latest one (not rc). I had an already patched kernel
(with an other working xenomai application)
<= br>    Gabriele

=0A=0A=0A=0A <= hr size=3D1>Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0= , consigli... e scrivi la tua opinione! --0-1471674837-1223652269=:28662-- From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 14 Oct 2008 10:01:38 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-204381555-1223978498=:75012" Message-ID: <621300.75012.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-204381555-1223978498=:75012 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>> You should trace the exception path in the I-pipe patch to find the=0A>= >> point where your exception handling callback is not called.=0A>> =0A>> = will it be a large print work or there are another ways to do that?=0A>> :)= =0A>=0A> Yes, a small printk works. There is not that much code involved.= =0A=0AI have found the problem.=0AI used a printf some instructions before = the call to the asm blob.=0AOnce removed seems to work as expected.=0AI've = seen also that writing=0A printf(expr); \=0A rt_task_set_mode(0, = T_PRIMARY, 0);=0Ait works (I think printf does a switch to secondary domain= ).=0ANow I should use a user-space-no-problem print like rtdm_printk in ker= nel space.=0AThe docs says rtdm_in_rt_context and rtdm_printk are avalaible= but in the rtdm.h=0Athere is no trace of them and I can't use rtdm_driver.= h 'cause it's kernel only...=0A=0A Gabriele=0A=0A=0A Scopri il blog= di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua opinione.=0Ahttp://= www.ymailblogit.com/blog --0-204381555-1223978498=:75012 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
&= gt;>> You should trace the exception path in the I-pipe patch to find= the
>>>  point where your exception handling callback is = not called.
>>
>> will it be a large print work or there= are another ways to do that?
>> :)
>
> Yes, a small p= rintk works. There is not that much code involved.

I have found the = problem.
I used a printf some instructions before the call to the asm bl= ob.
Once removed seems to work as expected.
I've seen also that writi= ng
      printf(expr); \
   &= nbsp;  rt_task_set_mode(0, T_PRIMARY, 0);
it works (I think printf does a switch to secondary domain).
Now I should use a user-space-no-pr= oblem print like rtdm_printk in kernel space.
The docs says rtdm_in_rt_c= ontext and rtdm_printk are avalaible but in the rtdm.h
there is no trace= of them and I can't use rtdm_driver.h 'cause it's kernel only...

&n= bsp;   Gabriele


=0A=0A=0A=0A Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0,= consigli... e scrivi la tua opinione! --0-204381555-1223978498=:75012-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F472B2.7050302@domain.hid> Date: Tue, 14 Oct 2008 12:21:38 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <621300.75012.qm@domain.hid> In-Reply-To: <621300.75012.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: >>>> You should trace the exception path in the I-pipe patch to find the >>>> point where your exception handling callback is not called. >>> will it be a large print work or there are another ways to do that? >>> :) >> Yes, a small printk works. There is not that much code involved. > > I have found the problem. > I used a printf some instructions before the call to the asm blob. > Once removed seems to work as expected. > I've seen also that writing > printf(expr); \ > rt_task_set_mode(0, T_PRIMARY, 0); > it works (I think printf does a switch to secondary domain). > Now I should use a user-space-no-problem print like rtdm_printk in kernel space. > The docs says rtdm_in_rt_context and rtdm_printk are avalaible but in the rtdm.h > there is no trace of them and I can't use rtdm_driver.h 'cause it's kernel only... rtdm_printk (read 'k' as 'kernel') is for driver development in kernel space only. What you are looking for is rt_printf from the rtdk lib. See related example (examples/native/rtprint.c). Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F48CDA.5050402@domain.hid> Date: Tue, 14 Oct 2008 14:13:14 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <621300.75012.qm@domain.hid> <48F472B2.7050302@domain.hid> In-Reply-To: <48F472B2.7050302@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Xenomai help , Gabriele Moabiti Jan Kiszka wrote: > Gabriele Moabiti wrote: >>>>> You should trace the exception path in the I-pipe patch to find the >>>>> point where your exception handling callback is not called. >>>> will it be a large print work or there are another ways to do that? >>>> :) >>> Yes, a small printk works. There is not that much code involved. >> I have found the problem. >> I used a printf some instructions before the call to the asm blob. >> Once removed seems to work as expected. >> I've seen also that writing >> printf(expr); \ >> rt_task_set_mode(0, T_PRIMARY, 0); >> it works (I think printf does a switch to secondary domain). >> Now I should use a user-space-no-problem print like rtdm_printk in kernel space. >> The docs says rtdm_in_rt_context and rtdm_printk are avalaible but in the rtdm.h >> there is no trace of them and I can't use rtdm_driver.h 'cause it's kernel only... > > rtdm_printk (read 'k' as 'kernel') is for driver development in kernel > space only. > > What you are looking for is rt_printf from the rtdk lib. See related > example (examples/native/rtprint.c). I think it would be nice if we had some doxygen documentation for the rtdk lib. This way, we could point users to this documentation. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 15 Oct 2008 15:30:43 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-128110599-1224084643=:66216" Message-ID: <373456.66216.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Xenomai help --0-128110599-1224084643=:66216 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >rtdm_printk (read 'k' as 'kernel') is for driver development in kernel=0A>= space only.=0A>=0A>What you are looking for is rt_printf from the rtdk lib.= See related=0A>example (examples/native/rtprint.c).=0A=0AAt kernel level I= usually write defines like this=0A=0A#define DBG_PRINTF(expr...) \=0A if = (rtdm_in_rt_context()) \=0A rtdm_printk(expr); \=0A else if (kdb_on) \= =0A printk(expr)=0A=0Ato manage xenomai and linux output for debugging.= =0AIs there something like rtdm_in_rt_context for the user space?=0A=0A=0A = Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua = opinione.=0Ahttp://www.ymailblogit.com/blog --0-128110599-1224084643=:66216 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
&= gt;rtdm_printk (read 'k' as 'kernel') is for driver development in kernel>space only.
>
>What you are looking for is rt_printf from= the rtdk lib. See related
>example (examples/native/rtprint.c).
<= br>At kernel level I usually write defines like this

#define DBG_PRI= NTF(expr...) \
  if (rtdm_in_rt_context()) \
    = rtdm_printk(expr); \
  else if (kdb_on) \
    pri= ntk(expr)

to manage xenomai and linux output for debugging.
Is th= ere something like rtdm_in_rt_context for the user space?


=0A=0A=0A=0A
= Scopri il Blog di Yahoo!= Mail: trucchi, novit=C3=A0, consigli... e scrivi la tua opinione! --0-128110599-1224084643=:66216-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F60EB2.9050100@domain.hid> Date: Wed, 15 Oct 2008 17:39:30 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <373456.66216.qm@domain.hid> In-Reply-To: <373456.66216.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: >> rtdm_printk (read 'k' as 'kernel') is for driver development in kernel >> space only. >> >> What you are looking for is rt_printf from the rtdk lib. See related >> example (examples/native/rtprint.c). > > At kernel level I usually write defines like this > > #define DBG_PRINTF(expr...) \ > if (rtdm_in_rt_context()) \ > rtdm_printk(expr); \ > else if (kdb_on) \ > printk(expr) > > to manage xenomai and linux output for debugging. > Is there something like rtdm_in_rt_context for the user space? In both domains, this differentiation is unneeded. Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48EF7D19.7000608@domain.hid> Date: Fri, 10 Oct 2008 18:04:41 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <129381.87674.qm@domain.hid> In-Reply-To: <129381.87674.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > > > >>> It's a long story... I know anonymous mapping is better but I have need physical contiguos memory >>> (not for the test of course). The binary blob has fixed addresses between 1 to 16 MB so I have mapped the >> To do this with RTDM, you should use rtdm_mmap_to_user, not >> rtdm_iomap_to_user. And to do this with an anonymous mapping, you simply >> need to pass the address where you want the mmap to occur to mmap, and >> pass MAP_FIXED to mmap flags, this is all documented in mmap manual. > > I did't specify I have passed mem=xxx to kernel to take the upper 16MB so I have to use rtdm_iomap_to_user. > I think the RTDM mapping works. > >>> I start UD from the terminal and the terminal always report the right error. >> Ok. Probably the I-pipe patch only calls your callback for real-time >> tasks. Is the thread which runs the binary blob created with xenomai >> services ? > > my_rt_task_func() > { > int 3 // This is trapped by the custom exception routine (forwarded to xenomai handler). The terminal write > // trace/breakpoint trap > } This does not tell me how the thread running "my_rt_task_func" is created. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 10 Oct 2008 17:57:49 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-396205436-1223661469=:45338" Message-ID: <563079.45338.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-396205436-1223661469=:45338 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A> =0A> my_rt_task_func()=0A> {=0A> int 3 // This is trapped by the c= ustom exception routine (forwarded to xenomai handler). The terminal write= =0A> // trace/breakpoint trap=0A> }=0A=0A> This does not tell m= e how the thread running "my_rt_task_func" is created.=0A=0AIn user space w= ith the standard=0A=0A rt_task_create(&task_desc, "MyTaskName", TASK= _STKSZ, TASK_PRIO, TASK_MODE);=0A rt_task_start(&task_desc, &my_rt_t= ask_func, NULL);=0A=0A Gabriele=0A=0A=0A=0A Scopri il blog di Yahoo= ! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.ymail= blogit.com/blog --0-396205436-1223661469=:45338 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<= br>>
> my_rt_task_func()
> {
>    int 3 //= This is trapped by the custom exception routine (forwarded to xenomai hand= ler). The terminal write
>            = // trace/breakpoint trap
> }

> This does not tell me how th= e thread running "my_rt_task_func" is created.

In user space with th= e standard

        rt_task_create(&= ;task_desc, "MyTaskName", TASK_STKSZ, TASK_PRIO, TASK_MODE);
  = ;      rt_task_start(&task_desc, &my_rt_ta= sk_func, NULL);

    Gabriele
=0A=0A=0A=0A
Scopri il <= a href=3D"http://us.rd.yahoo.com/mail/it/taglines/yahoo/ymail/SIG=3D11djrg4= 60/**http%3A%2F%2Fwww.ymailblogit.com%2Fblog%2F"> Blog di Yahoo! Mail: = trucchi, novit=C3=A0, consigli... e scrivi la tua opinione! --0-396205436-1223661469=:45338-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F08CD0.8000809@domain.hid> Date: Sat, 11 Oct 2008 13:24:00 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <129381.87674.qm@domain.hid> In-Reply-To: <129381.87674.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > > > >>> It's a long story... I know anonymous mapping is better but I have need physical contiguos memory >>> (not for the test of course). The binary blob has fixed addresses between 1 to 16 MB so I have mapped the >> To do this with RTDM, you should use rtdm_mmap_to_user, not >> rtdm_iomap_to_user. And to do this with an anonymous mapping, you simply >> need to pass the address where you want the mmap to occur to mmap, and >> pass MAP_FIXED to mmap flags, this is all documented in mmap manual. > > I did't specify I have passed mem=xxx to kernel to take the upper 16MB so I have to use rtdm_iomap_to_user. > I think the RTDM mapping works. Yes, but I still think this is useless. If your user-space code expects to be running from 1MB to 16MB, it expects this for virtual addresses, not for physical addresses. So, I really think you should mmap the 1MB to 16MB region by passing the start address to mmap with the MMAP_FIXED flag. > >>> I start UD from the terminal and the terminal always report the right error. >> Ok. Probably the I-pipe patch only calls your callback for real-time >> tasks. Is the thread which runs the binary blob created with xenomai >> services ? > > my_rt_task_func() > { > int 3 // This is trapped by the custom exception routine (forwarded to xenomai handler). The terminal write > // trace/breakpoint trap > } > > my_rt_task_func() > { > call *asm_part > } > > asm_part --- (it has been copied in the first 16 MB of user task mapped to the 16 MB kernel memory) > > int 3 // This is not trapped by the custom exception routine however the a trace/breakpoint trap is raised and > // it is written in terminal You should trace the exception path in the I-pipe patch to find the point where your exception handling callback is not called. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48EF76E1.4070706@domain.hid> Date: Fri, 10 Oct 2008 17:38:09 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <819144.28662.qm@domain.hid> In-Reply-To: <819144.28662.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: >> Where does custom_except leaves, in kernel-space or user-space ? > > I have called rthal_trap_catch in the init function of the KD. > I have tried also in a rt task inside KD. > >>> - KD has an rtdm interface to map the 16 MB memory on user space with >>> rtdm_iomap_to_user. >>> - UD starts and It maps with the rtdm (rtdm_iomap_to_user) >> This is completely useless. You can use an anonymous mapping in >> user-space, you will not need the help from an rtdm driver. And your >> mapping needs to be executable (you need to pass PROT_EXEC to mmap). >>> - UD copy a binary asm x86 test fpu (some instructions to generate >>> exceptions for tests) in the 16 MB memory mapped >> If you do that, your binary needs to be relocatable, that is its code >> must not depend on the address at which it is loaded. Are you sure your >> binary blob has this property ? > > It's a long story... I know anonymous mapping is better but I have need physical contiguos memory > (not for the test of course). The binary blob has fixed addresses between 1 to 16 MB so I have mapped the first 15 MB of the UD (starting to 1 MB). I Know it is very strange... To do this with RTDM, you should use rtdm_mmap_to_user, not rtdm_iomap_to_user. And to do this with an anonymous mapping, you simply need to pass the address where you want the mmap to occur to mmap, and pass MAP_FIXED to mmap flags, this is all documented in mmap manual. > I start UD from the terminal and the terminal always report the right error. Ok. Probably the I-pipe patch only calls your callback for real-time tasks. Is the thread which runs the binary blob created with xenomai services ? -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 24 Oct 2008 13:53:27 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-107273184-1224856407=:63324" Message-ID: <258091.63324.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix , Jan Kiszka Cc: Xenomai help --0-107273184-1224856407=:63324 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I have upgraded the kernel to 2.6.24 + xenomai 2.4.5=0A=0AThe custom except= ion doesn't work as I expected.=0A=0Astatic rthal_trap_handler_t old_trap_h= andler;=0A In an the kernel driver I set:=0Aold_trap_handler =3D rthal_tra= p_catch(&custom_trap_fault);=0A the custom handler is:=0Astatic int custom= _trap_fault(unsigned event, unsigned domid, void *data)=0A{=0A if (is_my_a= pplication(...) && i_want_to_manage_exception(event)) {=0A ManageCustomE= xceptions();=0A return RTHAL_EVENT_STOP; /* 1=3DSTOP */=0A }=0A return (= (rthal_trap_handler_t) old_trap_handler)(event, domid, data);=0A}=0A=0AThe = exception 7 is passed to the xenomai exception handler (TS flag).=0A=0AI co= nsider now ManageCustomExceptions a function that do nothing.=0A=0AINT 3 or= 1=0AAdeos does what I expected. It returns and nothing done.=0AThe program= continue happy to the next instruction.=0A=0AINT 0 (divide error) or 16 (f= pu exception)=0AThe system hangs.=0AWhen I pass to xenomai It doesn't handl= e the exception and relax the thread an propagate=0Ato linux (I think as ex= pected to do).=0A[in the xnpod_trap_fault, xnpod_shadow_p is true then xnsh= adow_relax is performed so the =0A routine return 0 (RTHAL_EVENT_PROPAGATE)= ]=0A=0AIs it possible to customize such exceptions? Am I missing something?= =0A=0A Gabriele=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, = novit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-107273184-1224856407=:63324 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
I have upgraded the kernel to 2.6.24 + xenomai 2.4.5
=0A
The custo= m exception doesn't work as I expected.

static rthal_trap_handler_t = old_trap_handler;
  In an the kernel driver I set:
old_trap_hand= ler =3D rthal_trap_catch(&custom_trap_fault);
  the custom hand= ler is:
static int custom_trap_fault(unsigned event, unsigned domid, voi= d *data)
{
  if (is_my_application(...) && i_want_to_man= age_exception(event)) {
    ManageCustomExceptions();
=     return RTHAL_EVENT_STOP; /* 1=3DSTOP */
 }
&n= bsp;return ((rthal_trap_handler_t) old_trap_handler)(event, domid, data);}

The exception 7 is passed to the xenomai exception handler (TS f= lag).

I consider now ManageCustomExceptions a function that do nothi= ng.

INT 3 or 1
Adeos does what I expected. It returns and nothing= done.
The program continue happy to the next instruction.

INT 0 = (divide error) or 16 (fpu exception)
The system hangs.
When I pass to xenomai It doesn't handle the exception and relax= the thread an propagate
to linux (I think as expected to do).
=0A[in= the xnpod_trap_fault, xnpod_shadow_p is true then xnshadow_relax is perfor= med so the
 routine return 0 (RTHAL_EVENT_PROPAGATE)]

Is it= possible to customize such exceptions? Am I missing something?

&nbs= p;   Gabriele


=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, consigli... e= scrivi la tua opinione!
--0-107273184-1224856407=:63324-- From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 24 Oct 2008 15:30:22 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-923364900-1224862222=:59776" Message-ID: <36141.59776.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix , Jan Kiszka Cc: Xenomai help --0-923364900-1224862222=:59776 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A=0A>INT 0 (divide error) or 16 (fpu exception)=0A>The system hangs.=0A= =0AMaybe it's not too clear: the system hangs if i return RTHAL_EVENT_STOP = doing nothing.=0AThe next one is the default behaviour when xenomai manage = itself the exception.=0A=0A>When I pass to xenomai It doesn't handle the ex= ception and relax the thread an propagate=0A>to linux (I think as expected = to do).=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0= e scrivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-923364900-1224862222=:59776 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

>INT 0 (divide error) or 16 (fpu exception)
>= ;The system=0A hangs.

Maybe it's not too clear: the system hangs if = i return RTHAL_EVENT_STOP doing nothing.
The next one is the default beh= aviour when xenomai manage itself the exception.
=0A
>When I pass = to xenomai It doesn't handle the exception and relax the thread an propagat= e
>to linux (I think as expected to do).
=0A


=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, consi= gli... e scrivi la tua opinione! --0-923364900-1224862222=:59776-- From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 11 Oct 2008 19:32:40 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1318023392-1223753560=:51777" Message-ID: <333188.51777.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1318023392-1223753560=:51777 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A>Yes, but I still think this is useless. If your user-space code expects= =0A>to be running from 1MB to 16MB, it expects this for virtual addresses,= =0A>not for physical addresses. So, I really think you should mmap the 1MB= =0A>to 16MB region by passing the start address to mmap with the MMAP_FIXED= =0A>flag.=0A=0AI know my way to solve this problem is very strange but ther= e are some reasons.=0AIt is done for compatibility reasons (DMA and a stran= ge architecture with custom gdt entries needed by the asm blob...)=0AIn thi= s application I don't need contiguous physical addresses so I will try the = mmap fixed way.=0AI didn't only want to fork the driver but it is not a big= problem...=0A=0A>You should trace the exception path in the I-pipe patch t= o find the=0A>point where your exception handling callback is not called.= =0A=0Awill it be a large print work or there are another ways to do that? := )=0A=0A Gabriele=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi,= novit=C3=A0 e scrivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-1318023392-1223753560=:51777 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<= br>>Yes, but I still think this is useless. If your user-space code expe= cts
>to be running from 1MB to 16MB, it expects this for virtual addr= esses,
>not for physical addresses. So, I really think you should mma= p the 1MB
>to 16MB region by passing the start address to mmap with t= he MMAP_FIXED
>flag.

I know my way to solve this problem is ve= ry strange but there are some reasons.
It is done for compatibility reas= ons (DMA and a strange architecture with custom gdt entries needed by the a= sm blob...)
In this application I don't need contiguous physical address= es so I will try the mmap fixed way.
I didn't only want to fork the driver but it is not a big problem...

>You should trace the exc= eption path in the I-pipe patch to find the
>point where your excepti= on handling callback is not called.

will it be a large print work or= there are another ways to do that? :)

    Gabriele

=0A=0A=0A=0A
Scopri il Blog di Yahoo! Mail: trucchi, novit=C3=A0, consigli... e scrivi la tu= a opinione! --0-1318023392-1223753560=:51777-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <49020943.80708@domain.hid> Date: Fri, 24 Oct 2008 19:43:31 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <258091.63324.qm@domain.hid> In-Reply-To: <258091.63324.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Jan Kiszka , Xenomai help Gabriele Moabiti wrote: > (...) > I consider now ManageCustomExceptions a function that do nothing. > (...) > INT 0 (divide error) or 16 (fpu exception) > The system hangs. It will not work. It is because you have to handle the exception. Otherwise, when returning to user-space, your programs tries the faulty exception again, triggers the handler, which does nothing, and loops indefinitely... -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <49020997.6050106@domain.hid> Date: Fri, 24 Oct 2008 19:44:55 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <258091.63324.qm@domain.hid> <49020943.80708@domain.hid> In-Reply-To: <49020943.80708@domain.hid> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Jan Kiszka , Xenomai help Gilles Chanteperdrix wrote: > Gabriele Moabiti wrote: >> (...) >> I consider now ManageCustomExceptions a function that do nothing. >> (...) >> INT 0 (divide error) or 16 (fpu exception) >> The system hangs. > > It will not work. It is because you have to handle the exception. > Otherwise, when returning to user-space, your programs tries the faulty > exception again, triggers the handler, which does nothing, and loops I meant try the faulty *instruction* again > indefinitely... > -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 24 Oct 2008 19:17:21 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-889301253-1224875841=:68232" Message-ID: <66014.68232.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Jan Kiszka , Xenomai help --0-889301253-1224875841=:68232 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0AGilles Chanteperdrix wrote:=0A> Gabriele Moabiti wrote:=0A>> (...)=0A>> = I consider now ManageCustomExceptions a function that do nothing.=0A>> (...= )=0A>> INT 0 (divide error) or 16 (fpu exception)=0A>> The system hangs.=0A= > =0A> It will not work. It is because you have to handle the exception.=0A= > Otherwise, when returning to user-space, your programs tries the faulty= =0A> exception again, triggers the handler, which does nothing, and loops= =0A> indefinitely...=0A> =0A=0Aso the int 1 and 3 are instead signed as tra= ps with the old CS:EIP points past instruction causing exception...=0A=0ASo= rry for the question (I have always done it directly in asm reprogramming c= ustomizing the IDT), do I have to change the eip of the pt_regs structure p= assed to the function?=0A=0AThank you,=0A Gabriele=0A=0A=0A=0A Scop= ri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua opinione.= =0Ahttp://www.ymailblogit.com/blog --0-889301253-1224875841=:68232 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
<= br>Gilles Chanteperdrix wrote:
> Gabriele Moabiti wrote:
>> = (...)
>> I consider now ManageCustomExceptions a function that do = nothing.
>> (...)
>> INT 0 (divide error) or 16 (fpu exce= ption)
>> The system hangs.
>
> It will not work. It = is because you have to handle the exception.
> Otherwise, when return= ing to user-space, your programs tries the faulty
> exception again, = triggers the handler, which does nothing, and loops
> indefinitely...=
>

so the int 1 and 3 are instead signed as traps with the ol= d CS:EIP points past instruction causing exception...

Sorry for the question (I have always done it directly in asm reprogramming customizing = the IDT), do I have to change the eip of the pt_regs structure passed to th= e function?

Thank you,
    Gabriele

=0A=0A=0A=0A
S= copri il Blog di Yahoo! = Mail: trucchi, novit=C3=A0, consigli... e scrivi la tua opinione! --0-889301253-1224875841=:68232-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <49050219.4050805@domain.hid> Date: Mon, 27 Oct 2008 00:49:45 +0100 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <66014.68232.qm@domain.hid> In-Reply-To: <66014.68232.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Jan Kiszka , Xenomai help Gabriele Moabiti wrote: > Gilles Chanteperdrix wrote: >> Gabriele Moabiti wrote: >>> (...) I consider now ManageCustomExceptions a function that do >>> nothing. (...) INT 0 (divide error) or 16 (fpu exception) The >>> system hangs. >> It will not work. It is because you have to handle the exception. >> Otherwise, when returning to user-space, your programs tries the >> faulty exception again, triggers the handler, which does nothing, >> and loops indefinitely... >> > > so the int 1 and 3 are instead signed as traps with the old CS:EIP > points past instruction causing exception... > > Sorry for the question (I have always done it directly in asm > reprogramming customizing the IDT), do I have to change the eip of > the pt_regs structure passed to the function? Errr no. You probably know better than me the details of exception handling (I trust Linux and/or Xenomai exception handling for my everyday usage), however, if your code contains an instruction which uses FPU, you should enable FPU and let the program retry that instruction, otherwise, if you skip this instruction, you will never know its result. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F0FFD1.7000307@domain.hid> Date: Sat, 11 Oct 2008 21:34:41 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <333188.51777.qm@domain.hid> In-Reply-To: <333188.51777.qm@domain.hid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: >> You should trace the exception path in the I-pipe patch to find the >> point where your exception handling callback is not called. > > will it be a large print work or there are another ways to do that? > :) Yes, a small printk works. There is not that much code involved. -- Gilles. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <48F11C12.20104@domain.hid> Date: Sat, 11 Oct 2008 23:35:14 +0200 From: Philippe Gerum MIME-Version: 1.0 References: <333188.51777.qm@domain.hid> In-Reply-To: <333188.51777.qm@domain.hid> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [Xenomai-help] trap exceptions in user Reply-To: rpm@xenomai.org List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gabriele Moabiti Cc: Xenomai help Gabriele Moabiti wrote: > >>Yes, but I still think this is useless. If your user-space code expects >>to be running from 1MB to 16MB, it expects this for virtual addresses, >>not for physical addresses. So, I really think you should mmap the 1MB >>to 16MB region by passing the start address to mmap with the MMAP_FIXED >>flag. > > I know my way to solve this problem is very strange but there are some > reasons. > It is done for compatibility reasons (DMA and a strange architecture > with custom gdt entries needed by the asm blob...) > In this application I don't need contiguous physical addresses so I will > try the mmap fixed way. > I didn't only want to fork the driver but it is not a big problem... > >>You should trace the exception path in the I-pipe patch to find the >>point where your exception handling callback is not called. > > will it be a large print work or there are another ways to do that? :) > You may want to have a look at the I-pipe tracer: http://www.xenomai.org/index.php/I-pipe:Tracer > Gabriele > > > ------------------------------------------------------------------------ > Scopri il Blog di Yahoo! Mail > : > trucchi, novità, consigli... e scrivi la tua opinione! > > > ------------------------------------------------------------------------ > > _______________________________________________ > Xenomai-help mailing list > Xenomai-help@domain.hid > https://mail.gna.org/listinfo/xenomai-help -- Philippe. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 13 Oct 2008 09:55:54 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1962456848-1223891754=:58327" Message-ID: <967654.58327.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1962456848-1223891754=:58327 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> I did't specify I have passed mem=3Dxxx to kernel to take the upper 16MB= =0A>> I think the RTDM mapping works.=0A>=0A>Yes, but I still think this is= useless. If your user-space code expects=0A>to be running from 1MB to 16MB= , it expects this for virtual addresses,=0A>not for physical addresses. So,= I really think you should mmap the 1MB=0A>to 16MB region by passing the st= art address to mmap with the MMAP_FIXED=0A>flag.=0A=0AI have tried fixed mm= ap mode and I have no luck.=0AOutside the mmap mapped memory exceptions are= trapped with rthal_trap_catch.=0AInside the callback doesn't work... seems= to dislike mapped memory...=0A=0AAnother question:=0AIs it right I can set= rthal_trap_catch only in kernel rt/nrt task?=0A=0A Gabriele=0A=0A=0A = Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e scrivi la tua op= inione.=0Ahttp://www.ymailblogit.com/blog --0-1962456848-1223891754=:58327 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
&= gt;> I did't specify I have passed mem=3Dxxx to kernel to take the upper= 16MB
>> I think the RTDM mapping works.
>
>Yes, but I= still think this is useless. If your user-space code expects
>to be = running from 1MB to 16MB, it expects this for virtual addresses,
>not= for physical addresses. So, I really think you should mmap the 1MB
>= to 16MB region by passing the start address to mmap with the MMAP_FIXED
= >flag.

I have tried fixed mmap mode and I have no luck.
Outsid= e the mmap mapped memory exceptions are trapped with rthal_trap_catch.
I= nside the callback doesn't work... seems to dislike mapped memory...

Another question:
Is it right I can set rthal_trap_cat= ch only in kernel rt/nrt task?

    Gabriele


=0A=0A=0A=0A
Scopri il Blog d= i Yahoo! Mail: trucchi, novit=C3=A0, consigli... e scrivi la tua opinio= ne! --0-1962456848-1223891754=:58327-- From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 10 Oct 2008 16:02:09 +0000 (GMT) From: Gabriele Moabiti MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1111212992-1223654529=:87674" Message-ID: <129381.87674.qm@domain.hid> Subject: Re: [Xenomai-help] trap exceptions in user List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: Xenomai help --0-1111212992-1223654529=:87674 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A=0A=0A=0A>> It's a long story... I know anonymous mapping is better but = I have need physical contiguos memory=0A>> (not for the test of course). Th= e binary blob has fixed addresses between 1 to 16 MB so I have mapped the = =0A>To do this with RTDM, you should use rtdm_mmap_to_user, not=0A>rtdm_iom= ap_to_user. And to do this with an anonymous mapping, you simply=0A>need to= pass the address where you want the mmap to occur to mmap, and=0A>pass MAP= _FIXED to mmap flags, this is all documented in mmap manual.=0A=0AI did't s= pecify I have passed mem=3Dxxx to kernel to take the upper 16MB so I have t= o use rtdm_iomap_to_user.=0AI think the RTDM mapping works.=0A=0A>> I start= UD from the terminal and the terminal always report the right error.=0A>= =0A>Ok. Probably the I-pipe patch only calls your callback for real-time=0A= >tasks. Is the thread which runs the binary blob created with xenomai=0A>se= rvices ?=0A=0Amy_rt_task_func()=0A{=0A int 3 // This is trapped by the c= ustom exception routine (forwarded to xenomai handler). The terminal write= =0A // trace/breakpoint trap=0A}=0A=0Amy_rt_task_func()=0A{=0A = call *asm_part=0A}=0A=0Aasm_part --- (it has been copied in the first 16 = MB of user task mapped to the 16 MB kernel memory)=0A=0Aint 3 // This is no= t trapped by the custom exception routine however the a trace/breakpoint tr= ap is raised and=0A // it is written in terminal=0A---=0A=0A Gabr= iele=0A=0A=0A Scopri il blog di Yahoo! Mail:=0ATrucchi, novit=C3=A0 e = scrivi la tua opinione.=0Ahttp://www.ymailblogit.com/blog --0-1111212992-1223654529=:87674 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


>> It's a long story... I know anonymous mapping is= better but I have need physical contiguos memory
>> (not for the = test of course). The binary blob has fixed addresses between 1 to 16 MB so = I have mapped the
>To do this with RTDM, you should use rtdm_mmap_to= _user, not
>rtdm_iomap_to_user. And to do this with an anonymous mapp= ing, you simply
>need to pass the address where you want the mmap to = occur to mmap, and
>pass MAP_FIXED to mmap flags, this is all documen= ted in mmap manual.

I did't specify I have passed mem=3Dxxx to kerne= l to take the upper 16MB so I have to use rtdm_iomap_to_user.
I think th= e RTDM mapping works.

>> I start UD from the terminal and the t= erminal always report the right error.
>
>Ok. Probably the I-pi= pe patch only calls your callback for real-time
>tasks. Is the thread= which runs the binary blob created with xenomai
>services ?

m= y_rt_task_func()
{
    int 3 // This is trapped by the= custom exception routine (forwarded to xenomai handler). The terminal writ= e
            // trace/brea= kpoint trap
}

my_rt_task_func()
=0A{
=0A    = call *asm_part
=0A}
=0A
asm_part --- (it has been copied in the fi= rst 16 MB of user task mapped to the 16 MB kernel memory)

int 3 // T= his is not trapped by the custom exception routine however the a trace/brea= kpoint trap is raised and
       //  = it is written in terminal
---

    Gabriele

=

=0A=0A=0A=0A
Scopri il Blog= di Yahoo! Mail: trucchi, novit=C3=A0, consigli... e scrivi la tua opin= ione! --0-1111212992-1223654529=:87674--