Hi, I've been lurking here for a while and started working on a kernel (whenever I'm not procrastinating), starting with the Barebones tutorial.
Currently I've got paging implemented with higher half, but I'm a bit confused by the GDT (I actually wanted to implement interrupts so I can catch Page Faults, but the wiki mentioned I should do the GDT first), so I decided to finally make an account and ask.
The Intel Manual mentions that models other than the basic flat model have hardware protections against program bugs.
What exactly are these protections and how relevant are they while using paging?
Are there any downsides to just using the basic flat model? (Any reason I should not use it? Is it a security issue?)
What should I be considering to pick the right model?
GDT: Downside of Basic Flat Model?
Re: GDT: Downside of Basic Flat Model?
No modern compiler or runtime supports non-flat models. That's a huge disadvantage that most people are not accepting (including Linux, Windows and all other common kernels). There have been some religious wars about whether x86 segmentation provides any meaningful provides any benefit at all (you can use the search function for that) but a majority of frequent users (me including) thinks that this is not the case.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: GDT: Downside of Basic Flat Model?
Alright, I'll be going with the flat model, then. Thanks.Korona wrote:No modern compiler or runtime supports non-flat models. That's a huge disadvantage that most people are not accepting (including Linux, Windows and all other common kernels). There have been some religious wars about whether x86 segmentation provides any meaningful provides any benefit at all (you can use the search function for that) but a majority of frequent users (me including) thinks that this is not the case.
I assume the segmentation itself is just there for historical/backwards compatibility reasons, since there is paging now?
Re: GDT: Downside of Basic Flat Model?
In Linux, Windows and the other established x86 kernels, yes, it is ignored as much as possible and Intel only includes it for backwards compatibility. You cannot disable it so you live with it and set all segments to a flat model. On x86_64 segmentation is not functional any more (i.e. segment limits are ignored).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].