need explanation on this (tss's prvil field)

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
ITchimp
Member
Member
Posts: 134
Joined: Sat Aug 18, 2018 8:44 pm

need explanation on this (tss's prvil field)

Post by ITchimp »

I am creating a tss segment so I can switch to user mode...
This is the privilege level description I got from osdev's article

Privl: Privilege, 2 bits. Contains the ring level, 0 = highest (kernel), 3 = lowest (user applications).

I still don't understand what I should set it to...

since tss should store the stack pointer and stack segment value for kernel... it should be set to 0.

but james molloy set the access byte to 0xE9, which implies that the privilege level is set to 3 ...

is he wrong or I intepret it wrong?
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: need explanation on this (tss's prvil field)

Post by iansjack »

The Intel manual seems to be pretty clear on this:
Any program or procedure with access to a TSS descriptor (that is, whose CPL is numerically equal to or less than the DPL of the TSS descriptor) can dispatch the task with a call or a jump.

In most systems, the DPLs of TSS descriptors are set to values less than 3, so that only privileged software can perform task switching. However, in multitasking applications, DPLs for some TSS descriptors may be set to 3 to allow task switching at the application (or user) privilege level.
So the answer is (as it so often is) - "It depends....".
ITchimp
Member
Member
Posts: 134
Joined: Sat Aug 18, 2018 8:44 pm

Re: need explanation on this (tss's prvil field)

Post by ITchimp »

my question is: switching to user level from kernel level, dpl is something between...

linux kernel book (bovet mentioned dpl should be set to 0)

james molloy sets it to 3 ....

I am confused...
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: need explanation on this (tss's prvil field)

Post by iansjack »

The setting in the descriptor is just telling you whether a user process can access the TSS or not; the kernel always can. I can't see any reason why you would want to make it accessible to a user process (and I can think of plenty of reasons not to).
Post Reply