Interrupt Handling in XNU
Posted: Tue Mar 23, 2010 12:21 pm
Hello,
I recently read somewhere that the XNU (Mac OS) Kernel has completely different address spaces for the kernel and the userspace programs.
All the exception handlers are only present in the kernel space (address 0x0 to 0x5000). I don't really know what happens when an interrupt or exception occours while being in usermode. The CPU switches the execution level to kernel mode but it doesn't change the page directory. Since the handlers are not available in usermode it would crash. But obviously it works. Does anybody of you know how?
Do they have some kind of trampoline which is present in all address spaces and just switches page directories? I couldn't find any section in the address layout for the userspace which could be used for something like that.
I don't know if I can post them here: Copyright 'n stuff...
I couldn't find any hint int the Book "Mac OS X Internals: A Systems Approach" about this.
I also had a look into the XNU sourcecode, but its just too much to find to relevant places without knowing each and every piece of this kernel
edit:
Yes, I know that the TLB gets trashed everytime the page directory is switched. But they really seem to do it. And it seems that it works just fine.
I recently read somewhere that the XNU (Mac OS) Kernel has completely different address spaces for the kernel and the userspace programs.
All the exception handlers are only present in the kernel space (address 0x0 to 0x5000). I don't really know what happens when an interrupt or exception occours while being in usermode. The CPU switches the execution level to kernel mode but it doesn't change the page directory. Since the handlers are not available in usermode it would crash. But obviously it works. Does anybody of you know how?
Do they have some kind of trampoline which is present in all address spaces and just switches page directories? I couldn't find any section in the address layout for the userspace which could be used for something like that.
I don't know if I can post them here: Copyright 'n stuff...
I couldn't find any hint int the Book "Mac OS X Internals: A Systems Approach" about this.
I also had a look into the XNU sourcecode, but its just too much to find to relevant places without knowing each and every piece of this kernel
edit:
Yes, I know that the TLB gets trashed everytime the page directory is switched. But they really seem to do it. And it seems that it works just fine.