OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:58 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Tasks TSS and MP
PostPosted: Wed Sep 20, 2017 10:31 pm 
Offline
Member
Member
User avatar

Joined: Sat May 20, 2017 1:25 am
Posts: 51
Location: PCI bus: 3, slot: 9, function: 5
I have already started all the processors. As I understand I need to load different TSS to every processor. But what exactly the TSS is doing? Should I need to use one for every process/thread?

_________________
How people react when a new update of your OS is coming:
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!


Top
 Profile  
 
 Post subject: Re: Tasks TSS and MP
PostPosted: Wed Sep 20, 2017 11:42 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
http://wiki.osdev.org/Task_State_Segment


Top
 Profile  
 
 Post subject: Re: Tasks TSS and MP
PostPosted: Thu Sep 21, 2017 3:44 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

ARISTOS wrote:
I have already started all the processors. As I understand I need to load different TSS to every processor. But what exactly the TSS is doing? Should I need to use one for every process/thread?


When a CPU switches from CPL=3 to CPL=0 (from user-space to kernel space) the CPU normally loads the "hopefully guaranteed safe to use" kernel stack from the TSS to make sure that malicious user-space code can't do something like setting its stack to an address in kernel space and tricking the kernel into trashing itself. Note: The SYSCALL instruction is a special case where the CPU does not switch to a safe stack.

At a minimum, each CPU will need to use different RAM for its kernel stack (otherwise you get problems when 2 or more CPUs are running kernel code at the same time). Beyond that; it depends on other design decisions (if the kernel uses hardware multi-tasking or software multi-tasking, if the kernel uses "one kernel stack per task" or "one kernel stack per CPU", if the kernel uses paging to make some of kernel space contain different things for different CPUs).

The typical case is "software multi-tasking, one kernel stack per task, all of kernel space is the same for all CPUs"; and in this case you'd need one TSS per CPU, where you'd set the "SS0:ESP0" fields in each CPU's TSS during boot/kernel initialisation.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Tasks TSS and MP
PostPosted: Thu Sep 21, 2017 7:32 am 
Offline
Member
Member
User avatar

Joined: Sat May 20, 2017 1:25 am
Posts: 51
Location: PCI bus: 3, slot: 9, function: 5
Brendan wrote:
Hi,

ARISTOS wrote:
I have already started all the processors. As I understand I need to load different TSS to every processor. But what exactly the TSS is doing? Should I need to use one for every process/thread?


When a CPU switches from CPL=3 to CPL=0 (from user-space to kernel space) the CPU normally loads the "hopefully guaranteed safe to use" kernel stack from the TSS to make sure that malicious user-space code can't do something like setting its stack to an address in kernel space and tricking the kernel into trashing itself. Note: The SYSCALL instruction is a special case where the CPU does not switch to a safe stack.

At a minimum, each CPU will need to use different RAM for its kernel stack (otherwise you get problems when 2 or more CPUs are running kernel code at the same time). Beyond that; it depends on other design decisions (if the kernel uses hardware multi-tasking or software multi-tasking, if the kernel uses "one kernel stack per task" or "one kernel stack per CPU", if the kernel uses paging to make some of kernel space contain different things for different CPUs).

The typical case is "software multi-tasking, one kernel stack per task, all of kernel space is the same for all CPUs"; and in this case you'd need one TSS per CPU, where you'd set the "SS0:ESP0" fields in each CPU's TSS during boot/kernel initialisation.


Cheers,

Brendan


Is TSS size fixed or I can use the first 0xC0 bytes only?

_________________
How people react when a new update of your OS is coming:
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!


Top
 Profile  
 
 Post subject: Re: Tasks TSS and MP
PostPosted: Thu Sep 21, 2017 7:47 am 
Offline
Member
Member

Joined: Thu Jul 05, 2007 8:58 am
Posts: 223
Honestly, those questions are best answered by the intel processor manuals. They can be found here. Beyond that, if you want to get anywhere with making an os, being able to do your own research is critical. Learn to use google, and read and understand what you find (in detail, looking up further details if needed). If you then find that you have a specific question that you cant find an answer to, it is okay to ask. But show in your questions that you made an effort to do your own research.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: FrankRay78 and 65 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group