How would you design a CPU, from a software point of view?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

How would you design a CPU, from a software point of view?

Post by axilmar »

How would you design a CPU, from a software (i.e. operating system) point of view? how many registers would you put in it? what security mechanism would your CPU have?

Since writing an O/S is largely an exercise in fighting against each CPU's oddities, I would like to know what you guys think about CPUs and how they should be designed in order to allow the writing of modern and effective operating systems.

It's especially interesting to see what everyone things on modularization/componetization and O/S software engineering.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

I am think about code a cpu, in software, as a way to run the same asm coded program's on differant processors (just port the VM ).
Like a modern chip8 http://en.wikipedia.org/wiki/CHIP-8

The layout is still to be worked out.
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

Thanks, but CHIP-8 does not define paging and protection structures.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I would have tagged TLBs and manual tlb management with OS-defined sizes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

Anyway, I've made my own CPU spec (attached).

It's nothing revolutionary. The most interesting point is the advanced protection mechanism. In a nutshell, it goes like this:

There are two tables for protection: a) the segment table, b) the access table.

The segment table defines how the 32-bit address space is segmented.

The access table defines the relationship between two segments for read, write and execute access.

This mechanism allows for a very fine-grained protection mechanism: each segment can can different access rights on any other segment (or itself).

Segments are used implicitly, much like the page table (i.e. there are no far pointers).

Additionally, I have made jumps targeted, i.e. if a jump does not transfer control to a known jump target, then a security violation exception is raised. This can limit invocation of wild pointers.

Finally, I have separated the stack into a data stack and a return-address stack, in order to get rid of buffer overflows exploits.

I think the mechanism is realistic and can be implemented in CPUs as an associative cache.
Attachments
cpu.zip
(4.65 KiB) Downloaded 73 times
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

1. Many (general purpose) registers.
2. Intra-page protection. Essentially segmentation, but much easier segmentation. I.e. I just want to give/remove access of this range of virtual memory addresses to a process. It would mean that common heaps and common buffers wouldn't have to be page-aligned.
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

JamesM wrote:1. Many (general purpose) registers.
2. Intra-page protection. Essentially segmentation, but much easier segmentation. I.e. I just want to give/remove access of this range of virtual memory addresses to a process. It would mean that common heaps and common buffers wouldn't have to be page-aligned.
So, good or bad? good, I presume :-).
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

Well, any other opinions?
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Post by JackScott »

I've had a look through the supplied file. As far as I can see, it doesn't have any huge flaws. However, does it need to have a base address for the stacks, or is this supplied through paging?
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

Other oppinions? of course, but i dont thing i have got enought knowledge on the subject to provide any usefull ideas.

I like to call my self "minimalistic perfectionist" which basicly means that if i dont need it i dont want it.

One of the nig issues i guess is the memory handling/protection. My oppinion on this is... well lets just say that i hate segments and paging and all that, if i want to use these features i can provide that posibility myself i should think. On a regular x86 system where i have to mess around with gdts, idts, ldts, and all that just to be enable "32/64bit mode" is just annoying. I believe there must be a better way.

I've allready said too much on a subject i dont really understand, but this is my oppinion non the less...
This was supposed to be a cool signature...
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post by SpooK »

I've worked on the Dynatos Virtual Machine Specification over the years. I am referencing it due to the register layout found in the VM.

The goal is simplicity of design. Simple instructions can be profiled and optimized better. I am still tweaking the program control (offseting instructions) to be more complete. This VM is the driving force behind my os development endeavors.

Any instructions with "???" next to it is something I came up with but later found questionably complex and possibly out of scope.

Let me know what you think ;)
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Zacariaz wrote:Other oppinions? of course, but i dont thing i have got enought knowledge on the subject to provide any usefull ideas.

I like to call my self "minimalistic perfectionist" which basicly means that if i dont need it i dont want it.

One of the nig issues i guess is the memory handling/protection. My oppinion on this is... well lets just say that i hate segments and paging and all that, if i want to use these features i can provide that posibility myself i should think. On a regular x86 system where i have to mess around with gdts, idts, ldts, and all that just to be enable "32/64bit mode" is just annoying. I believe there must be a better way.

I've allready said too much on a subject i dont really understand, but this is my oppinion non the less...
I think you would like the ARM processor's.
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

Yayyak wrote:I've had a look through the supplied file. As far as I can see, it doesn't have any huge flaws. However, does it need to have a base address for the stacks, or is this supplied through paging?
Supplied through paging (i.e. guard page).
axilmar
Member
Member
Posts: 28
Joined: Sat Jun 02, 2007 10:35 am

Post by axilmar »

SpooK wrote:I've worked on the Dynatos Virtual Machine Specification over the years. I am referencing it due to the register layout found in the VM.

The goal is simplicity of design. Simple instructions can be profiled and optimized better. I am still tweaking the program control (offseting instructions) to be more complete. This VM is the driving force behind my os development endeavors.

Any instructions with "???" next to it is something I came up with but later found questionably complex and possibly out of scope.

Let me know what you think ;)
Thanks, I will look it up when I have time.
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

mmix wrote: Hardware implementations

As of 2007, the MMIX instruction set architecture has not yet been implemented in hardware.(edit)
Post Reply