-
Notifications
You must be signed in to change notification settings - Fork 33
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
ia32/exceptions: improve FPU exceptions #624
Open
badochov
wants to merge
6
commits into
master
Choose a base branch
from
badochov/exc-int
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jnz .exception_pushRegisters should have flags from andl not subl instruction. JIRA: RTOS-954
savesp saved in exception_pushContext pointed to savesp instead of edi. JIRA: RTOS-954
Checking for FPU exception in preambule of exception handling causes infinite recursion of FPU exceptions if one is found. JIRA: RTOS-954
As we use interirupt gate for exceptions the interrupts are already disabled. JIRA: RTOS-954
Apply same optimizations as to exceptions_pushContext JIRA: RTOS-954
badochov
force-pushed
the
badochov/exc-int
branch
from
November 18, 2024 16:11
765fd16
to
095fdb4
Compare
badochov
changed the title
ia32/exceptions: fix FPU exceptions
ia32/exceptions: improve FPU exceptions
Nov 18, 2024
badochov
force-pushed
the
badochov/exc-int
branch
from
November 18, 2024 17:29
095fdb4
to
709b931
Compare
JIRA: RTOS-954
badochov
force-pushed
the
badochov/exc-int
branch
from
November 18, 2024 17:29
709b931
to
1967f0f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR aims to
resolveimprove situation with exceptions caused by FPU on Intel.FIrst commit resolves issue where recently instead of a triple fault on FPU error exception 16 got presented on the screen, due to wrong instruction setting flag.
The next commit fixes saving context in exceptions.
Following commit changes
fsave
in context saving procedure tofnsave
to prevent infinite recursion on FPU exception causing a triple fault. Due to this change exception 16 is reported correctly as exception 16 not as tripple fault. Thus, exception 16 is excepted to appear not Triple fault.The following commits are optimizations.
I tried to dig into the root cause, here are my findings:
In my testing I have found:
_signal_trampoline
, I have confirmed it is correct inphoenix-rtos-kernel/proc/threads.c
Line 1503 in e2a6b1f
savesp
andcr0Bits
. In affected runs thecr0Bits
is corrupted to hold the same value aseax
.The fail occurs due to bad
cr0Bits
as we remove theTS
flag fromcr0
without initializing the FPU.Additionally, I have noticed that in
phoenix-rtos-kernel/hal/ia32/_exceptions.S
Line 103 in e2a6b1f
phoenix-rtos-kernel/hal/ia32/_interrupts.S
Line 118 in e2a6b1f
cr0Bits
is temporarily replaced witheax
. Additionallyia32
is the only platform not disabling iterrupts during context restoration.Unfortunatelly, I was not able to understand the real reason behind it. Initially this PR got a commit with potential solution by disabling interrupts during stack restoration, sadly insufficient. Initially I thought that it worked but it didn't as the interrupts were not properly reenabled before passing control to the user space.
Perhaps interleave causing problems is timer interrupt just after
iret
instruction passsing control to the user inhal_jmp
.Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment