Page 1 of 1

access byte- segmentation

Posted: Tue Apr 17, 2012 7:28 am
by clavin123
when setting access byte of code segement and data segment we use 0x9a and 0x92
well its alright for code segement but setting 0x92 for data segment makes the segment executable bit 1.
so why is 0x92 used for data segment.(in the wiki its written that for data selector executable bit is 0)

Re: access byte- segmentation

Posted: Tue Apr 17, 2012 8:09 am
by bluemoon
clavin123 wrote:but setting 0x92 for data segment makes the segment executable bit 1.
No, according to intel manual 3.4.5.1 Code- and Data-Segment Descriptor Types,
The byte layout is [P][DPL][TYPE]
So, 0x92 means [Present][DPL=0] [Type=Read/Write Data]
It is not executable.

Re: access byte- segmentation

Posted: Tue Apr 17, 2012 10:12 am
by clavin123
even so, for both code and data segment the S bit is same. now isnt that wrong?

Re: access byte- segmentation

Posted: Tue Apr 17, 2012 11:13 am
by bluemoon
It is 50% chance intel was wrong, and 50% you misunderstood the manual.

You should re-read the table for those 4 bits for descriptor type.

Re: access byte- segmentation

Posted: Tue Apr 17, 2012 11:53 am
by iansjack
It is the highest bit of the Type field that determines whether a segment contains code or data, not the S bit. Hence A and 2 (1xxx for a code segment, 0xxx for a data segment).

You are correct that the S bit is the same in both cases - showing that it represents a data or code segment as opposed to a system selector of some sort. As advised, read the manual to see what the various bits do.