admin管理员组文章数量:1405543
When switching from real mode to i386 32-bit protected mode, what is the practical difference between not setting an IDT (i.e. not running an lidt instruction) or setting an empty IDT?
Which one is more useful, and which one should I do?
When switching from real mode to i386 32-bit protected mode, what is the practical difference between not setting an IDT (i.e. not running an lidt instruction) or setting an empty IDT?
Which one is more useful, and which one should I do?
Share Improve this question asked Mar 22 at 2:38 ptspts 87.7k23 gold badges115 silver badges198 bronze badges 1- 1 One of the most valuable things I did was to create reliable fault handlers that print useful information. It's so much easier to debug when you get a fault code and register dump instead of a hang or instant reboot. – prl Commented Mar 22 at 21:12
1 Answer
Reset to default 5There's no practical difference. If you don't enable interrupts or cause any exceptions, then it's moot because the CPU will never use the IDT. If you do, then both cases will result in failure.
Specifically, an interrupt or exception occurring when the IDT is empty (limit of 0) will cause a triple fault and reset the CPU. If you leave IDTR uninitialized, it is possible in principle that it's pointing to something that resembles a valid IDT enough that the CPU would actually jump somewhere if an interrupt or exception occurred, and you'd execute whatever garbage that happened to be. More likely, it doesn't, and an interrupt or exception would just cause a triple fault as before.
So in practice, you must leave interrupts disabled, and avoid causing any exceptions, until you have set up a real (non-empty) interrupt descriptor table. Until then, it's irrelevant what you do with the IDTR, so you might as well not bother to initialize it.
本文标签: x86Why set or not set the IDT when switching to protected modeStack Overflow
版权声明:本文标题:x86 - Why set or not set the IDT when switching to protected mode? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744326695a2600762.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论