Quote:
The main reason I map my kernel to 0xC0000000 is for ease (and speed) of communication between kernel and user programs. The kernel is mapped in to the top of *all* process address spaces. The user app may then run between 0x00000000-0xBFFFFFFF.
I do that, but I use a lower-half kernel. The kernel code/data/bss is loaded where GRUB puts it, and is identity mapped across all address spaces. The kernel and user heaps are up at 0xC000000 and 0xD0000000 respectively.
Quote:
If I'm getting it right, you're saying that both user apps and kernel can see into each other space (while not eventually writing, of course).
That is correct.
Quote:
That is, kernel has its own page dir that says "0xc0000000-0xffffffff are belong to us, 0x0-0xbfffffff are belong to user apps and I can write everything" while the user apps have their own (single?) page dir that says "0x0-0xbfffffff is ours and 0xc0000000-0xffffffff is taboo", am I right?
Not quite. Every process has it's own page directory. But across ALL process page directories, certain areas are mapped to EXACTLY the same physical addresses. Those being the kernel code/data/bss and kernel heap, mmapped devices, etc.
Quote:
Am I missing something? I have to recheck the part in which I have to do context switching between the kernel and the user apps.
The only thing you're missing is what I mentioned above. There is no dedicated kernel page directory, so there is no need for a full context-switch when performing a syscall.
Quote:
I see that Linux (at least) is using an INT (0x80, I think) to do syscalls. I used to think that this is the only way to go since a PL jump is involved. Is there some other way?
Yes. As of the pentium pro, you can use the SYSENTER/SYSEXIT instructions to change privilege level. I use these myself, but most tend to still use INT 0x80 or similar. Also note that in the x86_64 architecture there are SYSCALL/SYSRET instructions that are nicer than SYSENTER/EXIT.