Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
In some cases (probably most), it'll continue working. However, GCC expects/requires the descriptors to remain the same, and if your cpu reloads the descriptors (don't flame me, I've seen this this happen) on lgdt, then it might cause undefined behavior. Grub2 seems to load kernels to 0x10 instead of 0x8, and so if this happens, and your kernel code segment is 0x8, then you will get a #GP, a #DF, and finally a triple fault/cpu reset.
Personally, in cases involving segment register changes, stack changes, gdt, ect. I find it safer/easier to put a callable function in an external file.
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
In some cases (probably most), it'll continue working. However, GCC expects/requires the descriptors to remain the same, and if your cpu reloads the descriptors (don't flame me, I've seen this this happen) on lgdt, then it might cause undefined behavior. Grub2 seems to load kernels to 0x10 instead of 0x8, and so if this happens, and your kernel code segment is 0x8, then you will get a #GP, a #DF, and finally a triple fault/cpu reset.
You surely do know that you have to reload the segment register for any change to actually happen? If lgdt reloaded segments, it would be dead retarded and unusable. And you surely do know no modern compiler messes with segments, so it totally doesn't matter?
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
LGDT only update the CPU's GPT pointer, it does not invalidate and has no effect on current descriptor caches unless a reload of such register is performed.
So you probably want to reload DS/ES/SS/CS(via IRET) before re-enable interrupt.
In some cases (probably most), it'll continue working. However, GCC expects/requires the descriptors to remain the same, and if your cpu reloads the descriptors (don't flame me, I've seen this this happen) on lgdt, then it might cause undefined behavior. Grub2 seems to load kernels to 0x10 instead of 0x8, and so if this happens, and your kernel code segment is 0x8, then you will get a #GP, a #DF, and finally a triple fault/cpu reset.
You surely do know that you have to reload the segment register for any change to actually happen? If lgdt reloaded segments, it would be dead retarded and unusable. And you surely do know no modern compiler messes with segments, so it totally doesn't matter?
Didnt i say, "don't flame me, i've seen it happen"?
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.