-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix(x86_64): don't set CR0Flags::TASK_SWITCHED
#1501
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done some digging on why this was added:
kernel/librs/src/arch/x86_64/processor.rs
Lines 489 to 490 in 77bd5d1
// Call the IRQ7 handler on the first FPU access. | |
cr0.insert(CR0_TASK_SWITCHED); |
kernel/librs/src/arch/x86_64/irq.rs
Lines 211 to 218 in 77bd5d1
extern "x86-interrupt" fn device_not_available_exception(stack_frame: &mut ExceptionStackFrame) { | |
// We set the CR0_TASK_SWITCHED flag every time we switch to a task. | |
// This causes the "Device Not Available" Exception (int #7) to be thrown as soon as we use the FPU for the first time. | |
// We have to clear the CR0_TASK_SWITCHED here and save the FPU context of the old task. | |
unsafe { asm!("clts"); } | |
panic!("FPU ToDo"); | |
} |
If the processor executes a floating-point instruction while the TS flag in control register CR0 was set and the EM flag is clear, a device-not-available exception is generated.
I understand this was added intentionally to ensure the behavior for the initial task is the same as for subsequent tasks that were switched to and have set the TS flag implicitly.
I have not done enough digging to say whether it would be fine to remove this, but maybe you don't have a problem with the TS flag but with running interrupts in general.
We should accept the PR. I have the same opinion like @sarahspberrypi |
@sarahspberrypi I talked to @mkroening We would like to set TASK_SWITCHED flag. Do you really need to remove the flag? |
@stlankes The flag is set later during |
As previously mentioned, the manual setting of this flag seems to be unnecessary, so I propose to remove it from the code.