Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FXSAVE Instruction when Switching Tasks #243

Open
Kfeavel opened this issue Jul 2, 2021 · 3 comments
Open

Use FXSAVE Instruction when Switching Tasks #243

Kfeavel opened this issue Jul 2, 2021 · 3 comments
Assignees
Labels
bug Something isn't working easy Should be easy, good for newcomers high-priority Other issues depend upon this one

Comments

@Kfeavel
Copy link
Member

Kfeavel commented Jul 2, 2021

No description provided.

@micahswitzer
Copy link
Member

Our kernel uses SSE which means that the xmm registers and probably other registers as well could be used my multiple kernel tasks. Currently we don't save those registers during context switches which means that our kernel is a time bomb and at any moment the compiler could generate SSE instructions and detonate it. We really should fix that.

@Kfeavel
Copy link
Member Author

Kfeavel commented Jul 2, 2021

The OSDev Wiki provides a nice snippet we could integrate into our tasks struct that would allow us to save and restore the registers on a task-by-task basis.

char fxsave_region[512] __attribute__((aligned(16)));
asm volatile(" fxsave; "::"m"(fxsave_region));

https://wiki.osdev.org/SSE#FXSAVE_and_FXRSTOR

@Kfeavel Kfeavel added bug Something isn't working high-priority Other issues depend upon this one labels Jul 2, 2021
@Kfeavel Kfeavel added the easy Should be easy, good for newcomers label Jul 10, 2021
@Kfeavel
Copy link
Member Author

Kfeavel commented Sep 12, 2021

GCC provides functions that can do this for us, so we should look into using those instead of inline assembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working easy Should be easy, good for newcomers high-priority Other issues depend upon this one
Projects
None yet
Development

No branches or pull requests

2 participants