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

Potential UB upon entering unreal mode #241

Closed
refarb opened this issue Jul 12, 2022 · 1 comment
Closed

Potential UB upon entering unreal mode #241

refarb opened this issue Jul 12, 2022 · 1 comment

Comments

@refarb
Copy link

refarb commented Jul 12, 2022

According to the reference all registers not mentioned as clobbered by a block (by using out("<reg>") _) must have the same (undefined) value they had when entering the block when the asm block ends, "otherwise behavior is undefined".

However, both line 76 and line 85 of enter_unreal_mode in the second stage of the bootloader modify registers without stating this to the compiler.

Because I have never programmed any processor, except microprocessors without differing execution modes, I am unsure if this is actually fine (because upon switching into unreal mode all registers are to be considered clobbered for some reason? But then that would also require marking at least one asm block for the compiler?) or an actual bug which causes UB and should be fixed.

@phil-opp
Copy link
Member

phil-opp commented Jan 2, 2023

Thanks a lot for reporting! You're right that this was probably undefined behavior and should have been fixed. Sorry for not reacting earlier!

I think we no longer have this problem with #232 merged, so I think we can close this. Please let me know if you see any similar issue with the current implementation!

@phil-opp phil-opp closed this as completed Jan 2, 2023
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

No branches or pull requests

2 participants