80386

attributes include the 32-bit base linear address of the segment, the 20-bit length and granularity of the segment, the protection level, read, write or execute privileges, the default size of the operands (16-bit or 32-bit), and the type of segment. All of the attribute information about a segment is contained in 12 bits in the segment descriptor. Figure 4-5 shows the gen- eral format of a descriptor. All segments on the 80386 have three attribute fields in common: the P bit, the DPL bit, and the S bit. The Present P bit is 1 if the segment is loaded in physical memory, if P= 0 then any attempt to access this segment causes a not present exception (exception 11). The Descrip- tor Privilege Level DPL is a two-bit field which speci- fies the protection level 0-3 associated with a seg- ment.

The 80386 has two main categories of segments system segments and non-system segments (for code and data). The segment S bit in the segment descriptor determines if a given segment is a system segment or a code or data segment. If the S bit is 1 then the segment is either a code or data segment, if it is 0 then the segment is a system segment.

4.3.4.2386 CODE, DATA DESCRIPTORS (S= 1)

Figure 4-6 shows the general format of a code and data descriptor and Table 4-1 illustrates how the bits in the Access Rights Byte are interpreted.

31

 

 

 

o

 

SEGMENT BASE 15

... 0

 

SEGMENT LIMIT 15 ... 0

o

 

 

LIMIT

ACCESS

BASE

 

BASE 31 ... 24 G

0 0 0

RIGHTS

 

+4

19 ... 16

23 ... 16

 

 

BYTE

 

 

 

 

 

 

DIB 1 ~ Default Instructions Attnbutes are 32·81ts

 

G Granulanty Bit

1 - Segment length IS page granular

 

o~ Default Instruction Attributes are 16·8its

 

 

o~ Segment length is byte granular

 

Bit must be zero (0) for compatibility with future processors

Figure 4-6. Segment Descriptors

Table 4-1. Access Rights Byte Definition for Code and Data Descriptions

Bit

NameFunction

Position

7

Present (P)

P =

1

Segment is mapped into physical memory.

 

 

P =

0

No mapping to physical memory exits, base and limit are

 

 

 

 

not used.

6-5

Descriptor Privilege

 

 

Segment privilege attribute used in privilege tests.

 

Level (DPL)

 

 

 

4

Segment Descrip-

S =

1

Code or Data (includes stacks) segment descriptor

 

tor (S)

S=O

System Segment Descriptor or Gate Descriptor

 

3

Executable (E)

E

0

 

D'''';ptm typ' ;, data "gm,nt

rData

 

 

2

Expansion Direc-

ED~=

0 Expand up segment, offsets must be ,,; limit.

 

 

 

tion (ED)

ED =

1 Expand down segment, offsets must be > limit.

Segment

 

1

Writeable (W)

W =

0

Data segment may not be written into.

(S =

1,

Type

 

 

W =

1

Data segment may be written into.

E = 0)

Field

3

Executable (E)

E =

1

 

Descriptor type is code segment:

 

 

Definition

 

 

 

2

Conforming (C)

C =

1

 

Code segment may only be executed

Code

 

 

 

 

 

 

 

 

when CPL :2: DPL and CPL

Segment

 

 

 

 

 

 

remains unchanged.

(S =

1,

 

1

Readable (R)

R=O

 

Code segment may not be read.

E =

1)

 

 

 

R = 1 Code segment may be read.

r

 

 

0

Accessed (A)

A=O

 

Segment has not been accessed.

 

 

 

 

A=1

Segment selector has been loaded into segment register

 

 

 

 

 

 

or used by selector test instructions.

 

 

 

 

 

 

 

 

37

 

 

Page 98
Image 98
Intel 80386 manual Dptm typ , data gm,nt