Flat vs Segmented Memory Model
Posted: Wed Feb 09, 2005 12:00 am
Im trying to ensure I understand the difference and implications of one model over the other.
Flat is where you set up 2 Segments in the GDT, a Code and a Data segment, both running at CPL=0, and set to use from 0 -> 4GB of memory.
Segmented is where you set up (for example) 4 Segments in the GDT, a Code and Data segment running at CPL=0 using say the first 1MB of memory; and a Code and Data segment running at CPL=3, which uses from 1MB -> 4GB of memory.
If you choose the segmented model, when you perform a System Call you would need to modify CS and DS to point to the kernel segments, and then restore them where you exit correct? The OS would still be responsible for ensuring 2 user processes do not access each others memory, but the cpu can now ensure user processes do not touch kernel memory.
Under the flat model, the os is responsible for all memory security.
Flat is where you set up 2 Segments in the GDT, a Code and a Data segment, both running at CPL=0, and set to use from 0 -> 4GB of memory.
Segmented is where you set up (for example) 4 Segments in the GDT, a Code and Data segment running at CPL=0 using say the first 1MB of memory; and a Code and Data segment running at CPL=3, which uses from 1MB -> 4GB of memory.
If you choose the segmented model, when you perform a System Call you would need to modify CS and DS to point to the kernel segments, and then restore them where you exit correct? The OS would still be responsible for ensuring 2 user processes do not access each others memory, but the cpu can now ensure user processes do not touch kernel memory.
Under the flat model, the os is responsible for all memory security.