OSDev.org
https://forum.osdev.org/

Use TSS only for stack switching
https://forum.osdev.org/viewtopic.php?f=1&t=32494
Page 1 of 1

Author:  Coconut9 [ Sun Oct 15, 2017 9:30 am ]
Post subject:  Use TSS only for stack switching

I now that TSS is using for task switching but can I use it only for stack switching? If yes Do I need to set anything else except from "ss0" and "esp0" values to it? Which of the other values will change the processor behavior? Alos which of them are sitting by the processor and when (on task switching)? I am asking because I thought because my kernel functions will not push more than 8 bytes at the same time can that use the "eax","ebx",... positions as the stack, can I?

Author:  Korona [ Sun Oct 15, 2017 10:52 am ]
Post subject:  Re: Use TSS only for stack switching

Yes, just set the ESP and SS values.

There is a single cases where you need to use hardware context switching, even when your OS performs software context switching during normal operation, and that is the NMI and MCE handlers (when using the syscall instruction). The reason for that is that hardware switching can atomically change the stack even when there is no ring transition. syscall requires you to manually switch to the user mode stack while you're still in supervisor mode. After you did that, NMIs and MCEs will run on this user mode stack if they are not handled by a task gate.

Author:  Coconut9 [ Sun Oct 15, 2017 11:58 am ]
Post subject:  Re: Use TSS only for stack switching

Korona wrote:
Yes, just set the ESP and SS values.

There is a single cases where you need to use hardware context switching, even when your OS performs software context switching during normal operation, and that is the NMI and MCE handlers (when using the syscall instruction). The reason for that is that hardware switching can atomically change the stack even when there is no ring transition. syscall requires you to manually switch to the user mode stack while you're still in supervisor mode. After you did that, NMIs and MCEs will run on this user mode stack if they are not handled by a task gate.


I will not use the syscall instruction, I will have not any problem, will I have (maybe something that I didn't understand)?

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/