Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vxWorks memory protection

155 views
Skip to first unread message

usir...@nexabit.com

unread,
Jan 28, 2000, 3:00:00 AM1/28/00
to
Hello!
I am trying to implement a simple memory protection for vxWorks (Tornado
1.0.2 PowerPC). My model is
simple. I have a special taskSpawn, which allocates the stack space,
calls taskInit, and taskActivate. I put a
stamp in reserved2 field of TCB to indicate that their stack is safe.

In taskSwitchHook, I check if this is a safe task. If so, I write
protect the old task stack space in the page table,
and if unprotect the stack space for new task. But, sometimes I get data
access exception for resons unknown
to me.

I do know that the exception is data access...

Any help for this will be appreciated!

-Umesh


john_...@my-deja.com

unread,
Jan 29, 2000, 3:00:00 AM1/29/00
to

> In taskSwitchHook, I check if this is a safe task. If so, I write
> protect the old task stack space in the page table,
> and if unprotect the stack space for new task. But, sometimes I get
data
> access exception for resons unknown
> to me.

Two things come to mind:

1) Have you taken care of invalidating any TLB entries that may exist?
You don't say which PPC you are using, but even the lowliest of 8xx
members have some TLB entries. If you are changing the access
permissions of pages you need to flush the TLB of any affected entries
to make sure that the new task doesn't see those instead of reading the
translation tables in memory again.

2) If you have your cache in copyback mode, you want to ensure that you
are flushing the lines containing the updated page tables back to memory
since the cache is probably bypassed when a TLB miss occurs.

Hope that helps,

John...


Sent via Deja.com http://www.deja.com/
Before you buy.

usir...@nexabit.com

unread,
Jan 31, 2000, 3:00:00 AM1/31/00
to john_...@my-deja.com
Thanx John!
I am using motorolla 603.
I disable mmu and cache before updating pte. That should make
sure that TLBs are always in sync.

Do we know if vxWorks ever writes to a task's stack space? If it does than
that will explain the issue I am seeing.


-Umesh

john_...@my-deja.com

unread,
Feb 1, 2000, 3:00:00 AM2/1/00
to
In article <3895D001...@nexabit.com>,

usir...@nexabit.com wrote:
> Thanx John!
> I am using motorolla 603.
> I disable mmu and cache before updating pte. That should make
> sure that TLBs are always in sync.

Disabling the MMU does not cause the TLB to be flushed - any
pre-existing translations will still be there when you switch the MMU
back on. You must explicitly flush it if you change PTEs which may be in
there. The normal symptom of this is that you can still access memory
that should be inaccessible though (since it will be the outgoing task's
accesses that are in the TLB). It is quite possible that you have TLB
entries still after your change, but I don't think that is your
problem...

> Do we know if vxWorks ever writes to a task's stack space? If it does
than
> that will explain the issue I am seeing.

During a context switch the outgoing task's stack is used to run the
scheduling code (including your hook function). You cannot make that
task's stack inaccessible in a hook routine. To achieve what you want to
achieve is actually quite difficult because of this; in fact I'm not
sure it is possible without re-writing a lot of the rescheduling code!

Sorry,

0 new messages