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

Fix panic by disabling exceptions and more BIOS bug fixes #30

Merged
merged 11 commits into from
Jan 7, 2024
Merged

Conversation

ayrtonm
Copy link
Owner

@ayrtonm ayrtonm commented Jan 7, 2024

Hopefully the BIOS should be bug-free enough to be useful for CI now. See commit messages for details on other fixes.

This could be made safe by checking cop0::Status before the syscall but that
gets rid of the benefit that this function immediately disables exceptions
before any loads from cop0.
The example BIOS previously had very random bugs because panic was not
thread-safe. Essentially the loop {} was being ignored because if the exception
handler changed threads. This commit fixes that by ensuring that panic happens
in a critical section. A syscall is used to minimize the chance that an
exception happens between panic's prologue and the critical section call but to
really ensure this panic needs to be a naked function starting with the syscall.
I'm not sure if this is worth it, but it may be a good idea to add a
thread-aware panic handler in the example BIOS.

The panic function was also not reentrant. Normally this should not occur
because the panic function should be simple enough that it doesn't panic, but it
was happening because of a typo in the framebuffer handling introduced when I
added some video mode things. To make it reentrant I just use a static mut flag
since it's already in a critical section and previous iterations won't hold onto
mutable references.
This fixes a bug that was causing nested panics in a non-reentrant panic handler
In case of nested panics (e.g. cause by the CStr limit in println) this allows
execution to continue until the second panic message.
There was a panic message in linked_list_allocator in the BIOS that needed a
larger buffer.
@ayrtonm ayrtonm merged commit c823c4e into master Jan 7, 2024
1 check passed
@ayrtonm ayrtonm deleted the fix_CIv2 branch January 7, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant