All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Kiichi Kameda <k-kameda@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] SH4 port
Date: Mon, 02 Oct 2006 17:44:18 +0200	[thread overview]
Message-ID: <452133D2.7070006@domain.hid> (raw)
In-Reply-To: <002901c6e6ff$3f519d00$1501a8c0@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 2542 bytes --]

Kiichi Kameda wrote:
>> Kiichi Kameda wrote:
>>>> [ksrc/arch/sh/switch.c]
>>>>
>>>> void rthal_switch_to(xnarchtcb_t *prev, xnarchtcb_t *next)
>>>> {
>>>> ...
>>>>         /*
>>>>          * Restore the kernel mode register
>>>>          *      k7 (r7_bank1)
>>>>          */
>>>>  if(next->user_task) {
>>>>
>>>>             asm volatile("ldc       %0, r5_bank"
>>>>                      : /* no output */
>>>>                      : "r" (next->user_task->thread_info));
>>>>  }
>>>>
>>>> Is there a particular reason why comment and reality diverge regarding
>>>> the thread_info register? Could this cause your troubles?
>>>>
>>> I'm sorry, the comment is wrong.
>>> The code that uses r7_bank  results in overwriting "current".
>> What code is it?
> 
> Above code(rthal_switch_to) is derived from Linux, which uses r7_bank.
> At first I used r7_bank  in rthal_switch_to , but this code caused panic.

Why? Rhetorical questions. The point is you need to understand the
mechanisms preventing this to work because it looks to me like this is
the way to go.

Was there anything else that denies invoking the original Linux
__switch_to directly? That should be preferred if feasible.

> 
>>> To avoid this,  I changed  from r7_bank to r5_bank for Xenomai context
>>> switch .
>> Wouldn't it be better to avoid that overwriting in the first place
>> instead of escaping from it? You may not be safe from code running on
>> behalf of a Xenomai user-space thread that assumes current is still in
>> r7_bank.
>>
>>> Also, I added to the Linux context switch code  so that thread_info is
> set
>>> in r5_bank register  as well as in r7_bank regsiter.
>>> r5_bank register is referenced in the page fault handling code.
>> The handling code of Xenomai or Linux?
> 
> There exists only one page fault handling code for both Xenomai and Linux.
> Is this a problem?

Xenomai normally only has a hook here to suspend RT threads on faults
and/or migrate them to Linux. I just didn't know if you had to develop
something special for SH4.

> 
>> The goal must be that the environment for a shadowed Xenomai thread
>> looks (almost) like that of a normal Linux thread. If there is Xenomai
>> code that messes this up on SH4, this has to be fixed. Patching Linux
>> Linux outside the I-pipe context indicates that something is wrong with
>> the design. This is what I can say from my distant POV without knowing
>> the specific issues of SH4.
>>
> 
> Yes I think so too.
> 
> 
> 

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  reply	other threads:[~2006-10-02 15:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 13:21 [Xenomai-help] SH4 port Kiichi Kameda
2006-10-02 13:30 ` Jan Kiszka
2006-10-03 14:13   ` Kiichi Kameda
2006-10-02 14:43     ` Jan Kiszka
2006-10-03 15:18       ` Kiichi Kameda
2006-10-02 15:44         ` Jan Kiszka [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-09-30 13:10 Kiichi Kameda
2006-09-29 13:20 ` Jan Kiszka
2006-10-02  8:40   ` Jan Kiszka

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=452133D2.7070006@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=k-kameda@domain.hid \
    --cc=xenomai@xenomai.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.