For my custom bootloader project, I asked myself whether there is a risk or overhead in switching between real mode and protected mode multiple times. So far, I've been looking at the following questions:
- Switch to and from 16-bit Real Mode and 32-bit Protected Mode
- Switching to (un)real mode, reading disk and switching back to protected mode
I know that it is possible to switch between both modes, and I also know how I can achieve this. My question solely focuses on the possible issues that may arise when the kernel (or the bootloader, in that matter) switches between both modes multiple times during execution.
For one thing, I have heard (and read) about instructions in the pipeline that may be "stuck" after a operation mode switch which causes the CPU to fetch invalid opcodes. However, I've also been told that this is not an issue for newer CPUs (Intel 80386 and newer). What is true? Are there other risk or things to be considered?
Note: Since my project is targeting CPUs from Intel 80386 and newer (my current projects runs on Intel i7-4770 Haswell), I want to restrict my question for CPUs beginning from Intel 80386.