Long Mode, Documentation and more Questions
Posted: Sat Jan 28, 2012 11:14 pm
Hey everyone,
Been lurking around here for a while. I've read atleast half of the wiki (probably more), and have read tons of documentation online. I have started a "version 0" OS, basically a OS to play with/test different things (build system, testing/debugging, emulators) to figure out how I should organize things once I actually get going.
My main goal is to have a "modern" OS. Namely, Long mode only, SMP "almost only" (Designed for SMP, but I would like to make it work on a single core), High resolution GUI, etc. I know this is going to be hard. I'm not dumb enough to even claim I will have this done in a year, hell, I'll be happy with 5 years .
And, I have a couple questions for you guys, if you have a few minutes
1) When it comes to Long Mode, and SMP actually, is there any emulator that can "closely" resemble real hardware? (Long Mode support, multiple cores? SSE3+ extensions?) Or am I going to have to use real hardware to actually test?
2) I have downloaded and briefly looked at several hardware manuals from AMD and Intel. There are a ton! I realize, that eventually I will probably have to read all of them to understand everything I need, but can anyone offer a good starting point? (Maybe something like, for solid Task Switching on SMP you need to read..., etc.)
3) Plug and Play: (http://wiki.osdev.org/PNP_Calls_In_Protected_Mode) Can PnP calls be made the same way in Long Mode?
4) BIOS functions: Since v8086 does not work in Long Mode, if a BIOS function needs to be called, I need to go all the way back to real mose to make these calls? Or is there a new "v8086" method for Long mode?
5) CPU "rings": Everything I read says to use ring 0 and ring 3. Do modern processors have a ring 1 and 2? Do they offer anything different?
The following questions have a much more intimate relation to my desired implementation. So, I am aiming to have a high security, high performance OS. My GOAL (NOT expectations) is to replace Windows as the gaming OS.
So for performance, I am mainly looking at it as, everything else was designed so long ago, something designed specifically for modern hardware will perform better, because it will take advantage of a ton of new features all the way through the OS.
For security, I am looking to require user-land code to be delivered (from CD, Network, or Internet) as a IL executable, and will use Install-time-compilation to achieve better performance. This also helps with security, because I can determine at install time every function call, etc. Obviously pointer arithmetic will not be allowed, unless I can figure out a safe way to do it. Since I can guarantee a lot using this method, I can "cut" a lot of corners.
6) Given the above, I can make syscalls not require a context switch. I can add code into every "secure" kernel method (a macro probably) that determines where the call came from (by walking up the stack to find the "return" address of the calling function). Shouldn't this be sufficient for security?
7) Taking a step back, is this even something I need to worry about? What kind of overhead do existing syscall implementations cause? Am I over-/pre-optimizing this?
Data Execution Prevention: From what I understand, I can use CS and DS to say this section is code, and this section is data. Do modern processors actually enforce this distinction? Will they fault if a buffer overflow happens, and a function returns to somewhere in the DS?
I think that is it for right now. I know I could potentially find out all of this information through either a ton of googling (I have tried basic googling to find the info), or through trial and error. But, I was hoping that someone had either run into these same situations, and already had the answer, and could save me, and anyone else after me with the same questions, significant time.
I got to say, I love this forum and wiki so far. There is so much info up for grabs here already, and I hope I can add my knowledge some time in the future.
Sincerely,
- Monk
Been lurking around here for a while. I've read atleast half of the wiki (probably more), and have read tons of documentation online. I have started a "version 0" OS, basically a OS to play with/test different things (build system, testing/debugging, emulators) to figure out how I should organize things once I actually get going.
My main goal is to have a "modern" OS. Namely, Long mode only, SMP "almost only" (Designed for SMP, but I would like to make it work on a single core), High resolution GUI, etc. I know this is going to be hard. I'm not dumb enough to even claim I will have this done in a year, hell, I'll be happy with 5 years .
And, I have a couple questions for you guys, if you have a few minutes
1) When it comes to Long Mode, and SMP actually, is there any emulator that can "closely" resemble real hardware? (Long Mode support, multiple cores? SSE3+ extensions?) Or am I going to have to use real hardware to actually test?
2) I have downloaded and briefly looked at several hardware manuals from AMD and Intel. There are a ton! I realize, that eventually I will probably have to read all of them to understand everything I need, but can anyone offer a good starting point? (Maybe something like, for solid Task Switching on SMP you need to read..., etc.)
3) Plug and Play: (http://wiki.osdev.org/PNP_Calls_In_Protected_Mode) Can PnP calls be made the same way in Long Mode?
4) BIOS functions: Since v8086 does not work in Long Mode, if a BIOS function needs to be called, I need to go all the way back to real mose to make these calls? Or is there a new "v8086" method for Long mode?
5) CPU "rings": Everything I read says to use ring 0 and ring 3. Do modern processors have a ring 1 and 2? Do they offer anything different?
The following questions have a much more intimate relation to my desired implementation. So, I am aiming to have a high security, high performance OS. My GOAL (NOT expectations) is to replace Windows as the gaming OS.
So for performance, I am mainly looking at it as, everything else was designed so long ago, something designed specifically for modern hardware will perform better, because it will take advantage of a ton of new features all the way through the OS.
For security, I am looking to require user-land code to be delivered (from CD, Network, or Internet) as a IL executable, and will use Install-time-compilation to achieve better performance. This also helps with security, because I can determine at install time every function call, etc. Obviously pointer arithmetic will not be allowed, unless I can figure out a safe way to do it. Since I can guarantee a lot using this method, I can "cut" a lot of corners.
6) Given the above, I can make syscalls not require a context switch. I can add code into every "secure" kernel method (a macro probably) that determines where the call came from (by walking up the stack to find the "return" address of the calling function). Shouldn't this be sufficient for security?
7) Taking a step back, is this even something I need to worry about? What kind of overhead do existing syscall implementations cause? Am I over-/pre-optimizing this?
Data Execution Prevention: From what I understand, I can use CS and DS to say this section is code, and this section is data. Do modern processors actually enforce this distinction? Will they fault if a buffer overflow happens, and a function returns to somewhere in the DS?
I think that is it for right now. I know I could potentially find out all of this information through either a ton of googling (I have tried basic googling to find the info), or through trial and error. But, I was hoping that someone had either run into these same situations, and already had the answer, and could save me, and anyone else after me with the same questions, significant time.
I got to say, I love this forum and wiki so far. There is so much info up for grabs here already, and I hope I can add my knowledge some time in the future.
Sincerely,
- Monk