OSDev.org
https://forum.osdev.org/

GDT: Downside of Basic Flat Model?
https://forum.osdev.org/viewtopic.php?f=15&t=32824
Page 1 of 1

Author:  LazyKitty [ Wed Mar 28, 2018 7:21 am ]
Post subject:  GDT: Downside of Basic Flat Model?

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?

Author:  Korona [ Wed Mar 28, 2018 11:50 am ]
Post subject:  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.

Author:  LazyKitty [ Wed Mar 28, 2018 12:03 pm ]
Post subject:  Re: GDT: Downside of Basic Flat Model?

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.


Alright, I'll be going with the flat model, then. Thanks.

I assume the segmentation itself is just there for historical/backwards compatibility reasons, since there is paging now?

Author:  Korona [ Wed Mar 28, 2018 12:07 pm ]
Post subject:  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).

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/