well
i have thought about one thing:
after you execute the command "LIDT", and "LGDT", does the cpu refeeere to the mem where the tables are, or does it loads them into its own memory, so i for an example can overwrite the tables ???
KMT Dk
GDT and IDT
GDT and IDT
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: GDT and IDT
Yes and no.
When an entry is used, it is taken from memory. Since this would for segment registers imply that upon each use (memory access) they'd need to re-read the GDT, they have optimized things a bit. The segment registers have a hidden part that hold the GDT contents. When a segment register is loaded (even with the same value) the values from the GDT or LDT are copied and stored together with the selector, and it will keep using those values even if the GDT changes.
IDT entries are never cached. CS/DS/ES/FS/GS/SS keep a copy of the GDT entry that is associated to them. The remaining caches are the ones that come with TR and IDTR.
When an entry is used, it is taken from memory. Since this would for segment registers imply that upon each use (memory access) they'd need to re-read the GDT, they have optimized things a bit. The segment registers have a hidden part that hold the GDT contents. When a segment register is loaded (even with the same value) the values from the GDT or LDT are copied and stored together with the selector, and it will keep using those values even if the GDT changes.
IDT entries are never cached. CS/DS/ES/FS/GS/SS keep a copy of the GDT entry that is associated to them. The remaining caches are the ones that come with TR and IDTR.
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
Re: GDT and IDT
So if you've guaranteed that code will never reload segment registers, the kernel should be able to survive a corrupt GDT?
Re: GDT and IDT
Most likely, yes. But remember that user space processes can change segment registers as well. You don't want them to be able to crash your kernel...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: GDT and IDT
As well as interrupts and privilege changes - They implicitly load CS and also SS for the latter