OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:34 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: OS wiith no virtual memory
PostPosted: Wed Dec 30, 2020 2:59 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 401
nullplan wrote:
nexos wrote:
A malicious app could overwrite all of memory with zeroes, no matter what you do. No MMU almost means no security :) .
Even better: A malicious app could overwrite the IDT to register one of its own functions as interrupt handler, then call that interrupt. Thereby usurping kernel privileges and taking over the whole machine.


But, of course, you can still use the protection mechanisms of the MMU within a single address space to protect the kernel from the user applications.

Is position independent code something you'll be looking at in your OS?


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Wed Dec 30, 2020 3:19 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
thewrongchristian wrote:
But, of course, you can still use the protection mechanisms of the MMU within a single address space to protect the kernel from the user applications.
Then you have the situation I already mentioned with OS-9 on the e300 (but on the x86 it would work the same): If the MMU is used at all, then for each virtual address, it must look up protection attributes and physical address. Since we store those together, it does not matter if you can calculate the physical address from the virtual one, even if the page table walk is in software; you still have to look up the protection attributes anyway. Thereby negating all the supposed speed advantages of running without MMU. So you might as well do it properly.

thewrongchristian wrote:
Is position independent code something you'll be looking at in your OS?
All the PIC solutions I know of are built with memory mapping in mind, and don't really lend themselves to a single-address-space world. I know of OS-9, as stated, but I know of no toolchain (except the one from Radisys themselves) that can produce OS-9 modules. And ELF and ELF FDPIC require the distance between code and data to be known at link time, and kept at load time.

See, in a multitasking single-address-space OS, what you would want, ideally, is a design that allows you to load code and data section independently of each other. That allows you to have multiple processes running the same program, and each process would have a different data section, and would all share code. OS-9 can do that, at least.

ELF and ELF FDPIC don't allow that. If a dynamic library (and position independent executables are often claiming to be dynamic libraries) wants a 2MB break between code and data, you must allocate those 2MB for the process. If another process were to use the same program, you would have to load the entire program again. No code sharing possible. The whole thing will end up as a massive waste of space, just because the OS designer didn't want to implement paging properly. Don't get me wrong: This stuff is position independent. You can load the program anywhere in address space, but it must allocate the whole area.

I don't know PE enough to make a determination about it, though. It is possible it might allow such usage. Not likely, though.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Wed Dec 30, 2020 4:36 pm 
Offline
Member
Member

Joined: Wed Mar 09, 2011 3:55 am
Posts: 509
bzt wrote:
In general, yes. However we surely could anticipate serious speed up because separate address spaces means memory buffers must be copied (or at least mapped in CoW manner) from one address space into another.


A buffer mapped copy-on-write on a system with an MMU will still have to be copied before it is written to on a system without an MMU, it will just be incumbent upon the application to make sure that it performs the copy. And an IPC buffer can be mapped writable to all programs using it, so once it has been mapped in each process, access to it is just as fast as to any other area of a program's address space.


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Wed Dec 30, 2020 5:01 pm 
Offline
Member
Member
User avatar

Joined: Tue Sep 15, 2020 8:07 am
Posts: 264
Location: London, UK
nullplan wrote:
thewrongchristian wrote:
Is position independent code something you'll be looking at in your OS?
All the PIC solutions I know of are built with memory mapping in mind, and don't really lend themselves to a single-address-space world. I know of OS-9, as stated, but I know of no toolchain (except the one from Radisys themselves) that can produce OS-9 modules. And ELF and ELF FDPIC require the distance between code and data to be known at link time, and kept at load time.

See, in a multitasking single-address-space OS, what you would want, ideally, is a design that allows you to load code and data section independently of each other. That allows you to have multiple processes running the same program, and each process would have a different data section, and would all share code. OS-9 can do that, at least.

ELF and ELF FDPIC don't allow that. If a dynamic library (and position independent executables are often claiming to be dynamic libraries) wants a 2MB break between code and data, you must allocate those 2MB for the process. If another process were to use the same program, you would have to load the entire program again. No code sharing possible. The whole thing will end up as a massive waste of space, just because the OS designer didn't want to implement paging properly. Don't get me wrong: This stuff is position independent. You can load the program anywhere in address space, but it must allocate the whole area.

I don't know PE enough to make a determination about it, though. It is possible it might allow such usage. Not likely, though.


Or just use Relocs like the old Amiga Hunk format used.

_________________
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Mon Jan 04, 2021 8:36 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 812
Location: Hyperspace
I imagine true PIC can be done, but it carries a small performance penalty of its own. Indirection is never quite free. I'm not sure how small the penalty is on modern CPUs. I've also got a hunch it might need a register allocated just for the indirection.

Relocation does seem to be the way to go. If I'm not mistaken, it's basically the same code as you need for dynamic linking anyway. It increases program start time a little, but I'm sure this would only be noticeable if your shell-script webserver got slashdotted. ;) I'm going on my experience with shell scripts under various OSs, all but one with dynamic linking. I have found really big shell scripts a little slow on some OSs (never Linux), but more cores seemed to make a bigger difference than dynamic linking. The only combination which was unacceptably slow in moderate use was a 700-line CMS + 150-line web server on a single-core 466MHz PPC running OS X.

I'm currently planning to use an ARM device with a simple MPU (memory protection unit) which, if I understand right, protects but doesn't remap. I'm thinking IPC will include passing a pointer (or rather a reference) via the kernel so it can allow the recipient access.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Tue Jan 05, 2021 2:46 am 
Offline
Member
Member
User avatar

Joined: Tue Sep 15, 2020 8:07 am
Posts: 264
Location: London, UK
eekee wrote:
I imagine true PIC can be done, but it carries a small performance penalty of its own. Indirection is never quite free. I'm not sure how small the penalty is on modern CPUs. I've also got a hunch it might need a register allocated just for the indirection.

Relocation does seem to be the way to go. If I'm not mistaken, it's basically the same code as you need for dynamic linking anyway. It increases program start time a little, but I'm sure this would only be noticeable if your shell-script webserver got slashdotted. ;) I'm going on my experience with shell scripts under various OSs, all but one with dynamic linking. I have found really big shell scripts a little slow on some OSs (never Linux), but more cores seemed to make a bigger difference than dynamic linking. The only combination which was unacceptably slow in moderate use was a 700-line CMS + 150-line web server on a single-core 466MHz PPC running OS X.

I'm currently planning to use an ARM device with a simple MPU (memory protection unit) which, if I understand right, protects but doesn't remap. I'm thinking IPC will include passing a pointer (or rather a reference) via the kernel so it can allow the recipient access.


I am planning to start a thread regarding the relocation of ELF executables, as I’ve struggled with the ELF format in the past and I will need a bit of hand holding to properly understand it. I wanted to get started on this back in December, but I’ve found reimplementing the filesystem (properly this time, last time I just hacked it into my shell) so dull, I really lost motivation... so focused on GUI code instead.

_________________
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su


Top
 Profile  
 
 Post subject: Re: OS wiith no virtual memory
PostPosted: Wed Jan 06, 2021 2:56 pm 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 812
Location: Hyperspace
bloodline wrote:
I am planning to start a thread regarding the relocation of ELF executables, as I’ve struggled with the ELF format in the past and I will need a bit of hand holding to properly understand it. I wanted to get started on this back in December, but I’ve found reimplementing the filesystem (properly this time, last time I just hacked it into my shell) so dull, I really lost motivation... so focused on GUI code instead.

I was going to ignore ELF, but now I might need it because I'm thinking of a C-based Forth so I can get started more easily with these ARM devices. I've also been avoiding even thinking about filesystems much, :) but I may want a journalling block store for the onboard flash of some devices.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group