OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 12:27 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: My TSS can't relax at all
PostPosted: Sat Apr 22, 2017 2:40 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
Well I think it's a very simple question, but how to clear x64 TSS busy bit? I tried to reset the attribute direct to the descriptor, and to load another empty TSS, but the original TSS is still busy.
(By the way, could anybody tell me more about context switching in long mode?)

Code:
TssDesc->AttrLow = TSS | DESC_P; //During context switching
DumpTss();


Attachments:
File comment: The display of DumpTss()
捕获.PNG
捕获.PNG [ 888 Bytes | Viewed 2637 times ]

_________________
Doing steadfastly, or doing nil.
Top
 Profile  
 
 Post subject: Re: My TSS can't relax at all
PostPosted: Sat Apr 22, 2017 3:21 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
x86_64 does not support hardware task switching. The 64-bit TSS does not contain a register image (it's figure 7-11 in my copy of the Intel SDM). Use software task switching instead (i.e. save/restore all general-purpse registers and use iret to restore RIP and RFLAGS). AFAICT there is no need to bother with the busy bit (or more than one TSS per processor) in 64-bit mode.

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
 Post subject: Re: My TSS can't relax at all
PostPosted: Sat Apr 22, 2017 4:44 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 31, 2016 1:43 am
Posts: 48
Location: China
Korona wrote:
AFAICT there is no need to bother with the busy bit (or more than one TSS per processor) in 64-bit mode.


Yes of course you're right. So I've already made this. However, I created a process queue based on an array, and the enqueue and dequeue operation changes the position of each process, so I've got to change my TSS.RSP0 so it'll point to correct position. (I use stack to save GPR and so on, so the image will be stored in the process structure.)

So how to clear busy bits? Thanks for any advice.

_________________
Doing steadfastly, or doing nil.


Top
 Profile  
 
 Post subject: Re: My TSS can't relax at all
PostPosted: Sat Apr 22, 2017 8:55 am 
Offline
Member
Member

Joined: Thu Jul 05, 2007 8:58 am
Posts: 223
The busy flag is used in 32 bit mode to prevent things like recursively entering a task through a task gate when you use hardware task switching.

Although the manual isn't particularly clear on this, the 64 bit busy flag seems to be a leftover from hardware task switching. It seems to serve no particular function anymore. In particular (and this also holds in 32 bit mode), one can allways edit the elements of a TSS, even when it is loaded into the TR.

Do note however that simply changing TSS.RSP0 will not change your current stack pointer, it will only change the value that the processor will load when switching from ring 1, 2 or 3 to ring 0.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users 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