Hi, I read lots of pages, linux book about description of x86 segmentation, I got pretty good info but I have few doubts please help me on this. let m explain what I understood,
Segmentation is used to keep text, data, stack part separated so that we can manage access to respective memory. In linux the four segment user code, user data, kernel code kernel data has base offset as 0x00 and limit is 4 GB, user space has about 3 GB and kernel space has about 1 GB address space. kernel space begins somewhere 0xc000....
To access kernel data or code I need to load proper cs, ds same is true for user code and data. GDT is array of segment descriptor which has information of these limits and all.
My Que is: according to above segment arrangement any address above 3 GB is valid in user mode since base address of segment is zero and limit is 4 GB. so how segmentation separates user mode and kernel mode or raise exception on invalid access? how code and data are separated? what i mean by this is say 0x0010 is valid code address and data address for code and data segment but what will be its actual physical address because there can be same physical address for certain segment:offset pair?
Segmentation concept Help!!!
Re: Segmentation concept Help!!!
Hi,
Cheers,
Brendan
In this case, segmentation is not really used at all. Paging is used to separate user-space from kernel-space (and potentially to separate code from data too).tushs wrote:My Que is: according to above segment arrangement any address above 3 GB is valid in user mode since base address of segment is zero and limit is 4 GB. so how segmentation separates user mode and kernel mode or raise exception on invalid access? how code and data are separated? what i mean by this is say 0x0010 is valid code address and data address for code and data segment but what will be its actual physical address because there can be same physical address for certain segment:offset pair?
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Segmentation concept Help!!!
Ok, Most of web pages or doc talk about the virtual and physical address for first 8 MB or so are same i.e physical address is same as virtual address and all this space is used by OS to keep its data structures and DMA buffers. I am not getting calculations because of which this virtual and physical address are same, please give example if anybody knows...
Re: Segmentation concept Help!!!
This type of stuff is very OS specific so generally not true. On x86 most kernels are higher half. Although in Linux, the first 8MB of RAM is (or used to be) mapped to both 0x00000000 and 0xc0000000 during the boot process. Is that what you are talking about ?tushs wrote:Ok, Most of web pages or doc talk about the virtual and physical address for first 8 MB or so are same i.e physical address is same as virtual address and all this space is used by OS to keep its data structures and DMA buffers. I am not getting calculations because of which this virtual and physical address are same, please give example if anybody knows...
If a trainstation is where trains stop, what is a workstation ?
Re: Segmentation concept Help!!!
assume that we had some data structure initialized in real mode now we need to shift to 32 bit protected mode if paging is not enabled new 32 address and actual physical address will same i.e my pointer to data struct is valid, Now when paging is enabled value of pointer will (or might) be invalid since its corresponding physical address will be different. And to avoid this we need same virtual physical address mapping..
please correct me if I am wrong. what I want to know is,
please correct me if I am wrong. what I want to know is,
how this mapping happens?Although in Linux, the first 8MB of RAM is (or used to be) mapped to both 0x00000000 and 0xc0000000 during the boot process.
Re: Segmentation concept Help!!!
I got ans its Identity mapping concept ... Thank's for help!!!
Re: Segmentation concept Help!!!
I use 00100000 as a base and E0000000 as a limit for the usermode code and data selector for flat applications. There is no sense in giving applications access to kernel-space, or v86 reserved areas.