Switch between user and kernel mode
Posted: Mon Aug 20, 2012 2:37 am
Hi,
after some time I began work on a project again, a port of unix v7 to x86 (I know, it's been done, but meh...).
Currently I'm trying to figure out the switch between user and kernel mode, especially how to handle the paging.
Since I'm porting Unix, I kinda know the PDP-11 architecture (much nicer than x86 ), where different memory mappings happen depending on whether the processor runs in kernel or user mode. On the x86, as I understand it, switching between kernel and user mode does not cause the MMU to switch page mappings; that confuses me.
Does this mean I have to constantly map some part of the kernel (Interrupt vectors and TSS, I suppose) in user mode, and at the same addresses as in kernel mode? Isn't this a rather clumsy approach?
My initial plan was to locate the kernel after 1MB, identity map everything till there in kernel mode, and have the user mode paging map the current process data to 0, but that would conflict with the kernel, parts of which I have to map there too.
So I wonder how you guys handle this. Please give me any recommendations or explanations how other systems handle this.
Thank you.
after some time I began work on a project again, a port of unix v7 to x86 (I know, it's been done, but meh...).
Currently I'm trying to figure out the switch between user and kernel mode, especially how to handle the paging.
Since I'm porting Unix, I kinda know the PDP-11 architecture (much nicer than x86 ), where different memory mappings happen depending on whether the processor runs in kernel or user mode. On the x86, as I understand it, switching between kernel and user mode does not cause the MMU to switch page mappings; that confuses me.
Does this mean I have to constantly map some part of the kernel (Interrupt vectors and TSS, I suppose) in user mode, and at the same addresses as in kernel mode? Isn't this a rather clumsy approach?
My initial plan was to locate the kernel after 1MB, identity map everything till there in kernel mode, and have the user mode paging map the current process data to 0, but that would conflict with the kernel, parts of which I have to map there too.
So I wonder how you guys handle this. Please give me any recommendations or explanations how other systems handle this.
Thank you.