bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

Potential UB upon entering unreal mode

Open refarb opened this issue 2 years ago • 0 comments

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.

refarb avatar Jul 12 '22 09:07 refarb