Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: freqmax on May 10, 2009, 03:50:00 AM

Title: AmigaOS Memory protection, preemptive?
Post by: freqmax on May 10, 2009, 03:50:00 AM
Is there any functionality for memory protection on those m68k processors that support it?, ie such that programs can't just poke around and take down the OS.

Swapping is supported with AmigaOS v4.0 so I thought maybe there's a chance.

Title: Re: AmigaOS Memory protection, preemptive?
Post by: SamuraiCrow on May 10, 2009, 04:14:38 AM
There's a diagnostic tool called MuForce.  I think it's just a combination of MungWall and Enforcer.

-Edit-
http://aminet.net/package/dev/debug/MuForce
Title: Re: AmigaOS Memory protection, preemptive?
Post by: Piru on May 10, 2009, 09:15:45 AM
@freqmax
Quote
Is there any functionality for memory protection on those m68k processors that support it? ie such that programs can't just poke around and take down the OS.

No
Quote
Swapping is supported with AmigaOS v4.0 so I thought maybe there's a chance.

Not even AmigaOS 4 has memory protection (and neither has MorphOS), so no chance.
Title: Re: AmigaOS Memory protection, preemptive?
Post by: Karlos on May 10, 2009, 11:27:09 AM
AmigaOS wasn't designed with memory protection in mind. All of the processes see the same memory map and the ability to access memory owned by another process is critical to the  messaging system: Process A allocates memory, puts data into it and passes a pointer to Process B which can modify it directly and pass it back.

The only model I could envisage working is one in which public and private memory are implemented. Public memory would be used to allocate storage for any structures that are to be passed between processes and private memory used everywhere else. However, even assuming you could rewrite the entire OS to use this model, protection of private memory could only be implemented on a page basis. Furthermore, given the existing design of the OS, you'd not really be no safer due to the extent to which it depends on messaging etc. You simply can't prevent a broken Process B crapping all over the public memory Process A allocated for the message.
Title: Re: AmigaOS Memory protection, preemptive?
Post by: freqmax on May 10, 2009, 01:28:51 PM
You send the message to the kernel which then takes ownership of that memory range. Then the program can trash all around without any effect ;)
Title: Re: AmigaOS Memory protection, preemptive?
Post by: Karlos on May 10, 2009, 01:36:09 PM
Quote

freqmax wrote:
You send the message to the kernel which then takes ownership of that memory range. Then the program can trash all around without any effect ;)


Unfortunately, that is completely at odds with the amigaos messaging system. Messages are sent by reference, directly between message ports created by userland processes.

Even if you did managed to rework it so that they were sent by the "kernel" - which is a strange concept given that only the task scheduler and exception traps run in supervisor mode - you'd lose the principal advantage of the AmigaOS IPC mechanism, which is it's speed. If you copy the message, you introduce significant overhead.

So, you decide to opt for a zero copy but then only discrete pages can be protected. Unless you make all discrete allocations at least one page in size (which will waste memory like anything), you wouldn't want to do that. If you did, you might end up write protecting other bits of data in the same page that are in use by other processes.

Finally, assuming you overcome all this, if Process B craps all over the message and dies, it has still suceeded in hanging process A which is probably waiting for a ReplyMsg(). Anything waiting for Process A will now lock up too, and so on.
Title: Re: AmigaOS Memory protection, preemptive?
Post by: brianb on May 10, 2009, 02:31:51 PM
You can run Linux on your 68k Amiga and gain memory protection....   :-P

http://www.linux-m68k.org/
Title: Re: AmigaOS Memory protection, preemptive?
Post by: shoggoth on May 10, 2009, 03:22:29 PM
Quote

brianb wrote:
You can run Linux on your 68k Amiga and gain memory protection....   :-P

http://www.linux-m68k.org/


Sure, but in such case you're nolonger running AmigaOS (topic) :-)