Re: Regarding GDT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Il 29/09/2010 19.28, Sri Ram Vemulpali wrote:
Hi All,

       I have a doubt regarding implementation of segmentation in OS.

       Since GDT is used to implement the segmentation, in that table
you add all segments descriptors dividing the linear address space.
       In a flat model you assign for every descriptor the base as 0x0
and limit as 4GB. This way every DS,CS sees the complete 4GB memory.
       But how is the segment protection implemented. I mean if
segments are not divided with different base address and limit
preventing
       overlapping, there is a possibility of stepping in to other
segment. So, why is the flat model is implemented.

Linux (in x86) uses 4 main segments in GDT: user code, user data, kernel code and kernel data. Actually there are more segments (TSS, LDT, some to manage APM, some to manage PnP, and others) but for your question suffice to say that the main difference between user segments and kernel segments is the DPL (privilege) field. This is 3 for both user segments and 0 for both kernel segments.
That is:
- when the CPU is running at the CPL==3 (Current Privileged Mode, 3 is the lowest, this is when running in user space) it can access only segments with DPL==3 - when the CPU is running at the CPL==0 (0 is the highest, this is when running in kernel space) it can access all segments.

Also, If I strictly implement
       segmentation without paging, then I can have only 8192 segments
of size 64kb for whole 4GB address space.
Then I have all the segment
       descriptors in the GDT. Now if some task uses all its complete
segment size, and needs some more space, then is it possible to assign
       another DS segment. If so, how is that accomplished, since we
need to load in DS new index of segment descriptor and keep track of
all
       indexes in to GDT.

       Can anyone explain how above mentioned things can be achieved.

CMIIW but that is not completely true. If you implement segmentation without paging (in protected mode), you can access 8192 segments of 4GB. So you have to rethink all further assumptions.

regards
Luca

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux